Split Capturable into its own trait

This commit is contained in:
Paul Chote
2011-04-10 10:07:00 +12:00
parent 40f6c4e332
commit 43f81501a8
10 changed files with 44 additions and 48 deletions

View File

@@ -22,7 +22,6 @@ namespace OpenRA.Mods.RA.Buildings
public readonly bool BaseNormal = true; public readonly bool BaseNormal = true;
public readonly bool WaterBound = false; public readonly bool WaterBound = false;
public readonly int Adjacent = 2; public readonly int Adjacent = 2;
public readonly bool Capturable = false;
public readonly string Footprint = "x"; public readonly string Footprint = "x";
public readonly int2 Dimensions = new int2(1, 1); public readonly int2 Dimensions = new int2(1, 1);

View File

@@ -0,0 +1,23 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Linq;
using OpenRA.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class CapturableInfo : TraitInfo<Capturable>
{
public readonly string[] CaptureClasses = {"Building"};
}
public class Capturable {}
}

View File

@@ -10,6 +10,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders; using OpenRA.Mods.RA.Orders;
@@ -17,15 +18,26 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class EngineerCaptureInfo : TraitInfo<EngineerCapture> {} class EngineerCaptureInfo : ITraitInfo
{
public string[] CaptureClasses = {"Building"};
public object Create(ActorInitializer init) { return new EngineerCapture(this); }
}
class EngineerCapture : IIssueOrder, IResolveOrder, IOrderVoice class EngineerCapture : IIssueOrder, IResolveOrder, IOrderVoice
{ {
public readonly EngineerCaptureInfo Info;
public EngineerCapture(EngineerCaptureInfo info)
{
Info = info;
}
public IEnumerable<IOrderTargeter> Orders public IEnumerable<IOrderTargeter> Orders
{ {
get get
{ {
yield return new EnterOrderTargeter<Building>( "CaptureBuilding", 5, true, false, yield return new EnterOrderTargeter<Capturable>( "CaptureBuilding", 5, true, false,
_ => true, target => target.Info.Traits.Get<BuildingInfo>().Capturable ); _ => true, target => target.Info.Traits.Get<CapturableInfo>().CaptureClasses.Intersect(Info.CaptureClasses).Any() );
} }
} }

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -340,6 +340,7 @@
<Compile Include="Render\WithMuzzleFlash.cs" /> <Compile Include="Render\WithMuzzleFlash.cs" />
<Compile Include="Render\WithShadow.cs" /> <Compile Include="Render\WithShadow.cs" />
<Compile Include="AnnounceOnBuild.cs" /> <Compile Include="AnnounceOnBuild.cs" />
<Compile Include="Capturable.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -220,6 +220,7 @@
RelativeToTopLeft: yes RelativeToTopLeft: yes
ShakeOnDeath: ShakeOnDeath:
Sellable: Sellable:
Capturable:
^CivBuilding: ^CivBuilding:
Inherits: ^Building Inherits: ^Building
@@ -232,6 +233,7 @@
Type: Wood Type: Wood
Building: Building:
-RepairableBuilding: -RepairableBuilding:
-Capturable:
Tooltip: Tooltip:
Name: Civilian Building Name: Civilian Building
@@ -252,7 +254,6 @@
Dimensions: 1,1 Dimensions: 1,1
Footprint: x Footprint: x
BuildSounds: hvydoor1.aud BuildSounds: hvydoor1.aud
Capturable: false
BaseNormal: no BaseNormal: no
Adjacent: 7 Adjacent: 7
TargetableBuilding: TargetableBuilding:

View File

@@ -11,7 +11,6 @@ FACT:
Power: 15 Power: 15
Footprint: xxx xxx Footprint: xxx xxx
Dimensions: 3,2 Dimensions: 3,2
Capturable: true
Health: Health:
HP: 1750 HP: 1750
RevealsShroud: RevealsShroud:
@@ -60,7 +59,6 @@ NUKE:
Power: 100 Power: 100
Footprint: x_ xx Footprint: x_ xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 400 HP: 400
RevealsShroud: RevealsShroud:
@@ -83,7 +81,6 @@ PROC:
Power: -30 Power: -30
Footprint: xxx xxx === Footprint: xxx xxx ===
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 900 HP: 900
RevealsShroud: RevealsShroud:
@@ -121,7 +118,6 @@ SILO:
Power: -10 Power: -10
Footprint: xx Footprint: xx
Dimensions: 2,1 Dimensions: 2,1
Capturable: true
BaseNormal: no BaseNormal: no
Health: Health:
HP: 300 HP: 300
@@ -153,7 +149,6 @@ PYLE:
Power: -20 Power: -20
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 500 HP: 500
RevealsShroud: RevealsShroud:
@@ -196,7 +191,6 @@ HAND:
Power: -20 Power: -20
Footprint: __ xx xx Footprint: __ xx xx
Dimensions: 2,3 Dimensions: 2,3
Capturable: true
Health: Health:
HP: 500 HP: 500
RevealsShroud: RevealsShroud:
@@ -236,7 +230,6 @@ AFLD:
Power: -30 Power: -30
Footprint: xxxx xxxx Footprint: xxxx xxxx
Dimensions: 4,2 Dimensions: 4,2
Capturable: true
Health: Health:
HP: 1000 HP: 1000
RevealsShroud: RevealsShroud:
@@ -278,7 +271,6 @@ WEAP:
Power: -30 Power: -30
Footprint: ___ xxx === Footprint: ___ xxx ===
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 1000 HP: 1000
RevealsShroud: RevealsShroud:
@@ -321,7 +313,6 @@ HQ:
Power: -40 Power: -40
Footprint: x_ xx Footprint: x_ xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 1000 HP: 1000
RevealsShroud: RevealsShroud:
@@ -359,7 +350,6 @@ NUK2:
Power: 200 Power: 200
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 600 HP: 600
RevealsShroud: RevealsShroud:
@@ -382,7 +372,6 @@ FIX:
Power: -30 Power: -30
Footprint: _x_ xxx =x= Footprint: _x_ xxx =x=
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 800 HP: 800
RevealsShroud: RevealsShroud:
@@ -409,7 +398,6 @@ HPAD:
Power: -10 Power: -10
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 800 HP: 800
RevealsShroud: RevealsShroud:
@@ -451,7 +439,6 @@ EYE:
Power: -200 Power: -200
Footprint: x_ xx Footprint: x_ xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 1000 HP: 1000
RevealsShroud: RevealsShroud:
@@ -490,7 +477,6 @@ TMPL:
Power: -150 Power: -150
Footprint: ___ xxx xxx Footprint: ___ xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 2000 HP: 2000
RevealsShroud: RevealsShroud:

View File

@@ -7,10 +7,10 @@ V19:
Building: Building:
Footprint: x Footprint: x
Dimensions: 1,1 Dimensions: 1,1
Capturable: true
RevealsShroud: RevealsShroud:
Range: 3 Range: 3
-DeadBuildingState: -DeadBuildingState:
Capturable:
Tooltip: Tooltip:
Name: Oil Derrick Name: Oil Derrick
LeavesHusk: LeavesHusk:

View File

@@ -4,7 +4,6 @@ FCOM:
Power: -200 Power: -200
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 400 HP: 400
Armor: Armor:
@@ -124,7 +123,6 @@ MISS:
Building: Building:
Footprint: xxx xxx Footprint: xxx xxx
Dimensions: 3,2 Dimensions: 3,2
Capturable: true
Health: Health:
HP: 400 HP: 400
Armor: Armor:

View File

@@ -154,6 +154,7 @@
Building: Building:
Dimensions: 1,1 Dimensions: 1,1
Footprint: x Footprint: x
Capturable:
SoundOnDamageTransition: SoundOnDamageTransition:
DamagedSound: kaboom1.aud DamagedSound: kaboom1.aud
DestroyedSound: kaboom22.aud DestroyedSound: kaboom22.aud
@@ -181,7 +182,6 @@
Dimensions: 1,1 Dimensions: 1,1
Footprint: x Footprint: x
BuildSounds: placbldg.aud BuildSounds: placbldg.aud
Capturable: false
BaseNormal: no BaseNormal: no
Adjacent: 7 Adjacent: 7
SoundOnDamageTransition: SoundOnDamageTransition:

View File

@@ -55,7 +55,6 @@ GAP:
Power: -60 Power: -60
Footprint: _ x Footprint: _ x
Dimensions: 1,2 Dimensions: 1,2
Capturable: true
Health: Health:
HP: 1000 HP: 1000
Armor: Armor:
@@ -85,7 +84,6 @@ SPEN:
Power: -30 Power: -30
Footprint: xxx xxx xxx Footprint: xxx xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
BaseNormal: no BaseNormal: no
Adjacent: 8 Adjacent: 8
WaterBound: yes WaterBound: yes
@@ -141,7 +139,6 @@ SYRD:
Power: -30 Power: -30
Footprint: xxx xxx xxx Footprint: xxx xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
BaseNormal: no BaseNormal: no
Adjacent: 8 Adjacent: 8
WaterBound: yes WaterBound: yes
@@ -195,7 +192,6 @@ IRON:
Power: -200 Power: -200
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 400 HP: 400
Armor: Armor:
@@ -234,7 +230,6 @@ PDOX:
Power: -200 Power: -200
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 400 HP: 400
Armor: Armor:
@@ -351,7 +346,6 @@ DOME:
Power: -40 Power: -40
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 1000 HP: 1000
Armor: Armor:
@@ -542,7 +536,6 @@ ATEK:
Power: -200 Power: -200
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 400 HP: 400
Armor: Armor:
@@ -578,7 +571,6 @@ WEAP:
Power: -30 Power: -30
Footprint: xxx xxx Footprint: xxx xxx
Dimensions: 3,2 Dimensions: 3,2
Capturable: true
Health: Health:
HP: 1500 HP: 1500
Armor: Armor:
@@ -604,7 +596,6 @@ FACT:
Power: 0 Power: 0
Footprint: xxx xxx xxx Footprint: xxx xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 1000 HP: 1000
Armor: Armor:
@@ -646,7 +637,6 @@ PROC:
Power: -30 Power: -30
Footprint: _x_ xxx x== Footprint: _x_ xxx x==
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 900 HP: 900
Armor: Armor:
@@ -682,7 +672,6 @@ SILO:
Description: Stores excess harvested Ore Description: Stores excess harvested Ore
Building: Building:
Power: -10 Power: -10
Capturable: true
BaseNormal: no BaseNormal: no
Health: Health:
HP: 300 HP: 300
@@ -715,7 +704,6 @@ HPAD:
Power: -10 Power: -10
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 800 HP: 800
Armor: Armor:
@@ -751,7 +739,6 @@ AFLD:
Power: -20 Power: -20
Footprint: xxx xxx Footprint: xxx xxx
Dimensions: 3,2 Dimensions: 3,2
Capturable: true
Health: Health:
HP: 1000 HP: 1000
Armor: Armor:
@@ -804,7 +791,6 @@ POWR:
Power: 100 Power: 100
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 400 HP: 400
Armor: Armor:
@@ -833,7 +819,6 @@ APWR:
Power: 200 Power: 200
Footprint: ___ xxx xxx Footprint: ___ xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 700 HP: 700
Armor: Armor:
@@ -862,7 +847,6 @@ STEK:
Power: -100 Power: -100
Footprint: xxx xxx Footprint: xxx xxx
Dimensions: 3,2 Dimensions: 3,2
Capturable: true
Health: Health:
HP: 600 HP: 600
Armor: Armor:
@@ -889,7 +873,6 @@ BARR:
Power: -20 Power: -20
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 800 HP: 800
Armor: Armor:
@@ -927,7 +910,6 @@ TENT:
Power: -20 Power: -20
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
Health: Health:
HP: 800 HP: 800
Armor: Armor:
@@ -965,7 +947,6 @@ FIX:
Power: -30 Power: -30
Footprint: _x_ xxx _x_ Footprint: _x_ xxx _x_
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
Health: Health:
HP: 800 HP: 800
Armor: Armor:
@@ -992,7 +973,6 @@ FACF:
Power: -2 Power: -2
Footprint: xxx xxx xxx Footprint: xxx xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
BaseNormal: no BaseNormal: no
Health: Health:
HP: 30 HP: 30
@@ -1019,7 +999,6 @@ WEAF:
Power: -2 Power: -2
Footprint: xxx xxx Footprint: xxx xxx
Dimensions: 3,2 Dimensions: 3,2
Capturable: true
BaseNormal: no BaseNormal: no
Health: Health:
HP: 30 HP: 30
@@ -1053,7 +1032,6 @@ SYRF:
Power: -2 Power: -2
Footprint: xxx xxx xxx Footprint: xxx xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
BaseNormal: no BaseNormal: no
Adjacent: 8 Adjacent: 8
WaterBound: yes WaterBound: yes
@@ -1074,7 +1052,6 @@ SPEF:
Power: -2 Power: -2
Footprint: xxx xxx xxx Footprint: xxx xxx xxx
Dimensions: 3,3 Dimensions: 3,3
Capturable: true
BaseNormal: no BaseNormal: no
Adjacent: 8 Adjacent: 8
WaterBound: yes WaterBound: yes
@@ -1105,7 +1082,6 @@ DOMF:
Power: -2 Power: -2
Footprint: xx xx Footprint: xx xx
Dimensions: 2,2 Dimensions: 2,2
Capturable: true
BaseNormal: no BaseNormal: no
Health: Health:
HP: 30 HP: 30