Removed RenderUnit
Used this opportunity to unhardcode several sandworm-related sequences.
This commit is contained in:
@@ -400,7 +400,6 @@
|
||||
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
<Compile Include="Traits\Render\RenderSprites.cs" />
|
||||
<Compile Include="Traits\Render\RenderUnit.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingSilo.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
||||
<Compile Include="Traits\Render\RenderDetectionCircle.cs" />
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Render trait for non-animated actors that have sprites facing into each direction.",
|
||||
"Deprecated. This will soon be removed, use RenderSprites + WithFacingSpriteBody instead.")]
|
||||
public class RenderUnitInfo : RenderSimpleInfo, Requires<IFacingInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderUnit(init, this); }
|
||||
}
|
||||
|
||||
public class RenderUnit : RenderSimple, ISpriteBody
|
||||
{
|
||||
readonly RenderUnitInfo info;
|
||||
|
||||
public RenderUnit(ActorInitializer init, RenderUnitInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void PlayCustomAnimation(Actor self, string newAnimation, Action after)
|
||||
{
|
||||
DefaultAnimation.PlayThen(newAnimation, () => { DefaultAnimation.Play(info.Sequence); if (after != null) after(); });
|
||||
}
|
||||
|
||||
public void PlayCustomAnimationRepeating(Actor self, string name)
|
||||
{
|
||||
DefaultAnimation.PlayThen(name,
|
||||
() => PlayCustomAnimationRepeating(self, name));
|
||||
}
|
||||
|
||||
public void PlayCustomAnimationBackwards(Actor self, string name, Action after)
|
||||
{
|
||||
DefaultAnimation.PlayBackwardsThen(name,
|
||||
() => { DefaultAnimation.PlayRepeating(info.Sequence); if (after != null) after(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1317,6 +1317,38 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (rrh != null)
|
||||
rrh.Key = "-WithHarvestAnimation";
|
||||
}
|
||||
|
||||
// Replace RenderUnit with RenderSprites + WithFacingSpriteBody + AutoSelectionSize.
|
||||
// Normally this should have been removed by previous upgrade rules, but let's run this again
|
||||
// to make sure to get rid of potential left-over cases like D2k sandworms and harvesters.
|
||||
if (depth == 0)
|
||||
{
|
||||
var childKeys = new[] { "Sequence" };
|
||||
|
||||
var ru = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderUnit"));
|
||||
if (ru != null)
|
||||
{
|
||||
ru.Key = "WithFacingSpriteBody";
|
||||
|
||||
var rsNodes = ru.Value.Nodes.Where(n => !childKeys.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", ""));
|
||||
|
||||
ru.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
|
||||
|
||||
Console.WriteLine("RenderUnit has now been removed from code.");
|
||||
Console.WriteLine("Use RenderSprites + WithFacingSpriteBody (+ AutoSelectionSize, if necessary) instead.");
|
||||
}
|
||||
|
||||
var rru = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderUnit"));
|
||||
if (rru != null)
|
||||
rru.Key = "-WithFacingSpriteBody";
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
readonly Target target;
|
||||
readonly Sandworm sandworm;
|
||||
readonly WeaponInfo weapon;
|
||||
readonly RenderUnit renderUnit;
|
||||
readonly WithSpriteBody withSpriteBody;
|
||||
readonly RadarPings radarPings;
|
||||
readonly AttackSwallow swallow;
|
||||
readonly IPositionable positionable;
|
||||
@@ -44,11 +44,11 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
sandworm = self.Trait<Sandworm>();
|
||||
positionable = self.Trait<Mobile>();
|
||||
swallow = self.Trait<AttackSwallow>();
|
||||
renderUnit = self.Trait<RenderUnit>();
|
||||
withSpriteBody = self.Trait<WithSpriteBody>();
|
||||
radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
|
||||
countdown = swallow.Info.AttackTime;
|
||||
|
||||
renderUnit.DefaultAnimation.ReplaceAnim("burrowed");
|
||||
withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.BurrowedSequence);
|
||||
stance = AttackState.Burrowed;
|
||||
location = target.Actor.Location;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
// List because IEnumerable gets evaluated too late.
|
||||
void PlayAttack(Actor self, WPos attackPosition, List<Player> affectedPlayers)
|
||||
{
|
||||
renderUnit.PlayCustomAnim(self, "mouth");
|
||||
withSpriteBody.PlayCustomAnimation(self, sandworm.Info.MouthSequence);
|
||||
Sound.Play(swallow.Info.WormAttackSound, self.CenterPosition);
|
||||
|
||||
Game.RunAfterDelay(1000, () =>
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
self.World.AddFrameEndTask(w => self.Kill(self));
|
||||
}
|
||||
else
|
||||
renderUnit.DefaultAnimation.ReplaceAnim("idle");
|
||||
withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
|
||||
if (!WormAttack(self))
|
||||
{
|
||||
renderUnit.DefaultAnimation.ReplaceAnim("idle");
|
||||
withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.D2k.Traits
|
||||
{
|
||||
class SandwormInfo : WandersInfo, Requires<MobileInfo>, Requires<RenderUnitInfo>, Requires<AttackBaseInfo>
|
||||
class SandwormInfo : WandersInfo, Requires<MobileInfo>, Requires<WithSpriteBodyInfo>, Requires<AttackBaseInfo>
|
||||
{
|
||||
[Desc("Time between rescanning for targets (in ticks).")]
|
||||
public readonly int TargetRescanInterval = 32;
|
||||
@@ -30,7 +30,13 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
public readonly int ChanceToDisappear = 80;
|
||||
|
||||
[Desc("Name of the sequence that is used when the actor is idle or moving (not attacking).")]
|
||||
public readonly string IdleSequence = "idle";
|
||||
[SequenceReference] public readonly string IdleSequence = "idle";
|
||||
|
||||
[Desc("Name of the sequence that is used when the actor is attacking.")]
|
||||
[SequenceReference] public readonly string MouthSequence = "mouth";
|
||||
|
||||
[Desc("Name of the sequence that is used when the actor is burrowed.")]
|
||||
[SequenceReference] public readonly string BurrowedSequence = "burrowed";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new Sandworm(init.Self, this); }
|
||||
}
|
||||
@@ -41,7 +47,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
|
||||
readonly WormManager manager;
|
||||
readonly Lazy<Mobile> mobile;
|
||||
readonly Lazy<RenderUnit> renderUnit;
|
||||
readonly Lazy<WithSpriteBody> withSpriteBody;
|
||||
readonly Lazy<AttackBase> attackTrait;
|
||||
|
||||
public bool IsMovingTowardTarget { get; private set; }
|
||||
@@ -55,15 +61,15 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
{
|
||||
Info = info;
|
||||
mobile = Exts.Lazy(self.Trait<Mobile>);
|
||||
renderUnit = Exts.Lazy(self.Trait<RenderUnit>);
|
||||
withSpriteBody = Exts.Lazy(self.Trait<WithSpriteBody>);
|
||||
attackTrait = Exts.Lazy(self.Trait<AttackBase>);
|
||||
manager = self.World.WorldActor.Trait<WormManager>();
|
||||
}
|
||||
|
||||
public override void OnBecomingIdle(Actor self)
|
||||
{
|
||||
if (renderUnit.Value.DefaultAnimation.CurrentSequence.Name != Info.IdleSequence)
|
||||
renderUnit.Value.DefaultAnimation.PlayRepeating("idle");
|
||||
if (withSpriteBody.Value.DefaultAnimation.CurrentSequence.Name != Info.IdleSequence)
|
||||
withSpriteBody.Value.DefaultAnimation.PlayRepeating(Info.IdleSequence);
|
||||
|
||||
base.OnBecomingIdle(self);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ sandworm:
|
||||
Spice: 100
|
||||
TargetableUnit:
|
||||
TargetTypes: Ground
|
||||
RenderUnit:
|
||||
WithFacingSpriteBody:
|
||||
WithAttackOverlay:
|
||||
Sequence: sand
|
||||
BodyOrientation:
|
||||
@@ -51,6 +51,8 @@ sandworm:
|
||||
AnnounceOnSeen:
|
||||
Notification: WormSign
|
||||
PingRadar: True
|
||||
RenderSprites:
|
||||
AutoSelectionSize:
|
||||
|
||||
sietch:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -14,7 +14,7 @@ harvester.starport:
|
||||
Queue: Starport
|
||||
Valued:
|
||||
Cost: 1500
|
||||
RenderUnit:
|
||||
RenderSprites:
|
||||
Image: harvester
|
||||
|
||||
trike.starport:
|
||||
|
||||
@@ -77,10 +77,6 @@ harvester:
|
||||
EmptyWeapon: UnitExplodeScale
|
||||
LeavesHusk:
|
||||
HuskActor: Harvester.Husk
|
||||
RenderUnit:
|
||||
-RenderSprites:
|
||||
-WithFacingSpriteBody:
|
||||
-AutoSelectionSize:
|
||||
WithHarvestOverlay:
|
||||
Palette: effect50alpha
|
||||
WithDockingAnimation:
|
||||
|
||||
Reference in New Issue
Block a user