split render building/overlay and play sound for charge

to add the Tiberian Sun Nod Obelisk

tick slightly faster

tweak the local offsets
This commit is contained in:
Matthias Mailänder
2015-05-01 10:29:00 +02:00
parent cdc98013f7
commit d99ae3bcb9
9 changed files with 93 additions and 18 deletions

View File

@@ -390,6 +390,7 @@
<Compile Include="Traits\Render\WithActiveAnimation.cs" />
<Compile Include="Traits\Render\WithBuildingPlacedAnimation.cs" />
<Compile Include="Traits\Render\WithMakeAnimation.cs" />
<Compile Include="Traits\Render\WithChargeOverlay.cs" />
<Compile Include="Traits\Render\WithCrateBody.cs" />
<Compile Include="Traits\Render\WithDeathAnimation.cs" />
<Compile Include="Traits\Render\WithHarvestAnimation.cs" />

View File

@@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Delay between charge attacks (in ticks).")]
public readonly int ChargeDelay = 3;
[Desc("Sound to play when actor charges.")]
public readonly string ChargeAudio = null;
public override object Create(ActorInitializer init) { return new AttackCharge(init.Self, this); }
}
@@ -98,7 +101,11 @@ namespace OpenRA.Mods.Common.Traits
if (attack.charges == 0)
return this;
self.Trait<RenderBuildingCharge>().PlayCharge(self);
foreach (var notify in self.TraitsImplementing<INotifyCharging>())
notify.Charging(self, target);
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
Sound.Play(attack.info.ChargeAudio, self.CenterPosition);
return Util.SequenceActivities(new Wait(attack.info.InitialChargeDelay), new ChargeFire(attack, target), this);
}

View File

@@ -8,21 +8,20 @@
*/
#endregion
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Used for tesla coil and obelisk.")]
public class RenderBuildingChargeInfo : RenderBuildingInfo
{
[Desc("Sound to play when building charges.")]
public readonly string ChargeAudio = null;
[Desc("Sequence to use for building charge animation.")]
public readonly string ChargeSequence = "active";
public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init, this); }
}
public class RenderBuildingCharge : RenderBuilding
public class RenderBuildingCharge : RenderBuilding, INotifyCharging
{
RenderBuildingChargeInfo info;
@@ -32,9 +31,8 @@ namespace OpenRA.Mods.Common.Traits
this.info = info;
}
public void PlayCharge(Actor self)
public void Charging(Actor self, Target target)
{
Sound.Play(info.ChargeAudio, self.CenterPosition);
PlayCustomAnim(self, info.ChargeSequence);
}
}

View File

@@ -0,0 +1,68 @@
#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 OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Rendered together with AttackCharge.")]
public class WithChargeOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
{
[Desc("Sequence name to use")]
public readonly string Sequence = "active";
[Desc("Custom palette name")]
public readonly string Palette = null;
[Desc("Custom palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;
public object Create(ActorInitializer init) { return new WithChargeOverlay(init, this); }
}
public class WithChargeOverlay : INotifyCharging, INotifyDamageStateChanged, INotifySold
{
readonly Animation overlay;
readonly RenderSprites renderSprites;
readonly WithChargeOverlayInfo info;
bool charging;
public WithChargeOverlay(ActorInitializer init, WithChargeOverlayInfo info)
{
this.info = info;
renderSprites = init.Self.Trait<RenderSprites>();
overlay = new Animation(init.World, renderSprites.GetImage(init.Self));
renderSprites.Add(new AnimationWithOffset(overlay, null, () => !charging),
info.Palette, info.IsPlayerPalette);
}
public void Charging(Actor self, Target target)
{
charging = true;
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false);
}
public void DamageStateChanged(Actor self, AttackInfo e)
{
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence));
}
public void Sold(Actor self) { }
public void Selling(Actor self)
{
charging = false;
}
}
}

View File

@@ -28,6 +28,7 @@ namespace OpenRA.Mods.Common.Traits
}
public interface INotifyAttack { void Attacking(Actor self, Target target, Armament a, Barrel barrel); }
public interface INotifyCharging { void Charging(Actor self, Target target); }
public interface INotifyChat { bool OnChat(string from, string message); }
public interface INotifyParachuteLanded { void OnLanded(); }
public interface IRenderActorPreviewInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }

View File

@@ -711,12 +711,12 @@ OBLI:
Bib:
HasMinibib: Yes
RenderBuildingCharge:
ChargeAudio: obelpowr.aud
Armament:
Weapon: Laser
LocalOffset: 0,0,725
FireDelay: 0
AttackCharge:
ChargeAudio: obelpowr.aud
ReloadTime: 40
InitialChargeDelay: 50
AutoTarget:

View File

@@ -384,11 +384,11 @@ TSLA:
Bib:
HasMinibib: Yes
RenderBuildingCharge:
ChargeAudio: tslachg2.aud
Armament:
Weapon: TeslaZap
LocalOffset: 0,0,427
AttackCharge:
ChargeAudio: tslachg2.aud
MaxCharges: 3
ReloadTime: 120
AutoTarget:

View File

@@ -88,16 +88,18 @@ NAOBEL:
Type: Heavy
RevealsShroud:
Range: 8c0
RenderBuildingCharge:
ChargeAudio: obelpowr.aud
Armament:
Weapon: LaserFire
LocalOffset: 0,0,725
LocalOffset: 1400,200,1250
AttackCharge:
ChargeAudio: obelpowr.aud
ReloadTime: 50
InitialChargeDelay: 50
WithChargeOverlay:
Sequence: active
Palette: player
IsPlayerPalette: true
AutoTarget:
-RenderBuilding:
RenderRangeCircle:
RenderDetectionCircle:
DetectCloaked:

View File

@@ -582,11 +582,9 @@ naobel:
Start: 2
ShadowStart: 5
Tick: 400
active: naobel #placeholder until Charge supports overlays
ShadowStart: 3
# active: ntobel_b
# Length: 12
# Tick: 240
active: ntobel_b
Length: 12
Tick: 200
idle-lights: ntobel_a
Length: 12
Tick: 80