crushable walls

This commit is contained in:
Chris Forbes
2010-05-06 19:05:31 +12:00
parent 48c5a2ba19
commit 7a25bea751
8 changed files with 72 additions and 17 deletions

View File

@@ -18,10 +18,10 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -18,18 +18,12 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Traits.Activities;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
public class LineBuildInfo : TraitInfo<LineBuild> public class LineBuildInfo : TraitInfo<LineBuild>
{ {
public readonly int Range = 5; public readonly int Range = 5;
} }
public class LineBuild {} public class LineBuild {}
} }

View File

@@ -20,7 +20,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Graphics; using OpenRA.Graphics;

View File

@@ -18,8 +18,39 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
public class WallInfo : TraitInfo<Wall> {} public class WallInfo : ITraitInfo
public class Wall {} {
public readonly UnitMovementType[] CrushableBy = { };
public object Create(Actor self) { return new Wall(self); }
}
public class Wall : ICrushable, IOccupySpace
{
readonly Actor self;
public Wall(Actor self)
{
this.self = self;
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
}
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
public void OnCrush(Actor crusher) { self.InflictDamage(crusher, self.Health, null); }
public bool IsCrushableBy(UnitMovementType umt, Player player)
{
return self.Info.Traits.Get<WallInfo>().CrushableBy.Contains(umt);
}
public bool IsPathableCrush(UnitMovementType umt, Player player)
{
return IsCrushableBy(umt, player);
}
}
} }

View File

@@ -1,3 +1,23 @@
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Traits; using OpenRA.Traits;

View File

@@ -139,9 +139,9 @@ namespace OpenRA
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore) public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
{ {
var res = world.WorldActor.traits.Get<ResourceLayer>(); var res = world.WorldActor.traits.Get<ResourceLayer>();
return !Footprint.Tiles(name, building, topLeft).Any( return Footprint.Tiles(name, building, topLeft).All(
t => !world.Map.IsInMap(t.X, t.Y) || res.GetResource(t) != null || !world.IsCellBuildable(t, t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
building.WaterBound, toIgnore)); world.IsCellBuildable(t, building.WaterBound, toIgnore));
} }
public static bool IsVisible(this Actor a) public static bool IsVisible(this Actor a)

View File

@@ -61,12 +61,12 @@
Category: Building Category: Building
Building: Building:
Dimensions: 1,1 Dimensions: 1,1
Footprint: x Footprint: y
BuildSounds: placbldg.aud BuildSounds: placbldg.aud
Capturable: false Capturable: false
BaseNormal: no BaseNormal: no
Crewed: no Crewed: no
Sight: 0 Sight: 0
Wall: Wall:
LineBuild: LineBuild:
Selectable: Selectable:

View File

@@ -818,6 +818,8 @@ SBAG:
Building: Building:
HP: 100 HP: 100
Armor: none Armor: none
Wall:
CrushableBy: Wheel, Track
FENC: FENC:
Category: Defense Category: Defense
@@ -833,6 +835,8 @@ FENC:
Building: Building:
HP: 100 HP: 100
Armor: none Armor: none
Wall:
CrushableBy: Track
BRIK: BRIK:
Category: Defense Category: Defense
@@ -858,14 +862,21 @@ CYCL:
Armor: none Armor: none
RenderBuildingWall: RenderBuildingWall:
DamageStates: 3 DamageStates: 3
Wall:
CrushableBy: Track
BARB: BARB:
Inherits: ^Wall Inherits: ^Wall
Building: Building:
HP: 100 HP: 100
Armor: none Armor: none
Wall:
CrushableBy: Track
WOOD: WOOD:
Inherits: ^Wall Inherits: ^Wall
Building: Building:
HP: 100 HP: 100
Armor: none Armor: none
Wall:
CrushableBy: Track