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:
@@ -390,6 +390,7 @@
|
|||||||
<Compile Include="Traits\Render\WithActiveAnimation.cs" />
|
<Compile Include="Traits\Render\WithActiveAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithBuildingPlacedAnimation.cs" />
|
<Compile Include="Traits\Render\WithBuildingPlacedAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithMakeAnimation.cs" />
|
<Compile Include="Traits\Render\WithMakeAnimation.cs" />
|
||||||
|
<Compile Include="Traits\Render\WithChargeOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithCrateBody.cs" />
|
<Compile Include="Traits\Render\WithCrateBody.cs" />
|
||||||
<Compile Include="Traits\Render\WithDeathAnimation.cs" />
|
<Compile Include="Traits\Render\WithDeathAnimation.cs" />
|
||||||
<Compile Include="Traits\Render\WithHarvestAnimation.cs" />
|
<Compile Include="Traits\Render\WithHarvestAnimation.cs" />
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Delay between charge attacks (in ticks).")]
|
[Desc("Delay between charge attacks (in ticks).")]
|
||||||
public readonly int ChargeDelay = 3;
|
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); }
|
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)
|
if (attack.charges == 0)
|
||||||
return this;
|
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);
|
return Util.SequenceActivities(new Wait(attack.info.InitialChargeDelay), new ChargeFire(attack, target), this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,21 +8,20 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Used for tesla coil and obelisk.")]
|
[Desc("Used for tesla coil and obelisk.")]
|
||||||
public class RenderBuildingChargeInfo : RenderBuildingInfo
|
public class RenderBuildingChargeInfo : RenderBuildingInfo
|
||||||
{
|
{
|
||||||
[Desc("Sound to play when building charges.")]
|
|
||||||
public readonly string ChargeAudio = null;
|
|
||||||
|
|
||||||
[Desc("Sequence to use for building charge animation.")]
|
[Desc("Sequence to use for building charge animation.")]
|
||||||
public readonly string ChargeSequence = "active";
|
public readonly string ChargeSequence = "active";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init, this); }
|
public override object Create(ActorInitializer init) { return new RenderBuildingCharge(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RenderBuildingCharge : RenderBuilding
|
public class RenderBuildingCharge : RenderBuilding, INotifyCharging
|
||||||
{
|
{
|
||||||
RenderBuildingChargeInfo info;
|
RenderBuildingChargeInfo info;
|
||||||
|
|
||||||
@@ -32,9 +31,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
this.info = info;
|
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);
|
PlayCustomAnim(self, info.ChargeSequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
68
OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs
Normal file
68
OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface INotifyAttack { void Attacking(Actor self, Target target, Armament a, Barrel barrel); }
|
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 INotifyChat { bool OnChat(string from, string message); }
|
||||||
public interface INotifyParachuteLanded { void OnLanded(); }
|
public interface INotifyParachuteLanded { void OnLanded(); }
|
||||||
public interface IRenderActorPreviewInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }
|
public interface IRenderActorPreviewInfo { IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init); }
|
||||||
|
|||||||
@@ -711,12 +711,12 @@ OBLI:
|
|||||||
Bib:
|
Bib:
|
||||||
HasMinibib: Yes
|
HasMinibib: Yes
|
||||||
RenderBuildingCharge:
|
RenderBuildingCharge:
|
||||||
ChargeAudio: obelpowr.aud
|
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: Laser
|
Weapon: Laser
|
||||||
LocalOffset: 0,0,725
|
LocalOffset: 0,0,725
|
||||||
FireDelay: 0
|
FireDelay: 0
|
||||||
AttackCharge:
|
AttackCharge:
|
||||||
|
ChargeAudio: obelpowr.aud
|
||||||
ReloadTime: 40
|
ReloadTime: 40
|
||||||
InitialChargeDelay: 50
|
InitialChargeDelay: 50
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|||||||
@@ -384,11 +384,11 @@ TSLA:
|
|||||||
Bib:
|
Bib:
|
||||||
HasMinibib: Yes
|
HasMinibib: Yes
|
||||||
RenderBuildingCharge:
|
RenderBuildingCharge:
|
||||||
ChargeAudio: tslachg2.aud
|
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: TeslaZap
|
Weapon: TeslaZap
|
||||||
LocalOffset: 0,0,427
|
LocalOffset: 0,0,427
|
||||||
AttackCharge:
|
AttackCharge:
|
||||||
|
ChargeAudio: tslachg2.aud
|
||||||
MaxCharges: 3
|
MaxCharges: 3
|
||||||
ReloadTime: 120
|
ReloadTime: 120
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|||||||
@@ -88,16 +88,18 @@ NAOBEL:
|
|||||||
Type: Heavy
|
Type: Heavy
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 8c0
|
Range: 8c0
|
||||||
RenderBuildingCharge:
|
|
||||||
ChargeAudio: obelpowr.aud
|
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: LaserFire
|
Weapon: LaserFire
|
||||||
LocalOffset: 0,0,725
|
LocalOffset: 1400,200,1250
|
||||||
AttackCharge:
|
AttackCharge:
|
||||||
|
ChargeAudio: obelpowr.aud
|
||||||
ReloadTime: 50
|
ReloadTime: 50
|
||||||
InitialChargeDelay: 50
|
InitialChargeDelay: 50
|
||||||
|
WithChargeOverlay:
|
||||||
|
Sequence: active
|
||||||
|
Palette: player
|
||||||
|
IsPlayerPalette: true
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
-RenderBuilding:
|
|
||||||
RenderRangeCircle:
|
RenderRangeCircle:
|
||||||
RenderDetectionCircle:
|
RenderDetectionCircle:
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
|
|||||||
@@ -582,11 +582,9 @@ naobel:
|
|||||||
Start: 2
|
Start: 2
|
||||||
ShadowStart: 5
|
ShadowStart: 5
|
||||||
Tick: 400
|
Tick: 400
|
||||||
active: naobel #placeholder until Charge supports overlays
|
active: ntobel_b
|
||||||
ShadowStart: 3
|
Length: 12
|
||||||
# active: ntobel_b
|
Tick: 200
|
||||||
# Length: 12
|
|
||||||
# Tick: 240
|
|
||||||
idle-lights: ntobel_a
|
idle-lights: ntobel_a
|
||||||
Length: 12
|
Length: 12
|
||||||
Tick: 80
|
Tick: 80
|
||||||
|
|||||||
Reference in New Issue
Block a user