source: OniSplit/Level/ScriptCharacter.cs@ 1132

Last change on this file since 1132 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: 2.2 KB
Line 
1using System;
2using System.Xml;
3using Oni.Metadata;
4
5namespace Oni.Level
6{
7 internal class ScriptCharacter
8 {
9 public string className;
10 public string name;
11 public string weaponClassName;
12 public int flagId;
13 public int scriptId;
14 public InstanceMetadata.AISACharacterFlags flags;
15 public InstanceMetadata.AISACharacterTeam team;
16 public string onSpawn;
17 public string onDeath;
18 public string onSeenEnemy;
19 public string onAlarmed;
20 public string onHurt;
21 public string onDefeated;
22 public string onOutOfAmmo;
23 public string onNoPath;
24 public int ammo;
25
26 public static ScriptCharacter Read(XmlReader xml)
27 {
28 xml.ReadStartElement("Character");
29
30 var chr = new ScriptCharacter {
31 name = xml.ReadElementContentAsString("Name", ""),
32 scriptId = xml.ReadElementContentAsInt("ScriptId", ""),
33 flagId = xml.ReadElementContentAsInt("FlagId", ""),
34 flags = xml.ReadElementContentAsEnum<InstanceMetadata.AISACharacterFlags>("Flags"),
35 team = xml.ReadElementContentAsEnum<InstanceMetadata.AISACharacterTeam>("Team"),
36 className = xml.ReadElementContentAsString("Class", "")
37 };
38
39 xml.ReadStartElement("Scripts");
40 chr.onSpawn = xml.ReadElementContentAsString("Spawn", "");
41 chr.onDeath = xml.ReadElementContentAsString("Die", "");
42 chr.onSeenEnemy = xml.ReadElementContentAsString("Combat", "");
43 chr.onAlarmed = xml.ReadElementContentAsString("Alarm", "");
44 chr.onHurt = xml.ReadElementContentAsString("Hurt", "");
45 chr.onDefeated = xml.ReadElementContentAsString("Defeated", "");
46 chr.onOutOfAmmo = xml.ReadElementContentAsString("OutOfAmmo", "");
47 chr.onNoPath = xml.ReadElementContentAsString("NoPath", "");
48 xml.ReadEndElement();
49
50 chr.weaponClassName = xml.ReadElementContentAsString("Weapon", "");
51 chr.ammo = xml.ReadElementContentAsInt("Ammo", "");
52
53 xml.ReadEndElement();
54
55 return chr;
56 }
57 }
58}
Note: See TracBrowser for help on using the repository browser.