Applied VWec[] yaml loader
This commit is contained in:
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Cnc
|
||||
public class WithCargoInfo : ITraitInfo, Requires<CargoInfo>, Requires<IBodyOrientationInfo>
|
||||
{
|
||||
[Desc("Cargo position relative to turret or body. (forward, right, up) triples")]
|
||||
public readonly WRange[] LocalOffset = { };
|
||||
public readonly WVec[] LocalOffset = { };
|
||||
[Desc("Passenger CargoType to display.")]
|
||||
public readonly string[] DisplayTypes = { };
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace OpenRA.Mods.Cnc
|
||||
Cargo cargo;
|
||||
IFacing facing;
|
||||
WithCargoInfo cargoInfo;
|
||||
WVec[] positions;
|
||||
IBodyOrientation body;
|
||||
|
||||
public WithCargo(Actor self, WithCargoInfo info)
|
||||
@@ -44,12 +43,8 @@ namespace OpenRA.Mods.Cnc
|
||||
|
||||
body = self.Trait<IBodyOrientation>();
|
||||
|
||||
if (info.LocalOffset.Length % 3 != 0)
|
||||
throw new InvalidOperationException("Invalid LocalOffset array length");
|
||||
|
||||
positions = new WVec[info.LocalOffset.Length / 3];
|
||||
for (var i = 0; i < info.LocalOffset.Length / 3; i++)
|
||||
positions[i] = new WVec(info.LocalOffset[3 * i], info.LocalOffset[3 * i + 1], info.LocalOffset[3 * i + 2]);
|
||||
if (info.LocalOffset.Length == 0)
|
||||
throw new InvalidOperationException("LocalOffset must have at least one entry");
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
@@ -69,7 +64,7 @@ namespace OpenRA.Mods.Cnc
|
||||
var cargoPassenger = c.Trait<Passenger>();
|
||||
if (cargoInfo.DisplayTypes.Contains(cargoPassenger.info.CargoType))
|
||||
{
|
||||
var offset = pos - c.CenterPosition + body.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation));
|
||||
var offset = pos - c.CenterPosition + body.LocalToWorld(cargoInfo.LocalOffset[i++ % cargoInfo.LocalOffset.Length].Rotate(bodyOrientation));
|
||||
foreach (var cr in c.Render(wr))
|
||||
yield return cr.OffsetBy(offset).WithZOffset(1);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly int FireDelay = 0;
|
||||
|
||||
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
||||
public readonly WRange[] LocalOffset = {};
|
||||
public readonly WVec[] LocalOffset = {};
|
||||
[Desc("Muzzle yaw relative to turret or body.")]
|
||||
public readonly WAngle[] LocalYaw = {};
|
||||
[Desc("Move the turret backwards when firing.")]
|
||||
@@ -85,15 +85,12 @@ namespace OpenRA.Mods.RA
|
||||
Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
||||
Burst = Weapon.Burst;
|
||||
|
||||
if (info.LocalOffset.Length % 3 != 0)
|
||||
throw new InvalidOperationException("Invalid LocalOffset array length");
|
||||
|
||||
var barrels = new List<Barrel>();
|
||||
for (var i = 0; i < info.LocalOffset.Length / 3; i++)
|
||||
for (var i = 0; i < info.LocalOffset.Length; i++)
|
||||
{
|
||||
barrels.Add(new Barrel
|
||||
{
|
||||
Offset = new WVec(info.LocalOffset[3*i], info.LocalOffset[3*i + 1], info.LocalOffset[3*i + 2]),
|
||||
Offset = info.LocalOffset[i],
|
||||
Yaw = info.LocalYaw.Length > i ? info.LocalYaw[i] : WAngle.Zero
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
|
||||
public class AttackGarrisonedInfo : AttackFollowInfo, Requires<CargoInfo>
|
||||
{
|
||||
[Desc("Fire port offsets in local coordinates.")]
|
||||
public readonly WRange[] PortOffsets = {};
|
||||
public readonly WVec[] PortOffsets = {};
|
||||
|
||||
[Desc("Fire port yaw angles.")]
|
||||
public readonly WAngle[] PortYaws = {};
|
||||
@@ -68,21 +68,21 @@ namespace OpenRA.Mods.RA
|
||||
GetArmaments = () => armaments;
|
||||
|
||||
|
||||
if (info.PortOffsets.Length % 3 != 0 || info.PortOffsets.Length == 0)
|
||||
throw new InvalidOperationException("PortOffsets array length must be a multiple of three.");
|
||||
if (info.PortOffsets.Length == 0)
|
||||
throw new InvalidOperationException("PortOffsets must have at least one entry.");
|
||||
|
||||
if (info.PortYaws.Length * 3 != info.PortOffsets.Length)
|
||||
if (info.PortYaws.Length != info.PortOffsets.Length)
|
||||
throw new InvalidOperationException("PortYaws must define an angle for each port.");
|
||||
|
||||
if (info.PortCones.Length * 3 != info.PortOffsets.Length)
|
||||
if (info.PortCones.Length != info.PortOffsets.Length)
|
||||
throw new InvalidOperationException("PortCones must define an angle for each port.");
|
||||
|
||||
var p = new List<FirePort>();
|
||||
for (var i = 0; i < info.PortOffsets.Length / 3; i++)
|
||||
for (var i = 0; i < info.PortOffsets.Length; i++)
|
||||
{
|
||||
p.Add(new FirePort
|
||||
{
|
||||
Offset = new WVec(info.PortOffsets[3*i], info.PortOffsets[3*i + 1], info.PortOffsets[3*i + 2]),
|
||||
Offset = info.PortOffsets[i],
|
||||
Yaw = info.PortYaws[i],
|
||||
Cone = info.PortCones[i],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user