From 578f47d3b23486381e01d1024d39bf0559fcf078 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 21 Jul 2010 12:21:56 +1200 Subject: [PATCH] Fix crates. Untested but should work. --- OpenRA.Mods.RA/Crate.cs | 19 +++++++++++++++---- mods/cnc/system.yaml | 1 + mods/ra/system.yaml | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index 94d65458e2..83e657f7b9 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -31,7 +31,8 @@ namespace OpenRA.Mods.RA class CrateInfo : ITraitInfo, ITraitPrerequisite { public readonly int Lifetime = 5; // Seconds - public object Create(ActorInitializer init) { return new Crate(init); } + public readonly string[] TerrainTypes = {}; + public object Create(ActorInitializer init) { return new Crate(init, this); } } // IMove is required for paradrop @@ -44,10 +45,12 @@ namespace OpenRA.Mods.RA [Sync] public int2 Location; - public Crate(ActorInitializer init) + CrateInfo Info; + public Crate(ActorInitializer init, CrateInfo info) { this.self = init.self; this.Location = init.location; + this.Info = info; } public void OnCollected(Actor crusher) @@ -89,9 +92,17 @@ namespace OpenRA.Mods.RA int2[] noCells = new int2[] { }; public IEnumerable OccupiedCells() { return noCells; } - public bool CanEnterCell(int2 location) { return self.World.GetTerrainInfo(location).Buildable; } + public bool CanEnterCell(int2 cell) { return MovementCostForCell(self, cell) < float.PositiveInfinity; } - public float MovementCostForCell(Actor self, int2 cell) { return 0; } + public float MovementCostForCell(Actor self, int2 cell) + { + if (!self.World.Map.IsInMap(cell.X,cell.Y)) + return float.PositiveInfinity; + + var type = self.World.GetTerrainType(cell); + return Info.TerrainTypes.Contains(type) ? 0f : float.PositiveInfinity; + } + public float MovementSpeedForCell(Actor self, int2 cell) { return 1; } public IEnumerable GetCurrentPath(Actor self) { return new float2[] {}; } diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml index a260fc993b..f3d6c247ed 100644 --- a/mods/cnc/system.yaml +++ b/mods/cnc/system.yaml @@ -149,6 +149,7 @@ CRATE: Description: Crate Crate: Lifetime: 120 + TerrainTypes: Clear, Rough, Road, Ore, Beach GiveCashCrateAction: Amount: 1000 SelectionShares: 50 diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml index f049a3b4f3..2cbf1a9523 100644 --- a/mods/ra/system.yaml +++ b/mods/ra/system.yaml @@ -212,6 +212,7 @@ CRATE: Description: Crate Crate: Lifetime: 120 + TerrainTypes: Clear, Rough, Road, Water, Ore, Beach SpeedUpgradeCrateAction: Multiplier: 1.7 SelectionShares: 10