RenderBuildingSilo -> WithSiloAnimation
This commit is contained in:
@@ -411,7 +411,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\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" />
|
||||||
<Compile Include="Traits\Render\RenderRangeCircle.cs" />
|
<Compile Include="Traits\Render\RenderRangeCircle.cs" />
|
||||||
@@ -424,6 +423,7 @@
|
|||||||
<Compile Include="Traits\Render\WithActiveAnimation.cs" />
|
<Compile Include="Traits\Render\WithActiveAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithAttackAnimation.cs" />
|
<Compile Include="Traits\Render\WithAttackAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithMoveAnimation.cs" />
|
<Compile Include="Traits\Render\WithMoveAnimation.cs" />
|
||||||
|
<Compile Include="Traits\Render\WithSiloAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithBuildingPlacedAnimation.cs" />
|
<Compile Include="Traits\Render\WithBuildingPlacedAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithMakeAnimation.cs" />
|
<Compile Include="Traits\Render\WithMakeAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithChargeAnimation.cs" />
|
<Compile Include="Traits\Render\WithChargeAnimation.cs" />
|
||||||
|
|||||||
@@ -1,61 +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.Collections.Generic;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Mods.Common.Graphics;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
|
||||||
{
|
|
||||||
[Desc("Render trait for buildings that change the sprite according to the remaining resource storage capacity across all depots.")]
|
|
||||||
class RenderBuildingSiloInfo : RenderBuildingInfo
|
|
||||||
{
|
|
||||||
public override object Create(ActorInitializer init) { return new RenderBuildingSilo(init, this); }
|
|
||||||
|
|
||||||
public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
|
||||||
{
|
|
||||||
// Show a static frame instead of animating all of the fullness states
|
|
||||||
var anim = new Animation(init.World, image, () => 0);
|
|
||||||
anim.PlayFetchIndex(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence), () => 0);
|
|
||||||
|
|
||||||
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RenderBuildingSilo : RenderBuilding, INotifyBuildComplete, INotifyOwnerChanged
|
|
||||||
{
|
|
||||||
readonly RenderBuildingSiloInfo info;
|
|
||||||
PlayerResources playerResources;
|
|
||||||
|
|
||||||
public RenderBuildingSilo(ActorInitializer init, RenderBuildingSiloInfo info)
|
|
||||||
: base(init, info)
|
|
||||||
{
|
|
||||||
this.info = info;
|
|
||||||
playerResources = init.Self.Owner.PlayerActor.Trait<PlayerResources>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void BuildingComplete(Actor self)
|
|
||||||
{
|
|
||||||
var animation = RenderSprites.NormalizeSequence(DefaultAnimation, self.GetDamageState(), info.Sequence);
|
|
||||||
|
|
||||||
DefaultAnimation.PlayFetchIndex(animation,
|
|
||||||
() => playerResources.ResourceCapacity != 0
|
|
||||||
? ((10 * DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity)
|
|
||||||
: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
|
||||||
{
|
|
||||||
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
|
||||||
base.OnOwnerChanged(self, oldOwner, newOwner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
55
OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs
Normal file
55
OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#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.Collections.Generic;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
{
|
||||||
|
[Desc("Render trait for buildings that change the sprite according to the remaining resource storage capacity across all depots.")]
|
||||||
|
class WithSiloAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<RenderSpritesInfo>
|
||||||
|
{
|
||||||
|
public readonly int Stages = 10;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithSiloAnimation(init, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithSiloAnimation : INotifyBuildComplete, INotifyOwnerChanged
|
||||||
|
{
|
||||||
|
readonly WithSiloAnimationInfo info;
|
||||||
|
readonly WithSpriteBody wsb;
|
||||||
|
PlayerResources playerResources;
|
||||||
|
|
||||||
|
public WithSiloAnimation(ActorInitializer init, WithSiloAnimationInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
wsb = init.Self.Trait<WithSpriteBody>();
|
||||||
|
playerResources = init.Self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingComplete(Actor self)
|
||||||
|
{
|
||||||
|
var animation = wsb.NormalizeSequence(self, wsb.Info.Sequence);
|
||||||
|
|
||||||
|
wsb.DefaultAnimation.PlayFetchIndex(animation,
|
||||||
|
() => playerResources.ResourceCapacity != 0
|
||||||
|
? ((info.Stages * wsb.DefaultAnimation.CurrentSequence.Length - 1) * playerResources.Resources) / (info.Stages * playerResources.ResourceCapacity)
|
||||||
|
: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
|
{
|
||||||
|
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||||
|
OnOwnerChanged(self, oldOwner, newOwner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1841,6 +1841,40 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (rrb != null)
|
if (rrb != null)
|
||||||
rrb.Key = "-WithChargeAnimation";
|
rrb.Key = "-WithChargeAnimation";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaced RenderBuildingSilo with RenderSprites + WithSpriteBody + WithSiloAnimation (+AutoSelectionSize)
|
||||||
|
if (depth == 0)
|
||||||
|
{
|
||||||
|
var childKeySequence = new[] { "Sequence", "PauseOnLowPower" };
|
||||||
|
|
||||||
|
var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuildingSilo"));
|
||||||
|
if (rb != null)
|
||||||
|
{
|
||||||
|
rb.Key = "WithSiloAnimation";
|
||||||
|
|
||||||
|
var rsNodes = rb.Value.Nodes.Where(n => !childKeySequence.Contains(n.Key)).ToList();
|
||||||
|
var wsbNodes = rb.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", ""));
|
||||||
|
|
||||||
|
if (wsbNodes.Any())
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", new MiniYaml("", wsbNodes)));
|
||||||
|
else
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", ""));
|
||||||
|
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", ""));
|
||||||
|
|
||||||
|
rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
|
||||||
|
rb.Value.Nodes.RemoveAll(n => wsbNodes.Contains(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuildingSilo"));
|
||||||
|
if (rrb != null)
|
||||||
|
rrb.Key = "-WithSiloAnimation";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
|
|||||||
@@ -210,7 +210,10 @@ SILO:
|
|||||||
Range: 4c0
|
Range: 4c0
|
||||||
Bib:
|
Bib:
|
||||||
HasMinibib: Yes
|
HasMinibib: Yes
|
||||||
RenderBuildingSilo:
|
RenderSprites:
|
||||||
|
WithSpriteBody:
|
||||||
|
AutoSelectionSize:
|
||||||
|
WithSiloAnimation:
|
||||||
StoresResources:
|
StoresResources:
|
||||||
PipCount: 10
|
PipCount: 10
|
||||||
PipColor: Green
|
PipColor: Green
|
||||||
@@ -223,6 +226,7 @@ SILO:
|
|||||||
RequiredForShortGame: false
|
RequiredForShortGame: false
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 49,30
|
VisualBounds: 49,30
|
||||||
|
-WithMakeAnimation:
|
||||||
|
|
||||||
PYLE:
|
PYLE:
|
||||||
Inherits: ^BaseBuilding
|
Inherits: ^BaseBuilding
|
||||||
|
|||||||
@@ -242,11 +242,13 @@ silo:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4c0
|
Range: 4c0
|
||||||
-RenderBuilding:
|
-RenderBuilding:
|
||||||
RenderBuildingSilo:
|
RenderSprites:
|
||||||
Image: silo.harkonnen
|
Image: silo.harkonnen
|
||||||
FactionImages:
|
FactionImages:
|
||||||
atreides: silo.atreides
|
atreides: silo.atreides
|
||||||
ordos: silo.ordos
|
ordos: silo.ordos
|
||||||
|
WithSpriteBody:
|
||||||
|
WithSiloAnimation:
|
||||||
StoresResources:
|
StoresResources:
|
||||||
PipColor: green
|
PipColor: green
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
@@ -256,6 +258,7 @@ silo:
|
|||||||
Amount: -5
|
Amount: -5
|
||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
RequiredForShortGame: false
|
RequiredForShortGame: false
|
||||||
|
-WithMakeAnimation:
|
||||||
|
|
||||||
light:
|
light:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -982,7 +982,9 @@ SILO:
|
|||||||
Range: 4c0
|
Range: 4c0
|
||||||
Bib:
|
Bib:
|
||||||
HasMinibib: Yes
|
HasMinibib: Yes
|
||||||
RenderBuildingSilo:
|
RenderSprites:
|
||||||
|
WithSpriteBody:
|
||||||
|
WithSiloAnimation:
|
||||||
StoresResources:
|
StoresResources:
|
||||||
PipCount: 5
|
PipCount: 5
|
||||||
Capacity: 1500
|
Capacity: 1500
|
||||||
@@ -990,6 +992,7 @@ SILO:
|
|||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
Power:
|
Power:
|
||||||
Amount: -10
|
Amount: -10
|
||||||
|
-WithMakeAnimation:
|
||||||
|
|
||||||
HPAD:
|
HPAD:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -127,11 +127,13 @@ GASILO:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4c0
|
Range: 4c0
|
||||||
-RenderBuilding:
|
-RenderBuilding:
|
||||||
RenderBuildingSilo:
|
RenderSprites:
|
||||||
Image: gasilo.gdi
|
Image: gasilo.gdi
|
||||||
FactionImages:
|
FactionImages:
|
||||||
gdi: gasilo.gdi
|
gdi: gasilo.gdi
|
||||||
nod: gasilo.nod
|
nod: gasilo.nod
|
||||||
|
WithSpriteBody:
|
||||||
|
WithSiloAnimation:
|
||||||
WithIdleOverlay@UNDERLAY:
|
WithIdleOverlay@UNDERLAY:
|
||||||
Sequence: idle-underlay
|
Sequence: idle-underlay
|
||||||
WithIdleOverlay@LIGHTS:
|
WithIdleOverlay@LIGHTS:
|
||||||
@@ -143,6 +145,7 @@ GASILO:
|
|||||||
Amount: -10
|
Amount: -10
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 80, 48, -5, 0
|
VisualBounds: 80, 48, -5, 0
|
||||||
|
-WithMakeAnimation:
|
||||||
|
|
||||||
ANYPOWER:
|
ANYPOWER:
|
||||||
AlwaysVisible:
|
AlwaysVisible:
|
||||||
|
|||||||
Reference in New Issue
Block a user