Convert (Dynamic)FacingInit, (Dynamic)TurretFacingInit to WAngle.
This commit is contained in:
@@ -175,7 +175,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
new LocationInit(destination.Value),
|
||||
new OwnerInit(self.Owner),
|
||||
new FacingInit(info.Facing),
|
||||
new FacingInit(WAngle.FromFacing(info.Facing)),
|
||||
new FactionInit(faction),
|
||||
new HealthInit((int)(health.HP * 100L / health.MaxHP))
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
var passengerInits = new TypeDictionary()
|
||||
{
|
||||
new OwnerInit(p.Owner),
|
||||
new DynamicFacingInit(() => body.QuantizeFacing(facing.Facing).Facing),
|
||||
new DynamicFacingInit(() => body.QuantizeFacing(facing.Facing)),
|
||||
};
|
||||
|
||||
foreach (var api in p.TraitsImplementing<IActorPreviewInitModifier>())
|
||||
|
||||
@@ -13,6 +13,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.Common.Traits.Render;
|
||||
@@ -34,9 +35,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
var wsb = init.Actor.TraitInfos<WithSpriteBodyInfo>().FirstOrDefault();
|
||||
|
||||
// Show the correct turret facing
|
||||
var facing = WAngle.FromFacing(init.GetValue<TurretFacingInit, int>(this, t.InitialFacing));
|
||||
|
||||
var anim = new Animation(init.World, image, () => facing);
|
||||
var anim = new Animation(init.World, image, Turreted.TurretFacingFromInit(init, t));
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), wsb.Sequence));
|
||||
|
||||
yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale);
|
||||
|
||||
@@ -91,15 +91,15 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
base.Activate(self, order, manager);
|
||||
|
||||
SendDropPods(self, order, info.PodFacing);
|
||||
SendDropPods(self, order, WAngle.FromFacing(info.PodFacing));
|
||||
}
|
||||
|
||||
public void SendDropPods(Actor self, Order order, int podFacing)
|
||||
public void SendDropPods(Actor self, Order order, WAngle facing)
|
||||
{
|
||||
var actorInfo = self.World.Map.Rules.Actors[info.UnitTypes.First().ToLowerInvariant()];
|
||||
var aircraftInfo = actorInfo.TraitInfo<AircraftInfo>();
|
||||
var altitude = aircraftInfo.CruiseAltitude.Length;
|
||||
var approachRotation = WRot.FromFacing(podFacing);
|
||||
var approachRotation = WRot.FromYaw(facing);
|
||||
var fallsToEarthInfo = actorInfo.TraitInfo<FallsToEarthInfo>();
|
||||
var delta = new WVec(0, -altitude * aircraftInfo.Speed / fallsToEarthInfo.Velocity.Length, 0).Rotate(approachRotation);
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
new CenterPositionInit(location),
|
||||
new OwnerInit(self.Owner),
|
||||
new FacingInit(podFacing)
|
||||
new FacingInit(facing)
|
||||
});
|
||||
|
||||
var aircraft = pod.Trait<Aircraft>();
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
public override object Create(ActorInitializer init) { return new TDGunboat(init, this); }
|
||||
|
||||
public int GetInitialFacing() { return InitialFacing; }
|
||||
public WAngle GetInitialFacing() { return WAngle.FromFacing(InitialFacing); }
|
||||
|
||||
IEnumerable<ActorInit> IActorPreviewInitInfo.ActorPreviewInits(ActorInfo ai, ActorPreviewType type)
|
||||
{
|
||||
yield return new FacingInit(PreviewFacing);
|
||||
yield return new FacingInit(WAngle.FromFacing(PreviewFacing));
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (centerPositionInit != null)
|
||||
SetPosition(self, centerPositionInit.Value);
|
||||
|
||||
Facing = WAngle.FromFacing(init.GetValue<FacingInit, int>(Info.GetInitialFacing()));
|
||||
Facing = init.GetValue<FacingInit, WAngle>(Info.GetInitialFacing());
|
||||
|
||||
// Prevent mappers from setting bogus facings
|
||||
if (Facing != Left && Facing != Right)
|
||||
@@ -161,7 +161,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
void IDeathActorInitModifier.ModifyDeathActorInit(Actor self, TypeDictionary init)
|
||||
{
|
||||
init.Add(new FacingInit(Facing.Facing));
|
||||
init.Add(new FacingInit(Facing));
|
||||
}
|
||||
|
||||
public bool CanExistInCell(CPos cell) { return true; }
|
||||
@@ -232,7 +232,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
void IActorPreviewInitModifier.ModifyActorPreviewInit(Actor self, TypeDictionary inits)
|
||||
{
|
||||
if (!inits.Contains<DynamicFacingInit>() && !inits.Contains<FacingInit>())
|
||||
inits.Add(new DynamicFacingInit(() => Facing.Facing));
|
||||
inits.Add(new DynamicFacingInit(() => Facing));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user