cargo: added cargo-related sequences for APC/LST/TRAN; moved Passengers onto UnitInfo for convenience (and to allow garrisoning without a big hack); added Cargo trait to all known transports
This commit is contained in:
@@ -55,13 +55,14 @@ namespace OpenRa.Game.GameRules
|
||||
public readonly int OrePips = 0;
|
||||
public readonly string Icon = null;
|
||||
public readonly int[] SelectionSize = null;
|
||||
public readonly int Passengers = 0;
|
||||
public readonly int UnloadFacing = 0;
|
||||
|
||||
public UnitInfo(string name) { Name = name; }
|
||||
}
|
||||
|
||||
public class MobileInfo : UnitInfo
|
||||
{
|
||||
public readonly int Passengers = 0;
|
||||
public readonly int Speed = 0;
|
||||
public readonly bool NoMovingFire = false;
|
||||
public readonly string Voice = "GenericVoice";
|
||||
|
||||
@@ -185,6 +185,7 @@
|
||||
<Compile Include="Traits\Activities\Follow.cs" />
|
||||
<Compile Include="Traits\Activities\Turn.cs" />
|
||||
<Compile Include="Traits\Activities\UndeployMcv.cs" />
|
||||
<Compile Include="Traits\Activities\UnloadCargo.cs" />
|
||||
<Compile Include="Traits\APMine.cs" />
|
||||
<Compile Include="Traits\ATMine.cs" />
|
||||
<Compile Include="Traits\AttackBase.cs" />
|
||||
@@ -198,6 +199,7 @@
|
||||
<Compile Include="Traits\BelowUnits.cs" />
|
||||
<Compile Include="Traits\Building.cs" />
|
||||
<Compile Include="Traits\C4Demolition.cs" />
|
||||
<Compile Include="Traits\Cargo.cs" />
|
||||
<Compile Include="Traits\Chronoshiftable.cs" />
|
||||
<Compile Include="Traits\ChronoshiftPaletteEffect.cs" />
|
||||
<Compile Include="Traits\Chronosphere.cs" />
|
||||
|
||||
34
OpenRa.Game/Traits/Activities/UnloadCargo.cs
Normal file
34
OpenRa.Game/Traits/Activities/UnloadCargo.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
class UnloadCargo : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool isCanceled;
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (isCanceled) return NextActivity;
|
||||
|
||||
// if we're a thing that can turn, turn to the
|
||||
// right facing for the unload animation
|
||||
var unit = self.traits.GetOrDefault<Unit>();
|
||||
if (unit != null && unit.Facing != self.Info.UnloadFacing)
|
||||
return Util.SequenceActivities(new Turn(self.Info.UnloadFacing), this);
|
||||
|
||||
// todo: play the `open` anim (or the `close` anim backwards)
|
||||
// todo: unload all the cargo
|
||||
// todo: play the `close` anim (or the `open` anim backwards)
|
||||
|
||||
// as for open/close... the westwood guys suck at being consistent.
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { NextActivity = null; isCanceled = true; }
|
||||
}
|
||||
}
|
||||
61
OpenRa.Game/Traits/Cargo.cs
Normal file
61
OpenRa.Game/Traits/Cargo.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.GameRules;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class Cargo : IPips, IOrder
|
||||
{
|
||||
List<Actor> cargo = new List<Actor>();
|
||||
|
||||
public Cargo(Actor self) { }
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFull(Actor self)
|
||||
{
|
||||
return cargo.Count == self.Info.Passengers;
|
||||
}
|
||||
|
||||
public IEnumerable<PipType> 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<AutoHeal>())
|
||||
return PipType.Yellow;
|
||||
if (!a.traits.WithInterface<AttackBase>().Any())
|
||||
return PipType.Yellow; // noncombat [E6,SPY,THF]
|
||||
if (a.traits.Contains<C4Demolition>())
|
||||
return PipType.Red; // E7
|
||||
|
||||
return PipType.Green;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user