Rename tesla attack logic and move to Mods.Cnc.
This commit is contained in:
@@ -90,6 +90,10 @@
|
|||||||
<Compile Include="UtilityCommands\LegacyRulesImporter.cs" />
|
<Compile Include="UtilityCommands\LegacyRulesImporter.cs" />
|
||||||
<Compile Include="UtilityCommands\LegacySequenceImporter.cs" />
|
<Compile Include="UtilityCommands\LegacySequenceImporter.cs" />
|
||||||
<Compile Include="Widgets\Logic\PreReleaseWarningPrompt.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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||||
|
|||||||
@@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Cnc.Traits
|
||||||
{
|
{
|
||||||
[Desc("Charges up before being able to attack.")]
|
[Desc("Implements the charge-then-burst attack logic specific to the RA tesla coil.")]
|
||||||
class AttackChargeInfo : AttackOmniInfo
|
class AttackTeslaInfo : AttackOmniInfo
|
||||||
{
|
{
|
||||||
[Desc("How many charges this actor has to attack with, once charged.")]
|
[Desc("How many charges this actor has to attack with, once charged.")]
|
||||||
public readonly int MaxCharges = 1;
|
public readonly int MaxCharges = 1;
|
||||||
@@ -33,17 +34,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Sound to play when actor charges.")]
|
[Desc("Sound to play when actor charges.")]
|
||||||
public readonly string ChargeAudio = null;
|
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 charges;
|
||||||
[Sync] int timeToRecharge;
|
[Sync] int timeToRecharge;
|
||||||
|
|
||||||
public AttackCharge(Actor self, AttackChargeInfo info)
|
public AttackTesla(Actor self, AttackTeslaInfo info)
|
||||||
: base(self, info)
|
: base(self, info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
@@ -79,10 +80,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
class ChargeAttack : Activity
|
class ChargeAttack : Activity
|
||||||
{
|
{
|
||||||
readonly AttackCharge attack;
|
readonly AttackTesla attack;
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
|
|
||||||
public ChargeAttack(AttackCharge attack, Target target)
|
public ChargeAttack(AttackTesla attack, Target target)
|
||||||
{
|
{
|
||||||
this.attack = attack;
|
this.attack = attack;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
@@ -96,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (attack.charges == 0)
|
if (attack.charges == 0)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
foreach (var notify in self.TraitsImplementing<INotifyCharging>())
|
foreach (var notify in self.TraitsImplementing<INotifyTeslaCharging>())
|
||||||
notify.Charging(self, target);
|
notify.Charging(self, target);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
|
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
|
||||||
@@ -108,10 +109,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
class ChargeFire : Activity
|
class ChargeFire : Activity
|
||||||
{
|
{
|
||||||
readonly AttackCharge attack;
|
readonly AttackTesla attack;
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
|
|
||||||
public ChargeFire(AttackCharge attack, Target target)
|
public ChargeFire(AttackTesla attack, Target target)
|
||||||
{
|
{
|
||||||
this.attack = attack;
|
this.attack = attack;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
@@ -9,31 +9,32 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Mods.Common.Traits.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits.Render
|
namespace OpenRA.Mods.Cnc.Traits.Render
|
||||||
{
|
{
|
||||||
[Desc("This actor displays a charge-up animation before firing.")]
|
[Desc("This actor displays a charge-up animation before firing.")]
|
||||||
public class WithChargeAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<RenderSpritesInfo>
|
public class WithTeslaChargeAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<RenderSpritesInfo>
|
||||||
{
|
{
|
||||||
[Desc("Sequence to use for charge animation.")]
|
[Desc("Sequence to use for charge animation.")]
|
||||||
[SequenceReference] public readonly string ChargeSequence = "active";
|
[SequenceReference] public readonly string ChargeSequence = "active";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithChargeAnimation(init, this); }
|
public object Create(ActorInitializer init) { return new WithTeslaChargeAnimation(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithChargeAnimation : INotifyCharging
|
public class WithTeslaChargeAnimation : INotifyTeslaCharging
|
||||||
{
|
{
|
||||||
readonly WithChargeAnimationInfo info;
|
readonly WithTeslaChargeAnimationInfo info;
|
||||||
readonly WithSpriteBody wsb;
|
readonly WithSpriteBody wsb;
|
||||||
|
|
||||||
public WithChargeAnimation(ActorInitializer init, WithChargeAnimationInfo info)
|
public WithTeslaChargeAnimation(ActorInitializer init, WithTeslaChargeAnimationInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
wsb = init.Self.Trait<WithSpriteBody>();
|
wsb = init.Self.Trait<WithSpriteBody>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Charging(Actor self, Target target)
|
void INotifyTeslaCharging.Charging(Actor self, Target target)
|
||||||
{
|
{
|
||||||
wsb.PlayCustomAnimation(self, info.ChargeSequence, () => wsb.CancelCustomAnimation(self));
|
wsb.PlayCustomAnimation(self, info.ChargeSequence, () => wsb.CancelCustomAnimation(self));
|
||||||
}
|
}
|
||||||
@@ -10,12 +10,14 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Mods.Common.Traits.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits.Render
|
namespace OpenRA.Mods.Cnc.Traits.Render
|
||||||
{
|
{
|
||||||
[Desc("Rendered together with AttackCharge.")]
|
[Desc("Rendered together with AttackCharge.")]
|
||||||
public class WithChargeOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
public class WithTeslaChargeOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||||
{
|
{
|
||||||
[Desc("Sequence name to use")]
|
[Desc("Sequence name to use")]
|
||||||
[SequenceReference] public readonly string Sequence = "active";
|
[SequenceReference] public readonly string Sequence = "active";
|
||||||
@@ -26,18 +28,18 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
[Desc("Custom palette is a player palette BaseName")]
|
[Desc("Custom palette is a player palette BaseName")]
|
||||||
public readonly bool IsPlayerPalette = false;
|
public readonly bool IsPlayerPalette = false;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new WithChargeOverlay(init, this); }
|
public object Create(ActorInitializer init) { return new WithTeslaChargeOverlay(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithChargeOverlay : INotifyCharging, INotifyDamageStateChanged, INotifySold
|
public class WithTeslaChargeOverlay : INotifyTeslaCharging, INotifyDamageStateChanged, INotifySold
|
||||||
{
|
{
|
||||||
readonly Animation overlay;
|
readonly Animation overlay;
|
||||||
readonly RenderSprites renderSprites;
|
readonly RenderSprites renderSprites;
|
||||||
readonly WithChargeOverlayInfo info;
|
readonly WithTeslaChargeOverlayInfo info;
|
||||||
|
|
||||||
bool charging;
|
bool charging;
|
||||||
|
|
||||||
public WithChargeOverlay(ActorInitializer init, WithChargeOverlayInfo info)
|
public WithTeslaChargeOverlay(ActorInitializer init, WithTeslaChargeOverlayInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
info.Palette, info.IsPlayerPalette);
|
info.Palette, info.IsPlayerPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyCharging.Charging(Actor self, Target target)
|
void INotifyTeslaCharging.Charging(Actor self, Target target)
|
||||||
{
|
{
|
||||||
charging = true;
|
charging = true;
|
||||||
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false);
|
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => 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\Armor.cs" />
|
||||||
<Compile Include="Traits\AttackMove.cs" />
|
<Compile Include="Traits\AttackMove.cs" />
|
||||||
<Compile Include="Traits\Attack\AttackBase.cs" />
|
<Compile Include="Traits\Attack\AttackBase.cs" />
|
||||||
<Compile Include="Traits\Attack\AttackCharge.cs" />
|
|
||||||
<Compile Include="Traits\Attack\AttackFollow.cs" />
|
<Compile Include="Traits\Attack\AttackFollow.cs" />
|
||||||
<Compile Include="Traits\Attack\AttackFrontal.cs" />
|
<Compile Include="Traits\Attack\AttackFrontal.cs" />
|
||||||
<Compile Include="Traits\Attack\AttackGarrisoned.cs" />
|
<Compile Include="Traits\Attack\AttackGarrisoned.cs" />
|
||||||
@@ -431,8 +430,6 @@
|
|||||||
<Compile Include="Traits\Render\WithSiloAnimation.cs" />
|
<Compile Include="Traits\Render\WithSiloAnimation.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\WithChargeAnimation.cs" />
|
|
||||||
<Compile Include="Traits\Render\WithChargeOverlay.cs" />
|
|
||||||
<Compile Include="Traits\Render\WithCrateBody.cs" />
|
<Compile Include="Traits\Render\WithCrateBody.cs" />
|
||||||
<Compile Include="Traits\Render\WithDamageOverlay.cs" />
|
<Compile Include="Traits\Render\WithDamageOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithDeathAnimation.cs" />
|
<Compile Include="Traits\Render\WithDeathAnimation.cs" />
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.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); }
|
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)
|
public AttackOmni(Actor self, AttackOmniInfo info)
|
||||||
: base(self, info) { }
|
: base(self, info) { }
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
||||||
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
|
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
|
||||||
public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
|
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 INotifyChat { bool OnChat(string from, string message); }
|
||||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
||||||
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced); }
|
public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced); }
|
||||||
|
|||||||
@@ -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);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -758,12 +758,12 @@ OBLI:
|
|||||||
Range: 8c0
|
Range: 8c0
|
||||||
Bib:
|
Bib:
|
||||||
HasMinibib: Yes
|
HasMinibib: Yes
|
||||||
WithChargeAnimation:
|
WithTeslaChargeAnimation:
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: Laser
|
Weapon: Laser
|
||||||
LocalOffset: 0,-85,1280
|
LocalOffset: 0,-85,1280
|
||||||
FireDelay: 0
|
FireDelay: 0
|
||||||
AttackCharge:
|
AttackTesla:
|
||||||
ChargeAudio: obelpowr.aud
|
ChargeAudio: obelpowr.aud
|
||||||
ReloadDelay: 40
|
ReloadDelay: 40
|
||||||
InitialChargeDelay: 50
|
InitialChargeDelay: 50
|
||||||
|
|||||||
@@ -436,11 +436,11 @@ TSLA:
|
|||||||
Range: 6c0
|
Range: 6c0
|
||||||
Bib:
|
Bib:
|
||||||
HasMinibib: Yes
|
HasMinibib: Yes
|
||||||
WithChargeAnimation:
|
WithTeslaChargeAnimation:
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: TeslaZap
|
Weapon: TeslaZap
|
||||||
LocalOffset: 0,0,896
|
LocalOffset: 0,0,896
|
||||||
AttackCharge:
|
AttackTesla:
|
||||||
ChargeAudio: tslachg2.aud
|
ChargeAudio: tslachg2.aud
|
||||||
MaxCharges: 3
|
MaxCharges: 3
|
||||||
ReloadDelay: 120
|
ReloadDelay: 120
|
||||||
|
|||||||
@@ -108,10 +108,10 @@ NAOBEL:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: ObeliskLaserFire
|
Weapon: ObeliskLaserFire
|
||||||
LocalOffset: 1400,210,800
|
LocalOffset: 1400,210,800
|
||||||
AttackCharge:
|
AttackTesla:
|
||||||
ChargeAudio: obelpowr.aud
|
ChargeAudio: obelpowr.aud
|
||||||
InitialChargeDelay: 65
|
InitialChargeDelay: 65
|
||||||
WithChargeOverlay:
|
WithTeslaChargeOverlay:
|
||||||
Sequence: active
|
Sequence: active
|
||||||
Palette: player
|
Palette: player
|
||||||
IsPlayerPalette: true
|
IsPlayerPalette: true
|
||||||
|
|||||||
Reference in New Issue
Block a user