Merge pull request #3681 from Mailaender/overlays
Added WithIdleOverlay Render Trait
This commit is contained in:
@@ -432,7 +432,6 @@
|
||||
<Compile Include="Armament.cs" />
|
||||
<Compile Include="DebugMuzzlePositions.cs" />
|
||||
<Compile Include="Buildings\BaseProvider.cs" />
|
||||
<Compile Include="Render\WithSpinner.cs" />
|
||||
<Compile Include="Widgets\Logic\ObserverShroudSelectorLogic.cs" />
|
||||
<Compile Include="RepairsBridges.cs" />
|
||||
<Compile Include="Activities\RepairBridge.cs" />
|
||||
@@ -465,6 +464,7 @@
|
||||
<Compile Include="TeslaZapRenderable.cs" />
|
||||
<Compile Include="Buildings\Bib.cs" />
|
||||
<Compile Include="Orders\EnterAlliedActorTargeter.cs" />
|
||||
<Compile Include="Render\WithIdleOverlay.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
58
OpenRA.Mods.RA/Render/WithIdleOverlay.cs
Normal file
58
OpenRA.Mods.RA/Render/WithIdleOverlay.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 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 OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
public class WithIdleOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "idle-overlay";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithIdleOverlay(init.self, this); }
|
||||
}
|
||||
|
||||
public class WithIdleOverlay : INotifyDamageStateChanged, INotifyBuildComplete
|
||||
{
|
||||
Animation overlay;
|
||||
bool buildComplete;
|
||||
|
||||
public WithIdleOverlay(Actor self, WithIdleOverlayInfo info)
|
||||
{
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
|
||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||
overlay = new Animation(rs.GetImage(self));
|
||||
overlay.PlayRepeating(info.Sequence);
|
||||
rs.anims.Add("idle_overlay_{0}".F(info.Sequence),
|
||||
new AnimationWithOffset(overlay,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
() => !buildComplete, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
{
|
||||
buildComplete = true;
|
||||
}
|
||||
|
||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
class WithSpinnerInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
public readonly string Sequence = "spinner";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithSpinner(init.self, this); }
|
||||
}
|
||||
|
||||
class WithSpinner
|
||||
{
|
||||
public WithSpinner(Actor self, WithSpinnerInfo info)
|
||||
{
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
|
||||
var spinner = new Animation(rs.GetImage(self));
|
||||
spinner.PlayRepeating(info.Sequence);
|
||||
rs.anims.Add("spinner_{0}".F(info.Sequence), new AnimationWithOffset(spinner,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
null, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>OpenRA.Mods.TS</RootNamespace>
|
||||
<AssemblyName>OpenRA.Mods.TS</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
||||
@@ -565,7 +565,8 @@ MHQ:
|
||||
RevealsShroud:
|
||||
Range: 6
|
||||
RenderUnit:
|
||||
WithSpinner:
|
||||
WithIdleOverlay@SPINNER:
|
||||
Sequence: spinner
|
||||
Offset: -256,0,256
|
||||
AttackMove:
|
||||
JustMove: yes
|
||||
|
||||
@@ -509,8 +509,9 @@ MGG:
|
||||
RevealsShroud:
|
||||
Range: 6
|
||||
RenderUnit:
|
||||
WithSpinner:
|
||||
WithIdleOverlay@SPINNER:
|
||||
Offset: -299,0,171
|
||||
Sequence: spinner
|
||||
AttackMove:
|
||||
JustMove: yes
|
||||
CreatesShroud:
|
||||
@@ -554,7 +555,8 @@ MRJ:
|
||||
RevealsShroud:
|
||||
Range: 6
|
||||
RenderUnit:
|
||||
WithSpinner:
|
||||
WithIdleOverlay@SPINNER:
|
||||
Sequence: spinner
|
||||
Offset: -256,0,256
|
||||
AttackMove:
|
||||
JustMove: yes
|
||||
@@ -651,7 +653,8 @@ TTNK:
|
||||
LocalOffset: 0,0,213
|
||||
AttackFrontal:
|
||||
RenderUnit:
|
||||
WithSpinner:
|
||||
WithIdleOverlay@SPINNER:
|
||||
Sequence: spinner
|
||||
Selectable:
|
||||
Bounds: 28,28,0,0
|
||||
AutoTarget:
|
||||
|
||||
@@ -144,7 +144,7 @@ ServerTraits:
|
||||
MasterServerPinger
|
||||
|
||||
LobbyDefaults:
|
||||
AllowCheats: false
|
||||
AllowCheats: true
|
||||
Crates: true
|
||||
StartingUnitsClass: none
|
||||
FragileAlliances: false
|
||||
|
||||
@@ -31,6 +31,12 @@ GACNST:
|
||||
Facing: 96
|
||||
ProductionBar:
|
||||
-Sellable:
|
||||
WithIdleOverlay@TOP:
|
||||
Sequence: idle-top
|
||||
WithIdleOverlay@SIDE:
|
||||
Sequence: idle-side
|
||||
WithIdleOverlay@FRONT:
|
||||
Sequence: idle-front
|
||||
|
||||
GAPOWR:
|
||||
Inherits: ^Building
|
||||
@@ -57,6 +63,10 @@ GAPOWR:
|
||||
Type: Wood
|
||||
RevealsShroud:
|
||||
Range: 4
|
||||
WithIdleOverlay@LIGHTS:
|
||||
Sequence: idle-lights
|
||||
WithIdleOverlay@PLUG:
|
||||
Sequence: idle-plug
|
||||
|
||||
GAPILE:
|
||||
Inherits: ^Building
|
||||
@@ -91,6 +101,12 @@ GAPILE:
|
||||
PrimaryBuilding:
|
||||
IronCurtainable:
|
||||
ProductionBar:
|
||||
WithIdleOverlay@LIGHTS:
|
||||
Sequence: idle-lights
|
||||
WithIdleOverlay@LIGHT:
|
||||
Sequence: idle-light
|
||||
WithIdleOverlay@FLAG:
|
||||
Sequence: idle-flag
|
||||
|
||||
GAWEAP:
|
||||
Inherits: ^Building
|
||||
@@ -301,6 +317,8 @@ GASPOT: # TODO: has moving spotlights
|
||||
RenderDetectionCircle:
|
||||
DetectCloaked:
|
||||
Range: 3
|
||||
WithIdleOverlay@LIGHTS:
|
||||
Sequence: idle-lights
|
||||
|
||||
GAHPAD:
|
||||
Inherits: ^Building
|
||||
@@ -332,8 +350,10 @@ GAHPAD:
|
||||
RepairsUnits:
|
||||
# RallyPoint:
|
||||
ProductionBar:
|
||||
-RenderBuilding:
|
||||
RenderBuildingWarFactory: # TODO: workaround
|
||||
WithIdleOverlay@PLATFORM:
|
||||
Sequence: idle-platform
|
||||
WithIdleOverlay@LIGHTS:
|
||||
Sequence: idle-lights
|
||||
|
||||
# custom prerequisites:
|
||||
ANYPOWER:
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
gacnst: # TODO: write a render trait for the overlays
|
||||
gacnst:
|
||||
idle: gtcnst
|
||||
Start: 0
|
||||
ShadowStart: 3
|
||||
medium-damaged-idle: gtcnst
|
||||
damaged-idle: gtcnst
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
damaged-idle: gtcnst
|
||||
critical-idle: gtcnst
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
make: gtcnstmk
|
||||
Start: 0
|
||||
Length: 24
|
||||
ShadowStart: 24
|
||||
build-front: gtcnst_d
|
||||
build-front: gtcnst_d # TODO: needs a render overlay trait
|
||||
Start: 0
|
||||
Length: 20
|
||||
damaged-build-front: gtcnst_d
|
||||
damaged-build-front: gtcnst_d # TODO: needs a render overlay trait
|
||||
Start: 0
|
||||
Length: 20
|
||||
idle-top: gtcnst_c
|
||||
@@ -26,7 +26,7 @@ gacnst: # TODO: write a render trait for the overlays
|
||||
Start: 15
|
||||
Length: 15
|
||||
Tick: 200
|
||||
heavy-damaged-idle-top: gtcnst_c
|
||||
critical-idle-top: gtcnst_c
|
||||
Start: 30
|
||||
idle-side: gtcnst_a
|
||||
Start: 0
|
||||
@@ -34,7 +34,7 @@ gacnst: # TODO: write a render trait for the overlays
|
||||
damaged-idle-side: gtcnst_a
|
||||
Start: 10
|
||||
Length: 10
|
||||
heavy-damaged-idle-side: gtcnst_a
|
||||
critical-idle-side: gtcnst_a
|
||||
Start: 20
|
||||
Length: 10
|
||||
idle-front: gtcnst_b
|
||||
@@ -43,42 +43,85 @@ gacnst: # TODO: write a render trait for the overlays
|
||||
damaged-idle-front: gtcnst_b
|
||||
Start: 0
|
||||
Length: 10
|
||||
critical-idle-front: gtcnst_b
|
||||
Start: 0
|
||||
Length: 10
|
||||
|
||||
gapowr: # TODO: shadow, plugs
|
||||
gapowr:
|
||||
idle: gtpowr
|
||||
Start: 0
|
||||
ShadowStart: 3
|
||||
damaged-idle: gtpowr
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
critical-idle: gtpowr
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
idle-lights: gtpowr_a
|
||||
Start: 0
|
||||
Length: 12
|
||||
Tick: 200
|
||||
damaged-idle-lights: gtpowr_a
|
||||
Start: 12
|
||||
Length: 12
|
||||
Tick: 200
|
||||
critical-idle-lights: gtpowr_a
|
||||
Start: 24
|
||||
Length: 12
|
||||
Tick: 200
|
||||
idle-plug: gtpowr_b
|
||||
Start: 0
|
||||
Length: 12
|
||||
Tick: 200
|
||||
damaged-idle-plug: gtpowr_b
|
||||
Start: 0
|
||||
Length: 12
|
||||
Tick: 200
|
||||
critical-idle-plug: gtpowr_b
|
||||
Start: 0
|
||||
Length: 12
|
||||
Tick: 200
|
||||
make: gtpowrmk
|
||||
Start: 0
|
||||
Length: 20
|
||||
ShadowStart: 20
|
||||
damaged-idle: gtpowr
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
dead: gtpowr
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
|
||||
gapile:
|
||||
idle: gtpile
|
||||
Start: 0
|
||||
ShadowStart: 3
|
||||
# TODO: lights: gtpile_a
|
||||
# Start: 0
|
||||
# TODO: light: gtpile_b
|
||||
# Start: 0
|
||||
# TODO: flag: gtpile_c
|
||||
# Start:0
|
||||
damaged-idle: gtpile
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
critical-idle: gtpile
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
idle-lights: gtpile_a
|
||||
Start: 0
|
||||
Length: 7
|
||||
Tick: 200
|
||||
damaged-idle-lights: gtpile_a
|
||||
Start:7
|
||||
Length: 7
|
||||
Tick: 200
|
||||
idle-light: gtpile_b
|
||||
Start: 0
|
||||
Length: 7
|
||||
Tick: 200
|
||||
damaged-idle-light: gtpile_b
|
||||
Start:7
|
||||
Length: 7
|
||||
Tick: 200
|
||||
idle-flag: gtpile_c
|
||||
Start:0
|
||||
Length: 7
|
||||
damaged-idle-flag: gtpile_c
|
||||
Start:7
|
||||
Length: 7
|
||||
make: gtpilemk
|
||||
Start: 0
|
||||
Length: 20
|
||||
ShadowStart: 20
|
||||
damaged-idle: gtpile
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
dead: gtpile
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
|
||||
gaweap:
|
||||
idle: gtweap
|
||||
@@ -175,38 +218,68 @@ gaarty:
|
||||
Length: 16
|
||||
ShadowStart: 16
|
||||
|
||||
gaspot: # TODO: 1 more damage state, GASPOT_A active animation
|
||||
gaspot:
|
||||
idle:
|
||||
Start: 0
|
||||
ShadowStart: 3
|
||||
damaged-idle:
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
critical-idle:
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
idle-lights: gaspot_a
|
||||
Start: 0
|
||||
Length: 8
|
||||
Tick: 200
|
||||
damaged-idle-lights: gaspot_a
|
||||
Start: 8
|
||||
Length: 8
|
||||
Tick: 200
|
||||
critical-idle-lights: gaspot_a
|
||||
Start: 16
|
||||
Length: 8
|
||||
Tick: 200
|
||||
make: gaspotmk
|
||||
Start: 0
|
||||
Length: 14
|
||||
ShadowStart: 14
|
||||
|
||||
gahpad: # TODO: 1 more damage state
|
||||
gahpad:
|
||||
idle:
|
||||
Start: 0
|
||||
ShadowStart: 3
|
||||
damaged-idle:
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
critical-idle:
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
idle-platform: gthpadbb
|
||||
Start: 0
|
||||
ShadowStart: 3
|
||||
damaged-idle-platform: gthpadbb
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
critical-idle-platform: gthpadbb
|
||||
Start: 2
|
||||
ShadowStart: 5
|
||||
idle-lights: gahpad_a
|
||||
Start: 0
|
||||
Length: 8
|
||||
Offset: 2,-12
|
||||
Tick: 200
|
||||
damaged-idle-lights: gthpad_a
|
||||
Start: 8
|
||||
Length: 8
|
||||
Offset: 16,-16
|
||||
Tick: 200
|
||||
critical-idle-lights: gthpad_a
|
||||
Start: 16
|
||||
Length: 8
|
||||
Offset: 24,-24
|
||||
Tick: 200
|
||||
make: gahpadmk
|
||||
Start: 0
|
||||
Length: 18
|
||||
ShadowStart: 18
|
||||
build-top: gahpad_a
|
||||
Start: 8
|
||||
Length: 8
|
||||
damaged-build-top: gahpad_a
|
||||
Start: 0
|
||||
Length: 8
|
||||
idle-top: gahpadbb
|
||||
Start: 0
|
||||
ShadowStart: 3
|
||||
damaged-idle-top: gahpadbb
|
||||
Start: 1
|
||||
ShadowStart: 4
|
||||
ShadowStart: 18
|
||||
Reference in New Issue
Block a user