Added WithLandingCraftAnimation and removed RenderLandingCraft
This commit is contained in:
@@ -1227,6 +1227,47 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
// Renamed WithHarvestAnimation to WithHarvestOverlay
|
// Renamed WithHarvestAnimation to WithHarvestOverlay
|
||||||
if (node.Key == "WithHarvestAnimation")
|
if (node.Key == "WithHarvestAnimation")
|
||||||
node.Key = "WithHarvestOverlay";
|
node.Key = "WithHarvestOverlay";
|
||||||
|
|
||||||
|
// Replaced RenderLandingCraft with WithFacingSpriteBody + WithLandingCraftAnimation.
|
||||||
|
// Note: These rules are set up to do approximately the right thing for maps, but
|
||||||
|
// mods might need additional manual tweaks. This is the best we can do without having
|
||||||
|
// much smarter rules parsing, because we currently can't reason about inherited traits.
|
||||||
|
if (depth == 0)
|
||||||
|
{
|
||||||
|
var childKeySequence = new[] { "Sequence" };
|
||||||
|
var childKeysExcludeFromRS = new[] { "Sequence", "OpenTerrainTypes", "OpenSequence", "UnloadSequence" };
|
||||||
|
|
||||||
|
var rlc = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderLandingCraft"));
|
||||||
|
if (rlc != null)
|
||||||
|
{
|
||||||
|
rlc.Key = "WithLandingCraftAnimation";
|
||||||
|
|
||||||
|
var rsNodes = rlc.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList();
|
||||||
|
var wfsbNodes = rlc.Value.Nodes.Where(n => childKeySequence.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", ""));
|
||||||
|
|
||||||
|
// Note: For the RA landing craft WithSpriteBody would be sufficient since it has no facings,
|
||||||
|
// but WithFacingSpriteBody works as well and covers the potential case where a third-party mod
|
||||||
|
// might have given their landing craft multiple facings.
|
||||||
|
if (wfsbNodes.Any())
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("WithFacingSpriteBody", new MiniYaml("", wfsbNodes)));
|
||||||
|
else
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("WithFacingSpriteBody", ""));
|
||||||
|
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", ""));
|
||||||
|
|
||||||
|
rlc.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
|
||||||
|
rlc.Value.Nodes.RemoveAll(n => wfsbNodes.Contains(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
var rrlc = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderLandingCraft"));
|
||||||
|
if (rrlc != null)
|
||||||
|
rrlc.Key = "-WithLandingCraftAnimation";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
<Compile Include="Traits\PaletteEffects\ChronoshiftPaletteEffect.cs" />
|
<Compile Include="Traits\PaletteEffects\ChronoshiftPaletteEffect.cs" />
|
||||||
<Compile Include="Traits\PortableChrono.cs" />
|
<Compile Include="Traits\PortableChrono.cs" />
|
||||||
<Compile Include="Traits\Render\RenderJammerCircle.cs" />
|
<Compile Include="Traits\Render\RenderJammerCircle.cs" />
|
||||||
<Compile Include="Traits\Render\RenderLandingCraft.cs" />
|
<Compile Include="Traits\Render\WithLandingCraftAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\RenderShroudCircle.cs" />
|
<Compile Include="Traits\Render\RenderShroudCircle.cs" />
|
||||||
<Compile Include="Traits\SupportPowers\ChronoshiftPower.cs" />
|
<Compile Include="Traits\SupportPowers\ChronoshiftPower.cs" />
|
||||||
<Compile Include="Traits\SupportPowers\GpsPower.cs" />
|
<Compile Include="Traits\SupportPowers\GpsPower.cs" />
|
||||||
|
|||||||
@@ -14,30 +14,31 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA.Traits
|
namespace OpenRA.Mods.RA.Traits
|
||||||
{
|
{
|
||||||
public class RenderLandingCraftInfo : RenderUnitInfo, Requires<IMoveInfo>, Requires<CargoInfo>
|
public class WithLandingCraftAnimationInfo : ITraitInfo, Requires<IMoveInfo>, Requires<WithSpriteBodyInfo>, Requires<CargoInfo>
|
||||||
{
|
{
|
||||||
public readonly string[] OpenTerrainTypes = { "Clear" };
|
public readonly string[] OpenTerrainTypes = { "Clear" };
|
||||||
[SequenceReference] public readonly string OpenAnim = "open";
|
[SequenceReference] public readonly string OpenSequence = "open";
|
||||||
[SequenceReference] public readonly string UnloadAnim = "unload";
|
[SequenceReference] public readonly string UnloadSequence = "unload";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new RenderLandingCraft(init, this); }
|
public object Create(ActorInitializer init) { return new WithLandingCraftAnimation(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RenderLandingCraft : RenderUnit
|
public class WithLandingCraftAnimation : ITick
|
||||||
{
|
{
|
||||||
readonly RenderLandingCraftInfo info;
|
readonly WithLandingCraftAnimationInfo info;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly Cargo cargo;
|
readonly Cargo cargo;
|
||||||
readonly IMove move;
|
readonly IMove move;
|
||||||
|
readonly WithSpriteBody wsb;
|
||||||
bool open;
|
bool open;
|
||||||
|
|
||||||
public RenderLandingCraft(ActorInitializer init, RenderLandingCraftInfo info)
|
public WithLandingCraftAnimation(ActorInitializer init, WithLandingCraftAnimationInfo info)
|
||||||
: base(init, info)
|
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
self = init.Self;
|
self = init.Self;
|
||||||
cargo = self.Trait<Cargo>();
|
cargo = self.Trait<Cargo>();
|
||||||
move = self.Trait<IMove>();
|
move = self.Trait<IMove>();
|
||||||
|
wsb = init.Self.Trait<WithSpriteBody>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShouldBeOpen()
|
public bool ShouldBeOpen()
|
||||||
@@ -51,34 +52,32 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
void Open()
|
void Open()
|
||||||
{
|
{
|
||||||
if (open || !DefaultAnimation.HasSequence(info.OpenAnim))
|
if (open || !wsb.DefaultAnimation.HasSequence(info.OpenSequence))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
open = true;
|
open = true;
|
||||||
PlayCustomAnimation(self, info.OpenAnim, () =>
|
wsb.PlayCustomAnimation(self, info.OpenSequence, () =>
|
||||||
{
|
{
|
||||||
if (DefaultAnimation.HasSequence(info.UnloadAnim))
|
if (wsb.DefaultAnimation.HasSequence(info.UnloadSequence))
|
||||||
PlayCustomAnimationRepeating(self, info.UnloadAnim);
|
wsb.PlayCustomAnimationRepeating(self, info.UnloadSequence);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close()
|
void Close()
|
||||||
{
|
{
|
||||||
if (!open || !DefaultAnimation.HasSequence(info.OpenAnim))
|
if (!open || !wsb.DefaultAnimation.HasSequence(info.OpenSequence))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
open = false;
|
open = false;
|
||||||
PlayCustomAnimationBackwards(self, info.OpenAnim, null);
|
wsb.PlayCustomAnimationBackwards(self, info.OpenSequence, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ShouldBeOpen())
|
if (ShouldBeOpen())
|
||||||
Open();
|
Open();
|
||||||
else
|
else
|
||||||
Close();
|
Close();
|
||||||
|
|
||||||
base.Tick(self);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1658,7 +1658,7 @@ Rules:
|
|||||||
ShowOwnerRow: false
|
ShowOwnerRow: false
|
||||||
LST.IN:
|
LST.IN:
|
||||||
Inherits: LST
|
Inherits: LST
|
||||||
RenderLandingCraft:
|
RenderSprites:
|
||||||
Image: LST
|
Image: LST
|
||||||
Cargo:
|
Cargo:
|
||||||
Types: disabled
|
Types: disabled
|
||||||
|
|||||||
@@ -218,10 +218,7 @@ LST:
|
|||||||
Range: 6c0
|
Range: 6c0
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 36,36
|
VisualBounds: 36,36
|
||||||
-AutoSelectionSize:
|
WithLandingCraftAnimation:
|
||||||
-RenderSprites:
|
|
||||||
-WithFacingSpriteBody:
|
|
||||||
RenderLandingCraft:
|
|
||||||
OpenTerrainTypes: Clear, Rough, Road, Ore, Gems, Beach
|
OpenTerrainTypes: Clear, Rough, Road, Ore, Gems, Beach
|
||||||
Cargo:
|
Cargo:
|
||||||
Types: Infantry, Vehicle
|
Types: Infantry, Vehicle
|
||||||
|
|||||||
Reference in New Issue
Block a user