convert Crate to use crushable support again

This commit is contained in:
Chris Forbes
2010-07-29 18:48:25 +12:00
parent e325b5954c
commit bb0531b80f
4 changed files with 15 additions and 19 deletions

View File

@@ -10,12 +10,10 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Traits.Activities;
using OpenRA.FileFormats;
using System.Drawing;
using OpenRA.Support;
namespace OpenRA.Traits
{

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA
}
// ITeleportable is required for paradrop
class Crate : ITick, IOccupySpace, ITeleportable
class Crate : ITick, IOccupySpace, ITeleportable, ICrushable
{
readonly Actor self;
[Sync]
@@ -53,9 +53,10 @@ namespace OpenRA.Mods.RA
this.Info = info;
}
public void OnCollected(Actor crusher)
public void OnCrush(Actor crusher)
{
var shares = self.traits.WithInterface<CrateAction>().Select(a => Pair.New(a, a.GetSelectionShares(crusher)));
var shares = self.traits.WithInterface<CrateAction>().Select(
a => Pair.New(a, a.GetSelectionShares(crusher)));
var totalShares = shares.Sum(a => a.Second);
var n = self.World.SharedRandom.Next(totalShares);
@@ -73,13 +74,6 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self)
{
var cell = Util.CellContaining(self.CenterLocation);
var collector = self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(cell).FirstOrDefault();
if (collector != null)
{
OnCollected(collector);
return;
}
if (++ticks >= self.Info.Traits.Get<CrateInfo>().Lifetime * 25)
self.World.AddFrameEndTask(w => w.Remove(self));
@@ -89,8 +83,7 @@ namespace OpenRA.Mods.RA
}
public int2 TopLeft { get { return Location; } }
int2[] noCells = new int2[] { };
public IEnumerable<int2> OccupiedCells() { return noCells; }
public IEnumerable<int2> OccupiedCells() { return new int2[] { Location }; }
public bool CanEnterCell(int2 cell)
{
@@ -104,5 +97,7 @@ namespace OpenRA.Mods.RA
Location = cell;
self.CenterLocation = Util.CenterOfCell(cell);
}
public IEnumerable<string> CrushClasses { get { yield return "crate"; } }
}
}

View File

@@ -3,6 +3,7 @@
Unit:
ROT: 5
Mobile:
Crushes: crate
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 60%, 40%, 100%, 0%, 0%, 0%, 0%, 50%, 40%, 0%
Selectable:
@@ -23,7 +24,7 @@
Unit:
ROT: 5
Mobile:
Crushes: wall
Crushes: wall, crate
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 80%, 70%, 100%, 0%, 0%, 0%, 0%, 70%, 70%, 0%
Selectable:
@@ -61,6 +62,7 @@
RevealsShroud:
Range: 4
Mobile:
Crushes: crate
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 90%, 80%, 0%
Selectable:

View File

@@ -3,7 +3,7 @@
Unit:
ROT: 5
Mobile:
Crushes: atmine
Crushes: atmine, crate
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 60%, 40%, 100%, 0%, 0%, 0%, 0%, 90%, 40%, 0%
Selectable:
@@ -24,7 +24,7 @@
Unit:
ROT: 5
Mobile:
Crushes: wall, atmine
Crushes: wall, atmine, crate
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 80%, 70%, 100%, 0%, 0%, 0%, 0%, 90%, 70%, 0%
Selectable:
@@ -47,7 +47,7 @@
RevealsShroud:
Range: 4
Mobile:
Crushes: apmine
Crushes: apmine, crate
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 100%, 80%, 0%
Selectable:
@@ -67,6 +67,7 @@
Category: Ship
Unit:
Mobile:
Crushes: crate
TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River
TerrainSpeeds: 0%, 0%, 0%, 0%, 100%, 0%, 0%, 0%, 0%, 0%
Selectable: