Merge pull request #8814 from reaperrr/ssm-tur
Implement ammo-dependent turret art for TD Mobile SAM
This commit is contained in:
@@ -84,6 +84,7 @@
|
|||||||
<Compile Include="Traits\Render\WithGunboatBody.cs" />
|
<Compile Include="Traits\Render\WithGunboatBody.cs" />
|
||||||
<Compile Include="Traits\Render\WithCargo.cs" />
|
<Compile Include="Traits\Render\WithCargo.cs" />
|
||||||
<Compile Include="Traits\Render\WithDeliveryAnimation.cs" />
|
<Compile Include="Traits\Render\WithDeliveryAnimation.cs" />
|
||||||
|
<Compile Include="Traits\Render\WithReloadingTurret.cs" />
|
||||||
<Compile Include="Traits\Render\WithRoof.cs" />
|
<Compile Include="Traits\Render\WithRoof.cs" />
|
||||||
<Compile Include="Traits\SpawnViceroid.cs" />
|
<Compile Include="Traits\SpawnViceroid.cs" />
|
||||||
<Compile Include="Traits\SupportPowers\IonCannonPower.cs" />
|
<Compile Include="Traits\SupportPowers\IonCannonPower.cs" />
|
||||||
|
|||||||
76
OpenRA.Mods.Cnc/Traits/Render/WithReloadingTurret.cs
Normal file
76
OpenRA.Mods.Cnc/Traits/Render/WithReloadingTurret.cs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
#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 System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Cnc.Traits
|
||||||
|
{
|
||||||
|
[Desc("Renders ammo-dependent turret graphics for units with the Turreted trait.")]
|
||||||
|
public class WithReloadingTurretInfo : WithTurretInfo, Requires<AmmoPoolInfo>, Requires<ArmamentInfo>
|
||||||
|
{
|
||||||
|
[Desc("AmmoPool to use for ammo-dependent sequences.")]
|
||||||
|
public readonly string AmmoPoolName = null;
|
||||||
|
|
||||||
|
[Desc("How many reload stages does this turret have. Defaults to AmmoPool's Ammo.",
|
||||||
|
"Adds current reload stage to Sequence as suffix when a matching AmmoPool is present.")]
|
||||||
|
public readonly int ReloadStages = -1;
|
||||||
|
|
||||||
|
public override object Create(ActorInitializer init) { return new WithReloadingTurret(init.Self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithReloadingTurret : WithTurret
|
||||||
|
{
|
||||||
|
readonly int reloadStages;
|
||||||
|
readonly AmmoPool ammoPool;
|
||||||
|
string sequence;
|
||||||
|
string ammoSuffix;
|
||||||
|
|
||||||
|
public WithReloadingTurret(Actor self, WithReloadingTurretInfo info)
|
||||||
|
: base(self, info)
|
||||||
|
{
|
||||||
|
ammoPool = self.TraitsImplementing<AmmoPool>().FirstOrDefault(a => a.Info.Name == info.AmmoPoolName);
|
||||||
|
if (ammoPool == null)
|
||||||
|
throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a valid ammo pool for its reloading turret.");
|
||||||
|
|
||||||
|
sequence = Info.Sequence;
|
||||||
|
reloadStages = info.ReloadStages;
|
||||||
|
|
||||||
|
var initialAmmo = ammoPool.Info.InitialAmmo;
|
||||||
|
var ammo = ammoPool.Info.Ammo;
|
||||||
|
var initialAmmoStage = initialAmmo >= 0 && initialAmmo != ammo ? initialAmmo : ammo;
|
||||||
|
|
||||||
|
if (ammoPool != null && reloadStages < 0)
|
||||||
|
ammoSuffix = initialAmmoStage.ToString();
|
||||||
|
if (ammoPool != null && reloadStages >= 0)
|
||||||
|
ammoSuffix = (initialAmmoStage * reloadStages / ammo).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick(Actor self)
|
||||||
|
{
|
||||||
|
if (Info.AimSequence != null)
|
||||||
|
sequence = Attack.IsAttacking ? Info.AimSequence : Info.Sequence;
|
||||||
|
|
||||||
|
var currentAmmo = ammoPool.GetAmmoCount();
|
||||||
|
if (reloadStages < 0)
|
||||||
|
ammoSuffix = currentAmmo.ToString();
|
||||||
|
if (reloadStages >= 0)
|
||||||
|
ammoSuffix = (currentAmmo * reloadStages / ammoPool.Info.Ammo).ToString();
|
||||||
|
|
||||||
|
var newSequence = NormalizeSequence(self, sequence + ammoSuffix);
|
||||||
|
if (DefaultAnimation.CurrentSequence.Name != newSequence)
|
||||||
|
DefaultAnimation.ReplaceAnim(newSequence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,20 +58,19 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public class WithTurret : UpgradableTrait<WithTurretInfo>, ITick, INotifyDamageStateChanged
|
public class WithTurret : UpgradableTrait<WithTurretInfo>, ITick, INotifyDamageStateChanged
|
||||||
{
|
{
|
||||||
|
public readonly Animation DefaultAnimation;
|
||||||
|
protected readonly AttackBase Attack;
|
||||||
readonly RenderSprites rs;
|
readonly RenderSprites rs;
|
||||||
readonly IBodyOrientation body;
|
readonly IBodyOrientation body;
|
||||||
readonly AttackBase ab;
|
|
||||||
readonly Turreted t;
|
readonly Turreted t;
|
||||||
readonly Armament[] arms;
|
readonly Armament[] arms;
|
||||||
public readonly Animation DefaultAnimation;
|
|
||||||
|
|
||||||
public WithTurret(Actor self, WithTurretInfo info)
|
public WithTurret(Actor self, WithTurretInfo info)
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
rs = self.Trait<RenderSprites>();
|
rs = self.Trait<RenderSprites>();
|
||||||
body = self.Trait<IBodyOrientation>();
|
body = self.Trait<IBodyOrientation>();
|
||||||
|
Attack = self.TraitOrDefault<AttackBase>();
|
||||||
ab = self.TraitOrDefault<AttackBase>();
|
|
||||||
t = self.TraitsImplementing<Turreted>()
|
t = self.TraitsImplementing<Turreted>()
|
||||||
.First(tt => tt.Name == info.Turret);
|
.First(tt => tt.Name == info.Turret);
|
||||||
arms = self.TraitsImplementing<Armament>()
|
arms = self.TraitsImplementing<Armament>()
|
||||||
@@ -109,12 +108,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name));
|
DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public virtual void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (Info.AimSequence == null)
|
if (Info.AimSequence == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var sequence = ab.IsAttacking ? Info.AimSequence : Info.Sequence;
|
var sequence = Attack.IsAttacking ? Info.AimSequence : Info.Sequence;
|
||||||
DefaultAnimation.ReplaceAnim(sequence);
|
DefaultAnimation.ReplaceAnim(sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -477,9 +477,15 @@ MLRS:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: Patriot
|
Weapon: Patriot
|
||||||
LocalOffset: 0,-171,0, 0,171,0
|
LocalOffset: 0,-171,0, 0,171,0
|
||||||
|
AmmoPool:
|
||||||
|
Ammo: 2
|
||||||
|
PipCount: 0
|
||||||
|
SelfReloads: true
|
||||||
|
ReloadCount: 1
|
||||||
|
SelfReloadTicks: 100
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithTurret:
|
WithReloadingTurret:
|
||||||
AimSequence: aim
|
AmmoPoolName: primary
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
InitialStance: Defend
|
InitialStance: Defend
|
||||||
RenderRangeCircle:
|
RenderRangeCircle:
|
||||||
|
|||||||
@@ -215,10 +215,13 @@ mlrs:
|
|||||||
turret:
|
turret:
|
||||||
Start: 32
|
Start: 32
|
||||||
Facings: 32
|
Facings: 32
|
||||||
aim:
|
turret2:
|
||||||
Start: 32
|
Start: 32
|
||||||
Facings: 32
|
Facings: 32
|
||||||
empty-aim:
|
turret1:
|
||||||
|
Start: 64
|
||||||
|
Facings: 32
|
||||||
|
turret0:
|
||||||
Start: 96
|
Start: 96
|
||||||
Facings: 32
|
Facings: 32
|
||||||
icon: mlrsicnh.tem
|
icon: mlrsicnh.tem
|
||||||
|
|||||||
@@ -377,16 +377,12 @@ Patriot:
|
|||||||
RateOfTurn: 20
|
RateOfTurn: 20
|
||||||
Speed: 341
|
Speed: 341
|
||||||
RangeLimit: 30
|
RangeLimit: 30
|
||||||
Angle: 88
|
|
||||||
Warhead@1Dam: SpreadDamage
|
Warhead@1Dam: SpreadDamage
|
||||||
Spread: 682
|
Spread: 682
|
||||||
ValidTargets: Air
|
ValidTargets: Air
|
||||||
Versus:
|
Versus:
|
||||||
None: 100
|
|
||||||
Wood: 100
|
|
||||||
Light: 100
|
|
||||||
Heavy: 75
|
Heavy: 75
|
||||||
Damage: 32
|
Damage: 50
|
||||||
DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath
|
DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath
|
||||||
Warhead@2Smu: LeaveSmudge
|
Warhead@2Smu: LeaveSmudge
|
||||||
SmudgeType: Crater
|
SmudgeType: Crater
|
||||||
|
|||||||
Reference in New Issue
Block a user