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:
Chris Forbes
2010-01-05 12:50:12 +13:00
parent e74bcba694
commit 323d4bd671
6 changed files with 112 additions and 8 deletions

View File

@@ -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";

View File

@@ -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" />

View 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; }
}
}

View 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;
}
}
}

View File

@@ -283,6 +283,8 @@
<unit name="apc">
<sequence name="idle" start="0" length="32" />
<sequence name="muzzle" start="0" length="48" src="minigun" />
<sequence name="close" start="32" length="3" />
<sequence name="unload" start="32" length="1" />
</unit>
<!-- mine layer -->
<unit name="mnly">
@@ -376,7 +378,7 @@
<sequence name="default-minimap" start="80" length="1" />
<sequence name="ability" start="82" length="8" />
<sequence name="nuke" start="90" length="7" x="12" y="12" />
<sequence name="chrono-select" start="97" length="8" x="12" y="12" />
<sequence name="chrono-select" start="97" length="8" x="12" y="12" />
<sequence name="chrono-target" start="105" length="8" x="12" y="12" />
<sequence name="enter" start="113" length="3" x="12" y="12" />
<sequence name="c4" start="116" length="3" x="12" y="12" />
@@ -536,6 +538,8 @@
</unit>
<unit name="lst">
<sequence name="idle" start="0" length="1" />
<sequence name="open" start="1" length="4" />
<sequence name="unload" start="4" length="1" />
</unit>
<unit name="pips">
<sequence name="groups" start="8" length="10" />
@@ -572,6 +576,8 @@
<sequence name="rotor2" start="0" length="4" src="rrotor" />
<sequence name="slow-rotor" start="4" length="8" src="lrotor" />
<sequence name="slow-rotor2" start="4" length="8" src="rrotor" />
<sequence name="open" start="32" length="4" />
<sequence name="unload" start="35" length="1" />
</unit>
<unit name="v2">
<sequence name="idle" start="0" length="32" />
@@ -1008,8 +1014,8 @@
<sequence name="disabled" start="2" length="1" />
</unit>
<unit name="sell">
<sequence name="normal" start="0" length="1" />
<sequence name="pressed" start="1" length="1" />
<sequence name="disabled" start="2" length="1" />
<sequence name="normal" start="0" length="1" />
<sequence name="pressed" start="1" length="1" />
<sequence name="disabled" start="2" length="1" />
</unit>
</sequences>

View File

@@ -56,7 +56,7 @@ Voice=VehicleVoice
LongDesc=Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft
[APC]
Description=Armored Personnel Carrier
Traits=Unit, Mobile, AttackBase, RenderUnitMuzzleFlash, AutoTarget, Repairable, Chronoshiftable
Traits=Unit, Mobile, AttackBase, RenderUnitMuzzleFlash, AutoTarget, Repairable, Chronoshiftable, Cargo
PrimaryOffset=0,0,0,-4
MuzzleFlash=yes
Voice=VehicleVoice
@@ -138,7 +138,7 @@ Recoil=3
[LST]
Description=Transport
WaterBound=yes
Traits=Unit, Mobile, RenderUnit
Traits=Unit, Mobile, RenderUnit, Cargo
LongDesc=General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed
[PT]
Description=Gunboat
@@ -179,7 +179,7 @@ Description=Transport Helicopter
RotorOffset=0,14,0,-4
RotorOffset2=0,-14,0,-2
BuiltAt=hpad
Traits=Unit, Helicopter, RenderUnitRotor, WithShadow
Traits=Unit, Helicopter, RenderUnitRotor, WithShadow, Cargo
InitialFacing=20
LongDesc=Fast Infantry Transport Helicopter.\n Unarmed
[HELI]