tidy cnc mod dll
This commit is contained in:
70
OpenRA.Mods.Cnc/Render/RenderGunboat.cs
Normal file
70
OpenRA.Mods.Cnc/Render/RenderGunboat.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#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.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
class RenderGunboatInfo : RenderSpritesInfo, IQuantizeBodyOrientationInfo, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[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); }
|
||||
|
||||
public int QuantizedBodyFacings(SequenceProvider sequenceProvider, ActorInfo ai)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
class RenderGunboat : RenderSprites, INotifyDamageStateChanged
|
||||
{
|
||||
Animation left, right;
|
||||
|
||||
public RenderGunboat(Actor self, RenderGunboatInfo info)
|
||||
: base(self)
|
||||
{
|
||||
var name = GetImage(self);
|
||||
var facing = self.Trait<IFacing>();
|
||||
var turret = self.TraitsImplementing<Turreted>()
|
||||
.First(t => t.Name == info.Turret);
|
||||
|
||||
left = new Animation(self.World, name, () => turret.TurretFacing);
|
||||
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(info.RightSequence);
|
||||
Add(info.RightSequence, new AnimationWithOffset(right, null, () => facing.Facing <= 128, 0));
|
||||
|
||||
var leftWake = new Animation(self.World, name);
|
||||
leftWake.Play(info.WakeLeftSequence);
|
||||
Add(info.WakeLeftSequence, new AnimationWithOffset(leftWake, null, () => facing.Facing > 128, -87));
|
||||
|
||||
var rightWake = new Animation(self.World, name);
|
||||
rightWake.Play(info.WakeRightSequence);
|
||||
Add(info.WakeRightSequence, new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));
|
||||
}
|
||||
|
||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
left.ReplaceAnim(NormalizeSequence(left, e.DamageState, left.CurrentSequence.Name));
|
||||
right.ReplaceAnim(NormalizeSequence(right, e.DamageState, right.CurrentSequence.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
74
OpenRA.Mods.Cnc/Render/WithCargo.cs
Normal file
74
OpenRA.Mods.Cnc/Render/WithCargo.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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA;
|
||||
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 WVec[] LocalOffset = { };
|
||||
[Desc("Passenger CargoType to display.")]
|
||||
public readonly string[] DisplayTypes = { };
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithCargo(init.self, this); }
|
||||
}
|
||||
|
||||
public class WithCargo : IRenderModifier
|
||||
{
|
||||
Cargo cargo;
|
||||
IFacing facing;
|
||||
WithCargoInfo cargoInfo;
|
||||
IBodyOrientation body;
|
||||
|
||||
public WithCargo(Actor self, WithCargoInfo info)
|
||||
{
|
||||
cargo = self.Trait<Cargo>();
|
||||
facing = self.TraitOrDefault<IFacing>();
|
||||
cargoInfo = info;
|
||||
|
||||
body = self.Trait<IBodyOrientation>();
|
||||
|
||||
if (info.LocalOffset.Length == 0)
|
||||
throw new InvalidOperationException("LocalOffset must have at least one entry");
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
{
|
||||
foreach (var rr in r)
|
||||
yield return rr;
|
||||
|
||||
var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
|
||||
var pos = self.CenterPosition;
|
||||
var i = 0;
|
||||
foreach (var c in cargo.Passengers)
|
||||
{
|
||||
var cargoFacing = c.TraitOrDefault<IFacing>();
|
||||
if (facing != null && cargoFacing != null)
|
||||
cargoFacing.Facing = facing.Facing;
|
||||
|
||||
var cargoPassenger = c.Trait<Passenger>();
|
||||
if (cargoInfo.DisplayTypes.Contains(cargoPassenger.Info.CargoType))
|
||||
{
|
||||
var offset = pos - c.CenterPosition + body.LocalToWorld(cargoInfo.LocalOffset[i++ % cargoInfo.LocalOffset.Length].Rotate(bodyOrientation));
|
||||
foreach (var cr in c.Render(wr))
|
||||
yield return cr.OffsetBy(offset).WithZOffset(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
OpenRA.Mods.Cnc/Render/WithDeliveryAnimation.cs
Normal file
47
OpenRA.Mods.Cnc/Render/WithDeliveryAnimation.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#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.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";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
OpenRA.Mods.Cnc/Render/WithFire.cs
Normal file
36
OpenRA.Mods.Cnc/Render/WithFire.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
#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.Graphics;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
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); }
|
||||
}
|
||||
|
||||
class WithFire
|
||||
{
|
||||
public WithFire(Actor self, WithFireInfo info)
|
||||
{
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
35
OpenRA.Mods.Cnc/Render/WithRoof.cs
Normal file
35
OpenRA.Mods.Cnc/Render/WithRoof.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
#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.Graphics;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
[Desc("Provides an overlay for the Tiberian Dawn hover craft.")]
|
||||
public class WithRoofInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
public readonly string Sequence = "roof";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithRoof(init.self, this); }
|
||||
}
|
||||
|
||||
public class WithRoof
|
||||
{
|
||||
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(info.Sequence);
|
||||
rs.Add("roof", new AnimationWithOffset(roof, null, null, 1024));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user