Replace custom factpdox sprite with dynamically rendered vortex.
This commit is contained in:
63
OpenRA.Mods.Cnc/Effects/ConyardChronoVortex.cs
Normal file
63
OpenRA.Mods.Cnc/Effects/ConyardChronoVortex.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* 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;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Cnc.Graphics;
|
||||
using OpenRA.Mods.Cnc.Traits;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Effects
|
||||
{
|
||||
sealed class ConyardChronoVortex : IEffect, ISpatiallyPartitionable
|
||||
{
|
||||
static readonly Size Size = new(64, 64);
|
||||
static readonly WVec Offset = new(171, 0, 0);
|
||||
readonly ChronoVortexRenderer renderer;
|
||||
readonly WPos center;
|
||||
readonly Action onCompletion;
|
||||
WPos pos;
|
||||
WAngle angle;
|
||||
int loops = 3;
|
||||
int frame;
|
||||
|
||||
public ConyardChronoVortex(Actor launcher, Action onCompletion)
|
||||
{
|
||||
this.onCompletion = onCompletion;
|
||||
renderer = launcher.World.WorldActor.Trait<ChronoVortexRenderer>();
|
||||
center = launcher.CenterPosition;
|
||||
pos = center + Offset.Rotate(WRot.FromYaw(angle));
|
||||
launcher.World.ScreenMap.Add(this, pos, Size);
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
// First 16 frames are the vortex opening
|
||||
// Next 16 frames are loopable
|
||||
// Final 16 frames are the vortex closing
|
||||
if (++frame == 32 && --loops > 0)
|
||||
frame = 16;
|
||||
|
||||
angle += new WAngle(42);
|
||||
pos = center + Offset.Rotate(WRot.FromYaw(angle));
|
||||
world.ScreenMap.Update(this, pos, Size);
|
||||
if (frame == 48)
|
||||
world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); onCompletion(); });
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||
{
|
||||
yield return new ChronoVortexRenderable(renderer, pos, frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Cnc.Effects;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
@@ -25,13 +25,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
"Otherwise, a vortex animation is played and damage is dealt each tick, ignoring modifiers.")]
|
||||
public class ConyardChronoReturnInfo : TraitInfo, Requires<HealthInfo>, Requires<WithSpriteBodyInfo>, IObservesVariablesInfo
|
||||
{
|
||||
[SequenceReference]
|
||||
[Desc("Sequence name with the baked-in vortex animation")]
|
||||
public readonly string Sequence = "pdox";
|
||||
|
||||
[Desc("Sprite body to play the vortex animation on.")]
|
||||
public readonly string Body = "body";
|
||||
|
||||
[GrantedConditionReference]
|
||||
[Desc("Condition to grant while the vortex animation plays.")]
|
||||
public readonly string Condition = null;
|
||||
@@ -65,7 +58,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
IDeathActorInitModifier, ITransformActorInitModifier
|
||||
{
|
||||
readonly ConyardChronoReturnInfo info;
|
||||
readonly WithSpriteBody wsb;
|
||||
readonly Health health;
|
||||
readonly Actor self;
|
||||
readonly string faction;
|
||||
@@ -92,8 +84,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
self = init.Self;
|
||||
|
||||
health = self.Trait<Health>();
|
||||
|
||||
wsb = self.TraitsImplementing<WithSpriteBody>().Single(w => w.Info.Name == info.Body);
|
||||
faction = init.GetValue<FactionInit, string>(self.Owner.Faction.InternalName);
|
||||
|
||||
var returnInit = init.GetOrDefault<ChronoshiftReturnInit>();
|
||||
@@ -127,16 +117,12 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
triggered = true;
|
||||
|
||||
// Don't override the selling animation
|
||||
if (selling)
|
||||
return;
|
||||
|
||||
wsb.PlayCustomAnimation(self, info.Sequence, () =>
|
||||
self.World.AddFrameEndTask(w => w.Add(new ConyardChronoVortex(self, () =>
|
||||
{
|
||||
triggered = false;
|
||||
if (conditionToken != Actor.InvalidConditionToken)
|
||||
if (conditionToken != Actor.InvalidConditionToken && !self.Disposed)
|
||||
conditionToken = self.RevokeCondition(conditionToken);
|
||||
});
|
||||
})));
|
||||
}
|
||||
|
||||
CPos? ChooseBestDestinationCell(MobileInfo mobileInfo, CPos destination)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright (c) The OpenRA Developers and Contributors
|
||||
* 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;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class RemoveConyardChronoReturnAnimation : UpdateRule
|
||||
{
|
||||
public override string Name => "Remove Sequence and Body properties from ConyardChronoReturn.";
|
||||
|
||||
public override string Description => "These properties have been replaced with a dynamic vortex renderable.";
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNodeBuilder actorNode)
|
||||
{
|
||||
foreach (var trait in actorNode.ChildrenMatching("ConyardChronoReturn"))
|
||||
{
|
||||
trait.RemoveNodes("Sequence");
|
||||
trait.RemoveNodes("Body");
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
new RemoveValidRelationsFromCapturable(),
|
||||
new ExtractResourceStorageFromHarvester(),
|
||||
new ReplacePaletteModifiers(),
|
||||
new RemoveConyardChronoReturnAnimation(),
|
||||
|
||||
// Execute these rules last to avoid premature yaml merge crashes.
|
||||
new AbstractDocking(),
|
||||
|
||||
Binary file not shown.
@@ -92,6 +92,7 @@
|
||||
Name: immobile
|
||||
TerrainSpeeds:
|
||||
TerrainRenderer:
|
||||
ChronoVortexRenderer:
|
||||
ShroudRenderer:
|
||||
FogVariants: shroud
|
||||
Index: 255, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 20, 40, 56, 65, 97, 130, 148, 194, 24, 33, 66, 132, 28, 41, 67, 134, 1, 2, 4, 8, 3, 6, 12, 9, 7, 14, 13, 11, 5, 10, 15, 255
|
||||
|
||||
@@ -79,18 +79,11 @@ fact:
|
||||
build:
|
||||
Start: 1
|
||||
Length: 25
|
||||
pdox:
|
||||
Filename: factpdox.shp
|
||||
Length: 80
|
||||
damaged-idle:
|
||||
Start: 26
|
||||
damaged-build:
|
||||
Start: 27
|
||||
Length: 25
|
||||
damaged-pdox:
|
||||
Filename: factpdox.shp
|
||||
Start: 80
|
||||
Length: 80
|
||||
dead:
|
||||
Filename: factdead.shp
|
||||
Tick: 800
|
||||
|
||||
Reference in New Issue
Block a user