Merge pull request #12697 from pchote/attack-charge
Implement new charge attack logic for TD/TS obelisks.
This commit is contained in:
@@ -90,6 +90,10 @@
|
||||
<Compile Include="UtilityCommands\LegacyRulesImporter.cs" />
|
||||
<Compile Include="UtilityCommands\LegacySequenceImporter.cs" />
|
||||
<Compile Include="Widgets\Logic\PreReleaseWarningPrompt.cs" />
|
||||
<Compile Include="Traits\Attack\AttackTesla.cs" />
|
||||
<Compile Include="Traits\Render\WithTeslaChargeAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithTeslaChargeOverlay.cs" />
|
||||
<Compile Include="TraitsInterfaces.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
[Desc("Charges up before being able to attack.")]
|
||||
class AttackChargeInfo : AttackOmniInfo
|
||||
[Desc("Implements the charge-then-burst attack logic specific to the RA tesla coil.")]
|
||||
class AttackTeslaInfo : AttackOmniInfo
|
||||
{
|
||||
[Desc("How many charges this actor has to attack with, once charged.")]
|
||||
public readonly int MaxCharges = 1;
|
||||
@@ -33,17 +34,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[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 AttackTesla(init.Self, this); }
|
||||
}
|
||||
|
||||
class AttackCharge : AttackOmni, ITick, INotifyAttack
|
||||
class AttackTesla : AttackOmni, ITick, INotifyAttack
|
||||
{
|
||||
readonly AttackChargeInfo info;
|
||||
readonly AttackTeslaInfo info;
|
||||
|
||||
[Sync] int charges;
|
||||
[Sync] int timeToRecharge;
|
||||
|
||||
public AttackCharge(Actor self, AttackChargeInfo info)
|
||||
public AttackTesla(Actor self, AttackTeslaInfo info)
|
||||
: base(self, info)
|
||||
{
|
||||
this.info = info;
|
||||
@@ -79,10 +80,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class ChargeAttack : Activity
|
||||
{
|
||||
readonly AttackCharge attack;
|
||||
readonly AttackTesla attack;
|
||||
readonly Target target;
|
||||
|
||||
public ChargeAttack(AttackCharge attack, Target target)
|
||||
public ChargeAttack(AttackTesla attack, Target target)
|
||||
{
|
||||
this.attack = attack;
|
||||
this.target = target;
|
||||
@@ -96,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (attack.charges == 0)
|
||||
return this;
|
||||
|
||||
foreach (var notify in self.TraitsImplementing<INotifyCharging>())
|
||||
foreach (var notify in self.TraitsImplementing<INotifyTeslaCharging>())
|
||||
notify.Charging(self, target);
|
||||
|
||||
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
|
||||
@@ -108,10 +109,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class ChargeFire : Activity
|
||||
{
|
||||
readonly AttackCharge attack;
|
||||
readonly AttackTesla attack;
|
||||
readonly Target target;
|
||||
|
||||
public ChargeFire(AttackCharge attack, Target target)
|
||||
public ChargeFire(AttackTesla attack, Target target)
|
||||
{
|
||||
this.attack = attack;
|
||||
this.target = target;
|
||||
42
OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs
Normal file
42
OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeAnimation.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
{
|
||||
[Desc("This actor displays a charge-up animation before firing.")]
|
||||
public class WithTeslaChargeAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Sequence to use for charge animation.")]
|
||||
[SequenceReference] public readonly string ChargeSequence = "active";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithTeslaChargeAnimation(init, this); }
|
||||
}
|
||||
|
||||
public class WithTeslaChargeAnimation : INotifyTeslaCharging
|
||||
{
|
||||
readonly WithTeslaChargeAnimationInfo info;
|
||||
readonly WithSpriteBody wsb;
|
||||
|
||||
public WithTeslaChargeAnimation(ActorInitializer init, WithTeslaChargeAnimationInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
wsb = init.Self.Trait<WithSpriteBody>();
|
||||
}
|
||||
|
||||
void INotifyTeslaCharging.Charging(Actor self, Target target)
|
||||
{
|
||||
wsb.PlayCustomAnimation(self, info.ChargeSequence, () => wsb.CancelCustomAnimation(self));
|
||||
}
|
||||
}
|
||||
}
|
||||
71
OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeOverlay.cs
Normal file
71
OpenRA.Mods.Cnc/Traits/Render/WithTeslaChargeOverlay.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
{
|
||||
[Desc("Rendered together with AttackCharge.")]
|
||||
public class WithTeslaChargeOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
|
||||
[Desc("Custom palette name")]
|
||||
[PaletteReference("IsPlayerPalette")] 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 WithTeslaChargeOverlay(init, this); }
|
||||
}
|
||||
|
||||
public class WithTeslaChargeOverlay : INotifyTeslaCharging, INotifyDamageStateChanged, INotifySold
|
||||
{
|
||||
readonly Animation overlay;
|
||||
readonly RenderSprites renderSprites;
|
||||
readonly WithTeslaChargeOverlayInfo info;
|
||||
|
||||
bool charging;
|
||||
|
||||
public WithTeslaChargeOverlay(ActorInitializer init, WithTeslaChargeOverlayInfo 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);
|
||||
}
|
||||
|
||||
void INotifyTeslaCharging.Charging(Actor self, Target target)
|
||||
{
|
||||
charging = true;
|
||||
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false);
|
||||
}
|
||||
|
||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence));
|
||||
}
|
||||
|
||||
void INotifySold.Sold(Actor self) { }
|
||||
void INotifySold.Selling(Actor self)
|
||||
{
|
||||
charging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
OpenRA.Mods.Cnc/TraitsInterfaces.cs
Normal file
18
OpenRA.Mods.Cnc/TraitsInterfaces.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
[RequireExplicitImplementation]
|
||||
public interface INotifyTeslaCharging { void Charging(Actor self, Target target); }
|
||||
}
|
||||
@@ -262,7 +262,6 @@
|
||||
<Compile Include="Traits\Armor.cs" />
|
||||
<Compile Include="Traits\AttackMove.cs" />
|
||||
<Compile Include="Traits\Attack\AttackBase.cs" />
|
||||
<Compile Include="Traits\Attack\AttackCharge.cs" />
|
||||
<Compile Include="Traits\Attack\AttackFollow.cs" />
|
||||
<Compile Include="Traits\Attack\AttackFrontal.cs" />
|
||||
<Compile Include="Traits\Attack\AttackGarrisoned.cs" />
|
||||
@@ -431,8 +430,6 @@
|
||||
<Compile Include="Traits\Render\WithSiloAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithBuildingPlacedAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithMakeAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithChargeAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithChargeOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithCrateBody.cs" />
|
||||
<Compile Include="Traits\Render\WithDamageOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithDeathAnimation.cs" />
|
||||
@@ -802,6 +799,9 @@
|
||||
<Compile Include="Traits\World\JumpjetActorLayer.cs" />
|
||||
<Compile Include="Traits\World\ElevatedBridgeLayer.cs" />
|
||||
<Compile Include="Traits\World\ElevatedBridgePlaceholder.cs" />
|
||||
<Compile Include="Traits\Attack\AttackCharges.cs" />
|
||||
<Compile Include="Traits\Render\WithChargeAnimation.cs" />
|
||||
<Compile Include="Traits\Render\WithChargeOverlay.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="AfterBuild">
|
||||
|
||||
84
OpenRA.Mods.Common/Traits/Attack/AttackCharges.cs
Normal file
84
OpenRA.Mods.Common/Traits/Attack/AttackCharges.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Actor must charge up its armaments before firing.")]
|
||||
public class AttackChargesInfo : AttackOmniInfo
|
||||
{
|
||||
[Desc("Amount of charge required to attack.")]
|
||||
public readonly int ChargeLevel = 25;
|
||||
|
||||
[Desc("Amount to increase the charge level each tick with a valid target.")]
|
||||
public readonly int ChargeRate = 1;
|
||||
|
||||
[Desc("Amount to decrease the charge level each tick without a valid target.")]
|
||||
public readonly int DischargeRate = 1;
|
||||
|
||||
[GrantedConditionReference]
|
||||
[Desc("The condition to grant to self while the charge level is greater than zero.")]
|
||||
public readonly string ChargingCondition = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AttackCharges(init.Self, this); }
|
||||
}
|
||||
|
||||
public class AttackCharges : AttackOmni, INotifyCreated, ITick, INotifyAttack, INotifySold
|
||||
{
|
||||
readonly AttackChargesInfo info;
|
||||
ConditionManager conditionManager;
|
||||
int chargingToken = ConditionManager.InvalidConditionToken;
|
||||
bool charging;
|
||||
|
||||
public int ChargeLevel { get; private set; }
|
||||
|
||||
public AttackCharges(Actor self, AttackChargesInfo info)
|
||||
: base(self, info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
{
|
||||
// Stop charging when we lose our target
|
||||
charging &= self.CurrentActivity is SetTarget;
|
||||
|
||||
var delta = charging ? info.ChargeRate : -info.DischargeRate;
|
||||
ChargeLevel = (ChargeLevel + delta).Clamp(0, info.ChargeLevel);
|
||||
|
||||
if (ChargeLevel > 0 && conditionManager != null && !string.IsNullOrEmpty(info.ChargingCondition)
|
||||
&& chargingToken == ConditionManager.InvalidConditionToken)
|
||||
chargingToken = conditionManager.GrantCondition(self, info.ChargingCondition);
|
||||
|
||||
if (ChargeLevel == 0 && conditionManager != null && chargingToken != ConditionManager.InvalidConditionToken)
|
||||
chargingToken = conditionManager.RevokeCondition(self, chargingToken);
|
||||
}
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
{
|
||||
charging = base.CanAttack(self, target) && IsReachableTarget(target, true);
|
||||
return ChargeLevel >= info.ChargeLevel && charging;
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel) { ChargeLevel = 0; }
|
||||
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
|
||||
void INotifySold.Selling(Actor self) { ChargeLevel = 0; }
|
||||
void INotifySold.Sold(Actor self) { }
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,12 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
class AttackOmniInfo : AttackBaseInfo
|
||||
public class AttackOmniInfo : AttackBaseInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new AttackOmni(init.Self, this); }
|
||||
}
|
||||
|
||||
class AttackOmni : AttackBase
|
||||
public class AttackOmni : AttackBase
|
||||
{
|
||||
public AttackOmni(Actor self, AttackOmniInfo info)
|
||||
: base(self, info) { }
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return new SetTarget(this, newTarget);
|
||||
}
|
||||
|
||||
class SetTarget : Activity
|
||||
protected class SetTarget : Activity
|
||||
{
|
||||
readonly Target target;
|
||||
readonly AttackOmni attack;
|
||||
|
||||
@@ -13,29 +13,34 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("This actor displays a charge-up animation before firing.")]
|
||||
public class WithChargeAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<RenderSpritesInfo>
|
||||
[Desc("Render trait that varies the animation frame based on the AttackCharges trait's charge level.")]
|
||||
class WithChargeAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<AttackChargesInfo>
|
||||
{
|
||||
[Desc("Sequence to use for charge animation.")]
|
||||
[SequenceReference] public readonly string ChargeSequence = "active";
|
||||
[SequenceReference]
|
||||
[Desc("Sequence to use for the charge levels.")]
|
||||
public readonly string Sequence = "active";
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithChargeAnimation(init, this); }
|
||||
public object Create(ActorInitializer init) { return new WithChargeAnimation(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithChargeAnimation : INotifyCharging
|
||||
class WithChargeAnimation : INotifyBuildComplete
|
||||
{
|
||||
readonly WithChargeAnimationInfo info;
|
||||
readonly WithSpriteBody wsb;
|
||||
readonly AttackCharges attackCharges;
|
||||
|
||||
public WithChargeAnimation(ActorInitializer init, WithChargeAnimationInfo info)
|
||||
public WithChargeAnimation(Actor self, WithChargeAnimationInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
wsb = init.Self.Trait<WithSpriteBody>();
|
||||
wsb = self.Trait<WithSpriteBody>();
|
||||
attackCharges = self.Trait<AttackCharges>();
|
||||
}
|
||||
|
||||
public void Charging(Actor self, Target target)
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||
{
|
||||
wsb.PlayCustomAnimation(self, info.ChargeSequence, () => wsb.CancelCustomAnimation(self));
|
||||
var attackChargesInfo = (AttackChargesInfo)attackCharges.Info;
|
||||
wsb.DefaultAnimation.PlayFetchIndex(wsb.NormalizeSequence(self, info.Sequence),
|
||||
() => int2.Lerp(0, wsb.DefaultAnimation.CurrentSequence.Length, attackCharges.ChargeLevel, attackChargesInfo.ChargeLevel + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Rendered together with AttackCharge.")]
|
||||
public class WithChargeOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
[Desc("Render overlay that varies the animation frame based on the AttackCharges trait's charge level.")]
|
||||
class WithChargeOverlayInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
[SequenceReference]
|
||||
[Desc("Sequence to use for the charge levels.")]
|
||||
public readonly string Sequence = "active";
|
||||
|
||||
[Desc("Custom palette name")]
|
||||
[PaletteReference("IsPlayerPalette")] public readonly string Palette = null;
|
||||
@@ -26,33 +27,38 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
[Desc("Custom palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithChargeOverlay(init, this); }
|
||||
public object Create(ActorInitializer init) { return new WithChargeOverlay(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithChargeOverlay : INotifyCharging, INotifyDamageStateChanged, INotifySold
|
||||
class WithChargeOverlay : INotifyBuildComplete, INotifySold, INotifyDamageStateChanged
|
||||
{
|
||||
readonly Animation overlay;
|
||||
readonly RenderSprites renderSprites;
|
||||
readonly WithChargeOverlayInfo info;
|
||||
readonly Animation overlay;
|
||||
readonly RenderSprites rs;
|
||||
readonly WithSpriteBody wsb;
|
||||
|
||||
bool charging;
|
||||
bool buildComplete;
|
||||
|
||||
public WithChargeOverlay(ActorInitializer init, WithChargeOverlayInfo info)
|
||||
public WithChargeOverlay(Actor self, WithChargeOverlayInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
rs = self.Trait<RenderSprites>();
|
||||
wsb = self.Trait<WithSpriteBody>();
|
||||
|
||||
renderSprites = init.Self.Trait<RenderSprites>();
|
||||
var attackCharges = self.Trait<AttackCharges>();
|
||||
var attackChargesInfo = (AttackChargesInfo)attackCharges.Info;
|
||||
|
||||
overlay = new Animation(init.World, renderSprites.GetImage(init.Self));
|
||||
overlay = new Animation(self.World, rs.GetImage(self));
|
||||
overlay.PlayFetchIndex(wsb.NormalizeSequence(self, info.Sequence),
|
||||
() => int2.Lerp(0, overlay.CurrentSequence.Length, attackCharges.ChargeLevel, attackChargesInfo.ChargeLevel + 1));
|
||||
|
||||
renderSprites.Add(new AnimationWithOffset(overlay, null, () => !charging),
|
||||
rs.Add(new AnimationWithOffset(overlay, null, () => !buildComplete, 1024),
|
||||
info.Palette, info.IsPlayerPalette);
|
||||
}
|
||||
|
||||
void INotifyCharging.Charging(Actor self, Target target)
|
||||
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||
{
|
||||
charging = true;
|
||||
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false);
|
||||
buildComplete = true;
|
||||
}
|
||||
|
||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||
@@ -60,10 +66,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence));
|
||||
}
|
||||
|
||||
void INotifySold.Selling(Actor self) { buildComplete = false; }
|
||||
void INotifySold.Sold(Actor self) { }
|
||||
void INotifySold.Selling(Actor self)
|
||||
{
|
||||
charging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Sound
|
||||
@@ -33,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
class AmbientSound : ConditionalTrait<AmbientSoundInfo>, ITick, INotifyRemovedFromWorld
|
||||
{
|
||||
readonly bool loop;
|
||||
ISound currentSound;
|
||||
HashSet<ISound> currentSounds = new HashSet<ISound>();
|
||||
WPos cachedPosition;
|
||||
int delay;
|
||||
|
||||
@@ -49,10 +50,14 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
|
||||
currentSounds.RemoveWhere(s => s == null || !s.Playing);
|
||||
|
||||
var pos = self.CenterPosition;
|
||||
if (currentSound != null && pos != cachedPosition)
|
||||
if (pos != cachedPosition)
|
||||
{
|
||||
currentSound.SetPosition(pos);
|
||||
foreach (var s in currentSounds)
|
||||
s.SetPosition(pos);
|
||||
|
||||
cachedPosition = pos;
|
||||
}
|
||||
|
||||
@@ -69,24 +74,26 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
|
||||
void StartSound(Actor self)
|
||||
{
|
||||
ISound s;
|
||||
if (self.OccupiesSpace != null)
|
||||
{
|
||||
cachedPosition = self.CenterPosition;
|
||||
currentSound = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile, cachedPosition) :
|
||||
s = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile, cachedPosition) :
|
||||
Game.Sound.Play(SoundType.World, Info.SoundFile, self.CenterPosition);
|
||||
}
|
||||
else
|
||||
currentSound = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile) :
|
||||
s = loop ? Game.Sound.PlayLooped(SoundType.World, Info.SoundFile) :
|
||||
Game.Sound.Play(SoundType.World, Info.SoundFile);
|
||||
|
||||
currentSounds.Add(s);
|
||||
}
|
||||
|
||||
void StopSound()
|
||||
{
|
||||
if (currentSound == null)
|
||||
return;
|
||||
foreach (var s in currentSounds)
|
||||
Game.Sound.StopSound(s);
|
||||
|
||||
Game.Sound.StopSound(currentSound);
|
||||
currentSound = null;
|
||||
currentSounds.Clear();
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self) { delay = Util.RandomDelay(self.World, Info.Delay); }
|
||||
|
||||
@@ -81,7 +81,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
||||
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
|
||||
public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
|
||||
public interface INotifyCharging { void Charging(Actor self, Target target); }
|
||||
public interface INotifyChat { bool OnChat(string from, string message); }
|
||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
||||
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced); }
|
||||
|
||||
@@ -779,7 +779,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
// Rename UpgradeOverlay to WithColoredOverlay
|
||||
if (engineVersion < 20170201)
|
||||
if (node.Key.StartsWith("UpgradeOverlay", StringComparison.Ordinal))
|
||||
RenameNodeKey(node, "WithColoredOverlay" + node.Key.Substring(14));
|
||||
RenameNodeKey(node, "WithColoredOverlay");
|
||||
|
||||
// Remove SpiceBloom.RespawnDelay to get rid of DelayedAction, and rename GrowthDelay to Lifetime
|
||||
if (engineVersion < 20170203)
|
||||
@@ -818,6 +818,18 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
}
|
||||
|
||||
if (engineVersion < 20170210)
|
||||
{
|
||||
if (node.Key.StartsWith("AttackCharge", StringComparison.Ordinal))
|
||||
RenameNodeKey(node, "AttackTesla");
|
||||
|
||||
if (node.Key.StartsWith("WithChargeOverlay", StringComparison.Ordinal))
|
||||
RenameNodeKey(node, "WithTeslaChargeOverlay");
|
||||
|
||||
if (node.Key.StartsWith("WithChargeAnimation", StringComparison.Ordinal))
|
||||
RenameNodeKey(node, "WithTeslaChargeAnimation");
|
||||
}
|
||||
|
||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -762,11 +762,13 @@ OBLI:
|
||||
Armament:
|
||||
Weapon: Laser
|
||||
LocalOffset: 0,-85,1280
|
||||
FireDelay: 0
|
||||
AttackCharge:
|
||||
ChargeAudio: obelpowr.aud
|
||||
ReloadDelay: 40
|
||||
InitialChargeDelay: 50
|
||||
AttackCharges:
|
||||
ChargeLevel: 50
|
||||
ChargingCondition: charging
|
||||
AmbientSound:
|
||||
RequiresCondition: charging
|
||||
SoundFile: obelpowr.aud
|
||||
Interval: 30, 40
|
||||
-EmitInfantryOnSell:
|
||||
DetectCloaked:
|
||||
Range: 5c0
|
||||
|
||||
@@ -80,7 +80,7 @@ Napalm:
|
||||
Explosions: med_napalm
|
||||
|
||||
Laser:
|
||||
ReloadDelay: 1
|
||||
ReloadDelay: 40
|
||||
Range: 7c512
|
||||
Report: obelray1.aud
|
||||
Projectile: LaserZap
|
||||
|
||||
@@ -436,11 +436,11 @@ TSLA:
|
||||
Range: 6c0
|
||||
Bib:
|
||||
HasMinibib: Yes
|
||||
WithChargeAnimation:
|
||||
WithTeslaChargeAnimation:
|
||||
Armament:
|
||||
Weapon: TeslaZap
|
||||
LocalOffset: 0,0,896
|
||||
AttackCharge:
|
||||
AttackTesla:
|
||||
ChargeAudio: tslachg2.aud
|
||||
MaxCharges: 3
|
||||
ReloadDelay: 120
|
||||
|
||||
@@ -108,11 +108,14 @@ NAOBEL:
|
||||
Armament:
|
||||
Weapon: ObeliskLaserFire
|
||||
LocalOffset: 1400,210,800
|
||||
AttackCharge:
|
||||
ChargeAudio: obelpowr.aud
|
||||
InitialChargeDelay: 65
|
||||
AttackCharges:
|
||||
ChargeLevel: 65
|
||||
ChargingCondition: charging
|
||||
AmbientSound:
|
||||
RequiresCondition: charging
|
||||
SoundFile: obelpowr.aud
|
||||
Interval: 30, 40
|
||||
WithChargeOverlay:
|
||||
Sequence: active
|
||||
Palette: player
|
||||
IsPlayerPalette: true
|
||||
WithIdleOverlay@LIGHTS:
|
||||
|
||||
@@ -180,7 +180,7 @@ Proton:
|
||||
|
||||
ObeliskLaserFire:
|
||||
Inherits: ^Laser
|
||||
ReloadDelay: 1
|
||||
ReloadDelay: 120
|
||||
Range: 10c512
|
||||
Report: obelray1.aud
|
||||
Warhead@1Dam: SpreadDamage
|
||||
|
||||
Reference in New Issue
Block a user