@@ -83,6 +83,7 @@
|
|||||||
<Compile Include="FogPaletteFromR8.cs" />
|
<Compile Include="FogPaletteFromR8.cs" />
|
||||||
<Compile Include="DamagedWithoutFoundation.cs" />
|
<Compile Include="DamagedWithoutFoundation.cs" />
|
||||||
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
||||||
|
<Compile Include="Render\WithProductionOverlay.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
95
OpenRA.Mods.D2k/Render/WithProductionOverlay.cs
Normal file
95
OpenRA.Mods.D2k/Render/WithProductionOverlay.cs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#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 System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Render
|
||||||
|
{
|
||||||
|
public class WithProductionOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
public readonly string Sequence = "production-overlay";
|
||||||
|
|
||||||
|
[Desc("Position relative to body")]
|
||||||
|
public readonly WVec Offset = WVec.Zero;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithProductionOverlay(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithProductionOverlay : INotifyDamageStateChanged, ITick, INotifyBuildComplete, INotifySold
|
||||||
|
{
|
||||||
|
Animation overlay;
|
||||||
|
ProductionQueue queue;
|
||||||
|
bool buildComplete;
|
||||||
|
|
||||||
|
bool IsProducing
|
||||||
|
{
|
||||||
|
get { return queue != null && queue.CurrentItem() != null && !queue.CurrentPaused; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public WithProductionOverlay(Actor self, WithProductionOverlayInfo 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.PlayRepeating(info.Sequence);
|
||||||
|
rs.anims.Add("production_overlay_{0}".F(info.Sequence),
|
||||||
|
new AnimationWithOffset(overlay,
|
||||||
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
|
() => !IsProducing || !buildComplete));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick(Actor self)
|
||||||
|
{
|
||||||
|
// search for the queue here once so we don't rely on order of trait initialization
|
||||||
|
if (queue == null)
|
||||||
|
{
|
||||||
|
var production = self.TraitOrDefault<Production>();
|
||||||
|
|
||||||
|
var perBuildingQueues = self.TraitsImplementing<ProductionQueue>();
|
||||||
|
queue = perBuildingQueues.FirstOrDefault(q => production.Info.Produces.Contains(q.Info.Type));
|
||||||
|
|
||||||
|
if (queue == null)
|
||||||
|
{
|
||||||
|
var perPlayerQueues = self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>();
|
||||||
|
queue = perPlayerQueues.FirstOrDefault(q => production.Info.Produces.Contains(q.Info.Type));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (queue == null)
|
||||||
|
throw new InvalidOperationException("Can't find production queues.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingComplete(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Sold(Actor self) { }
|
||||||
|
public void Selling(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
|
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -260,8 +260,8 @@ CONCRETEB:
|
|||||||
ProductionBar:
|
ProductionBar:
|
||||||
ProvidesCustomPrerequisite:
|
ProvidesCustomPrerequisite:
|
||||||
Prerequisite: Light
|
Prerequisite: Light
|
||||||
WithIdleOverlay@WELDING:
|
WithProductionOverlay@WELDING:
|
||||||
Sequence: idle-welding
|
Sequence: production-welding
|
||||||
|
|
||||||
^HEAVY:
|
^HEAVY:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -300,8 +300,8 @@ CONCRETEB:
|
|||||||
ProductionBar:
|
ProductionBar:
|
||||||
ProvidesCustomPrerequisite:
|
ProvidesCustomPrerequisite:
|
||||||
Prerequisite: Heavy
|
Prerequisite: Heavy
|
||||||
WithIdleOverlay@WELDING:
|
WithProductionOverlay@WELDING:
|
||||||
Sequence: idle-welding
|
Sequence: production-welding
|
||||||
|
|
||||||
^RADAR:
|
^RADAR:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -603,8 +603,8 @@ WALL:
|
|||||||
Range: 4c0
|
Range: 4c0
|
||||||
ProvidesCustomPrerequisite:
|
ProvidesCustomPrerequisite:
|
||||||
Prerequisite: Hitech
|
Prerequisite: Hitech
|
||||||
WithIdleOverlay@WELDING:
|
# WithProductionOverlay@WELDING:
|
||||||
Sequence: idle-welding
|
# Sequence: production-welding
|
||||||
|
|
||||||
^RESEARCH:
|
^RESEARCH:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ hightecha:
|
|||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2565
|
Start: 2565
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4614
|
Start: 4614
|
||||||
Length: 30
|
Length: 30
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
@@ -690,7 +690,7 @@ lighta:
|
|||||||
damaged-idle-top: DATA
|
damaged-idle-top: DATA
|
||||||
Start: 2675
|
Start: 2675
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4644
|
Start: 4644
|
||||||
Length: 30
|
Length: 30
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
@@ -739,7 +739,7 @@ heavya:
|
|||||||
damaged-idle-top: DATA
|
damaged-idle-top: DATA
|
||||||
Start: 2520
|
Start: 2520
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4674
|
Start: 4674
|
||||||
Length: 47
|
Length: 47
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
@@ -1005,7 +1005,7 @@ hightechh:
|
|||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2725
|
Start: 2725
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4614
|
Start: 4614
|
||||||
Length: 30
|
Length: 30
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
@@ -1090,7 +1090,7 @@ lighth:
|
|||||||
damaged-idle-top: DATA
|
damaged-idle-top: DATA
|
||||||
Start: 2835
|
Start: 2835
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4644
|
Start: 4644
|
||||||
Length: 30
|
Length: 30
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
@@ -1139,7 +1139,7 @@ heavyh:
|
|||||||
damaged-idle-top: DATA
|
damaged-idle-top: DATA
|
||||||
Start: 2680
|
Start: 2680
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4674
|
Start: 4674
|
||||||
Length: 47
|
Length: 47
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
@@ -1406,7 +1406,7 @@ hightecho:
|
|||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2885
|
Start: 2885
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4614
|
Start: 4614
|
||||||
Length: 30
|
Length: 30
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
@@ -1483,7 +1483,7 @@ lighto:
|
|||||||
damaged-idle-top: DATA
|
damaged-idle-top: DATA
|
||||||
Start: 2995
|
Start: 2995
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4644
|
Start: 4644
|
||||||
Length: 30
|
Length: 30
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
@@ -1532,7 +1532,7 @@ heavyo:
|
|||||||
damaged-idle-top: DATA
|
damaged-idle-top: DATA
|
||||||
Start: 2840
|
Start: 2840
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4674
|
Start: 4674
|
||||||
Length: 47
|
Length: 47
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
@@ -1647,7 +1647,7 @@ heavyc: # TODO: unused
|
|||||||
damaged-idle-top: DATA
|
damaged-idle-top: DATA
|
||||||
Start: 3003
|
Start: 3003
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
idle-welding: DATA
|
production-welding: DATA
|
||||||
Start: 4674
|
Start: 4674
|
||||||
Length: 47
|
Length: 47
|
||||||
Offset: -48,80
|
Offset: -48,80
|
||||||
|
|||||||
Reference in New Issue
Block a user