Refactor supply traits to *Cash traits
Adding 'Type' and 'Stances' support as well.
This commit is contained in:
@@ -248,7 +248,7 @@
|
|||||||
<Compile Include="Scripting\Properties\ParadropProperties.cs" />
|
<Compile Include="Scripting\Properties\ParadropProperties.cs" />
|
||||||
<Compile Include="Scripting\Properties\ParatroopersProperties.cs" />
|
<Compile Include="Scripting\Properties\ParatroopersProperties.cs" />
|
||||||
<Compile Include="TraitsInterfaces.cs" />
|
<Compile Include="TraitsInterfaces.cs" />
|
||||||
<Compile Include="Traits\AcceptsSupplies.cs" />
|
<Compile Include="Traits\AcceptsDeliveredCash.cs" />
|
||||||
<Compile Include="Traits\Air\Aircraft.cs" />
|
<Compile Include="Traits\Air\Aircraft.cs" />
|
||||||
<Compile Include="Traits\Air\AttackBomber.cs" />
|
<Compile Include="Traits\Air\AttackBomber.cs" />
|
||||||
<Compile Include="Traits\Air\AttackHeli.cs" />
|
<Compile Include="Traits\Air\AttackHeli.cs" />
|
||||||
@@ -478,7 +478,7 @@
|
|||||||
<Compile Include="Traits\Sound\DeathSounds.cs" />
|
<Compile Include="Traits\Sound\DeathSounds.cs" />
|
||||||
<Compile Include="Traits\Sound\SoundOnDamageTransition.cs" />
|
<Compile Include="Traits\Sound\SoundOnDamageTransition.cs" />
|
||||||
<Compile Include="Traits\Sound\AttackSounds.cs" />
|
<Compile Include="Traits\Sound\AttackSounds.cs" />
|
||||||
<Compile Include="Traits\SupplyTruck.cs" />
|
<Compile Include="Traits\DeliversCash.cs" />
|
||||||
<Compile Include="Traits\SupportPowers\AirstrikePower.cs" />
|
<Compile Include="Traits\SupportPowers\AirstrikePower.cs" />
|
||||||
<Compile Include="Traits\SupportPowers\GrantExternalConditionPower.cs" />
|
<Compile Include="Traits\SupportPowers\GrantExternalConditionPower.cs" />
|
||||||
<Compile Include="Traits\SupportPowers\NukePower.cs" />
|
<Compile Include="Traits\SupportPowers\NukePower.cs" />
|
||||||
|
|||||||
33
OpenRA.Mods.Common/Traits/AcceptsDeliveredCash.cs
Normal file
33
OpenRA.Mods.Common/Traits/AcceptsDeliveredCash.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2017 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, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Tag trait for actors with `DeliversCash`.")]
|
||||||
|
public class AcceptsDeliveredCashInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
[Desc("Accepted `DeliversCash` types. Leave empty to accept all types.")]
|
||||||
|
public readonly HashSet<string> ValidTypes = new HashSet<string>();
|
||||||
|
|
||||||
|
[Desc("Stance the delivering actor needs to enter.")]
|
||||||
|
public readonly Stance ValidStances = Stance.Ally;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new AcceptsDeliveredCash(init.Self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AcceptsDeliveredCash
|
||||||
|
{
|
||||||
|
public AcceptsDeliveredCash(Actor self, AcceptsDeliveredCashInfo info) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2017 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, either version 3 of
|
|
||||||
* the License, or (at your option) any later version. For more
|
|
||||||
* information, see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
|
||||||
{
|
|
||||||
[Desc("Tag trait for `SupplyTruck` actors.")]
|
|
||||||
class AcceptsSuppliesInfo : TraitInfo<AcceptsSupplies> { }
|
|
||||||
|
|
||||||
class AcceptsSupplies { }
|
|
||||||
}
|
|
||||||
@@ -17,8 +17,8 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Donate money to actors with the `AcceptSupplies` trait.")]
|
[Desc("Donate money to actors with the `AcceptsDeliveredCash` trait.")]
|
||||||
class SupplyTruckInfo : ITraitInfo
|
class DeliversCashInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
[Desc("The amount of cash the owner receives.")]
|
[Desc("The amount of cash the owner receives.")]
|
||||||
public readonly int Payload = 500;
|
public readonly int Payload = 500;
|
||||||
@@ -26,28 +26,31 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("The amount of experience the donating player receives.")]
|
[Desc("The amount of experience the donating player receives.")]
|
||||||
public readonly int PlayerExperience = 0;
|
public readonly int PlayerExperience = 0;
|
||||||
|
|
||||||
|
[Desc("Identifier checked against AcceptsDeliveredCash.ValidTypes. Only needed if the latter is not empty.")]
|
||||||
|
public readonly string Type = null;
|
||||||
|
|
||||||
[VoiceReference] public readonly string Voice = "Action";
|
[VoiceReference] public readonly string Voice = "Action";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new SupplyTruck(this); }
|
public object Create(ActorInitializer init) { return new DeliversCash(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class SupplyTruck : IIssueOrder, IResolveOrder, IOrderVoice
|
class DeliversCash : IIssueOrder, IResolveOrder, IOrderVoice
|
||||||
{
|
{
|
||||||
readonly SupplyTruckInfo info;
|
readonly DeliversCashInfo info;
|
||||||
|
|
||||||
public SupplyTruck(SupplyTruckInfo info)
|
public DeliversCash(DeliversCashInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
{
|
{
|
||||||
get { yield return new SupplyTruckOrderTargeter(); }
|
get { yield return new DeliversCashOrderTargeter(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
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 != "DeliverSupplies")
|
if (order.OrderID != "DeliverCash")
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (target.Type == TargetType.FrozenActor)
|
if (target.Type == TargetType.FrozenActor)
|
||||||
@@ -63,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString != "DeliverSupplies")
|
if (order.OrderString != "DeliverCash")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var target = self.ResolveFrozenActorOrder(order, Color.Yellow);
|
var target = self.ResolveFrozenActorOrder(order, Color.Yellow);
|
||||||
@@ -77,21 +80,29 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.QueueActivity(new DonateSupplies(self, target.Actor, info.Payload, info.PlayerExperience));
|
self.QueueActivity(new DonateSupplies(self, target.Actor, info.Payload, info.PlayerExperience));
|
||||||
}
|
}
|
||||||
|
|
||||||
class SupplyTruckOrderTargeter : UnitOrderTargeter
|
public class DeliversCashOrderTargeter : UnitOrderTargeter
|
||||||
{
|
{
|
||||||
public SupplyTruckOrderTargeter()
|
public DeliversCashOrderTargeter()
|
||||||
: base("DeliverSupplies", 5, "enter", false, true)
|
: base("DeliverCash", 5, "enter", false, 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)
|
||||||
{
|
{
|
||||||
return target.Info.HasTraitInfo<AcceptsSuppliesInfo>();
|
var type = self.Info.TraitInfo<DeliversCashInfo>().Type;
|
||||||
|
var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredCashInfo>();
|
||||||
|
return targetInfo != null
|
||||||
|
&& targetInfo.ValidStances.HasStance(target.Owner.Stances[self.Owner])
|
||||||
|
&& (targetInfo.ValidTypes.Count == 0
|
||||||
|
|| (!string.IsNullOrEmpty(type) && targetInfo.ValidTypes.Contains(type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
return target.Info.HasTraitInfo<AcceptsSuppliesInfo>();
|
var type = self.Info.TraitInfo<DeliversCashInfo>().Type;
|
||||||
|
var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredCashInfo>();
|
||||||
|
return targetInfo != null
|
||||||
|
&& targetInfo.ValidStances.HasStance(target.Owner.Stances[self.Owner])
|
||||||
|
&& (targetInfo.ValidTypes.Count == 0
|
||||||
|
|| (!string.IsNullOrEmpty(type) && targetInfo.ValidTypes.Contains(type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -582,6 +582,20 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (engineVersion < 20170318)
|
if (engineVersion < 20170318)
|
||||||
node.Value.Nodes.RemoveAll(n => n.Key == "ActorGroupProxy");
|
node.Value.Nodes.RemoveAll(n => n.Key == "ActorGroupProxy");
|
||||||
|
|
||||||
|
// Refactor SupplyTruck/AcceptsSupplies traits to DeliversCash/AcceptsDeliveredCash
|
||||||
|
if (engineVersion < 20170415)
|
||||||
|
{
|
||||||
|
if (node.Key == "SupplyTruck")
|
||||||
|
RenameNodeKey(node, "DeliversCash");
|
||||||
|
if (node.Key == "-SupplyTruck")
|
||||||
|
RenameNodeKey(node, "-DeliversCash");
|
||||||
|
|
||||||
|
if (node.Key == "AcceptsSupplies")
|
||||||
|
RenameNodeKey(node, "AcceptsDeliveredCash");
|
||||||
|
if (node.Key == "-AcceptsSupplies")
|
||||||
|
RenameNodeKey(node, "-AcceptsDeliveredCash");
|
||||||
|
}
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ TRUK.Hijackable:
|
|||||||
ExternalCapturable:
|
ExternalCapturable:
|
||||||
Type: MissionObjective
|
Type: MissionObjective
|
||||||
CaptureCompleteTime: 1
|
CaptureCompleteTime: 1
|
||||||
-SupplyTruck:
|
-DeliversCash:
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Image: TRUK
|
Image: TRUK
|
||||||
Palette: truk-soviets
|
Palette: truk-soviets
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ APC:
|
|||||||
|
|
||||||
TRUK:
|
TRUK:
|
||||||
-SpawnActorOnDeath:
|
-SpawnActorOnDeath:
|
||||||
-SupplyTruck:
|
-DeliversCash:
|
||||||
Buildable:
|
Buildable:
|
||||||
Prerequisites: ~disabled
|
Prerequisites: ~disabled
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ APC:
|
|||||||
|
|
||||||
TRUK:
|
TRUK:
|
||||||
-SpawnActorOnDeath:
|
-SpawnActorOnDeath:
|
||||||
-SupplyTruck:
|
-DeliversCash:
|
||||||
Buildable:
|
Buildable:
|
||||||
Prerequisites: ~disabled
|
Prerequisites: ~disabled
|
||||||
|
|
||||||
|
|||||||
@@ -527,7 +527,7 @@
|
|||||||
RepairableBuilding:
|
RepairableBuilding:
|
||||||
PlayerExperience: 25
|
PlayerExperience: 25
|
||||||
EngineerRepairable:
|
EngineerRepairable:
|
||||||
AcceptsSupplies:
|
AcceptsDeliveredCash:
|
||||||
WithMakeAnimation:
|
WithMakeAnimation:
|
||||||
ExternalCapturable:
|
ExternalCapturable:
|
||||||
ExternalCapturableBar:
|
ExternalCapturableBar:
|
||||||
@@ -553,7 +553,7 @@
|
|||||||
RequiredForShortGame: false
|
RequiredForShortGame: false
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
-GivesBuildableArea:
|
-GivesBuildableArea:
|
||||||
-AcceptsSupplies:
|
-AcceptsDeliveredCash:
|
||||||
DrawLineToTarget:
|
DrawLineToTarget:
|
||||||
RenderRangeCircle:
|
RenderRangeCircle:
|
||||||
Explodes:
|
Explodes:
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ PDOX:
|
|||||||
DisplayRadarPing: True
|
DisplayRadarPing: True
|
||||||
Range: 2
|
Range: 2
|
||||||
SupportPowerChargeBar:
|
SupportPowerChargeBar:
|
||||||
-AcceptsSupplies:
|
-AcceptsDeliveredCash:
|
||||||
Power:
|
Power:
|
||||||
Amount: -200
|
Amount: -200
|
||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ TRUK:
|
|||||||
Speed: 128
|
Speed: 128
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4c0
|
Range: 4c0
|
||||||
SupplyTruck:
|
DeliversCash:
|
||||||
Payload: 500
|
Payload: 500
|
||||||
PlayerExperience: 50
|
PlayerExperience: 50
|
||||||
SpawnActorOnDeath:
|
SpawnActorOnDeath:
|
||||||
|
|||||||
@@ -1309,7 +1309,6 @@ GAICBM:
|
|||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 800
|
Cost: 800
|
||||||
-AcceptsSupplies:
|
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Deployed ICBM
|
Name: Deployed ICBM
|
||||||
-GivesBuildableArea:
|
-GivesBuildableArea:
|
||||||
|
|||||||
@@ -152,7 +152,6 @@
|
|||||||
Type: Footprint
|
Type: Footprint
|
||||||
EngineerRepairable:
|
EngineerRepairable:
|
||||||
ShakeOnDeath:
|
ShakeOnDeath:
|
||||||
AcceptsSupplies:
|
|
||||||
Guardable:
|
Guardable:
|
||||||
Range: 3c0
|
Range: 3c0
|
||||||
Demolishable:
|
Demolishable:
|
||||||
|
|||||||
Reference in New Issue
Block a user