Merge pull request #6503 from huwpascoe/turretalign
Turrets now realign by default
This commit is contained in:
@@ -265,7 +265,8 @@ namespace OpenRA
|
|||||||
Uid = ComputeHash();
|
Uid = ComputeHash();
|
||||||
|
|
||||||
if (Container.Exists("map.png"))
|
if (Container.Exists("map.png"))
|
||||||
CustomPreview = new Bitmap(Container.GetContent("map.png"));
|
using (var dataStream = Container.GetContent("map.png"))
|
||||||
|
CustomPreview = new Bitmap(dataStream);
|
||||||
|
|
||||||
PostInit();
|
PostInit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -645,6 +645,15 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (engineVersion < 20141002)
|
||||||
|
{
|
||||||
|
if (node.Key == "AlignWhenIdle" && parentKey == "Turreted")
|
||||||
|
{
|
||||||
|
node.Key = "RealignDelay";
|
||||||
|
node.Value.Value = "0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
@@ -18,7 +19,9 @@ namespace OpenRA.Mods.RA
|
|||||||
[Desc("Rate of Turning")]
|
[Desc("Rate of Turning")]
|
||||||
public readonly int ROT = 255;
|
public readonly int ROT = 255;
|
||||||
public readonly int InitialFacing = 128;
|
public readonly int InitialFacing = 128;
|
||||||
public readonly bool AlignWhenIdle = false;
|
|
||||||
|
[Desc("Number of ticks before turret is realigned. (-1 turns off realignment)")]
|
||||||
|
public readonly int RealignDelay = 40;
|
||||||
|
|
||||||
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
||||||
public readonly WVec Offset = WVec.Zero;
|
public readonly WVec Offset = WVec.Zero;
|
||||||
@@ -26,13 +29,15 @@ namespace OpenRA.Mods.RA
|
|||||||
public virtual object Create(ActorInitializer init) { return new Turreted(init, this); }
|
public virtual object Create(ActorInitializer init) { return new Turreted(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Turreted : ITick, ISync, IResolveOrder
|
public class Turreted : ITick, ISync
|
||||||
{
|
{
|
||||||
[Sync] public int QuantizedFacings = 0;
|
[Sync] public int QuantizedFacings = 0;
|
||||||
[Sync] public int turretFacing = 0;
|
[Sync] public int turretFacing = 0;
|
||||||
public int? desiredFacing;
|
public int? desiredFacing;
|
||||||
TurretedInfo info;
|
TurretedInfo info;
|
||||||
IFacing facing;
|
IFacing facing;
|
||||||
|
Lazy<AttackTurreted> attack;
|
||||||
|
int realignTick = 0;
|
||||||
|
|
||||||
// For subclasses that want to move the turret relative to the body
|
// For subclasses that want to move the turret relative to the body
|
||||||
protected WVec LocalOffset = WVec.Zero;
|
protected WVec LocalOffset = WVec.Zero;
|
||||||
@@ -56,10 +61,21 @@ namespace OpenRA.Mods.RA
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
turretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
turretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
||||||
facing = init.self.TraitOrDefault<IFacing>();
|
facing = init.self.TraitOrDefault<IFacing>();
|
||||||
|
attack = Exts.Lazy(() => init.self.TraitOrDefault<AttackTurreted>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Tick(Actor self)
|
public virtual void Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (attack.Value != null && !attack.Value.IsAttacking)
|
||||||
|
{
|
||||||
|
if (realignTick < info.RealignDelay)
|
||||||
|
realignTick++;
|
||||||
|
else if (info.RealignDelay > -1)
|
||||||
|
desiredFacing = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
realignTick = 0;
|
||||||
|
|
||||||
var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing );
|
var df = desiredFacing ?? ( facing != null ? facing.Facing : turretFacing );
|
||||||
turretFacing = Util.TickFacing(turretFacing, df, info.ROT);
|
turretFacing = Util.TickFacing(turretFacing, df, info.ROT);
|
||||||
}
|
}
|
||||||
@@ -70,12 +86,6 @@ namespace OpenRA.Mods.RA
|
|||||||
return turretFacing == desiredFacing;
|
return turretFacing == desiredFacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ResolveOrder(Actor self, Order order)
|
|
||||||
{
|
|
||||||
if (info.AlignWhenIdle && order.OrderString != "Attack")
|
|
||||||
desiredFacing = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turret offset in world-space
|
// Turret offset in world-space
|
||||||
public WVec Position(Actor self)
|
public WVec Position(Actor self)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ MLRS:
|
|||||||
Turreted:
|
Turreted:
|
||||||
ROT: 8
|
ROT: 8
|
||||||
Offset: -128,0,128
|
Offset: -128,0,128
|
||||||
AlignWhenIdle: true
|
RealignDelay: 0
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: Patriot
|
Weapon: Patriot
|
||||||
LocalOffset: 0,-171,0, 0,171,0
|
LocalOffset: 0,-171,0, 0,171,0
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ QUAD.starport:
|
|||||||
Range: 7c0
|
Range: 7c0
|
||||||
Turreted:
|
Turreted:
|
||||||
ROT: 6
|
ROT: 6
|
||||||
AlignWhenIdle: true
|
RealignDelay: 0
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: 90mm
|
Weapon: 90mm
|
||||||
Recoil: 128
|
Recoil: 128
|
||||||
|
|||||||
Reference in New Issue
Block a user