RenderBuildingTurreted -> WithTurretedSpriteBody
This commit is contained in:
@@ -15,15 +15,25 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
[Desc("Actor's turret rises from the ground before attacking.")]
|
||||
class AttackPopupTurretedInfo : AttackTurretedInfo, Requires<BuildingInfo>, Requires<RenderBuildingInfo>
|
||||
class AttackPopupTurretedInfo : AttackTurretedInfo, Requires<BuildingInfo>, Requires<WithTurretedSpriteBodyInfo>
|
||||
{
|
||||
[Desc("How many game ticks should pass before closing the actor's turret.")]
|
||||
public int CloseDelay = 125;
|
||||
|
||||
public int DefaultFacing = 0;
|
||||
|
||||
[Desc("The percentage of damage that is received while this actor is closed.")]
|
||||
public int ClosedDamageMultiplier = 50;
|
||||
|
||||
[Desc("Sequence to play when opening.")]
|
||||
[SequenceReference] public string OpeningSequence = "opening";
|
||||
|
||||
[Desc("Sequence to play when closing.")]
|
||||
[SequenceReference] public string ClosingSequence = "closing";
|
||||
|
||||
[Desc("Idle sequence to play when closed.")]
|
||||
[SequenceReference] public string ClosedIdleSequence = "closed-idle";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackPopupTurreted(init, this); }
|
||||
}
|
||||
|
||||
@@ -32,11 +42,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
enum PopupState { Open, Rotating, Transitioning, Closed }
|
||||
|
||||
readonly AttackPopupTurretedInfo info;
|
||||
RenderBuilding rb;
|
||||
readonly WithSpriteBody wsb;
|
||||
readonly Turreted turret;
|
||||
|
||||
int idleTicks = 0;
|
||||
PopupState state = PopupState.Open;
|
||||
Turreted turret;
|
||||
bool skippedMakeAnimation;
|
||||
|
||||
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
|
||||
@@ -44,7 +54,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
this.info = info;
|
||||
turret = turrets.FirstOrDefault();
|
||||
rb = init.Self.Trait<RenderBuilding>();
|
||||
wsb = init.Self.Trait<WithSpriteBody>();
|
||||
skippedMakeAnimation = init.Contains<SkipMakeAnimsInit>();
|
||||
}
|
||||
|
||||
@@ -60,10 +70,10 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (state == PopupState.Closed)
|
||||
{
|
||||
state = PopupState.Transitioning;
|
||||
rb.PlayCustomAnimThen(self, "opening", () =>
|
||||
wsb.PlayCustomAnimation(self, info.OpeningSequence, () =>
|
||||
{
|
||||
state = PopupState.Open;
|
||||
rb.PlayCustomAnimRepeating(self, "idle");
|
||||
wsb.PlayCustomAnimationRepeating(self, wsb.Info.Sequence);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@@ -81,10 +91,10 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
else if (state == PopupState.Rotating && turret.TurretFacing == info.DefaultFacing)
|
||||
{
|
||||
state = PopupState.Transitioning;
|
||||
rb.PlayCustomAnimThen(self, "closing", () =>
|
||||
wsb.PlayCustomAnimation(self, info.ClosingSequence, () =>
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||
wsb.PlayCustomAnimationRepeating(self, info.ClosedIdleSequence);
|
||||
turret.DesiredFacing = null;
|
||||
});
|
||||
}
|
||||
@@ -95,7 +105,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (skippedMakeAnimation)
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
rb.PlayCustomAnimRepeating(self, "closed-idle");
|
||||
wsb.PlayCustomAnimationRepeating(self, info.ClosedIdleSequence);
|
||||
turret.DesiredFacing = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,8 +406,8 @@
|
||||
<Compile Include="Traits\Render\Hovers.cs" />
|
||||
<Compile Include="Traits\Render\LeavesTrails.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuilding.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
|
||||
<Compile Include="Traits\Render\RenderSpritesEditorOnly.cs" />
|
||||
<Compile Include="Traits\Render\WithTurretedSpriteBody.cs" />
|
||||
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
<Compile Include="Traits\Render\RenderSprites.cs" />
|
||||
|
||||
@@ -17,24 +17,25 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
class RenderBuildingTurretedInfo : RenderBuildingInfo, Requires<TurretedInfo>
|
||||
[Desc("This actor has turret art with facings baked into the sprite.")]
|
||||
public class WithTurretedSpriteBodyInfo : WithSpriteBodyInfo, Requires<TurretedInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderBuildingTurreted(init, this); }
|
||||
public override object Create(ActorInitializer init) { return new WithTurretedSpriteBody(init, this); }
|
||||
|
||||
public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
{
|
||||
var t = init.Actor.Traits.WithInterface<TurretedInfo>()
|
||||
.FirstOrDefault();
|
||||
var t = init.Actor.Traits.WithInterface<TurretedInfo>().FirstOrDefault();
|
||||
var wsb = init.Actor.Traits.WithInterface<WithSpriteBodyInfo>().FirstOrDefault();
|
||||
|
||||
// Show the correct turret facing
|
||||
var anim = new Animation(init.World, image, () => t.InitialFacing);
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), wsb.Sequence));
|
||||
|
||||
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
||||
}
|
||||
}
|
||||
|
||||
class RenderBuildingTurreted : RenderBuilding
|
||||
public class WithTurretedSpriteBody : WithSpriteBody
|
||||
{
|
||||
readonly Turreted turreted;
|
||||
|
||||
@@ -45,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return () => turreted.TurretFacing;
|
||||
}
|
||||
|
||||
public RenderBuildingTurreted(ActorInitializer init, RenderBuildingInfo info)
|
||||
public WithTurretedSpriteBody(ActorInitializer init, WithSpriteBodyInfo info)
|
||||
: base(init, info, MakeTurretFacingFunc(init.Self))
|
||||
{
|
||||
turreted = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||
@@ -1875,6 +1875,33 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (rrb != null)
|
||||
rrb.Key = "-WithSiloAnimation";
|
||||
}
|
||||
|
||||
// Replaced RenderBuildingTurreted with RenderSprites + WithTurretedSpriteBody (+AutoSelectionSize)
|
||||
if (depth == 0)
|
||||
{
|
||||
var childKeysExcludeFromRS = new[] { "Sequence", "PauseOnLowPower" };
|
||||
|
||||
var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuildingTurreted"));
|
||||
if (rb != null)
|
||||
{
|
||||
rb.Key = "WithTurretedSpriteBody";
|
||||
|
||||
var rsNodes = rb.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList();
|
||||
|
||||
if (rsNodes.Any())
|
||||
node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes)));
|
||||
else
|
||||
node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", ""));
|
||||
|
||||
node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", ""));
|
||||
|
||||
rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
|
||||
}
|
||||
|
||||
var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuildingTurreted"));
|
||||
if (rrb != null)
|
||||
rrb.Key = "-WithTurretedSpriteBody";
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
|
||||
@@ -654,7 +654,8 @@ GUN:
|
||||
Turreted:
|
||||
ROT: 12
|
||||
InitialFacing: 50
|
||||
RenderBuildingTurreted:
|
||||
RenderSprites:
|
||||
WithTurretedSpriteBody:
|
||||
Armament:
|
||||
Weapon: TurretGun
|
||||
LocalOffset: 512,0,112
|
||||
@@ -667,6 +668,7 @@ GUN:
|
||||
Range: 3
|
||||
Power:
|
||||
Amount: -20
|
||||
-WithMakeAnimation:
|
||||
|
||||
SAM:
|
||||
Inherits: ^Defense
|
||||
@@ -695,7 +697,9 @@ SAM:
|
||||
Turreted:
|
||||
ROT: 10
|
||||
InitialFacing: 0
|
||||
RenderBuildingTurreted:
|
||||
RenderSprites:
|
||||
WithTurretedSpriteBody:
|
||||
AutoSelectionSize:
|
||||
Armament:
|
||||
Weapon: SAMMissile
|
||||
MuzzleSequence: muzzle
|
||||
@@ -705,6 +709,7 @@ SAM:
|
||||
-RenderDetectionCircle:
|
||||
Power:
|
||||
Amount: -20
|
||||
-WithMakeAnimation:
|
||||
|
||||
OBLI:
|
||||
Inherits: ^Defense
|
||||
|
||||
@@ -1729,8 +1729,9 @@ Rules:
|
||||
Turreted:
|
||||
ROT: 15
|
||||
InitialFacing: 224
|
||||
RenderBuildingTurreted:
|
||||
RenderSprites:
|
||||
Image: AGUN
|
||||
WithTurretedSpriteBody:
|
||||
Armament:
|
||||
Weapon: MissionColt
|
||||
LocalOffset: 432,150,-30, 432,-150,-30
|
||||
@@ -1738,6 +1739,7 @@ Rules:
|
||||
AutoTarget:
|
||||
-RenderBuilding:
|
||||
-Selectable:
|
||||
-WithMakeAnimation:
|
||||
E1.Autotarget:
|
||||
Inherits: E1
|
||||
Buildable:
|
||||
|
||||
@@ -451,7 +451,8 @@ AGUN:
|
||||
Turreted:
|
||||
ROT: 15
|
||||
InitialFacing: 224
|
||||
RenderBuildingTurreted:
|
||||
RenderSprites:
|
||||
WithTurretedSpriteBody:
|
||||
Armament:
|
||||
Weapon: ZSU-23
|
||||
LocalOffset: 432,150,-30, 432,-150,-30
|
||||
@@ -465,6 +466,7 @@ AGUN:
|
||||
Amount: -50
|
||||
DetectCloaked:
|
||||
Range: 6
|
||||
-WithMakeAnimation:
|
||||
|
||||
DOME:
|
||||
Inherits: ^Building
|
||||
@@ -610,7 +612,8 @@ GUN:
|
||||
Turreted:
|
||||
ROT: 12
|
||||
InitialFacing: 50
|
||||
RenderBuildingTurreted:
|
||||
RenderSprites:
|
||||
WithTurretedSpriteBody:
|
||||
Armament:
|
||||
Weapon: TurretGun
|
||||
LocalOffset: 512,0,112
|
||||
@@ -622,6 +625,7 @@ GUN:
|
||||
Amount: -40
|
||||
DetectCloaked:
|
||||
Range: 7
|
||||
-WithMakeAnimation:
|
||||
|
||||
FTUR:
|
||||
Inherits: ^Defense
|
||||
@@ -686,7 +690,8 @@ SAM:
|
||||
Turreted:
|
||||
ROT: 30
|
||||
InitialFacing: 0
|
||||
RenderBuildingTurreted:
|
||||
RenderSprites:
|
||||
WithTurretedSpriteBody:
|
||||
Armament:
|
||||
Weapon: Nike
|
||||
MuzzleSequence: muzzle
|
||||
@@ -699,6 +704,7 @@ SAM:
|
||||
Amount: -40
|
||||
DetectCloaked:
|
||||
Range: 5
|
||||
-WithMakeAnimation:
|
||||
|
||||
ATEK:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -123,6 +123,7 @@ GACTWR:
|
||||
ProvidesPrerequisite@buildingname:
|
||||
SelectionDecorations:
|
||||
VisualBounds: 48, 48, 0, -12
|
||||
-WithMakeAnimation:
|
||||
|
||||
GAVULC:
|
||||
Inherits: ^BuildingPlug
|
||||
|
||||
Reference in New Issue
Block a user