using System.Collections.Generic; public partial class Structure : GameObject { public Order CurrentOrder { get; protected set; } public bool IsPlayer { get; private set; } public bool IsMobile { get; protected set; } public bool IsLanded { get; protected set; } public bool IsOrbiting { get; protected set; } public long Diameter { get; protected set; } public AI AI { get; protected set; } public List Components { get; protected set; } public List Cargo { get; protected set; } public List Crew { get; protected set; } public Structure(string name, CoordinateVector position, GameObject parent, long diameter, bool isPlayer) : base(name, position, new CoordinateVector(0, 0), parent) { this.IsPlayer = isPlayer; this.IsMobile = false; this.IsLanded = false; this.IsOrbiting = false; this.Diameter = diameter; this.AI = isPlayer ? null : new AI(this); this.Components = new List(); this.Cargo = new List(); this.Crew = new List(); } public override void Simulate() { base.Simulate(); foreach (GameObject component in this.Components) { component.Simulate(); } foreach (GameObject cargoItem in this.Cargo) { cargoItem.Simulate(); } foreach (GameObject crewMember in this.Crew) { crewMember.Simulate(); } ExecuteOrder(); } public bool SetNewPlayerOrder(Order newOrder) { if (!this.IsPlayer) { return false; } this.CurrentOrder = newOrder; return true; } protected bool ExecuteOrder() { bool finished = false; if (this.CurrentOrder == null) { if (!this.IsPlayer && this.AI != null) { this.CurrentOrder = this.AI.Think(); } return false; } if (this.CurrentOrder.Category == Order.OrderCategory.TICK) { finished = ExecuteTickOrder(this.CurrentOrder as TickOrder); } if (this.CurrentOrder.Category == Order.OrderCategory.DESTINATION) { finished = ExecuteDestinationOrder(this.CurrentOrder as DestinationOrder); } if (finished) { this.CurrentOrder = null; } return finished; } protected bool ExecuteTickOrder(TickOrder tickOrder) { bool finished = false; switch (tickOrder.Type) { case Order.OrderType.IDLE: break; case Order.OrderType.ORBIT: break; case Order.OrderType.LAND: break; } return finished; } protected bool ExecuteDestinationOrder(DestinationOrder destinationOrder) { bool finished = false; switch (destinationOrder.Type) { case Order.OrderType.MOVE_THRUSTERS: finished = this.TravelTo(destinationOrder.Destination, false); break; case Order.OrderType.MOVE_WARP: finished = this.TravelTo(destinationOrder.Destination, true); break; } return finished; } }