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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.Traits.Activities; using OpenRA.Traits.Activities;
using OpenRA.FileFormats;
using System.Drawing;
using OpenRA.Support;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {

View File

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

View File

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

View File

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