add the Tiberian Sun harvester unload overlay
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user