using System; using System.Collections.Generic; using System.Linq; using System.Text; using OpenRa.Game.GameRules; using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { class Cargo : IPips, IOrder { List cargo = new List(); public Cargo(Actor self) { // hack: cargo.Add(new Actor(Rules.UnitInfo["E1"], int2.Zero, self.Owner)); cargo.Add(new Actor(Rules.UnitInfo["E1"], int2.Zero, self.Owner)); cargo.Add(new Actor(Rules.UnitInfo["E1"], int2.Zero, self.Owner)); cargo.Add(new Actor(Rules.UnitInfo["E6"], int2.Zero, self.Owner)); cargo.Add(new Actor(Rules.UnitInfo["E7"], int2.Zero, self.Owner)); } public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { // todo: check if there is an unoccupied `land` tile adjacent if (mi.Button == MouseButton.Right && underCursor == self && cargo.Count > 0) return new Order("Deploy", self, null, int2.Zero, null); return null; } public void ResolveOrder(Actor self, Order order) { if (order.OrderString == "Deploy") { // todo: eject the units self.CancelActivity(); self.QueueActivity(new UnloadCargo()); } } public bool IsFull(Actor self) { return cargo.Count == self.Info.Passengers; } public bool IsEmpty(Actor self) { return cargo.Count == 0; } public Actor UnloadOne(Actor self) { var a = cargo[0]; cargo.RemoveAt(0); return a; } public IEnumerable GetPips( Actor self ) { for (var i = 0; i < self.Info.Passengers; i++) if (i >= cargo.Count) yield return PipType.Transparent; else yield return GetPipForPassenger(cargo[i]); } static PipType GetPipForPassenger(Actor a) { // probably not actually right yet; fix to match real-ra if (a.traits.Contains()) return PipType.Yellow; if (!a.traits.WithInterface().Any()) return PipType.Yellow; // noncombat [E6,SPY,THF] if (a.traits.Contains()) return PipType.Red; // E7 return PipType.Green; } } }