cargo: added EnterTransport activity; made things mostly work. still very WIP.
This commit is contained in:
@@ -36,7 +36,6 @@ namespace OpenRa.Game
|
||||
Location = location;
|
||||
CenterLocation = Traits.Util.CenterOfCell(Location);
|
||||
Owner = owner;
|
||||
IsInWorld = true;
|
||||
|
||||
if (Info == null) return;
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
<Compile Include="Traits\Activities\Attack.cs" />
|
||||
<Compile Include="Traits\Activities\CaptureBuilding.cs" />
|
||||
<Compile Include="Traits\Activities\Demolish.cs" />
|
||||
<Compile Include="Traits\Activities\EnterTransport.cs" />
|
||||
<Compile Include="Traits\Activities\Fly.cs" />
|
||||
<Compile Include="Traits\Activities\FlyAttack.cs" />
|
||||
<Compile Include="Traits\Activities\FlyTimed.cs" />
|
||||
|
||||
36
OpenRa.Game/Traits/Activities/EnterTransport.cs
Normal file
36
OpenRa.Game/Traits/Activities/EnterTransport.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
class EnterTransport : IActivity
|
||||
{
|
||||
public IActivity NextActivity { get; set; }
|
||||
bool isCanceled;
|
||||
public Actor transport;
|
||||
|
||||
public EnterTransport(Actor self, Actor transport)
|
||||
{
|
||||
this.transport = transport;
|
||||
}
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (isCanceled) return NextActivity;
|
||||
if (transport == null || !transport.IsInWorld) return NextActivity;
|
||||
|
||||
var cargo = transport.traits.Get<Cargo>();
|
||||
if (cargo.IsFull(transport))
|
||||
return NextActivity;
|
||||
|
||||
cargo.Load(transport, self);
|
||||
Game.world.AddFrameEndTask(w => w.Remove(self));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,8 @@ namespace OpenRa.Game.Traits.Activities
|
||||
if (exitTile == null)
|
||||
return this;
|
||||
|
||||
var actor = cargo.UnloadOne(self);
|
||||
var actor = cargo.Unload(self);
|
||||
|
||||
Game.world.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Add(actor);
|
||||
|
||||
@@ -11,15 +11,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
List<Actor> cargo = new List<Actor>();
|
||||
|
||||
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 Cargo(Actor self) {}
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
@@ -50,7 +42,7 @@ namespace OpenRa.Game.Traits
|
||||
return cargo.Count == 0;
|
||||
}
|
||||
|
||||
public Actor UnloadOne(Actor self)
|
||||
public Actor Unload(Actor self)
|
||||
{
|
||||
var a = cargo[0];
|
||||
cargo.RemoveAt(0);
|
||||
@@ -79,5 +71,10 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
return PipType.Green;
|
||||
}
|
||||
|
||||
public void Load(Actor self, Actor a)
|
||||
{
|
||||
cargo.Add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace OpenRa.Game.Traits
|
||||
if (order.OrderString == "EnterTransport")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 0));
|
||||
// todo: actually enter the transport
|
||||
self.QueueActivity(new Move(order.TargetActor.Location, 1));
|
||||
self.QueueActivity(new EnterTransport(self, order.TargetActor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,18 @@ namespace OpenRa.Game
|
||||
List<IEffect> effects = new List<IEffect>();
|
||||
List<Action<World>> frameEndActions = new List<Action<World>>();
|
||||
|
||||
public void Add(Actor a) { actors.Add(a); ActorAdded(a); }
|
||||
public void Add(Actor a)
|
||||
{
|
||||
a.IsInWorld = true;
|
||||
actors.Add(a);
|
||||
ActorAdded(a);
|
||||
}
|
||||
|
||||
public void Remove(Actor a)
|
||||
{
|
||||
a.IsInWorld = false; actors.Remove(a); ActorRemoved(a);
|
||||
a.IsInWorld = false;
|
||||
actors.Remove(a);
|
||||
ActorRemoved(a);
|
||||
}
|
||||
|
||||
public void Add(IEffect b) { effects.Add(b); }
|
||||
|
||||
Reference in New Issue
Block a user