cargo: added EnterTransport activity; made things mostly work. still very WIP.
This commit is contained in:
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);
|
||||
|
||||
Reference in New Issue
Block a user