diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index da1e2b10cf..9458478a7a 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -106,6 +106,7 @@ + diff --git a/OpenRA.Mods.Cnc/RenderBuildingRefinery.cs b/OpenRA.Mods.Cnc/RenderBuildingRefinery.cs new file mode 100755 index 0000000000..b8ed7da1fc --- /dev/null +++ b/OpenRA.Mods.Cnc/RenderBuildingRefinery.cs @@ -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(); + + 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(); + } + + public void Selling(Actor self) { anims.Remove("lights"); } + public void Sold(Actor self) { } + } +} diff --git a/mods/cnc/bits/proctwr.shp b/mods/cnc/bits/proctwr.shp new file mode 100644 index 0000000000..92c0345a2c Binary files /dev/null and b/mods/cnc/bits/proctwr.shp differ diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index 01427ca934..f3505549aa 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -102,6 +102,8 @@ PROC: InitialActivity: FindResources SpawnOffset: 1,2 Facing: 64 + -RenderBuilding: + RenderBuildingRefinery: SILO: Inherits: ^Building diff --git a/mods/cnc/sequences/structures.yaml b/mods/cnc/sequences/structures.yaml index 08cde6a98c..2cddd02972 100644 --- a/mods/cnc/sequences/structures.yaml +++ b/mods/cnc/sequences/structures.yaml @@ -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: