Skip to content

Instantly share code, notes, and snippets.

@Mailaender
Created June 25, 2012 20:16
Show Gist options
  • Save Mailaender/2990951 to your computer and use it in GitHub Desktop.
Save Mailaender/2990951 to your computer and use it in GitHub Desktop.
RenderBuildingTurreted with a separate turret sequence
#region Copyright & License Information
/*
* Copyright 2007-2012 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.Graphics;
using OpenRA.Traits;
using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Mods.RA.Render
{
class RenderBuildingSeparateTurretInfo : RenderBuildingInfo, Requires<TurretedInfo>, Requires<AttackBaseInfo>
{
public override object Create(ActorInitializer init) { return new RenderBuildingSeparateTurret(init, this); }
}
class RenderBuildingSeparateTurret : RenderBuilding
{
public RenderBuildingSeparateTurret(ActorInitializer init, RenderBuildingInfo info)
: base(init, info)
{
var facing = init.self.Trait<IFacing>();
var turreted = init.self.Trait<Turreted>();
var attack = init.self.Trait<AttackBase>();
var turretAnim = new Animation(GetImage(init.self), () => turreted.turretFacing);
turretAnim.Play("turret");
for( var i = 0; i < attack.Turrets.Count; i++ )
{
var turret = attack.Turrets[i];
anims.Add( "turret_{0}".F(i),
new AnimationWithOffset(turretAnim,
() => Combat.GetTurretPosition(init.self, facing, turret).ToFloat2(),
null));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment