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\RenderNameTag.cs" />
|
||||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||||
<Compile Include="Traits\Render\RenderSprites.cs" />
|
<Compile Include="Traits\Render\RenderSprites.cs" />
|
||||||
<Compile Include="Traits\Render\RenderUnit.cs" />
|
|
||||||
<Compile Include="Traits\Render\RenderBuildingSilo.cs" />
|
<Compile Include="Traits\Render\RenderBuildingSilo.cs" />
|
||||||
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
||||||
<Compile Include="Traits\Render\RenderDetectionCircle.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)
|
if (rrh != null)
|
||||||
rrh.Key = "-WithHarvestAnimation";
|
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);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
readonly Target target;
|
readonly Target target;
|
||||||
readonly Sandworm sandworm;
|
readonly Sandworm sandworm;
|
||||||
readonly WeaponInfo weapon;
|
readonly WeaponInfo weapon;
|
||||||
readonly RenderUnit renderUnit;
|
readonly WithSpriteBody withSpriteBody;
|
||||||
readonly RadarPings radarPings;
|
readonly RadarPings radarPings;
|
||||||
readonly AttackSwallow swallow;
|
readonly AttackSwallow swallow;
|
||||||
readonly IPositionable positionable;
|
readonly IPositionable positionable;
|
||||||
@@ -44,11 +44,11 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
sandworm = self.Trait<Sandworm>();
|
sandworm = self.Trait<Sandworm>();
|
||||||
positionable = self.Trait<Mobile>();
|
positionable = self.Trait<Mobile>();
|
||||||
swallow = self.Trait<AttackSwallow>();
|
swallow = self.Trait<AttackSwallow>();
|
||||||
renderUnit = self.Trait<RenderUnit>();
|
withSpriteBody = self.Trait<WithSpriteBody>();
|
||||||
radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
|
radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
|
||||||
countdown = swallow.Info.AttackTime;
|
countdown = swallow.Info.AttackTime;
|
||||||
|
|
||||||
renderUnit.DefaultAnimation.ReplaceAnim("burrowed");
|
withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.BurrowedSequence);
|
||||||
stance = AttackState.Burrowed;
|
stance = AttackState.Burrowed;
|
||||||
location = target.Actor.Location;
|
location = target.Actor.Location;
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
// List because IEnumerable gets evaluated too late.
|
// List because IEnumerable gets evaluated too late.
|
||||||
void PlayAttack(Actor self, WPos attackPosition, List<Player> affectedPlayers)
|
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);
|
Sound.Play(swallow.Info.WormAttackSound, self.CenterPosition);
|
||||||
|
|
||||||
Game.RunAfterDelay(1000, () =>
|
Game.RunAfterDelay(1000, () =>
|
||||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
self.World.AddFrameEndTask(w => self.Kill(self));
|
self.World.AddFrameEndTask(w => self.Kill(self));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
renderUnit.DefaultAnimation.ReplaceAnim("idle");
|
withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.D2k.Activities
|
|||||||
|
|
||||||
if (!WormAttack(self))
|
if (!WormAttack(self))
|
||||||
{
|
{
|
||||||
renderUnit.DefaultAnimation.ReplaceAnim("idle");
|
withSpriteBody.DefaultAnimation.ReplaceAnim(sandworm.Info.IdleSequence);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.D2k.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).")]
|
[Desc("Time between rescanning for targets (in ticks).")]
|
||||||
public readonly int TargetRescanInterval = 32;
|
public readonly int TargetRescanInterval = 32;
|
||||||
@@ -30,7 +30,13 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
public readonly int ChanceToDisappear = 80;
|
public readonly int ChanceToDisappear = 80;
|
||||||
|
|
||||||
[Desc("Name of the sequence that is used when the actor is idle or moving (not attacking).")]
|
[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); }
|
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 WormManager manager;
|
||||||
readonly Lazy<Mobile> mobile;
|
readonly Lazy<Mobile> mobile;
|
||||||
readonly Lazy<RenderUnit> renderUnit;
|
readonly Lazy<WithSpriteBody> withSpriteBody;
|
||||||
readonly Lazy<AttackBase> attackTrait;
|
readonly Lazy<AttackBase> attackTrait;
|
||||||
|
|
||||||
public bool IsMovingTowardTarget { get; private set; }
|
public bool IsMovingTowardTarget { get; private set; }
|
||||||
@@ -55,15 +61,15 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
mobile = Exts.Lazy(self.Trait<Mobile>);
|
mobile = Exts.Lazy(self.Trait<Mobile>);
|
||||||
renderUnit = Exts.Lazy(self.Trait<RenderUnit>);
|
withSpriteBody = Exts.Lazy(self.Trait<WithSpriteBody>);
|
||||||
attackTrait = Exts.Lazy(self.Trait<AttackBase>);
|
attackTrait = Exts.Lazy(self.Trait<AttackBase>);
|
||||||
manager = self.World.WorldActor.Trait<WormManager>();
|
manager = self.World.WorldActor.Trait<WormManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnBecomingIdle(Actor self)
|
public override void OnBecomingIdle(Actor self)
|
||||||
{
|
{
|
||||||
if (renderUnit.Value.DefaultAnimation.CurrentSequence.Name != Info.IdleSequence)
|
if (withSpriteBody.Value.DefaultAnimation.CurrentSequence.Name != Info.IdleSequence)
|
||||||
renderUnit.Value.DefaultAnimation.PlayRepeating("idle");
|
withSpriteBody.Value.DefaultAnimation.PlayRepeating(Info.IdleSequence);
|
||||||
|
|
||||||
base.OnBecomingIdle(self);
|
base.OnBecomingIdle(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ sandworm:
|
|||||||
Spice: 100
|
Spice: 100
|
||||||
TargetableUnit:
|
TargetableUnit:
|
||||||
TargetTypes: Ground
|
TargetTypes: Ground
|
||||||
RenderUnit:
|
WithFacingSpriteBody:
|
||||||
WithAttackOverlay:
|
WithAttackOverlay:
|
||||||
Sequence: sand
|
Sequence: sand
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
@@ -51,6 +51,8 @@ sandworm:
|
|||||||
AnnounceOnSeen:
|
AnnounceOnSeen:
|
||||||
Notification: WormSign
|
Notification: WormSign
|
||||||
PingRadar: True
|
PingRadar: True
|
||||||
|
RenderSprites:
|
||||||
|
AutoSelectionSize:
|
||||||
|
|
||||||
sietch:
|
sietch:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ harvester.starport:
|
|||||||
Queue: Starport
|
Queue: Starport
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 1500
|
Cost: 1500
|
||||||
RenderUnit:
|
RenderSprites:
|
||||||
Image: harvester
|
Image: harvester
|
||||||
|
|
||||||
trike.starport:
|
trike.starport:
|
||||||
|
|||||||
@@ -77,10 +77,6 @@ harvester:
|
|||||||
EmptyWeapon: UnitExplodeScale
|
EmptyWeapon: UnitExplodeScale
|
||||||
LeavesHusk:
|
LeavesHusk:
|
||||||
HuskActor: Harvester.Husk
|
HuskActor: Harvester.Husk
|
||||||
RenderUnit:
|
|
||||||
-RenderSprites:
|
|
||||||
-WithFacingSpriteBody:
|
|
||||||
-AutoSelectionSize:
|
|
||||||
WithHarvestOverlay:
|
WithHarvestOverlay:
|
||||||
Palette: effect50alpha
|
Palette: effect50alpha
|
||||||
WithDockingAnimation:
|
WithDockingAnimation:
|
||||||
|
|||||||
Reference in New Issue
Block a user