@@ -72,6 +72,7 @@ namespace OpenRA.Traits
|
|||||||
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
||||||
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
||||||
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
||||||
|
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
||||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
||||||
public interface INotifyOwnerChanged { void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner); }
|
public interface INotifyOwnerChanged { void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner); }
|
||||||
public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); }
|
public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); }
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
<Compile Include="D2kResourceLayer.cs" />
|
<Compile Include="D2kResourceLayer.cs" />
|
||||||
<Compile Include="FogPaletteFromR8.cs" />
|
<Compile Include="FogPaletteFromR8.cs" />
|
||||||
<Compile Include="DamagedWithoutFoundation.cs" />
|
<Compile Include="DamagedWithoutFoundation.cs" />
|
||||||
|
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
70
OpenRA.Mods.D2k/Render/WithBuildingPlacedOverlayInfo.cs
Normal file
70
OpenRA.Mods.D2k/Render/WithBuildingPlacedOverlayInfo.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#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.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Render
|
||||||
|
{
|
||||||
|
public class WithBuildingPlacedOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
public readonly string Sequence = "crane-overlay";
|
||||||
|
|
||||||
|
[Desc("Position relative to body")]
|
||||||
|
public readonly WVec Offset = WVec.Zero;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithBuildingPlacedOverlay(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithBuildingPlacedOverlay : INotifyBuildComplete, INotifySold, INotifyDamageStateChanged, INotifyBuildingPlaced
|
||||||
|
{
|
||||||
|
Animation overlay;
|
||||||
|
bool buildComplete;
|
||||||
|
|
||||||
|
public WithBuildingPlacedOverlay(Actor self, WithBuildingPlacedOverlayInfo 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("crane_overlay_{0}".F(info.Sequence),
|
||||||
|
new AnimationWithOffset(overlay,
|
||||||
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
|
() => !buildComplete));
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingPlaced(Actor self)
|
||||||
|
{
|
||||||
|
overlay.Play(overlay.CurrentSequence.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -494,6 +494,7 @@
|
|||||||
<Compile Include="Widgets\Logic\ControlGroupLogic.cs" />
|
<Compile Include="Widgets\Logic\ControlGroupLogic.cs" />
|
||||||
<Compile Include="Buildings\LineBuildNode.cs" />
|
<Compile Include="Buildings\LineBuildNode.cs" />
|
||||||
<Compile Include="ModChooserLoadScreen.cs" />
|
<Compile Include="ModChooserLoadScreen.cs" />
|
||||||
|
<Compile Include="Render\WithBuildingPlacedAnimation.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
|
|||||||
@@ -113,6 +113,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (producer.Actor == null)
|
if (producer.Actor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
foreach (var nbp in producer.Actor.TraitsImplementing<INotifyBuildingPlaced>())
|
||||||
|
nbp.BuildingPlaced(producer.Actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetNumBuildables(Player p)
|
static int GetNumBuildables(Player p)
|
||||||
|
|||||||
41
OpenRA.Mods.RA/Render/WithBuildingPlacedAnimation.cs
Normal file
41
OpenRA.Mods.RA/Render/WithBuildingPlacedAnimation.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#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.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Render
|
||||||
|
{
|
||||||
|
public class WithBuildingPlacedAnimationInfo : ITraitInfo, Requires<RenderSimpleInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
public readonly string Sequence = "build";
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithBuildingPlacedAnimation : INotifyBuildingPlaced
|
||||||
|
{
|
||||||
|
WithBuildingPlacedAnimationInfo info;
|
||||||
|
RenderSimple renderSimple;
|
||||||
|
|
||||||
|
public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
renderSimple = self.Trait<RenderSimple>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingPlaced(Actor self)
|
||||||
|
{
|
||||||
|
renderSimple.PlayCustomAnim(self, info.Sequence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,7 @@ FACT:
|
|||||||
BaseProvider:
|
BaseProvider:
|
||||||
Cooldown: 75
|
Cooldown: 75
|
||||||
Range: 14
|
Range: 14
|
||||||
|
WithBuildingPlacedAnimation:
|
||||||
|
|
||||||
NUKE:
|
NUKE:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ CONCRETEB:
|
|||||||
ProductionBar:
|
ProductionBar:
|
||||||
ProvidesCustomPrerequisite:
|
ProvidesCustomPrerequisite:
|
||||||
Prerequisite: Conyard
|
Prerequisite: Conyard
|
||||||
|
WithBuildingPlacedOverlay:
|
||||||
|
|
||||||
^POWER:
|
^POWER:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -183,14 +183,16 @@ conyarda:
|
|||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2560
|
Start: 2560
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
# build: DATA # TODO: overlay
|
crane-overlay: DATA
|
||||||
# Start: 4436
|
Start: 4436
|
||||||
# Length: 14
|
Length: 14
|
||||||
# Offset: -48,64
|
Offset: -48,64
|
||||||
# damaged-build: DATA # TODO: overlay
|
Tick: 80
|
||||||
# Start: 4436
|
damaged-crane-overlay: DATA
|
||||||
# Length: 14
|
Start: 4436
|
||||||
# Offset: -48,64
|
Length: 14
|
||||||
|
Offset: -48,64
|
||||||
|
Tick: 80
|
||||||
bib: BLOXBASE
|
bib: BLOXBASE
|
||||||
Frames: 611, 612, 613, 631, 632, 633
|
Frames: 611, 612, 613, 631, 632, 633
|
||||||
Length: 6
|
Length: 6
|
||||||
@@ -771,14 +773,16 @@ conyardh:
|
|||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2720
|
Start: 2720
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
# build: DATA # TODO: overlay
|
crane-overlay: DATA
|
||||||
# Start: 4450
|
Start: 4450
|
||||||
# Length: 14
|
Length: 14
|
||||||
# Offset: -48,64
|
Offset: -48,64
|
||||||
# damaged-build: DATA # TODO: overlay
|
Tick: 80
|
||||||
# Start: 4450
|
damaged-crane-overlay: DATA
|
||||||
# Length: 14
|
Start: 4450
|
||||||
# Offset: -48,64
|
Length: 14
|
||||||
|
Offset: -48,64
|
||||||
|
Tick: 80
|
||||||
bib: BLOXBASE
|
bib: BLOXBASE
|
||||||
Frames: 611, 612, 613, 631, 632, 633
|
Frames: 611, 612, 613, 631, 632, 633
|
||||||
Length: 6
|
Length: 6
|
||||||
@@ -1169,14 +1173,16 @@ conyardo:
|
|||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2880
|
Start: 2880
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
# build: DATA # TODO: overlay
|
crane-overlay: DATA
|
||||||
# Start: 4464
|
Start: 4464
|
||||||
# Length: 14
|
Length: 14
|
||||||
# Offset: -48,64
|
Offset: -48,64
|
||||||
# damaged-build: DATA # TODO: overlay
|
Tick: 80
|
||||||
# Start: 4464
|
damaged-crane-overlay: DATA
|
||||||
# Length: 14
|
Start: 4464
|
||||||
# Offset: -48,64
|
Length: 14
|
||||||
|
Offset: -48,64
|
||||||
|
Tick: 80
|
||||||
bib: BLOXBASE
|
bib: BLOXBASE
|
||||||
Frames: 611, 612, 613, 631, 632, 633
|
Frames: 611, 612, 613, 631, 632, 633
|
||||||
Length: 6
|
Length: 6
|
||||||
@@ -1675,14 +1681,16 @@ conyardc: # TODO: unused
|
|||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 3007
|
Start: 3007
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
# build: DATA # TODO: overlay
|
crane-overlay: DATA
|
||||||
# Start: 4478
|
Start: 4478
|
||||||
# Length: 14
|
Length: 14
|
||||||
# Offset: -48,64
|
Offset: -48,64
|
||||||
# damaged-build: DATA # TODO: overlay
|
Tick: 80
|
||||||
# Start: 4478
|
damaged-crane-overlay: DATA
|
||||||
# Length: 14
|
Start: 4478
|
||||||
# Offset: -48,64
|
Length: 14
|
||||||
|
Offset: -48,64
|
||||||
|
Tick: 80
|
||||||
bib: BLOXBASE
|
bib: BLOXBASE
|
||||||
Frames: 611, 612, 613, 631, 632, 633
|
Frames: 611, 612, 613, 631, 632, 633
|
||||||
Length: 6
|
Length: 6
|
||||||
|
|||||||
@@ -817,6 +817,7 @@ FACT:
|
|||||||
DeadBuildingState:
|
DeadBuildingState:
|
||||||
BaseProvider:
|
BaseProvider:
|
||||||
Range: 16
|
Range: 16
|
||||||
|
WithBuildingPlacedAnimation:
|
||||||
|
|
||||||
PROC:
|
PROC:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ Chrome:
|
|||||||
|
|
||||||
Assemblies:
|
Assemblies:
|
||||||
mods/ra/OpenRA.Mods.RA.dll
|
mods/ra/OpenRA.Mods.RA.dll
|
||||||
|
mods/d2k/OpenRA.Mods.D2k.dll
|
||||||
mods/ts/OpenRA.Mods.TS.dll
|
mods/ts/OpenRA.Mods.TS.dll
|
||||||
|
|
||||||
ChromeLayout:
|
ChromeLayout:
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ GACNST:
|
|||||||
Sequence: idle-side
|
Sequence: idle-side
|
||||||
WithIdleOverlay@FRONT:
|
WithIdleOverlay@FRONT:
|
||||||
Sequence: idle-front
|
Sequence: idle-front
|
||||||
|
WithBuildingPlacedOverlay:
|
||||||
|
|
||||||
GAPOWR:
|
GAPOWR:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -12,12 +12,15 @@ gacnst:
|
|||||||
Start: 0
|
Start: 0
|
||||||
Length: 24
|
Length: 24
|
||||||
ShadowStart: 24
|
ShadowStart: 24
|
||||||
build-front: gtcnst_d # TODO: needs a render overlay trait
|
crane-overlay: gtcnst_d
|
||||||
Start: 0
|
Start: 0
|
||||||
Length: 20
|
Length: 20
|
||||||
damaged-build-front: gtcnst_d # TODO: needs a render overlay trait
|
damaged-crane-overlay: gtcnst_d
|
||||||
Start: 0
|
Start: 0
|
||||||
Length: 20
|
Length: 20
|
||||||
|
critical-crane-overlay: gtcnst_d
|
||||||
|
Start: 20
|
||||||
|
Length: 20
|
||||||
idle-top: gtcnst_c
|
idle-top: gtcnst_c
|
||||||
Start: 0
|
Start: 0
|
||||||
Length: 15
|
Length: 15
|
||||||
|
|||||||
Reference in New Issue
Block a user