Last change
on this file since 1157 was 1114, checked in by iritscen, 5 years ago |
Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.
|
File size:
1.9 KB
|
Rev | Line | |
---|
[1114] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 |
|
---|
| 4 | namespace Oni.Particles
|
---|
| 5 | {
|
---|
| 6 | internal class EventAction
|
---|
| 7 | {
|
---|
| 8 | private readonly List<Value> parameters;
|
---|
| 9 | private readonly List<VariableReference> variables;
|
---|
| 10 | private readonly EventActionType type;
|
---|
| 11 |
|
---|
| 12 | private EventAction()
|
---|
| 13 | {
|
---|
| 14 | this.parameters = new List<Value>();
|
---|
| 15 | this.variables = new List<VariableReference>();
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | public EventAction(EventActionType type)
|
---|
| 19 | : this()
|
---|
| 20 | {
|
---|
| 21 | this.type = type;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | public EventAction(BinaryReader reader)
|
---|
| 25 | : this()
|
---|
| 26 | {
|
---|
| 27 | type = (EventActionType)reader.ReadInt32();
|
---|
| 28 | reader.ReadInt32();
|
---|
| 29 |
|
---|
| 30 | for (int i = 0; i < 8; i++)
|
---|
| 31 | {
|
---|
| 32 | VariableReference value = new VariableReference(reader);
|
---|
| 33 |
|
---|
| 34 | if (value.IsDefined)
|
---|
| 35 | variables.Add(value);
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | for (int i = 0; i < 8; i++)
|
---|
| 39 | {
|
---|
| 40 | Value value = Value.Read(reader);
|
---|
| 41 |
|
---|
| 42 | if (value != null)
|
---|
| 43 | parameters.Add(value);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public void Write(BinaryWriter writer)
|
---|
| 48 | {
|
---|
| 49 | writer.Write((int)type);
|
---|
| 50 | writer.Write(0);
|
---|
| 51 |
|
---|
| 52 | foreach (VariableReference variable in variables)
|
---|
| 53 | variable.Write(writer);
|
---|
| 54 |
|
---|
| 55 | for (int i = variables.Count; i < 8; i++)
|
---|
| 56 | VariableReference.Empty.Write(writer);
|
---|
| 57 |
|
---|
| 58 | foreach (Value value in parameters)
|
---|
| 59 | value.Write(writer);
|
---|
| 60 |
|
---|
| 61 | for (int i = parameters.Count; i < 8; i++)
|
---|
| 62 | Value.Empty.Write(writer);
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | public EventActionType Type => type;
|
---|
| 66 |
|
---|
| 67 | public List<Value> Parameters => parameters;
|
---|
| 68 |
|
---|
| 69 | public List<VariableReference> Variables => variables;
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.