Rename WithSmoke into a more generic WithDamageOverlay trait.

Rename Sequence parameter to Image to avoid confusion.
This commit is contained in:
Matthias Mailänder
2016-04-24 19:48:41 +02:00
parent 2567d59af4
commit 99c7989ebc
5 changed files with 37 additions and 21 deletions

View File

@@ -431,6 +431,7 @@
<Compile Include="Traits\Render\WithChargeAnimation.cs" /> <Compile Include="Traits\Render\WithChargeAnimation.cs" />
<Compile Include="Traits\Render\WithChargeOverlay.cs" /> <Compile Include="Traits\Render\WithChargeOverlay.cs" />
<Compile Include="Traits\Render\WithCrateBody.cs" /> <Compile Include="Traits\Render\WithCrateBody.cs" />
<Compile Include="Traits\Render\WithDamageOverlay.cs" />
<Compile Include="Traits\Render\WithDeathAnimation.cs" /> <Compile Include="Traits\Render\WithDeathAnimation.cs" />
<Compile Include="Traits\Render\WithDecoration.cs" /> <Compile Include="Traits\Render\WithDecoration.cs" />
<Compile Include="Traits\Render\WithDockingAnimation.cs" /> <Compile Include="Traits\Render\WithDockingAnimation.cs" />
@@ -447,7 +448,6 @@
<Compile Include="Traits\Render\WithResources.cs" /> <Compile Include="Traits\Render\WithResources.cs" />
<Compile Include="Traits\Render\WithSpriteRotorOverlay.cs" /> <Compile Include="Traits\Render\WithSpriteRotorOverlay.cs" />
<Compile Include="Traits\Render\WithShadow.cs" /> <Compile Include="Traits\Render\WithShadow.cs" />
<Compile Include="Traits\Render\WithSmoke.cs" />
<Compile Include="Traits\Render\WithSpriteBody.cs" /> <Compile Include="Traits\Render\WithSpriteBody.cs" />
<Compile Include="Traits\Render\WithSpriteTurret.cs" /> <Compile Include="Traits\Render\WithSpriteTurret.cs" />
<Compile Include="Traits\Render\WithFacingSpriteBody.cs" /> <Compile Include="Traits\Render\WithFacingSpriteBody.cs" />

View File

@@ -17,13 +17,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Renders an overlay when the actor is taking heavy damage.")] [Desc("Renders an overlay when the actor is taking heavy damage.")]
public class WithSmokeInfo : ITraitInfo, Requires<RenderSpritesInfo> // TODO: rename to WithDamageOverlay public class WithDamageOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
{ {
public readonly string Sequence = "smoke_m"; // TODO: rename to image public readonly string Image = "smoke_m";
[SequenceReference("Sequence")] public readonly string IdleSequence = "idle"; [SequenceReference("Image")] public readonly string IdleSequence = "idle";
[SequenceReference("Sequence")] public readonly string LoopSequence = "loop"; [SequenceReference("Image")] public readonly string LoopSequence = "loop";
[SequenceReference("Sequence")] public readonly string EndSequence = "end"; [SequenceReference("Image")] public readonly string EndSequence = "end";
[Desc("Damage types that this should be used for (defined on the warheads).", [Desc("Damage types that this should be used for (defined on the warheads).",
"Leave empty to disable all filtering.")] "Leave empty to disable all filtering.")]
@@ -33,23 +33,23 @@ namespace OpenRA.Mods.Common.Traits.Render
public readonly DamageState MinimumDamageState = DamageState.Heavy; public readonly DamageState MinimumDamageState = DamageState.Heavy;
public readonly DamageState MaximumDamageState = DamageState.Dead; public readonly DamageState MaximumDamageState = DamageState.Dead;
public object Create(ActorInitializer init) { return new WithSmoke(init.Self, this); } public object Create(ActorInitializer init) { return new WithDamageOverlay(init.Self, this); }
} }
public class WithSmoke : INotifyDamage public class WithDamageOverlay : INotifyDamage
{ {
readonly WithSmokeInfo info; readonly WithDamageOverlayInfo info;
readonly Animation anim; readonly Animation anim;
bool isSmoking; bool isSmoking;
public WithSmoke(Actor self, WithSmokeInfo info) public WithDamageOverlay(Actor self, WithDamageOverlayInfo info)
{ {
this.info = info; this.info = info;
var rs = self.Trait<RenderSprites>(); var rs = self.Trait<RenderSprites>();
anim = new Animation(self.World, info.Sequence); anim = new Animation(self.World, info.Image);
rs.Add(new AnimationWithOffset(anim, null, () => !isSmoking)); rs.Add(new AnimationWithOffset(anim, null, () => !isSmoking));
} }

View File

@@ -788,6 +788,22 @@ namespace OpenRA.Mods.Common.UtilityCommands
n.Key = "DetonationDelay"; n.Key = "DetonationDelay";
} }
// WithSmoke was refactored to become more generic and Sequence/Image notation has been unified.
if (engineVersion < 20160528)
{
if (depth == 1 && node.Key.StartsWith("WithSmoke"))
{
var s = node.Value.Nodes.FirstOrDefault(n => n.Key == "Sequence");
if (s != null)
s.Key = "Image";
var parts = node.Key.Split('@');
node.Key = "WithDamageOverlay";
if (parts.Length > 1)
node.Key += "@" + parts[1];
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
} }
} }

View File

@@ -79,7 +79,7 @@
HiddenUnderFog: HiddenUnderFog:
AttackMove: AttackMove:
DrawLineToTarget: DrawLineToTarget:
WithSmoke: WithDamageOverlay:
WithFacingSpriteBody: WithFacingSpriteBody:
Explodes: Explodes:
Weapon: UnitExplodeSmall Weapon: UnitExplodeSmall
@@ -446,7 +446,7 @@
ActorLostNotification: ActorLostNotification:
AttackMove: AttackMove:
DrawLineToTarget: DrawLineToTarget:
WithSmoke: WithDamageOverlay:
Explodes: Explodes:
Weapon: UnitExplodeShip Weapon: UnitExplodeShip
EmptyWeapon: UnitExplodeShip EmptyWeapon: UnitExplodeShip
@@ -636,19 +636,19 @@
Type: Wood Type: Wood
Targetable: Targetable:
TargetTypes: Trees TargetTypes: Trees
WithSmoke@SmallBurn: WithDamageOverlay@SmallBurn:
DamageType: Incendiary DamageType: Incendiary
Sequence: burn-s Image: burn-s
MinimumDamageState: Light MinimumDamageState: Light
MaximumDamageState: Medium MaximumDamageState: Medium
WithSmoke@MediumBurn: WithDamageOverlay@MediumBurn:
DamageType: Incendiary DamageType: Incendiary
Sequence: burn-m Image: burn-m
MinimumDamageState: Medium MinimumDamageState: Medium
MaximumDamageState: Heavy MaximumDamageState: Heavy
WithSmoke@LargeBurn: WithDamageOverlay@LargeBurn:
DamageType: Incendiary DamageType: Incendiary
Sequence: burn-l Image: burn-l
MinimumDamageState: Heavy MinimumDamageState: Heavy
MaximumDamageState: Dead MaximumDamageState: Dead
AutoTargetIgnore: AutoTargetIgnore:

View File

@@ -99,7 +99,7 @@
GivesBounty: GivesBounty:
GpsDot: GpsDot:
String: Vehicle String: Vehicle
WithSmoke: WithDamageOverlay:
Guard: Guard:
Guardable: Guardable:
Tooltip: Tooltip:
@@ -325,7 +325,7 @@
RepairableNear: RepairableNear:
GpsDot: GpsDot:
String: Ship String: Ship
WithSmoke: WithDamageOverlay:
Explodes: Explodes:
Weapon: UnitExplodeShip Weapon: UnitExplodeShip
EmptyWeapon: UnitExplodeShip EmptyWeapon: UnitExplodeShip