Merge pull request #5124 from Mailaender/crane-overlay
Added crane build animation to construction yards in Dune 2000 and Tiberian Sun
This commit is contained in:
@@ -72,6 +72,7 @@ namespace OpenRA.Traits
|
||||
public interface INotifyKilled { void Killed(Actor self, AttackInfo e); }
|
||||
public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); }
|
||||
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 INotifyOwnerChanged { void OnOwnerChanged(Actor self, 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="FogPaletteFromR8.cs" />
|
||||
<Compile Include="DamagedWithoutFoundation.cs" />
|
||||
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,6 +495,7 @@
|
||||
<Compile Include="Widgets\Logic\ControlGroupLogic.cs" />
|
||||
<Compile Include="Buildings\LineBuildNode.cs" />
|
||||
<Compile Include="ModChooserLoadScreen.cs" />
|
||||
<Compile Include="Render\WithBuildingPlacedAnimation.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
|
||||
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class PlaceBuildingInfo : TraitInfo<PlaceBuilding> {}
|
||||
class PlaceBuildingInfo : TraitInfo<PlaceBuilding> { }
|
||||
|
||||
class PlaceBuilding : IResolveOrder
|
||||
{
|
||||
@@ -50,8 +50,8 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var building = w.CreateActor(order.TargetString, new TypeDictionary
|
||||
{
|
||||
new LocationInit( t ),
|
||||
new OwnerInit( order.Player ),
|
||||
new LocationInit(t),
|
||||
new OwnerInit(order.Player),
|
||||
});
|
||||
|
||||
if (playSounds)
|
||||
@@ -70,14 +70,14 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var building = w.CreateActor(order.TargetString, new TypeDictionary
|
||||
{
|
||||
new LocationInit( order.TargetLocation ),
|
||||
new OwnerInit( order.Player ),
|
||||
new LocationInit(order.TargetLocation),
|
||||
new OwnerInit(order.Player),
|
||||
});
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
|
||||
}
|
||||
|
||||
PlayBuildAnim( self, unit );
|
||||
PlayBuildAnim(self, unit);
|
||||
|
||||
queue.FinishProduction();
|
||||
|
||||
@@ -98,21 +98,24 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
// finds a construction yard (or equivalent) and runs its "build" animation.
|
||||
static void PlayBuildAnim( Actor self, ActorInfo unit )
|
||||
static void PlayBuildAnim(Actor self, ActorInfo unit)
|
||||
{
|
||||
var bi = unit.Traits.GetOrDefault<BuildableInfo>();
|
||||
if (bi == null)
|
||||
return;
|
||||
|
||||
var producers = self.World.ActorsWithTrait<Production>()
|
||||
.Where( x => x.Actor.Owner == self.Owner
|
||||
&& x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( bi.Queue ) )
|
||||
.Where(x => x.Actor.Owner == self.Owner
|
||||
&& x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(bi.Queue))
|
||||
.ToList();
|
||||
var producer = producers.Where( x => x.Actor.IsPrimaryBuilding() ).Concat( producers )
|
||||
var producer = producers.Where(x => x.Actor.IsPrimaryBuilding()).Concat(producers)
|
||||
.FirstOrDefault();
|
||||
|
||||
if( producer.Actor != null )
|
||||
producer.Actor.Trait<RenderSimple>().PlayCustomAnim( producer.Actor, "build" );
|
||||
if (producer.Actor == null)
|
||||
return;
|
||||
|
||||
foreach (var nbp in producer.Actor.TraitsImplementing<INotifyBuildingPlaced>())
|
||||
nbp.BuildingPlaced(producer.Actor);
|
||||
}
|
||||
|
||||
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:
|
||||
Cooldown: 75
|
||||
Range: 14
|
||||
WithBuildingPlacedAnimation:
|
||||
|
||||
NUKE:
|
||||
Inherits: ^BaseBuilding
|
||||
|
||||
@@ -73,6 +73,7 @@ CONCRETEB:
|
||||
ProductionBar:
|
||||
ProvidesCustomPrerequisite:
|
||||
Prerequisite: Conyard
|
||||
WithBuildingPlacedOverlay:
|
||||
|
||||
^POWER:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -183,14 +183,16 @@ conyarda:
|
||||
damaged-idle: DATA
|
||||
Start: 2560
|
||||
Offset: -48,64
|
||||
# build: DATA # TODO: overlay
|
||||
# Start: 4436
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
# damaged-build: DATA # TODO: overlay
|
||||
# Start: 4436
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
crane-overlay: DATA
|
||||
Start: 4436
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
damaged-crane-overlay: DATA
|
||||
Start: 4436
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
bib: BLOXBASE
|
||||
Frames: 611, 612, 613, 631, 632, 633
|
||||
Length: 6
|
||||
@@ -771,14 +773,16 @@ conyardh:
|
||||
damaged-idle: DATA
|
||||
Start: 2720
|
||||
Offset: -48,64
|
||||
# build: DATA # TODO: overlay
|
||||
# Start: 4450
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
# damaged-build: DATA # TODO: overlay
|
||||
# Start: 4450
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
crane-overlay: DATA
|
||||
Start: 4450
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
damaged-crane-overlay: DATA
|
||||
Start: 4450
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
bib: BLOXBASE
|
||||
Frames: 611, 612, 613, 631, 632, 633
|
||||
Length: 6
|
||||
@@ -1169,14 +1173,16 @@ conyardo:
|
||||
damaged-idle: DATA
|
||||
Start: 2880
|
||||
Offset: -48,64
|
||||
# build: DATA # TODO: overlay
|
||||
# Start: 4464
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
# damaged-build: DATA # TODO: overlay
|
||||
# Start: 4464
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
crane-overlay: DATA
|
||||
Start: 4464
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
damaged-crane-overlay: DATA
|
||||
Start: 4464
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
bib: BLOXBASE
|
||||
Frames: 611, 612, 613, 631, 632, 633
|
||||
Length: 6
|
||||
@@ -1675,14 +1681,16 @@ conyardc: # TODO: unused
|
||||
damaged-idle: DATA
|
||||
Start: 3007
|
||||
Offset: -48,64
|
||||
# build: DATA # TODO: overlay
|
||||
# Start: 4478
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
# damaged-build: DATA # TODO: overlay
|
||||
# Start: 4478
|
||||
# Length: 14
|
||||
# Offset: -48,64
|
||||
crane-overlay: DATA
|
||||
Start: 4478
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
damaged-crane-overlay: DATA
|
||||
Start: 4478
|
||||
Length: 14
|
||||
Offset: -48,64
|
||||
Tick: 80
|
||||
bib: BLOXBASE
|
||||
Frames: 611, 612, 613, 631, 632, 633
|
||||
Length: 6
|
||||
|
||||
@@ -817,6 +817,7 @@ FACT:
|
||||
DeadBuildingState:
|
||||
BaseProvider:
|
||||
Range: 16
|
||||
WithBuildingPlacedAnimation:
|
||||
|
||||
PROC:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -91,6 +91,7 @@ Chrome:
|
||||
|
||||
Assemblies:
|
||||
mods/ra/OpenRA.Mods.RA.dll
|
||||
mods/d2k/OpenRA.Mods.D2k.dll
|
||||
mods/ts/OpenRA.Mods.TS.dll
|
||||
|
||||
ChromeLayout:
|
||||
|
||||
@@ -40,6 +40,7 @@ GACNST:
|
||||
Sequence: idle-side
|
||||
WithIdleOverlay@FRONT:
|
||||
Sequence: idle-front
|
||||
WithBuildingPlacedOverlay:
|
||||
|
||||
GAPOWR:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -12,12 +12,15 @@ gacnst:
|
||||
Start: 0
|
||||
Length: 24
|
||||
ShadowStart: 24
|
||||
build-front: gtcnst_d # TODO: needs a render overlay trait
|
||||
crane-overlay: gtcnst_d
|
||||
Start: 0
|
||||
Length: 20
|
||||
damaged-build-front: gtcnst_d # TODO: needs a render overlay trait
|
||||
damaged-crane-overlay: gtcnst_d
|
||||
Start: 0
|
||||
Length: 20
|
||||
critical-crane-overlay: gtcnst_d
|
||||
Start: 20
|
||||
Length: 20
|
||||
idle-top: gtcnst_c
|
||||
Start: 0
|
||||
Length: 15
|
||||
|
||||
Reference in New Issue
Block a user