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;
|
Location = location;
|
||||||
CenterLocation = Traits.Util.CenterOfCell(Location);
|
CenterLocation = Traits.Util.CenterOfCell(Location);
|
||||||
Owner = owner;
|
Owner = owner;
|
||||||
IsInWorld = true;
|
|
||||||
|
|
||||||
if (Info == null) return;
|
if (Info == null) return;
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,7 @@
|
|||||||
<Compile Include="Traits\Activities\Attack.cs" />
|
<Compile Include="Traits\Activities\Attack.cs" />
|
||||||
<Compile Include="Traits\Activities\CaptureBuilding.cs" />
|
<Compile Include="Traits\Activities\CaptureBuilding.cs" />
|
||||||
<Compile Include="Traits\Activities\Demolish.cs" />
|
<Compile Include="Traits\Activities\Demolish.cs" />
|
||||||
|
<Compile Include="Traits\Activities\EnterTransport.cs" />
|
||||||
<Compile Include="Traits\Activities\Fly.cs" />
|
<Compile Include="Traits\Activities\Fly.cs" />
|
||||||
<Compile Include="Traits\Activities\FlyAttack.cs" />
|
<Compile Include="Traits\Activities\FlyAttack.cs" />
|
||||||
<Compile Include="Traits\Activities\FlyTimed.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)
|
if (exitTile == null)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
var actor = cargo.UnloadOne(self);
|
var actor = cargo.Unload(self);
|
||||||
|
|
||||||
Game.world.AddFrameEndTask(w =>
|
Game.world.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Add(actor);
|
w.Add(actor);
|
||||||
|
|||||||
@@ -11,15 +11,7 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
List<Actor> cargo = new List<Actor>();
|
List<Actor> cargo = new List<Actor>();
|
||||||
|
|
||||||
public Cargo(Actor self)
|
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)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
@@ -50,7 +42,7 @@ namespace OpenRa.Game.Traits
|
|||||||
return cargo.Count == 0;
|
return cargo.Count == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor UnloadOne(Actor self)
|
public Actor Unload(Actor self)
|
||||||
{
|
{
|
||||||
var a = cargo[0];
|
var a = cargo[0];
|
||||||
cargo.RemoveAt(0);
|
cargo.RemoveAt(0);
|
||||||
@@ -79,5 +71,10 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
return PipType.Green;
|
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")
|
if (order.OrderString == "EnterTransport")
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new Move(order.TargetActor, 0));
|
self.QueueActivity(new Move(order.TargetActor.Location, 1));
|
||||||
// todo: actually enter the transport
|
self.QueueActivity(new EnterTransport(self, order.TargetActor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,18 @@ namespace OpenRa.Game
|
|||||||
List<IEffect> effects = new List<IEffect>();
|
List<IEffect> effects = new List<IEffect>();
|
||||||
List<Action<World>> frameEndActions = new List<Action<World>>();
|
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)
|
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); }
|
public void Add(IEffect b) { effects.Add(b); }
|
||||||
|
|||||||
Reference in New Issue
Block a user