RenderBuildingRefinery -> WithResources.
This commit is contained in:
@@ -55,7 +55,7 @@ namespace OpenRA.Traits
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual string NormalizeSequence(Actor self, string baseSequence)
|
public virtual string NormalizeSequence(Actor self, string baseSequence)
|
||||||
{
|
{
|
||||||
string damageState = self.GetDamageState() >= DamageState.Heavy ? "damaged-" : "";
|
string damageState = self.GetDamageState() >= DamageState.Heavy ? "damaged-" : "";
|
||||||
if (anim.HasSequence(damageState + baseSequence))
|
if (anim.HasSequence(damageState + baseSequence))
|
||||||
|
|||||||
@@ -85,7 +85,6 @@
|
|||||||
<Compile Include="ProductionAirdrop.cs" />
|
<Compile Include="ProductionAirdrop.cs" />
|
||||||
<Compile Include="ProductionQueueFromSelection.cs" />
|
<Compile Include="ProductionQueueFromSelection.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="RenderBuildingRefinery.cs" />
|
|
||||||
<Compile Include="WithCargo.cs" />
|
<Compile Include="WithCargo.cs" />
|
||||||
<Compile Include="RenderGunboat.cs" />
|
<Compile Include="RenderGunboat.cs" />
|
||||||
<Compile Include="SpawnViceroid.cs" />
|
<Compile Include="SpawnViceroid.cs" />
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
#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, RenderBuildingRefineryInfo 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);
|
|
||||||
|
|
||||||
anims.Add("lights", new AnimationWithOffset(lights, null, () => !buildComplete, 1024));
|
|
||||||
}
|
|
||||||
|
|
||||||
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) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -453,6 +453,7 @@
|
|||||||
<Compile Include="Render\WithVoxelBarrel.cs" />
|
<Compile Include="Render\WithVoxelBarrel.cs" />
|
||||||
<Compile Include="Render\WithVoxelWalkerBody.cs" />
|
<Compile Include="Render\WithVoxelWalkerBody.cs" />
|
||||||
<Compile Include="Widgets\Logic\CreditsLogic.cs" />
|
<Compile Include="Widgets\Logic\CreditsLogic.cs" />
|
||||||
|
<Compile Include="Render\WithResources.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
70
OpenRA.Mods.RA/Render/WithResources.cs
Executable file
70
OpenRA.Mods.RA/Render/WithResources.cs
Executable file
@@ -0,0 +1,70 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2013 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.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Render
|
||||||
|
{
|
||||||
|
class WithResourcesInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
public readonly string Sequence = "resources";
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithResources(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithResources : INotifyBuildComplete, INotifySold, INotifyCapture, INotifyDamageStateChanged
|
||||||
|
{
|
||||||
|
WithResourcesInfo info;
|
||||||
|
Animation anim;
|
||||||
|
RenderSimple rs;
|
||||||
|
PlayerResources playerResources;
|
||||||
|
bool buildComplete;
|
||||||
|
|
||||||
|
public WithResources(Actor self, WithResourcesInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
rs = self.Trait<RenderSimple>();
|
||||||
|
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
|
|
||||||
|
anim = new Animation(rs.GetImage(self));
|
||||||
|
anim.PlayFetchIndex(info.Sequence,
|
||||||
|
() => playerResources.OreCapacity != 0
|
||||||
|
? ((10 * anim.CurrentSequence.Length - 1) * playerResources.Ore) / (10 * playerResources.OreCapacity)
|
||||||
|
: 0);
|
||||||
|
|
||||||
|
rs.anims.Add("resources_{0}".F(info.Sequence), new AnimationWithOffset(
|
||||||
|
anim, null, () => !buildComplete, 1024));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingComplete( Actor self )
|
||||||
|
{
|
||||||
|
buildComplete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
|
if (anim.CurrentSequence != null)
|
||||||
|
anim.ReplaceAnim(rs.NormalizeSequence(self, info.Sequence));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnCapture (Actor self, Actor captor, Player oldOwner, Player newOwner)
|
||||||
|
{
|
||||||
|
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Selling(Actor self) { rs.anims.Remove("resources_{0}".F(info.Sequence)); }
|
||||||
|
public void Sold(Actor self) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -134,8 +134,7 @@ PROC:
|
|||||||
InitialActivity: FindResources
|
InitialActivity: FindResources
|
||||||
SpawnOffset: 1,2
|
SpawnOffset: 1,2
|
||||||
Facing: 64
|
Facing: 64
|
||||||
-RenderBuilding:
|
WithResources:
|
||||||
RenderBuildingRefinery:
|
|
||||||
|
|
||||||
SILO:
|
SILO:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ proc:
|
|||||||
Start: 0
|
Start: 0
|
||||||
Length: *
|
Length: *
|
||||||
Tick: 80
|
Tick: 80
|
||||||
lights: proctwr
|
resources: proctwr
|
||||||
Start: 0
|
Start: 0
|
||||||
Length: 6
|
Length: 6
|
||||||
Offset: -32,-21
|
Offset: -32,-21
|
||||||
damaged-lights: proctwr
|
damaged-resources: proctwr
|
||||||
Start: 6
|
Start: 6
|
||||||
Length: 6
|
Length: 6
|
||||||
Offset: -32,-21
|
Offset: -32,-21
|
||||||
|
|||||||
Reference in New Issue
Block a user