Merge pull request #10364 from Mailaender/unload-overlay
Added the Tiberian Sun harvester unload overlay
This commit is contained in:
@@ -433,7 +433,7 @@
|
||||
<Compile Include="Traits\Render\WithDeathAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithDecoration.cs" />
|
||||
<Compile Include="Traits\Render\WithDockingAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithDockingOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithDockedOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithHarvestAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithHarvestOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithIdleOverlay.cs" />
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Rendered when a harvester is docked.")]
|
||||
public class WithDockingOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
public class WithDockedOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
[SequenceReference] public readonly string Sequence = "docking-overlay";
|
||||
@@ -29,17 +29,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Custom palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithDockingOverlay(init.Self, this); }
|
||||
public object Create(ActorInitializer init) { return new WithDockedOverlay(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithDockingOverlay : INotifyDocking, INotifyBuildComplete, INotifySold
|
||||
public class WithDockedOverlay : INotifyDocking, INotifyBuildComplete, INotifySold
|
||||
{
|
||||
readonly WithDockingOverlayInfo info;
|
||||
readonly WithDockedOverlayInfo info;
|
||||
readonly AnimationWithOffset anim;
|
||||
bool buildComplete;
|
||||
bool docked;
|
||||
|
||||
public WithDockingOverlay(Actor self, WithDockingOverlayInfo info)
|
||||
public WithDockedOverlay(Actor self, WithDockedOverlayInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
@@ -2876,6 +2876,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
// Rename WithDockingOverlay to WithDockedOverlay
|
||||
if (engineVersion < 20160116)
|
||||
{
|
||||
if (node.Key.StartsWith("WithDockingOverlay"))
|
||||
node.Key = "WithDockedOverlay" + node.Key.Substring(18);
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.TS.Traits;
|
||||
|
||||
namespace OpenRA.Mods.TS.Activities
|
||||
@@ -17,24 +18,52 @@ namespace OpenRA.Mods.TS.Activities
|
||||
public class VoxelHarvesterDockSequence : HarvesterDockSequence
|
||||
{
|
||||
readonly WithVoxelUnloadBody body;
|
||||
readonly WithDockingOverlay spriteOverlay;
|
||||
|
||||
public VoxelHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
|
||||
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
|
||||
{
|
||||
body = self.Trait<WithVoxelUnloadBody>();
|
||||
spriteOverlay = refinery.TraitOrDefault<WithDockingOverlay>();
|
||||
}
|
||||
|
||||
public override Activity OnStateDock(Actor self)
|
||||
{
|
||||
body.Docked = true;
|
||||
dockingState = State.Loop;
|
||||
|
||||
if (spriteOverlay != null && !spriteOverlay.Visible)
|
||||
{
|
||||
spriteOverlay.Visible = true;
|
||||
spriteOverlay.WithOffset.Animation.PlayThen(spriteOverlay.Info.Sequence, () => {
|
||||
dockingState = State.Loop;
|
||||
spriteOverlay.Visible = false;
|
||||
});
|
||||
}
|
||||
else
|
||||
dockingState = State.Loop;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Activity OnStateUndock(Actor self)
|
||||
{
|
||||
body.Docked = false;
|
||||
dockingState = State.Complete;
|
||||
dockingState = State.Wait;
|
||||
|
||||
if (spriteOverlay != null && !spriteOverlay.Visible)
|
||||
{
|
||||
spriteOverlay.Visible = true;
|
||||
spriteOverlay.WithOffset.Animation.PlayBackwardsThen(spriteOverlay.Info.Sequence, () => {
|
||||
dockingState = State.Complete;
|
||||
body.Docked = false;
|
||||
spriteOverlay.Visible = false;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
dockingState = State.Complete;
|
||||
body.Docked = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<Compile Include="Activities\VoxelHarvesterDockSequence.cs" />
|
||||
<Compile Include="SpriteLoaders\TmpTSLoader.cs" />
|
||||
<Compile Include="Traits\Buildings\TiberianSunRefinery.cs" />
|
||||
<Compile Include="Traits\Render\WithDockingOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithPermanentInjury.cs" />
|
||||
<Compile Include="Traits\Render\WithVoxelWalkerBody.cs" />
|
||||
<Compile Include="Traits\Render\WithVoxelUnloadBody.cs" />
|
||||
|
||||
59
OpenRA.Mods.TS/Traits/Render/WithDockingOverlay.cs
Normal file
59
OpenRA.Mods.TS/Traits/Render/WithDockingOverlay.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
#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 OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.TS.Traits
|
||||
{
|
||||
[Desc("Rendered on the refinery when a voxel harvester is docking and undocking.")]
|
||||
public class WithDockingOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
[SequenceReference] public readonly string Sequence = "unload-overlay";
|
||||
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
[Desc("Custom palette name")]
|
||||
[PaletteReference("IsPlayerPalette")] public readonly string Palette = null;
|
||||
|
||||
[Desc("Custom palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithDockingOverlay(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithDockingOverlay
|
||||
{
|
||||
public readonly WithDockingOverlayInfo Info;
|
||||
public readonly AnimationWithOffset WithOffset;
|
||||
|
||||
public bool Visible;
|
||||
|
||||
public WithDockingOverlay(Actor self, WithDockingOverlayInfo info)
|
||||
{
|
||||
Info = info;
|
||||
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
var overlay = new Animation(self.World, rs.GetImage(self));
|
||||
overlay.Play(info.Sequence);
|
||||
|
||||
WithOffset = new AnimationWithOffset(overlay,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
() => !Visible);
|
||||
|
||||
rs.Add(WithOffset, info.Palette, info.IsPlayerPalette);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ refinery:
|
||||
FactionImages:
|
||||
atreides: refinery.atreides
|
||||
ordos: refinery.ordos
|
||||
WithDockingOverlay@SMOKE:
|
||||
WithDockedOverlay@SMOKE:
|
||||
Sequence: smoke
|
||||
Power:
|
||||
Amount: -75
|
||||
|
||||
@@ -91,9 +91,10 @@ PROC:
|
||||
Sequence: idle-redlights
|
||||
WithIdleOverlay@BIB:
|
||||
Sequence: bib
|
||||
WithDockingOverlay@flame:
|
||||
WithDockedOverlay@FLAME:
|
||||
Sequence: flame
|
||||
Palette: effect
|
||||
WithDockingOverlay@UNLOAD:
|
||||
Power:
|
||||
Amount: -30
|
||||
ProvidesPrerequisite@buildingname:
|
||||
|
||||
@@ -1038,7 +1038,6 @@ nahpad:
|
||||
Offset: 0, 0
|
||||
UseTilesetCode: false
|
||||
|
||||
# TODO: unused narefn_a
|
||||
proc.gdi:
|
||||
Defaults: ntrefn
|
||||
Offset: -12, -42
|
||||
@@ -1057,6 +1056,9 @@ proc.gdi:
|
||||
ShadowStart: 20
|
||||
flame: ntrefn_b
|
||||
Length: *
|
||||
unload-overlay: narefn_a
|
||||
Length: *
|
||||
ZOffset: 1024
|
||||
idle-redlights: ntrefn_c
|
||||
Length: 16
|
||||
Tick: 120
|
||||
@@ -1078,7 +1080,6 @@ proc.gdi:
|
||||
Offset: 0, 0
|
||||
UseTilesetCode: false
|
||||
|
||||
# TODO: unused narefn_a
|
||||
proc.nod:
|
||||
Defaults: ntrefn
|
||||
Offset: -12, -42
|
||||
@@ -1097,6 +1098,9 @@ proc.nod:
|
||||
ShadowStart: 20
|
||||
flame: ntrefn_b
|
||||
Length: *
|
||||
unload-overlay: narefn_a
|
||||
Length: *
|
||||
ZOffset: 1024
|
||||
idle-redlights: ntrefn_c
|
||||
Length: 16
|
||||
Tick: 120
|
||||
|
||||
Reference in New Issue
Block a user