document the various overlay and animation change traits

This commit is contained in:
Matthias Mailänder
2014-07-01 17:46:15 +02:00
parent cf7bd75dad
commit 6097b3eb19
25 changed files with 104 additions and 34 deletions

View File

@@ -19,6 +19,11 @@ namespace OpenRA.Mods.RA.Render
[Desc("Turreted 'Turret' key to display")]
public readonly string Turret = "primary";
public readonly string LeftSequence = "left";
public readonly string RightSequence = "right";
public readonly string WakeLeftSequence = "wake-left";
public readonly string WakeRightSequence = "wake-right";
public override object Create(ActorInitializer init) { return new RenderGunboat(init.self, this); }
}
@@ -35,28 +40,28 @@ namespace OpenRA.Mods.RA.Render
.First(t => t.Name == info.Turret);
left = new Animation(self.World, name, () => turret.turretFacing);
left.Play("left");
Add("left", new AnimationWithOffset(left, null, () => facing.Facing > 128, 0));
left.Play(info.LeftSequence);
Add(info.LeftSequence, new AnimationWithOffset(left, null, () => facing.Facing > 128, 0));
right = new Animation(self.World, name, () => turret.turretFacing);
right.Play("right");
Add("right", new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
right.Play(info.RightSequence);
Add(info.RightSequence, new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
var leftWake = new Animation(self.World, name);
leftWake.Play("wake-left");
Add("wake-left", new AnimationWithOffset(leftWake, null, () => facing.Facing > 128, -87));
leftWake.Play(info.WakeLeftSequence);
Add(info.WakeLeftSequence, new AnimationWithOffset(leftWake, null, () => facing.Facing > 128, -87));
var rightWake = new Animation(self.World, name);
rightWake.Play("wake-right");
Add("wake-right", new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));
rightWake.Play(info.WakeRightSequence);
Add(info.WakeRightSequence, new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));
self.Trait<IBodyOrientation>().SetAutodetectedFacings(2);
}
public void DamageStateChanged(Actor self, AttackInfo e)
{
left.ReplaceAnim(NormalizeSequence(left, e.DamageState, "left"));
right.ReplaceAnim(NormalizeSequence(right, e.DamageState, "right"));
left.ReplaceAnim(NormalizeSequence(left, e.DamageState, left.CurrentSequence.Name));
right.ReplaceAnim(NormalizeSequence(right, e.DamageState, right.CurrentSequence.Name));
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* 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,
@@ -17,10 +17,12 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc
{
[Desc("Renders the cargo loaded into the unit.")]
public class WithCargoInfo : ITraitInfo, Requires<CargoInfo>, Requires<IBodyOrientationInfo>
{
[Desc("Cargo position relative to turret or body. (forward, right, up) triples")]
public readonly WRange[] LocalOffset = { };
[Desc("Passenger CargoType to display.")]
public readonly string[] DisplayTypes = { };
public object Create(ActorInitializer init) { return new WithCargo(init.self, this); }

View File

@@ -12,6 +12,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
[Desc("Building animation to play when ProductionAirdrop is used to deliver units.")]
public class WithDeliveryAnimationInfo : ITraitInfo, Requires<RenderBuildingInfo>
{
public readonly string ActiveSequence = "active";

View File

@@ -13,8 +13,12 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc
{
[Desc("Renders a flame sprite on top of the actor.")]
class WithFireInfo : ITraitInfo, Requires<RenderSpritesInfo>
{
public readonly string StartSequence = "fire-start";
public readonly string LoopSequence = "fire-loop";
public object Create(ActorInitializer init) { return new WithFire(init.self, this); }
}
@@ -23,9 +27,9 @@ namespace OpenRA.Mods.Cnc
public WithFire(Actor self, WithFireInfo info)
{
var rs = self.Trait<RenderSprites>();
var roof = new Animation(self.World, rs.GetImage(self));
roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop"));
rs.Add("fire", new AnimationWithOffset(roof, null, null, 1024));
var fire = new Animation(self.World, rs.GetImage(self));
fire.PlayThen(info.StartSequence, () => fire.PlayRepeating(info.LoopSequence));
rs.Add("fire", new AnimationWithOffset(fire, null, null, 1024));
}
}
}

View File

@@ -13,18 +13,21 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Cnc
{
[Desc("Provides an overlay for the Tiberian Dawn hover craft.")]
public class WithRoofInfo : ITraitInfo, Requires<RenderSpritesInfo>
{
public object Create(ActorInitializer init) { return new WithRoof(init.self); }
public readonly string Sequence = "roof";
public object Create(ActorInitializer init) { return new WithRoof(init.self, this); }
}
public class WithRoof
{
public WithRoof(Actor self)
public WithRoof(Actor self, WithRoofInfo info)
{
var rs = self.Trait<RenderSprites>();
var roof = new Animation(self.World, rs.GetImage(self), () => self.Trait<IFacing>().Facing);
roof.Play("roof");
roof.Play(info.Sequence);
rs.Add("roof", new AnimationWithOffset(roof, null, null, 1024));
}
}