Use proc tower lights as a fullness indicator (Feature #1035).
This commit is contained in:
@@ -106,6 +106,7 @@
|
||||
<Compile Include="Widgets\ToggleButtonWidget.cs" />
|
||||
<Compile Include="Widgets\Logic\CncColorPickerLogic.cs" />
|
||||
<Compile Include="Widgets\LogicTickerWidget.cs" />
|
||||
<Compile Include="RenderBuildingRefinery.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
67
OpenRA.Mods.Cnc/RenderBuildingRefinery.cs
Executable file
67
OpenRA.Mods.Cnc/RenderBuildingRefinery.cs
Executable file
@@ -0,0 +1,67 @@
|
||||
#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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class RenderBuildingRefineryInfo : RenderBuildingInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new RenderBuildingRefinery( init, this ); }
|
||||
}
|
||||
|
||||
class RenderBuildingRefinery : RenderBuilding, INotifyBuildComplete, INotifySold, INotifyCapture
|
||||
{
|
||||
public Animation lights;
|
||||
PlayerResources playerResources;
|
||||
bool buildComplete;
|
||||
|
||||
public RenderBuildingRefinery(ActorInitializer init, RenderBuildingInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
playerResources = init.self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
|
||||
lights = new Animation(GetImage(init.self));
|
||||
lights.PlayFetchIndex("lights",
|
||||
() => playerResources.OreCapacity != 0
|
||||
? (59 * playerResources.Ore) / (10 * playerResources.OreCapacity)
|
||||
: 0);
|
||||
|
||||
var offset = new float2(-32,-21);
|
||||
anims.Add("lights", new AnimationWithOffset( lights, () => offset, () => !buildComplete )
|
||||
{ ZOffset = 24 });
|
||||
}
|
||||
|
||||
public void BuildingComplete( Actor self )
|
||||
{
|
||||
buildComplete = true;
|
||||
}
|
||||
|
||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (lights.CurrentSequence != null)
|
||||
lights.ReplaceAnim(NormalizeSequence(self, "lights"));
|
||||
|
||||
base.DamageStateChanged(self, e);
|
||||
}
|
||||
|
||||
public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||
{
|
||||
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||
}
|
||||
|
||||
public void Selling(Actor self) { anims.Remove("lights"); }
|
||||
public void Sold(Actor self) { }
|
||||
}
|
||||
}
|
||||
BIN
mods/cnc/bits/proctwr.shp
Normal file
BIN
mods/cnc/bits/proctwr.shp
Normal file
Binary file not shown.
@@ -102,6 +102,8 @@ PROC:
|
||||
InitialActivity: FindResources
|
||||
SpawnOffset: 1,2
|
||||
Facing: 64
|
||||
-RenderBuilding:
|
||||
RenderBuildingRefinery:
|
||||
|
||||
SILO:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -57,6 +57,12 @@ proc:
|
||||
make: procmake
|
||||
Start: 0
|
||||
Length: *
|
||||
lights: proctwr
|
||||
Start: 0
|
||||
Length: 6
|
||||
damaged-lights: proctwr
|
||||
Start: 6
|
||||
Length: 6
|
||||
|
||||
silo:
|
||||
idle:
|
||||
|
||||
Reference in New Issue
Block a user