Auto-detect offset coordinate type.
This commit is contained in:
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly float LegacyRecoilRecovery = 0.2f;
|
public readonly float LegacyRecoilRecovery = 0.2f;
|
||||||
public readonly int[] LegacyLocalOffset = { };
|
public readonly int[] LegacyLocalOffset = { };
|
||||||
|
|
||||||
public readonly CoordinateModel OffsetModel = CoordinateModel.Legacy;
|
public CoordinateModel OffsetModel = CoordinateModel.Legacy;
|
||||||
[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 WRange[] LocalOffset = {};
|
public readonly WRange[] LocalOffset = {};
|
||||||
[Desc("Muzzle yaw relative to turret or body.")]
|
[Desc("Muzzle yaw relative to turret or body.")]
|
||||||
@@ -57,7 +57,14 @@ namespace OpenRA.Mods.RA
|
|||||||
[Desc("Recoil recovery per-frame")]
|
[Desc("Recoil recovery per-frame")]
|
||||||
public readonly WRange RecoilRecovery = new WRange(9);
|
public readonly WRange RecoilRecovery = new WRange(9);
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Armament(init.self, this); }
|
public object Create(ActorInitializer init)
|
||||||
|
{
|
||||||
|
// Auto-detect coordinate type
|
||||||
|
if (LocalOffset.Length > 0 && OffsetModel == CoordinateModel.Legacy)
|
||||||
|
OffsetModel = CoordinateModel.World;
|
||||||
|
|
||||||
|
return new Armament(init.self, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Armament : ITick
|
public class Armament : ITick
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -25,11 +26,25 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int[] LegacyOffset = {0,0};
|
public readonly int[] LegacyOffset = {0,0};
|
||||||
public readonly bool AlignWhenIdle = false;
|
public readonly bool AlignWhenIdle = false;
|
||||||
|
|
||||||
public readonly CoordinateModel OffsetModel = CoordinateModel.Legacy;
|
public CoordinateModel OffsetModel = CoordinateModel.Legacy;
|
||||||
[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;
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init) { return new Turreted(init, this); }
|
|
||||||
|
bool HasWorldOffset(ArmamentInfo ai)
|
||||||
|
{
|
||||||
|
return ai.OffsetModel == CoordinateModel.World || ai.LocalOffset.Length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual object Create(ActorInitializer init)
|
||||||
|
{
|
||||||
|
// Auto-detect coordinate type
|
||||||
|
var arms = init.self.Info.Traits.WithInterface<ArmamentInfo>();
|
||||||
|
if (Offset != WVec.Zero || arms.Any(ai => HasWorldOffset(ai)))
|
||||||
|
OffsetModel = CoordinateModel.World;
|
||||||
|
|
||||||
|
return new Turreted(init, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Turreted : ITick, ISync, IResolveOrder
|
public class Turreted : ITick, ISync, IResolveOrder
|
||||||
|
|||||||
Reference in New Issue
Block a user