cargo: added EnterTransport activity; made things mostly work. still very WIP.

This commit is contained in:
Chris Forbes
2010-01-05 15:25:12 +13:00
parent 026a33d2e2
commit 8c9fbb8d6b
7 changed files with 58 additions and 16 deletions

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

View File

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