This commit is contained in:
Paul Chote
2010-06-25 23:07:11 +12:00
parent 2373528ad9
commit cf265c8b58
7 changed files with 62 additions and 98 deletions

View File

@@ -45,7 +45,8 @@ namespace OpenRA.Mods.RA
public object Create(ActorInitializer init) { return new Crate(init); }
}
class Crate : ITick, IOccupySpace
// IMove is required for paradrop
class Crate : ITick, IOccupySpace, IMove
{
readonly Actor self;
[Sync]
@@ -98,5 +99,15 @@ namespace OpenRA.Mods.RA
public int2 TopLeft {get { return Location; }}
int2[] noCells = new int2[] { };
public IEnumerable<int2> OccupiedCells() { return noCells; }
public bool CanEnterCell(int2 location) { return true; }
public float MovementCostForCell(Actor self, int2 cell) { return 0; }
public float MovementSpeedForCell(Actor self, int2 cell) { return 1; }
public IEnumerable<float2> GetCurrentPath(Actor self) { return new float2[] {}; }
public void SetPosition(Actor self, int2 cell)
{
Location = cell;
self.CenterLocation = Util.CenterOfCell(cell);
}
}
}

View File

@@ -19,6 +19,7 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Effects;
@@ -30,6 +31,7 @@ namespace OpenRA.Mods.RA
public class ParaDropInfo : TraitInfo<ParaDrop>
{
public readonly int LZRange = 4;
public readonly string ChuteSound = "chute1.aud";
}
public class ParaDrop : ITick
@@ -47,7 +49,8 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self)
{
var r = self.Info.Traits.Get<ParaDropInfo>().LZRange;
var info = self.Info.Traits.Get<ParaDropInfo>();
var r = info.LZRange;
if ((self.Location - lz).LengthSquared <= r * r && !droppedAt.Contains(self.Location))
{
@@ -70,14 +73,14 @@ namespace OpenRA.Mods.RA
Util.CenterOfCell(Util.CellContaining(self.CenterLocation)),
self.traits.Get<Unit>().Altitude, a)));
Sound.Play("chute1.aud", self.CenterLocation);
Sound.Play(info.ChuteSound, self.CenterLocation);
}
}
}
bool IsSuitableCell(Actor self, int2 p)
{
return self.traits.Get<Mobile>().CanEnterCell(p);
return self.traits.WithInterface<IMove>().FirstOrDefault().CanEnterCell(p);
}
void FinishedDropping(Actor self)