// Following three functions are used for initializing, saving, and loading data. // Initialization function. // Default values. Called on creation, NOT on load. public CivilianMilitia() { this.Centerpiece = -1; this.Status = CivilianMilitiaStatus.Idle; this.PlanetFocus = -1; this.EntityFocus = -1; for (int x = 0; x < (int)CivilianResource.Length; x++) { this.ShipTypeData.Add(x, "none"); this.Ships.Add(x, new List <int>()); this.ShipCapacity.Add(x, 0); } this.CostMultiplier = 100; // 100% this.CapMultiplier = 100; // 100% }
/// <summary> /// Used to load our data from buffer. /// </summary> /// <param name="Buffer"></param> public CivilianMilitia(ArcenDeserializationBuffer Buffer) { this.Version = Buffer.ReadInt32(ReadStyle.NonNeg); this.Centerpiece = Buffer.ReadInt32(ReadStyle.Signed); this.Status = (CivilianMilitiaStatus)Buffer.ReadByte(ReadStyleByte.Normal); if (this.Version < 2) { this.PlanetFocus = (short)Buffer.ReadInt32(ReadStyle.Signed); } else { this.PlanetFocus = Buffer.ReadInt16(ReadStyle.Signed); } this.EntityFocus = Buffer.ReadInt32(ReadStyle.Signed); int count = Buffer.ReadInt32(ReadStyle.NonNeg); for (int x = 0; x < count; x++) { this.ShipTypeData.Add(x, Buffer.ReadString()); this.Ships[x] = new List <int>(); int subCount = Buffer.ReadInt32(ReadStyle.NonNeg); for (int y = 0; y < subCount; y++) { this.Ships[x].Add(Buffer.ReadInt32(ReadStyle.NonNeg)); } this.ShipCapacity[x] = Buffer.ReadInt32(ReadStyle.NonNeg); } if (this.ShipTypeData.Count < (int)CivilianResource.Length) { for (int x = count; x < (int)CivilianResource.Length; x++) { this.ShipTypeData.Add(x, "none"); this.Ships.Add(x, new List <int>()); this.ShipCapacity.Add(x, 0); } } this.CostMultiplier = Buffer.ReadInt32(ReadStyle.NonNeg); this.CapMultiplier = Buffer.ReadInt32(ReadStyle.NonNeg); }