Files
OpenRA/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs
pevers 17fec82348 fixed taking over sam/pillbox/etc. to stop firing
fixed issue with powered down samsites

more optimization

very small optimization

undo changes to powerdown samsite fixes

refixed powered down sam sites

removed debug line

redid the fix in another approach by queueing a sell activity on the top of the queue. This was already present but didn't always work

fixed line I removed

prevented attack activity to be queued when actor is disabled

another style fail of me

reverse and queueactivity activities are now executed on top of the queue for a sell action
2015-03-04 18:13:33 +01:00

60 lines
1.6 KiB
C#

#region Copyright & License Information
/*
* Copyright 2007-2015 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.Linq;
using OpenRA.Activities;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class WithMakeAnimationInfo : ITraitInfo, Requires<BuildingInfo>, Requires<RenderBuildingInfo>
{
[Desc("Sequence name to use")]
public readonly string Sequence = "make";
public object Create(ActorInitializer init) { return new WithMakeAnimation(init, this); }
}
public class WithMakeAnimation
{
readonly WithMakeAnimationInfo info;
readonly RenderBuilding renderBuilding;
public WithMakeAnimation(ActorInitializer init, WithMakeAnimationInfo info)
{
this.info = info;
var self = init.Self;
renderBuilding = self.Trait<RenderBuilding>();
var building = self.Trait<Building>();
if (!building.SkipMakeAnimation)
{
renderBuilding.PlayCustomAnimThen(self, info.Sequence, () =>
{
building.NotifyBuildingComplete(self);
});
}
}
public void Reverse(Actor self, Activity activity, bool queued = true)
{
renderBuilding.PlayCustomAnimBackwards(self, info.Sequence, () =>
{
// avoids visual glitches as we wait for the actor to get destroyed
renderBuilding.DefaultAnimation.PlayFetchIndex(info.Sequence, () => 0);
self.QueueActivity(queued, activity);
});
}
}
}