Rename Capture related traits to ExternalCapture

This commit is contained in:
Curtis Shmyr
2013-10-27 16:17:52 -06:00
parent b86ddbf66b
commit c1e5be380e
17 changed files with 65 additions and 68 deletions

View File

@@ -16,18 +16,18 @@ using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Mods.RA.Activities namespace OpenRA.Mods.RA.Activities
{ {
class CaptureActor : Activity class ExternalCaptureActor : Activity
{ {
Target target; Target target;
public CaptureActor(Target target) { this.target = target; } public ExternalCaptureActor(Target target) { this.target = target; }
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (target.Type != TargetType.Actor) if (target.Type != TargetType.Actor)
return NextActivity; return NextActivity;
var capturable = target.Actor.Trait<Capturable>(); var capturable = target.Actor.Trait<ExternalCapturable>();
if (IsCanceled || !self.IsInWorld || self.IsDead() || !target.IsValidFor(self)) if (IsCanceled || !self.IsInWorld || self.IsDead() || !target.IsValidFor(self))
{ {
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Activities
if (capturable.CaptureProgressTime == capturable.Info.CaptureCompleteTime * 25) if (capturable.CaptureProgressTime == capturable.Info.CaptureCompleteTime * 25)
{ {
var capturesInfo = self.Info.Traits.Get<CapturesInfo>(); var capturesInfo = self.Info.Traits.Get<ExternalCapturesInfo>();
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {

View File

@@ -17,20 +17,20 @@ using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
[Desc("This actor can be captured by a unit with Captures: trait.")] [Desc("This actor can be captured by a unit with ExternalCaptures: trait.")]
public class CapturableInfo : ITraitInfo public class ExternalCapturableInfo : ITraitInfo
{ {
[Desc("Type of actor (the Captures: trait defines what Types it can capture).")] [Desc("Type of actor (the ExternalCaptures: trait defines what Types it can capture).")]
public readonly string Type = "building"; public readonly string Type = "building";
public readonly bool AllowAllies = false; public readonly bool AllowAllies = false;
public readonly bool AllowNeutral = true; public readonly bool AllowNeutral = true;
public readonly bool AllowEnemies = true; public readonly bool AllowEnemies = true;
[Desc("Seconds it takes to change the owner.", "You might want to add a CapturableBar: trait, too.")] [Desc("Seconds it takes to change the owner.", "You might want to add a ExternalCapturableBar: trait, too.")]
public readonly int CaptureCompleteTime = 15; public readonly int CaptureCompleteTime = 15;
public bool CanBeTargetedBy(Actor captor, Player owner) public bool CanBeTargetedBy(Actor captor, Player owner)
{ {
var c = captor.TraitOrDefault<Captures>(); var c = captor.TraitOrDefault<ExternalCaptures>();
if (c == null) if (c == null)
return false; return false;
@@ -50,18 +50,18 @@ namespace OpenRA.Mods.RA
return true; return true;
} }
public object Create(ActorInitializer init) { return new Capturable(init.self, this); } public object Create(ActorInitializer init) { return new ExternalCapturable(init.self, this); }
} }
public class Capturable : ITick public class ExternalCapturable : ITick
{ {
[Sync] public int CaptureProgressTime = 0; [Sync] public int CaptureProgressTime = 0;
[Sync] public Actor Captor; [Sync] public Actor Captor;
private Actor self; private Actor self;
public CapturableInfo Info; public ExternalCapturableInfo Info;
public bool CaptureInProgress { get { return Captor != null; } } public bool CaptureInProgress { get { return Captor != null; } }
public Capturable(Actor self, CapturableInfo info) public ExternalCapturable(Actor self, ExternalCapturableInfo info)
{ {
this.self = self; this.self = self;
Info = info; Info = info;

View File

@@ -15,19 +15,19 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
[Desc("Visualize the remaining CaptureCompleteTime from Capturable: trait.")] [Desc("Visualize the remaining CaptureCompleteTime from ExternalCapturable: trait.")]
class CapturableBarInfo : ITraitInfo, Requires<CapturableInfo> class ExternalCapturableBarInfo : ITraitInfo, Requires<ExternalCapturableInfo>
{ {
public object Create(ActorInitializer init) { return new CapturableBar(init.self); } public object Create(ActorInitializer init) { return new ExternalCapturableBar(init.self); }
} }
class CapturableBar : ISelectionBar class ExternalCapturableBar : ISelectionBar
{ {
Capturable cap; ExternalCapturable cap;
public CapturableBar(Actor self) public ExternalCapturableBar(Actor self)
{ {
this.cap = self.Trait<Capturable>(); this.cap = self.Trait<ExternalCapturable>();
} }
public float GetValue() public float GetValue()

View File

@@ -20,22 +20,22 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
[Desc("This actor can capture other actors which have the Capturable: trait.")] [Desc("This actor can capture other actors which have the ExternalCapturable: trait.")]
class CapturesInfo : ITraitInfo class ExternalCapturesInfo : ITraitInfo
{ {
[Desc("Types of actors that it can capture, as long as the type also exists in the Capturable Type: trait.")] [Desc("Types of actors that it can capture, as long as the type also exists in the ExternalCapturable Type: trait.")]
public readonly string[] CaptureTypes = { "building" }; public readonly string[] CaptureTypes = { "building" };
[Desc("Destroy the unit after capturing.")] [Desc("Destroy the unit after capturing.")]
public readonly bool ConsumeActor = false; public readonly bool ConsumeActor = false;
public object Create(ActorInitializer init) { return new Captures(init.self, this); } public object Create(ActorInitializer init) { return new ExternalCaptures(init.self, this); }
} }
class Captures : IIssueOrder, IResolveOrder, IOrderVoice class ExternalCaptures : IIssueOrder, IResolveOrder, IOrderVoice
{ {
public readonly CapturesInfo Info; public readonly ExternalCapturesInfo Info;
public Captures(Actor self, CapturesInfo info) public ExternalCaptures(Actor self, ExternalCapturesInfo info)
{ {
Info = info; Info = info;
} }
@@ -44,13 +44,13 @@ namespace OpenRA.Mods.RA
{ {
get get
{ {
yield return new CaptureOrderTargeter(); yield return new ExternalCaptureOrderTargeter();
} }
} }
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
{ {
if (order.OrderID != "CaptureActor") if (order.OrderID != "ExternalCaptureActor")
return null; return null;
if (target.Type == TargetType.FrozenActor) if (target.Type == TargetType.FrozenActor)
@@ -76,23 +76,23 @@ namespace OpenRA.Mods.RA
if (frozen == null) if (frozen == null)
return false; return false;
var ci = frozen.Info.Traits.GetOrDefault<CapturableInfo>(); var ci = frozen.Info.Traits.GetOrDefault<ExternalCapturableInfo>();
return ci != null && ci.CanBeTargetedBy(self, frozen.Owner); return ci != null && ci.CanBeTargetedBy(self, frozen.Owner);
} }
var c = order.TargetActor.TraitOrDefault<Capturable>(); var c = order.TargetActor.TraitOrDefault<ExternalCapturable>();
return c != null && !c.CaptureInProgress && c.Info.CanBeTargetedBy(self, order.TargetActor.Owner); return c != null && !c.CaptureInProgress && c.Info.CanBeTargetedBy(self, order.TargetActor.Owner);
} }
public string VoicePhraseForOrder(Actor self, Order order) public string VoicePhraseForOrder(Actor self, Order order)
{ {
return order.OrderString == "CaptureActor" && IsValidOrder(self, order) return order.OrderString == "ExternalCaptureActor" && IsValidOrder(self, order)
? "Attack" : null; ? "Attack" : null;
} }
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString != "CaptureActor" || !IsValidOrder(self, order)) if (order.OrderString != "ExternalCaptureActor" || !IsValidOrder(self, order))
return; return;
var target = self.ResolveFrozenActorOrder(order, Color.Red); var target = self.ResolveFrozenActorOrder(order, Color.Red);
@@ -103,17 +103,17 @@ namespace OpenRA.Mods.RA
self.CancelActivity(); self.CancelActivity();
self.SetTargetLine(target, Color.Red); self.SetTargetLine(target, Color.Red);
self.QueueActivity(new CaptureActor(target)); self.QueueActivity(new ExternalCaptureActor(target));
} }
} }
class CaptureOrderTargeter : UnitOrderTargeter class ExternalCaptureOrderTargeter : UnitOrderTargeter
{ {
public CaptureOrderTargeter() : base("CaptureActor", 6, "enter", true, true) { } public ExternalCaptureOrderTargeter() : base("ExternalCaptureActor", 6, "enter", true, true) { }
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{ {
var c = target.TraitOrDefault<Capturable>(); var c = target.TraitOrDefault<ExternalCapturable>();
var canTargetActor = c != null && !c.CaptureInProgress && c.Info.CanBeTargetedBy(self, target.Owner); var canTargetActor = c != null && !c.CaptureInProgress && c.Info.CanBeTargetedBy(self, target.Owner);
cursor = canTargetActor ? "ability" : "move-blocked"; cursor = canTargetActor ? "ability" : "move-blocked";
@@ -122,7 +122,7 @@ namespace OpenRA.Mods.RA
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{ {
var c = target.Info.Traits.GetOrDefault<CapturableInfo>(); var c = target.Info.Traits.GetOrDefault<ExternalCapturableInfo>();
var canTargetActor = c != null && c.CanBeTargetedBy(self, target.Owner); var canTargetActor = c != null && c.CanBeTargetedBy(self, target.Owner);
cursor = canTargetActor ? "ability" : "move-blocked"; cursor = canTargetActor ? "ability" : "move-blocked";

View File

@@ -87,7 +87,7 @@
<Compile Include="AcceptsSupplies.cs" /> <Compile Include="AcceptsSupplies.cs" />
<Compile Include="Activities\Attack.cs" /> <Compile Include="Activities\Attack.cs" />
<Compile Include="Activities\CallFunc.cs" /> <Compile Include="Activities\CallFunc.cs" />
<Compile Include="Activities\CaptureActor.cs" /> <Compile Include="Activities\ExternalCaptureActor.cs" />
<Compile Include="Activities\DeliverResources.cs" /> <Compile Include="Activities\DeliverResources.cs" />
<Compile Include="Activities\Demolish.cs" /> <Compile Include="Activities\Demolish.cs" />
<Compile Include="Activities\DonateSupplies.cs" /> <Compile Include="Activities\DonateSupplies.cs" />
@@ -174,10 +174,10 @@
<Compile Include="Buildings\Wall.cs" /> <Compile Include="Buildings\Wall.cs" />
<Compile Include="Burns.cs" /> <Compile Include="Burns.cs" />
<Compile Include="C4Demolition.cs" /> <Compile Include="C4Demolition.cs" />
<Compile Include="Capturable.cs" /> <Compile Include="ExternalCapturable.cs" />
<Compile Include="CapturableBar.cs" /> <Compile Include="ExternalCapturableBar.cs" />
<Compile Include="LegacyCapturable.cs" /> <Compile Include="LegacyCapturable.cs" />
<Compile Include="Captures.cs" /> <Compile Include="ExternalCaptures.cs" />
<Compile Include="Cargo.cs" /> <Compile Include="Cargo.cs" />
<Compile Include="CarpetBomb.cs" /> <Compile Include="CarpetBomb.cs" />
<Compile Include="CashTrickler.cs" /> <Compile Include="CashTrickler.cs" />
@@ -529,7 +529,5 @@ cd "$(SolutionDir)thirdparty/"
copy "FuzzyLogicLibrary.dll" "$(SolutionDir)" copy "FuzzyLogicLibrary.dll" "$(SolutionDir)"
cd "$(SolutionDir)"</PostBuildEvent> cd "$(SolutionDir)"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup />
<Folder Include="AI\States\" />
</ItemGroup>
</Project> </Project>

View File

@@ -208,8 +208,8 @@
SellSounds: BUILD1.WAV SellSounds: BUILD1.WAV
Adjacent: 3 Adjacent: 3
GivesBuildableArea: GivesBuildableArea:
Capturable: ExternalCapturable:
CapturableBar: ExternalCapturableBar:
SoundOnDamageTransition: SoundOnDamageTransition:
DamagedSound: EXPLSML1.WAV DamagedSound: EXPLSML1.WAV
DestroyedSound: EXPLHG1.WAV DestroyedSound: EXPLHG1.WAV

View File

@@ -47,7 +47,7 @@ ENGINEER:
Passenger: Passenger:
PipType: Yellow PipType: Yellow
EngineerRepair: EngineerRepair:
Captures: ExternalCaptures:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:
JustMove: true JustMove: true

View File

@@ -640,8 +640,8 @@ SIETCH:
Range: 10 Range: 10
-GivesBuildableArea: -GivesBuildableArea:
-Sellable: -Sellable:
-Capturable: -ExternalCapturable:
-CapturableBar: -ExternalCapturableBar:
STARPORTC: STARPORTC:
Inherits: ^STARPORT Inherits: ^STARPORT

View File

@@ -529,8 +529,8 @@ Rules:
Bib: Bib:
RevealsShroud: RevealsShroud:
Range: 3 Range: 3
Capturable: ExternalCapturable:
CapturableBar: ExternalCapturableBar:
EngineerRepairable: EngineerRepairable:
-MustBeDestroyed: -MustBeDestroyed:
CashTrickler: CashTrickler:

View File

@@ -2606,8 +2606,8 @@ Rules:
HP: 2000 HP: 2000
Armor: Armor:
Heavy: Heavy:
Capturable: ExternalCapturable:
CapturableBar: ExternalCapturableBar:
CashTrickler: CashTrickler:
Period: 750 Period: 750
Amount: 333 Amount: 333

View File

@@ -2940,7 +2940,7 @@ Rules:
HP: 1500 HP: 1500
Armor: Armor:
Heavy: Heavy:
Capturable: ExternalCapturable:
CashTrickler: CashTrickler:
Period: 250 Period: 250
Amount: 50 Amount: 50

View File

@@ -2157,8 +2157,8 @@ Rules:
HP: 2000 HP: 2000
Armor: Armor:
Heavy: Heavy:
Capturable: ExternalCapturable:
CapturableBar: ExternalCapturableBar:
CashTrickler: CashTrickler:
Period: 750 Period: 750
Amount: 333 Amount: 333

View File

@@ -2588,7 +2588,7 @@ Rules:
HP: 2000 HP: 2000
Armor: Armor:
Heavy: Heavy:
Capturable: ExternalCapturable:
CashTrickler: CashTrickler:
Period: 750 Period: 750
Amount: 333 Amount: 333

View File

@@ -79,8 +79,8 @@ HOSP:
Dimensions: 2,2 Dimensions: 2,2
Health: Health:
HP: 1000 HP: 1000
Capturable: ExternalCapturable:
CapturableBar: ExternalCapturableBar:
EngineerRepairable: EngineerRepairable:
SelfHealingTech: SelfHealingTech:
Type: InfantryHealing Type: InfantryHealing
@@ -320,8 +320,8 @@ OILB:
HP: 1000 HP: 1000
RevealsShroud: RevealsShroud:
Range: 3 Range: 3
Capturable: ExternalCapturable:
CapturableBar: ExternalCapturableBar:
EngineerRepairable: EngineerRepairable:
-MustBeDestroyed: -MustBeDestroyed:
CashTrickler: CashTrickler:

View File

@@ -222,8 +222,8 @@
TerrainTypes: Clear,Road TerrainTypes: Clear,Road
RequiresBaseProvider: True RequiresBaseProvider: True
GivesBuildableArea: GivesBuildableArea:
Capturable: ExternalCapturable:
CapturableBar: ExternalCapturableBar:
SoundOnDamageTransition: SoundOnDamageTransition:
DamagedSound: kaboom1.aud DamagedSound: kaboom1.aud
DestroyedSound: kaboom22.aud DestroyedSound: kaboom22.aud
@@ -303,8 +303,8 @@
-AcceptsSupplies: -AcceptsSupplies:
-GivesBuildableArea: -GivesBuildableArea:
-Sellable: -Sellable:
-Capturable: -ExternalCapturable:
-CapturableBar: -ExternalCapturableBar:
FrozenUnderFog: FrozenUnderFog:
StartsRevealed: true StartsRevealed: true
-GpsDot: -GpsDot:

View File

@@ -172,7 +172,7 @@ E6:
PipType: Yellow PipType: Yellow
EngineerRepair: EngineerRepair:
RepairsBridges: RepairsBridges:
Captures: ExternalCaptures:
TakeCover: TakeCover:
-AutoTarget: -AutoTarget:
AttackMove: AttackMove:

View File

@@ -11,7 +11,6 @@
TerrainTypes: Clear,Road TerrainTypes: Clear,Road
GivesBuildableArea: GivesBuildableArea:
Capturable: Capturable:
CapturableBar:
SoundOnDamageTransition: SoundOnDamageTransition:
DamagedSound: #TODO DamagedSound: #TODO
DestroyedSound: #TODO DestroyedSound: #TODO