public static RTSUnit Deserialize(BinaryReader s, RTSTeam team, out int?target) { int type = s.ReadInt32(); RTSUnit e = team.AddUnit(type, Vector2.Zero); if (e == null) { throw new Exception("Could Not Create A Unit That Was Previously Created"); } e.UUID = s.ReadInt32(); e.State = s.ReadInt32(); e.ViewDirection = s.ReadVector2(); e.GridPosition = s.ReadVector2(); e.Height = s.ReadSingle(); if (s.ReadBoolean()) { target = s.ReadInt32(); } else { target = null; } e.Health = s.ReadInt32(); e.MovementMultiplier = s.ReadSingle(); e.Resources = s.ReadInt32(); if (s.ReadBoolean()) { if (e.ActionController != null) { e.ActionController.Deserialize(s); } } else { e.ActionController = null; } if (s.ReadBoolean()) { if (e.CombatController != null) { e.CombatController.Deserialize(s); } } else { e.CombatController = null; } if (s.ReadBoolean()) { if (e.MovementController != null) { e.MovementController.Deserialize(s); } } else { e.MovementController = null; } if (s.ReadBoolean()) { if (e.AnimationController != null) { e.AnimationController.Deserialize(s); } } else { e.AnimationController = null; } return(e); }
public static RTSUnit Deserialize(BinaryReader s, RTSTeam team, out int? target) { int type = s.ReadInt32(); RTSUnit e = team.AddUnit(type, Vector2.Zero); if(e == null) throw new Exception("Could Not Create A Unit That Was Previously Created"); e.UUID = s.ReadInt32(); e.State = s.ReadInt32(); e.ViewDirection = s.ReadVector2(); e.GridPosition = s.ReadVector2(); e.Height = s.ReadSingle(); if(s.ReadBoolean()) { target = s.ReadInt32(); } else { target = null; } e.Health = s.ReadInt32(); e.MovementMultiplier = s.ReadSingle(); e.Resources = s.ReadInt32(); if(s.ReadBoolean()) { if(e.ActionController != null) e.ActionController.Deserialize(s); } else { e.ActionController = null; } if(s.ReadBoolean()) { if(e.CombatController != null) e.CombatController.Deserialize(s); } else { e.CombatController = null; } if(s.ReadBoolean()) { if(e.MovementController != null) e.MovementController.Deserialize(s); } else { e.MovementController = null; } if(s.ReadBoolean()) { if(e.AnimationController != null) e.AnimationController.Deserialize(s); } else { e.AnimationController = null; } return e; }