add the starport active animation
This commit is contained in:
@@ -74,6 +74,7 @@ namespace OpenRA.Traits
|
|||||||
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
||||||
public interface INotifyBuildingPlaced { void BuildingPlaced(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 INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); }
|
||||||
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); }
|
||||||
public interface INotifyHarvest { void Harvested(Actor self, ResourceType resource); }
|
public interface INotifyHarvest { void Harvested(Actor self, ResourceType resource); }
|
||||||
|
|||||||
@@ -102,6 +102,7 @@
|
|||||||
<Compile Include="Widgets\Logic\ProductionTabsLogic.cs" />
|
<Compile Include="Widgets\Logic\ProductionTabsLogic.cs" />
|
||||||
<Compile Include="Widgets\ProductionTypeButtonWidget.cs" />
|
<Compile Include="Widgets\ProductionTypeButtonWidget.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncInstallMusicLogic.cs" />
|
<Compile Include="Widgets\Logic\CncInstallMusicLogic.cs" />
|
||||||
|
<Compile Include="WithDeliveryAnimation.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
// Assume a single exit point for simplicity
|
// Assume a single exit point for simplicity
|
||||||
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
|
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
|
||||||
|
|
||||||
var rb = self.Trait<RenderBuilding>();
|
foreach (var tower in self.TraitsImplementing<INotifyDelivery>())
|
||||||
rb.PlayCustomAnimRepeating(self, "active");
|
tower.IncomingDelivery(self);
|
||||||
|
|
||||||
var actorType = (Info as ProductionAirdropInfo).ActorType;
|
var actorType = (Info as ProductionAirdropInfo).ActorType;
|
||||||
|
|
||||||
@@ -67,7 +67,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
if (!self.IsInWorld || self.IsDead())
|
if (!self.IsInWorld || self.IsDead())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rb.PlayCustomAnimRepeating(self, "idle");
|
foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
|
||||||
|
cargo.Delivered(self);
|
||||||
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
||||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", (Info as ProductionAirdropInfo).ReadyAudio, self.Owner.Country.Race);
|
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", (Info as ProductionAirdropInfo).ReadyAudio, self.Owner.Country.Race);
|
||||||
}));
|
}));
|
||||||
|
|||||||
52
OpenRA.Mods.Cnc/WithDeliveryAnimation.cs
Normal file
52
OpenRA.Mods.Cnc/WithDeliveryAnimation.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#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.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
using OpenRA.Effects;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Render
|
||||||
|
{
|
||||||
|
public class WithDeliveryAnimationInfo : ITraitInfo, Requires<RenderBuildingInfo>
|
||||||
|
{
|
||||||
|
public readonly string ActiveSequence = "active";
|
||||||
|
|
||||||
|
public readonly string IdleSequence = "idle";
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithDeliveryAnimation(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithDeliveryAnimation : INotifyDelivery
|
||||||
|
{
|
||||||
|
WithDeliveryAnimationInfo info;
|
||||||
|
RenderBuilding building;
|
||||||
|
|
||||||
|
public WithDeliveryAnimation(Actor self, WithDeliveryAnimationInfo info)
|
||||||
|
{
|
||||||
|
building = self.Trait<RenderBuilding>();
|
||||||
|
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void IncomingDelivery(Actor self)
|
||||||
|
{
|
||||||
|
building.PlayCustomAnimRepeating(self, info.ActiveSequence);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delivered(Actor self)
|
||||||
|
{
|
||||||
|
building.PlayCustomAnimRepeating(self, info.IdleSequence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -90,6 +90,7 @@
|
|||||||
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
<Compile Include="Render\WithBuildingPlacedOverlayInfo.cs" />
|
||||||
<Compile Include="Render\WithProductionOverlay.cs" />
|
<Compile Include="Render\WithProductionOverlay.cs" />
|
||||||
<Compile Include="Render\WithDockingOverlay.cs" />
|
<Compile Include="Render\WithDockingOverlay.cs" />
|
||||||
|
<Compile Include="Render\WithDeliveryOverlay.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
74
OpenRA.Mods.D2k/Render/WithDeliveryOverlay.cs
Normal file
74
OpenRA.Mods.D2k/Render/WithDeliveryOverlay.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#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.Effects;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Render
|
||||||
|
{
|
||||||
|
public class WithDeliveryOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
public readonly string Sequence = "active";
|
||||||
|
|
||||||
|
[Desc("Position relative to body")]
|
||||||
|
public readonly WVec Offset = WVec.Zero;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new WithDeliveryOverlay(init.self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithDeliveryOverlay : INotifyBuildComplete, INotifySold, INotifyDelivery
|
||||||
|
{
|
||||||
|
WithDeliveryOverlayInfo info;
|
||||||
|
Animation overlay;
|
||||||
|
bool buildComplete, delivering;
|
||||||
|
|
||||||
|
public WithDeliveryOverlay(Actor self, WithDeliveryOverlayInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
|
||||||
|
var rs = self.Trait<RenderSprites>();
|
||||||
|
var body = self.Trait<IBodyOrientation>();
|
||||||
|
|
||||||
|
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||||
|
|
||||||
|
overlay = new Animation(self.World, rs.GetImage(self));
|
||||||
|
overlay.Play(info.Sequence);
|
||||||
|
rs.anims.Add("delivery_overlay_{0}".F(info.Sequence),
|
||||||
|
new AnimationWithOffset(overlay,
|
||||||
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
|
() => !buildComplete));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayDeliveryOverlay()
|
||||||
|
{
|
||||||
|
if (delivering)
|
||||||
|
overlay.PlayThen(info.Sequence, PlayDeliveryOverlay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildingComplete(Actor self)
|
||||||
|
{
|
||||||
|
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(120, () =>
|
||||||
|
buildComplete = true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Sold(Actor self) { }
|
||||||
|
public void Selling(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void IncomingDelivery(Actor self) { delivering = true; PlayDeliveryOverlay(); }
|
||||||
|
public void Delivered(Actor self) { delivering = false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -269,6 +269,7 @@ AFLD:
|
|||||||
ExitCell: 3,1
|
ExitCell: 3,1
|
||||||
ProductionAirdrop:
|
ProductionAirdrop:
|
||||||
Produces: Vehicle
|
Produces: Vehicle
|
||||||
|
WithDeliveryAnimation:
|
||||||
ProductionQueue:
|
ProductionQueue:
|
||||||
Type: Vehicle
|
Type: Vehicle
|
||||||
Group: Vehicle
|
Group: Vehicle
|
||||||
|
|||||||
@@ -379,6 +379,7 @@ CONCRETEB:
|
|||||||
ProductionAirdrop:
|
ProductionAirdrop:
|
||||||
Produces: Starport
|
Produces: Starport
|
||||||
ActorType: frigate
|
ActorType: frigate
|
||||||
|
WithDeliveryOverlay:
|
||||||
ProductionBar:
|
ProductionBar:
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
|
|||||||
@@ -309,19 +309,24 @@ starporta:
|
|||||||
Start: 2671
|
Start: 2671
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
active: DATA
|
|
||||||
Start: 2671
|
|
||||||
Length: 1
|
|
||||||
ZOffset: -1c511
|
|
||||||
Offset: -48,64
|
|
||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2672
|
Start: 2672
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
damaged-active: DATA
|
active: DATA
|
||||||
Start: 2672
|
Start: 4723
|
||||||
|
Length: 23
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
|
damaged-active: DATA
|
||||||
|
Start: 4723
|
||||||
|
Length: 23
|
||||||
|
ZOffset: -1c511
|
||||||
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
make: DATA
|
make: DATA
|
||||||
Start: 4347
|
Start: 4347
|
||||||
Length: 11
|
Length: 11
|
||||||
@@ -806,19 +811,24 @@ starporth:
|
|||||||
Start: 2831
|
Start: 2831
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
active: DATA
|
|
||||||
Start: 2831
|
|
||||||
Length: 1
|
|
||||||
Offset: -48,64
|
|
||||||
ZOffset: -1c511
|
|
||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2832
|
Start: 2832
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
damaged-active: DATA
|
active: DATA
|
||||||
Start: 2832
|
Start: 4723
|
||||||
Offset: -48,64
|
Length: 23
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
|
damaged-active: DATA
|
||||||
|
Start: 4723
|
||||||
|
Length: 23
|
||||||
|
ZOffset: -1c511
|
||||||
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
make: DATA
|
make: DATA
|
||||||
Start: 4347
|
Start: 4347
|
||||||
Length: 11
|
Length: 11
|
||||||
@@ -1212,19 +1222,24 @@ starporto:
|
|||||||
Start: 2991
|
Start: 2991
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
active: DATA
|
|
||||||
Start: 2991
|
|
||||||
Length: 1
|
|
||||||
Offset: -48,64
|
|
||||||
ZOffset: -1c511
|
|
||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 2992
|
Start: 2992
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
damaged-active: DATA
|
active: DATA
|
||||||
Start: 2992
|
Start: 4723
|
||||||
Offset: -48,64
|
Length: 23
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
|
damaged-active: DATA
|
||||||
|
Start: 4723
|
||||||
|
Length: 23
|
||||||
|
ZOffset: -1c511
|
||||||
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
make: DATA
|
make: DATA
|
||||||
Start: 4347
|
Start: 4347
|
||||||
Length: 11
|
Length: 11
|
||||||
@@ -1600,19 +1615,24 @@ starportc: # TODO: unused
|
|||||||
Start: 2999
|
Start: 2999
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
active: DATA
|
|
||||||
Start: 2999
|
|
||||||
Length: 1
|
|
||||||
Offset: -48,64
|
|
||||||
ZOffset: -1c511
|
|
||||||
damaged-idle: DATA
|
damaged-idle: DATA
|
||||||
Start: 3000
|
Start: 3000
|
||||||
Offset: -48,64
|
Offset: -48,64
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
damaged-active: DATA
|
active: DATA
|
||||||
Start: 3000
|
Start: 4723
|
||||||
Offset: -48,64
|
Length: 23
|
||||||
ZOffset: -1c511
|
ZOffset: -1c511
|
||||||
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
|
damaged-active: DATA
|
||||||
|
Start: 4723
|
||||||
|
Length: 23
|
||||||
|
ZOffset: -1c511
|
||||||
|
Offset: -48,64
|
||||||
|
BlendMode: Alpha
|
||||||
|
Tick: 200
|
||||||
make: DATA
|
make: DATA
|
||||||
Start: 4347
|
Start: 4347
|
||||||
Length: 11
|
Length: 11
|
||||||
|
|||||||
Reference in New Issue
Block a user