source: OniSplit/Objects/Character.cs@ 1126

Last change on this file since 1126 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: 10.2 KB
RevLine 
[1114]1using System;
2using System.Xml;
3using Oni.Metadata;
4
5namespace Oni.Objects
6{
7 internal class Character : ObjectBase
8 {
9 public CharacterFlags Flags;
10
11 public string ClassName;
12 public string Name;
13 public string WeaponClassName;
14
15 public string OnSpawn;
16 public string OnDeath;
17 public string OnSeenEnemy;
18 public string OnAlarmed;
19 public string OnHurt;
20 public string OnDefeated;
21 public string OnOutOfAmmo;
22 public string OnNoPath;
23
24 public int AdditionalHealth;
25 public CharacterJobType Job;
26 public int PatrolPathId;
27 public int CombatId;
28 public int MeleeId;
29 public int NeutralId;
30
31 public int MaxAmmoUsed;
32 public int MaxAmmoDropped;
33 public int MaxCellsUsed;
34 public int MaxCellsDropped;
35 public int MaxHyposUsed;
36 public int MaxHyposDropped;
37 public int MaxShieldsUsed;
38 public int MaxShieldsDropped;
39 public int MaxCloakUsed;
40 public int MaxCloakDropped;
41
42 public CharacterTeam Team;
43 public int AmmoPercent;
44 public CharacterAlertStatus InitialAlertLevel;
45 public CharacterAlertStatus MinimalAlertLevel;
46 public CharacterAlertStatus JobStartingAlertLevel;
47 public CharacterAlertStatus InvestigatingAlertLevel;
48 public int AlarmGroups;
49
50 public CharacterPursuitMode PursuitStrongUnseen;
51 public CharacterPursuitMode PursuitWeakUnseen;
52 public CharacterPursuitMode PursuitStrongSeen;
53 public CharacterPursuitMode PursuitWeakSeen;
54 public CharacterPursuitLostBehavior PursuitLost;
55
56 public Character()
57 {
58 TypeId = ObjectType.Character;
59 }
60
61 protected override void WriteOsd(BinaryWriter writer)
62 {
63 writer.Write((int)Flags);
64
65 writer.Write(ClassName, 64);
66 writer.Write(Name, 32);
67 writer.Write(WeaponClassName, 64);
68
69 writer.Write(OnSpawn, 32);
70 writer.Write(OnDeath, 32);
71 writer.Write(OnSeenEnemy, 32);
72 writer.Write(OnAlarmed, 32);
73 writer.Write(OnHurt, 32);
74 writer.Write(OnDefeated, 32);
75 writer.Write(OnOutOfAmmo, 32);
76 writer.Write(OnNoPath, 32);
77
78 writer.Write(AdditionalHealth);
79 writer.Write((int)Job);
80
81 writer.WriteInt16(PatrolPathId);
82 writer.WriteInt16(CombatId);
83 writer.WriteInt16(MeleeId);
84 writer.WriteInt16(NeutralId);
85
86 writer.WriteInt16(MaxAmmoUsed);
87 writer.WriteInt16(MaxAmmoDropped);
88 writer.WriteInt16(MaxCellsUsed);
89 writer.WriteInt16(MaxCellsDropped);
90 writer.WriteInt16(MaxHyposUsed);
91 writer.WriteInt16(MaxHyposDropped);
92 writer.WriteInt16(MaxShieldsUsed);
93 writer.WriteInt16(MaxShieldsDropped);
94 writer.WriteInt16(MaxCloakUsed);
95 writer.WriteInt16(MaxCloakDropped);
96
97 writer.Skip(4);
98
99 writer.Write((int)Team);
100 writer.Write(AmmoPercent);
101
102 writer.Write((int)InitialAlertLevel);
103 writer.Write((int)MinimalAlertLevel);
104 writer.Write((int)JobStartingAlertLevel);
105 writer.Write((int)InvestigatingAlertLevel);
106
107 writer.Write(AlarmGroups);
108
109 writer.Write((int)PursuitStrongUnseen);
110 writer.Write((int)PursuitWeakUnseen);
111 writer.Write((int)PursuitStrongSeen);
112 writer.Write((int)PursuitWeakSeen);
113 writer.Write((int)PursuitLost);
114 }
115
116 protected override void ReadOsd(BinaryReader reader)
117 {
118 Flags = (CharacterFlags)reader.ReadInt32();
119
120 ClassName = reader.ReadString(64);
121 Name = reader.ReadString(32);
122 WeaponClassName = reader.ReadString(64);
123
124 OnSpawn = reader.ReadString(32);
125 OnDeath = reader.ReadString(32);
126 OnSeenEnemy = reader.ReadString(32);
127 OnAlarmed = reader.ReadString(32);
128 OnHurt = reader.ReadString(32);
129 OnDefeated = reader.ReadString(32);
130 OnOutOfAmmo = reader.ReadString(32);
131 OnNoPath = reader.ReadString(32);
132
133 AdditionalHealth = reader.ReadInt32();
134 Job = (CharacterJobType)reader.ReadInt32();
135
136 PatrolPathId = reader.ReadInt16();
137 CombatId = reader.ReadInt16();
138 MeleeId = reader.ReadInt16();
139 NeutralId = reader.ReadInt16();
140
141 MaxAmmoUsed = reader.ReadInt16();
142 MaxAmmoDropped = reader.ReadInt16();
143 MaxCellsUsed = reader.ReadInt16();
144 MaxCellsDropped = reader.ReadInt16();
145 MaxHyposUsed = reader.ReadInt16();
146 MaxHyposDropped = reader.ReadInt16();
147 MaxShieldsUsed = reader.ReadInt16();
148 MaxShieldsDropped = reader.ReadInt16();
149 MaxCloakUsed = reader.ReadInt16();
150 MaxCloakDropped = reader.ReadInt16();
151
152 reader.Skip(4);
153
154 Team = (CharacterTeam)reader.ReadInt32();
155 AmmoPercent = reader.ReadInt32();
156
157 InitialAlertLevel = (CharacterAlertStatus)reader.ReadInt32();
158 MinimalAlertLevel = (CharacterAlertStatus)reader.ReadInt32();
159 JobStartingAlertLevel = (CharacterAlertStatus)reader.ReadInt32();
160 InvestigatingAlertLevel = (CharacterAlertStatus)reader.ReadInt32();
161
162 AlarmGroups = reader.ReadInt32();
163
164 PursuitStrongUnseen = (CharacterPursuitMode)reader.ReadInt32();
165 PursuitWeakUnseen = (CharacterPursuitMode)reader.ReadInt32();
166 PursuitStrongSeen = (CharacterPursuitMode)reader.ReadInt32();
167 PursuitWeakSeen = (CharacterPursuitMode)reader.ReadInt32();
168 PursuitLost = (CharacterPursuitLostBehavior)reader.ReadInt32();
169 }
170
171 protected override void WriteOsd(XmlWriter xml)
172 {
173 throw new NotImplementedException();
174 }
175
176 protected override void ReadOsd(XmlReader xml, ObjectLoadContext context)
177 {
178 Flags = xml.ReadElementContentAsEnum<CharacterFlags>("Flags");
179 ClassName = xml.ReadElementContentAsString("Class", "");
180 Name = xml.ReadElementContentAsString("Name", "");
181 WeaponClassName = xml.ReadElementContentAsString("Weapon", "");
182
183 xml.ReadStartElement("Scripts");
184 OnSpawn = xml.ReadElementContentAsString("Spawn", "");
185 OnDeath = xml.ReadElementContentAsString("Die", "");
186 OnSeenEnemy = xml.ReadElementContentAsString("Combat", "");
187 OnAlarmed = xml.ReadElementContentAsString("Alarm", "");
188 OnHurt = xml.ReadElementContentAsString("Hurt", "");
189 OnDefeated = xml.ReadElementContentAsString("Defeated", "");
190 OnOutOfAmmo = xml.ReadElementContentAsString("OutOfAmmo", "");
191 OnNoPath = xml.ReadElementContentAsString("NoPath", "");
192 xml.ReadEndElement();
193
194 AdditionalHealth = xml.ReadElementContentAsInt("AdditionalHealth", "");
195
196 xml.ReadStartElement("Job");
197 Job = xml.ReadElementContentAsEnum<CharacterJobType>("Type");
198 PatrolPathId = xml.ReadElementContentAsInt("PatrolPathId", "");
199 xml.ReadEndElement();
200
201 xml.ReadStartElement("Behaviors");
202 CombatId = xml.ReadElementContentAsInt("CombatId", "");
203 MeleeId = xml.ReadElementContentAsInt("MeleeId", "");
204 NeutralId = xml.ReadElementContentAsInt("NeutralId", "");
205 xml.ReadEndElement();
206
207 xml.ReadStartElement("Inventory");
208 xml.ReadStartElement("Ammo");
209 MaxAmmoUsed = xml.ReadElementContentAsInt("Use", "");
210 MaxAmmoDropped = xml.ReadElementContentAsInt("Drop", "");
211 xml.ReadEndElement();
212 xml.ReadStartElement("EnergyCell");
213 MaxCellsUsed = xml.ReadElementContentAsInt("Use", "");
214 MaxCellsDropped = xml.ReadElementContentAsInt("Drop", "");
215 xml.ReadEndElement();
216 xml.ReadStartElement("Hypo");
217 MaxHyposUsed = xml.ReadElementContentAsInt("Use", "");
218 MaxHyposDropped = xml.ReadElementContentAsInt("Drop", "");
219 xml.ReadEndElement();
220 xml.ReadStartElement("Shield");
221 MaxShieldsUsed = xml.ReadElementContentAsInt("Use", "");
222 MaxShieldsDropped = xml.ReadElementContentAsInt("Drop", "");
223 xml.ReadEndElement();
224 xml.ReadStartElement("Invisibility");
225 MaxCloakUsed = xml.ReadElementContentAsInt("Use", "");
226 MaxCloakDropped = xml.ReadElementContentAsInt("Drop", "");
227 xml.ReadEndElement();
228 xml.ReadEndElement();
229
230 Team = xml.ReadElementContentAsEnum<CharacterTeam>("Team");
231 AmmoPercent = xml.ReadElementContentAsInt("AmmoPercentage", "");
232
233 xml.ReadStartElement("Alert");
234 InitialAlertLevel = xml.ReadElementContentAsEnum<CharacterAlertStatus>("Initial");
235 MinimalAlertLevel = xml.ReadElementContentAsEnum<CharacterAlertStatus>("Minimal");
236 JobStartingAlertLevel = xml.ReadElementContentAsEnum<CharacterAlertStatus>("JobStart");
237 InvestigatingAlertLevel = xml.ReadElementContentAsEnum<CharacterAlertStatus>("Investigate");
238 xml.ReadEndElement();
239
240 AlarmGroups = xml.ReadElementContentAsInt("AlarmGroups", "");
241
242 xml.ReadStartElement("Pursuit");
243 PursuitStrongUnseen = xml.ReadElementContentAsEnum<CharacterPursuitMode>("StrongUnseen");
244 PursuitWeakUnseen = xml.ReadElementContentAsEnum<CharacterPursuitMode>("WeakUnseen");
245 PursuitStrongSeen = xml.ReadElementContentAsEnum<CharacterPursuitMode>("StrongSeen");
246 PursuitWeakSeen = xml.ReadElementContentAsEnum<CharacterPursuitMode>("WeakSeen");
247 PursuitLost = xml.ReadElementContentAsEnum<CharacterPursuitLostBehavior>("Lost");
248 xml.ReadEndElement();
249 }
250 }
251}
Note: See TracBrowser for help on using the repository browser.