add spice refinery smoke overlay when harvester docked
This commit is contained in:
@@ -86,6 +86,7 @@ namespace OpenRA.Traits
|
|||||||
bool IsValidTarget(Actor self, Actor saboteur);
|
bool IsValidTarget(Actor self, Actor saboteur);
|
||||||
}
|
}
|
||||||
public interface IStoreOre { int Capacity { get; } }
|
public interface IStoreOre { int Capacity { get; } }
|
||||||
|
public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); }
|
||||||
public interface IEffectiveOwner
|
public interface IEffectiveOwner
|
||||||
{
|
{
|
||||||
bool Disguised { get; }
|
bool Disguised { get; }
|
||||||
|
|||||||
@@ -52,7 +52,12 @@ namespace OpenRA.Mods.Cnc
|
|||||||
state = State.Dock;
|
state = State.Dock;
|
||||||
return Util.SequenceActivities(new Drag(startDock, endDock, 12), this);
|
return Util.SequenceActivities(new Drag(startDock, endDock, 12), this);
|
||||||
case State.Dock:
|
case State.Dock:
|
||||||
ru.PlayCustomAnimation(self, "dock", () => { ru.PlayCustomAnimRepeating(self, "dock-loop"); state = State.Loop; });
|
ru.PlayCustomAnimation(self, "dock", () => {
|
||||||
|
ru.PlayCustomAnimRepeating(self, "dock-loop");
|
||||||
|
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||||
|
nd.Docked(proc, self);
|
||||||
|
state = State.Loop;
|
||||||
|
});
|
||||||
state = State.Wait;
|
state = State.Wait;
|
||||||
return this;
|
return this;
|
||||||
case State.Loop:
|
case State.Loop:
|
||||||
@@ -61,6 +66,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
return this;
|
return this;
|
||||||
case State.Undock:
|
case State.Undock:
|
||||||
ru.PlayCustomAnimBackwards(self, "dock", () => state = State.DragOut);
|
ru.PlayCustomAnimBackwards(self, "dock", () => state = State.DragOut);
|
||||||
|
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||||
|
nd.Undocked(proc, self);
|
||||||
state = State.Wait;
|
state = State.Wait;
|
||||||
return this;
|
return this;
|
||||||
case State.DragOut:
|
case State.DragOut:
|
||||||
|
|||||||
@@ -89,6 +89,7 @@
|
|||||||
<Compile Include="DamagedWithoutFoundation.cs" />
|
<Compile Include="DamagedWithoutFoundation.cs" />
|
||||||
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
||||||
<Compile Include="Render\WithProductionOverlay.cs" />
|
<Compile Include="Render\WithProductionOverlay.cs" />
|
||||||
|
<Compile Include="Render\WithDockingOverlay.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
74
OpenRA.Mods.D2k/Render/WithDockingOverlay.cs
Normal file
74
OpenRA.Mods.D2k/Render/WithDockingOverlay.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2014 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.Effects;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Render
|
||||||
|
{
|
||||||
|
public class WithDockingOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
public readonly string Sequence = "docking-overlay";
|
||||||
|
|
||||||
|
[Desc("Position relative to body")]
|
||||||
|
public readonly WVec Offset = WVec.Zero;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithDockingOverlay(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithDockingOverlay : INotifyDocking, INotifyBuildComplete, INotifySold
|
||||||
|
{
|
||||||
|
WithDockingOverlayInfo info;
|
||||||
|
Animation overlay;
|
||||||
|
bool buildComplete, docked;
|
||||||
|
|
||||||
|
public WithDockingOverlay(Actor self, WithDockingOverlayInfo info)
|
||||||
|
{
|
||||||
|
this.info = 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.Play(info.Sequence);
|
||||||
|
rs.anims.Add("docking_overlay_{0}".F(info.Sequence),
|
||||||
|
new AnimationWithOffset(overlay,
|
||||||
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
|
() => !buildComplete));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayDockingOverlay()
|
||||||
|
{
|
||||||
|
if (docked)
|
||||||
|
overlay.PlayThen(info.Sequence, PlayDockingOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingComplete(Actor self)
|
||||||
|
{
|
||||||
|
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(120, () =>
|
||||||
|
buildComplete = true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Sold(Actor self) { }
|
||||||
|
public void Selling(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Docked(Actor self, Actor harvester) { docked = true; PlayDockingOverlay(); }
|
||||||
|
public void Undocked(Actor self, Actor harvester) { docked = false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,7 +45,12 @@ namespace OpenRA.Mods.RA
|
|||||||
state = State.Dock;
|
state = State.Dock;
|
||||||
return Util.SequenceActivities(new Turn(angle), this);
|
return Util.SequenceActivities(new Turn(angle), this);
|
||||||
case State.Dock:
|
case State.Dock:
|
||||||
ru.PlayCustomAnimation(self, "dock", () => {ru.PlayCustomAnimRepeating(self, "dock-loop"); state = State.Loop;});
|
ru.PlayCustomAnimation(self, "dock", () => {
|
||||||
|
ru.PlayCustomAnimRepeating(self, "dock-loop");
|
||||||
|
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||||
|
nd.Docked(proc, self);
|
||||||
|
state = State.Loop;
|
||||||
|
});
|
||||||
state = State.Wait;
|
state = State.Wait;
|
||||||
return this;
|
return this;
|
||||||
case State.Loop:
|
case State.Loop:
|
||||||
@@ -59,8 +64,11 @@ namespace OpenRA.Mods.RA
|
|||||||
case State.Complete:
|
case State.Complete:
|
||||||
harv.LastLinkedProc = harv.LinkedProc;
|
harv.LastLinkedProc = harv.LinkedProc;
|
||||||
harv.LinkProc(self, null);
|
harv.LinkProc(self, null);
|
||||||
|
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||||
|
nd.Undocked(proc, self);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidOperationException("Invalid harvester dock state");
|
throw new InvalidOperationException("Invalid harvester dock state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ namespace OpenRA.Mods.RA
|
|||||||
[Sync] bool preventDock = false;
|
[Sync] bool preventDock = false;
|
||||||
|
|
||||||
public bool AllowDocking { get { return !preventDock; } }
|
public bool AllowDocking { get { return !preventDock; } }
|
||||||
|
|
||||||
public CVec DeliverOffset { get { return (CVec)Info.DockOffset; } }
|
public CVec DeliverOffset { get { return (CVec)Info.DockOffset; } }
|
||||||
|
|
||||||
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, Info.DockAngle); }
|
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, Info.DockAngle); }
|
||||||
@@ -110,11 +111,11 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (!preventDock)
|
if (!preventDock)
|
||||||
{
|
{
|
||||||
harv.QueueActivity( new CallFunc( () => dockedHarv = harv, false ) );
|
harv.QueueActivity(new CallFunc( () => dockedHarv = harv, false));
|
||||||
harv.QueueActivity( DockSequence(harv, self) );
|
harv.QueueActivity(DockSequence(harv, self));
|
||||||
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
|
harv.QueueActivity(new CallFunc( () => dockedHarv = null, false));
|
||||||
}
|
}
|
||||||
harv.QueueActivity( new CallFunc( () => harv.Trait<Harvester>().ContinueHarvesting(harv) ) );
|
harv.QueueActivity(new CallFunc(() => harv.Trait<Harvester>().ContinueHarvesting(harv)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||||
|
|||||||
@@ -190,6 +190,8 @@ CONCRETEB:
|
|||||||
Facing: 160
|
Facing: 160
|
||||||
ProvidesCustomPrerequisite:
|
ProvidesCustomPrerequisite:
|
||||||
Prerequisite: Refinery
|
Prerequisite: Refinery
|
||||||
|
WithDockingOverlay@SMOKE:
|
||||||
|
Sequence: smoke
|
||||||
|
|
||||||
^SILO:
|
^SILO:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -475,6 +475,12 @@ refa:
|
|||||||
icon: DATA
|
icon: DATA
|
||||||
Start: 4066
|
Start: 4066
|
||||||
Offset: -30,-24
|
Offset: -30,-24
|
||||||
|
smoke: DATA
|
||||||
|
Start: 3885
|
||||||
|
Length: 14
|
||||||
|
Offset: 10,-16
|
||||||
|
Tick: 200
|
||||||
|
BlendMode: Additive
|
||||||
|
|
||||||
siloa:
|
siloa:
|
||||||
idle: DATA
|
idle: DATA
|
||||||
@@ -966,6 +972,12 @@ refh:
|
|||||||
icon: DATA
|
icon: DATA
|
||||||
Start: 4067
|
Start: 4067
|
||||||
Offset: -30,-24
|
Offset: -30,-24
|
||||||
|
smoke: DATA
|
||||||
|
Start: 3885
|
||||||
|
Length: 14
|
||||||
|
Offset: 10,-16
|
||||||
|
Tick: 200
|
||||||
|
BlendMode: Additive
|
||||||
|
|
||||||
siloh:
|
siloh:
|
||||||
idle: DATA
|
idle: DATA
|
||||||
@@ -1367,6 +1379,12 @@ refo:
|
|||||||
icon: DATA
|
icon: DATA
|
||||||
Start: 4068
|
Start: 4068
|
||||||
Offset: -30,-24
|
Offset: -30,-24
|
||||||
|
smoke: DATA
|
||||||
|
Start: 3885
|
||||||
|
Length: 14
|
||||||
|
Offset: 10,-16
|
||||||
|
Tick: 200
|
||||||
|
BlendMode: Additive
|
||||||
|
|
||||||
siloo:
|
siloo:
|
||||||
idle: DATA
|
idle: DATA
|
||||||
|
|||||||
Reference in New Issue
Block a user