add the starport active animation
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
<Compile Include="Widgets\Logic\ProductionTabsLogic.cs" />
|
||||
<Compile Include="Widgets\ProductionTypeButtonWidget.cs" />
|
||||
<Compile Include="Widgets\Logic\CncInstallMusicLogic.cs" />
|
||||
<Compile Include="WithDeliveryAnimation.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace OpenRA.Mods.Cnc
|
||||
// Assume a single exit point for simplicity
|
||||
var exit = self.Info.Traits.WithInterface<ExitInfo>().First();
|
||||
|
||||
var rb = self.Trait<RenderBuilding>();
|
||||
rb.PlayCustomAnimRepeating(self, "active");
|
||||
foreach (var tower in self.TraitsImplementing<INotifyDelivery>())
|
||||
tower.IncomingDelivery(self);
|
||||
|
||||
var actorType = (Info as ProductionAirdropInfo).ActorType;
|
||||
|
||||
@@ -67,7 +67,8 @@ namespace OpenRA.Mods.Cnc
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
return;
|
||||
|
||||
rb.PlayCustomAnimRepeating(self, "idle");
|
||||
foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
|
||||
cargo.Delivered(self);
|
||||
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);
|
||||
}));
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user