Nod Airfield behavior (fly units from offscreen)

This commit is contained in:
Paul Chote
2010-02-01 20:00:09 +13:00
parent ae751ace98
commit f09bdfc49f
11 changed files with 99 additions and 11 deletions

View File

@@ -8,7 +8,8 @@ namespace OpenRa.Traits.Activities
bool isCanceled; bool isCanceled;
public Fly(float2 pos) { Pos = pos; } public Fly(float2 pos) { Pos = pos; }
public Fly(int2 pos) { Pos = Util.CenterOfCell(pos); }
public IActivity NextActivity { get; set; } public IActivity NextActivity { get; set; }
const int CruiseAltitude = 20; const int CruiseAltitude = 20;

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace OpenRa.Traits.Activities namespace OpenRa.Traits.Activities
{ {
class Land : IActivity public class Land : IActivity
{ {
readonly float2 Pos; readonly float2 Pos;
bool isCanceled; bool isCanceled;

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace OpenRa.Traits.Activities namespace OpenRa.Traits.Activities
{ {
class UnloadCargo : IActivity public class UnloadCargo : IActivity
{ {
public IActivity NextActivity { get; set; } public IActivity NextActivity { get; set; }
bool isCanceled; bool isCanceled;

View File

@@ -4,7 +4,7 @@ using OpenRa.GameRules;
namespace OpenRa.Traits namespace OpenRa.Traits
{ {
class ProductionInfo : ITraitInfo public class ProductionInfo : ITraitInfo
{ {
public readonly int[] SpawnOffset = null; public readonly int[] SpawnOffset = null;
public readonly string[] Produces = { }; public readonly string[] Produces = { };
@@ -12,7 +12,7 @@ namespace OpenRa.Traits
public virtual object Create(Actor self) { return new Production(self); } public virtual object Create(Actor self) { return new Production(self); }
} }
class Production : IIssueOrder, IResolveOrder, IProducer, ITags public class Production : IIssueOrder, IResolveOrder, IProducer, ITags
{ {
bool isPrimary = false; bool isPrimary = false;
public bool IsPrimary { get { return isPrimary; } } public bool IsPrimary { get { return isPrimary; } }
@@ -29,7 +29,7 @@ namespace OpenRa.Traits
return newUnit.Info.Traits.GetOrDefault<UnitInfo>().InitialFacing; return newUnit.Info.Traits.GetOrDefault<UnitInfo>().InitialFacing;
} }
public bool Produce( Actor self, ActorInfo producee ) public virtual bool Produce( Actor self, ActorInfo producee )
{ {
var location = CreationLocation( self, producee ); var location = CreationLocation( self, producee );
if( location == null || self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt( location.Value ).Any() ) if( location == null || self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt( location.Value ).Any() )

View File

@@ -11,7 +11,7 @@ namespace OpenRa.Traits
public object Create(Actor self) { return new RallyPoint(self); } public object Create(Actor self) { return new RallyPoint(self); }
} }
class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick public class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick
{ {
[Sync] [Sync]
public int2 rallyPoint; public int2 rallyPoint;

View File

@@ -51,6 +51,7 @@
<Compile Include="Activities\Infiltrate.cs" /> <Compile Include="Activities\Infiltrate.cs" />
<Compile Include="Activities\LayMine.cs" /> <Compile Include="Activities\LayMine.cs" />
<Compile Include="Activities\Steal.cs" /> <Compile Include="Activities\Steal.cs" />
<Compile Include="ProductionAirdrop.cs" />
<Compile Include="C4Demolition.cs" /> <Compile Include="C4Demolition.cs" />
<Compile Include="Effects\CrateEffect.cs" /> <Compile Include="Effects\CrateEffect.cs" />
<Compile Include="Effects\GpsSatellite.cs" /> <Compile Include="Effects\GpsSatellite.cs" />

View File

@@ -0,0 +1,60 @@
using System.Collections.Generic;
using System.Linq;
using OpenRa.GameRules;
using OpenRa.Traits.Activities;
using OpenRa.Traits;
namespace OpenRa.Mods.RA
{
public class ProductionAirdropInfo : ProductionInfo
{
public override object Create(Actor self) { return new ProductionAirdrop(self); }
}
class ProductionAirdrop : Production
{
public ProductionAirdrop(Actor self) : base(self) { }
public override bool Produce( Actor self, ActorInfo producee )
{
var location = CreationLocation(self, producee);
var owner = self.Owner;
// Start at the edge of the map, to the right of the airfield
var startPos = new int2(owner.World.Map.XOffset + owner.World.Map.Width, self.Location.Y);
var endPos = new int2(owner.World.Map.XOffset, self.Location.Y);
var deployOffset = new float2(24f,0);
var rp = self.traits.GetOrDefault<RallyPoint>();
owner.World.AddFrameEndTask(w =>
{
var a = w.CreateActor("C17", startPos, owner);
var cargo = a.traits.Get<Cargo>();
var newUnit = new Actor(self.World, producee.Name, new int2(0, 0), self.Owner);
cargo.Load(a, newUnit);
a.CancelActivity();
a.QueueActivity(new Land(self.CenterLocation+deployOffset));
a.QueueActivity(new CallFunc(() =>
{
var actor = cargo.Unload(self);
self.World.AddFrameEndTask(ww =>
{
ww.Add(actor);
actor.traits.Get<Mobile>().TeleportTo(actor, self.Location);
actor.CancelActivity();
actor.QueueActivity(new Move(rp.rallyPoint, 0));
foreach (var t in self.traits.WithInterface<INotifyProduction>())
t.UnitProduced(self, actor);
});
}));
a.QueueActivity(new Fly(endPos));
a.QueueActivity(new RemoveSelf());
});
return true;
}
}
}

View File

@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<sequences> <sequences>
<!-- Mobile Construction Vehicle -->
<unit name="mcv"> <unit name="mcv">
<sequence name="idle" start="0" length="*" /> <sequence name="idle" start="0" length="*" />
</unit> </unit>
<!-- Tiberium Harvester -->
<unit name="harv"> <unit name="harv">
<sequence name="idle" start="0" length="32" /> <sequence name="idle" start="0" length="32" />
<sequence name="harvest0" start="32" length="4" /> <sequence name="harvest0" start="32" length="4" />
@@ -14,9 +18,16 @@
<sequence name="harvest6" start="56" length="4" /> <sequence name="harvest6" start="56" length="4" />
<sequence name="harvest7" start="60" length="4" /> <sequence name="harvest7" start="60" length="4" />
</unit> </unit>
<!-- Nod Buggy -->
<unit name="bggy"> <unit name="bggy">
<sequence name="idle" start="0" length="32" /> <sequence name="idle" start="0" length="32" />
<sequence name="turret" start="32" length="32" /> <sequence name="turret" start="32" length="32" />
<sequence name="muzzle" start="0" length="48" src="minigun" /> <sequence name="muzzle" start="0" length="48" src="minigun" />
</unit> </unit>
<!-- Nod Supply Aircraft -->
<unit name="c17">
<sequence name="idle" start="0" length="32" />
</unit>
</sequences> </sequences>

View File

@@ -955,7 +955,4 @@
<sequence name="open" start="0" length="5" /> <sequence name="open" start="0" length="5" />
<sequence name="idle" start="5" length="11" /> <sequence name="idle" start="5" length="11" />
</unit> </unit>
<unit name="badr">
<sequence name="idle" start="0" length="16" />
</unit>
</sequences> </sequences>

View File

@@ -151,7 +151,8 @@ AFLD:
Crewed: yes Crewed: yes
Sight: 5 Sight: 5
RallyPoint: RallyPoint:
Production: BelowUnits:
ProductionAirdrop:
Produces: Vehicle Produces: Vehicle
WEAP: WEAP:

View File

@@ -67,3 +67,20 @@ BGGY:
MuzzleFlash: yes MuzzleFlash: yes
RenderUnitTurreted: RenderUnitTurreted:
AutoTarget: AutoTarget:
C17:
ParaDrop:
LZRange: 1
Inherits: ^Plane
Unit:
HP: 25
Armor: light
ROT: 5
Sight: 0
Speed: 40
Plane:
RenderUnit:
WithShadow:
Cargo:
Passengers: 10
-Selectable: