Fix turret facings for GTWR etc. Fixes #3610.
This commit is contained in:
@@ -18,6 +18,9 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public class BodyOrientationInfo : ITraitInfo, IBodyOrientationInfo
|
public class BodyOrientationInfo : ITraitInfo, IBodyOrientationInfo
|
||||||
{
|
{
|
||||||
|
[Desc("Number of facings for gameplay calculations. -1 indiciates auto-detection from sequence")]
|
||||||
|
public readonly int QuantizedFacings = -1;
|
||||||
|
|
||||||
[Desc("Camera pitch for rotation calculations")]
|
[Desc("Camera pitch for rotation calculations")]
|
||||||
public readonly WAngle CameraPitch = WAngle.FromDegrees(40);
|
public readonly WAngle CameraPitch = WAngle.FromDegrees(40);
|
||||||
public object Create(ActorInitializer init) { return new BodyOrientation(init.self, this); }
|
public object Create(ActorInitializer init) { return new BodyOrientation(init.self, this); }
|
||||||
@@ -25,21 +28,23 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class BodyOrientation : IBodyOrientation
|
public class BodyOrientation : IBodyOrientation
|
||||||
{
|
{
|
||||||
[Sync] public int QuantizedFacings { get; set; }
|
[Sync] public int QuantizedFacings { get; private set; }
|
||||||
BodyOrientationInfo Info;
|
BodyOrientationInfo info;
|
||||||
|
|
||||||
public BodyOrientation(Actor self, BodyOrientationInfo info)
|
public BodyOrientation(Actor self, BodyOrientationInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
this.info = info;
|
||||||
|
if (info.QuantizedFacings > 0)
|
||||||
|
QuantizedFacings = info.QuantizedFacings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WAngle CameraPitch { get { return Info.CameraPitch; } }
|
public WAngle CameraPitch { get { return info.CameraPitch; } }
|
||||||
|
|
||||||
public WVec LocalToWorld(WVec vec)
|
public WVec LocalToWorld(WVec vec)
|
||||||
{
|
{
|
||||||
// RA's 2d perspective doesn't correspond to an orthonormal 3D
|
// RA's 2d perspective doesn't correspond to an orthonormal 3D
|
||||||
// coordinate system, so fudge the y axis to make things look good
|
// coordinate system, so fudge the y axis to make things look good
|
||||||
return new WVec(vec.Y, -Info.CameraPitch.Sin()*vec.X/1024, vec.Z);
|
return new WVec(vec.Y, -info.CameraPitch.Sin()*vec.X/1024, vec.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WRot QuantizeOrientation(Actor self, WRot orientation)
|
public WRot QuantizeOrientation(Actor self, WRot orientation)
|
||||||
@@ -54,5 +59,11 @@ namespace OpenRA.Traits
|
|||||||
// Roll and pitch are always zero if yaw is quantized
|
// Roll and pitch are always zero if yaw is quantized
|
||||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetAutodetectedFacings(int facings)
|
||||||
|
{
|
||||||
|
if (info.QuantizedFacings < 0)
|
||||||
|
QuantizedFacings = facings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Traits
|
|||||||
: this(self, MakeFacingFunc(self))
|
: this(self, MakeFacingFunc(self))
|
||||||
{
|
{
|
||||||
anim.PlayRepeating("idle");
|
anim.PlayRepeating("idle");
|
||||||
self.Trait<IBodyOrientation>().QuantizedFacings = anim.CurrentSequence.Facings;
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(anim.CurrentSequence.Facings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 SelectionSize(Actor self)
|
public int2 SelectionSize(Actor self)
|
||||||
|
|||||||
@@ -191,9 +191,10 @@ namespace OpenRA.Traits
|
|||||||
public interface IBodyOrientation
|
public interface IBodyOrientation
|
||||||
{
|
{
|
||||||
WAngle CameraPitch { get; }
|
WAngle CameraPitch { get; }
|
||||||
int QuantizedFacings { get; set; }
|
int QuantizedFacings { get; }
|
||||||
WVec LocalToWorld(WVec vec);
|
WVec LocalToWorld(WVec vec);
|
||||||
WRot QuantizeOrientation(Actor self, WRot orientation);
|
WRot QuantizeOrientation(Actor self, WRot orientation);
|
||||||
|
void SetAutodetectedFacings(int facings);
|
||||||
}
|
}
|
||||||
public interface IBodyOrientationInfo {}
|
public interface IBodyOrientationInfo {}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
rightWake.Play("wake-right");
|
rightWake.Play("wake-right");
|
||||||
anims.Add("wake-right", new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));
|
anims.Add("wake-right", new AnimationWithOffset(rightWake, null, () => facing.Facing <= 128, -87));
|
||||||
|
|
||||||
self.Trait<IBodyOrientation>().QuantizedFacings = 2;
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
// Work around a bogus crash
|
// Work around a bogus crash
|
||||||
anim.PlayRepeating( NormalizeSequence(self, "idle") );
|
anim.PlayRepeating( NormalizeSequence(self, "idle") );
|
||||||
self.Trait<IBodyOrientation>().QuantizedFacings = anim.CurrentSequence.Facings;
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(anim.CurrentSequence.Facings);
|
||||||
|
|
||||||
// Can't call Complete() directly from ctor because other traits haven't been inited yet
|
// Can't call Complete() directly from ctor because other traits haven't been inited yet
|
||||||
if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())
|
if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
State = AnimationState.Waiting;
|
State = AnimationState.Waiting;
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
self.Trait<IBodyOrientation>().QuantizedFacings = anim.CurrentSequence.Facings;
|
self.Trait<IBodyOrientation>().SetAutodetectedFacings(anim.CurrentSequence.Facings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Attacking(Actor self, Target target)
|
public void Attacking(Actor self, Target target)
|
||||||
|
|||||||
@@ -605,8 +605,6 @@ OBLI:
|
|||||||
Turreted:
|
Turreted:
|
||||||
ROT:255
|
ROT:255
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
RenderBuilding:
|
|
||||||
QuantizedFacings: 8
|
|
||||||
-RenderBuilding:
|
-RenderBuilding:
|
||||||
RenderRangeCircle:
|
RenderRangeCircle:
|
||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
@@ -638,7 +636,7 @@ GTWR:
|
|||||||
Weapon: HighV
|
Weapon: HighV
|
||||||
LocalOffset: 256,0,256
|
LocalOffset: 256,0,256
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
RenderBuilding:
|
BodyOrientation:
|
||||||
QuantizedFacings: 8
|
QuantizedFacings: 8
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
@@ -682,7 +680,7 @@ ATWR:
|
|||||||
LocalYaw: -100,100
|
LocalYaw: -100,100
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
RenderBuilding:
|
BodyOrientation:
|
||||||
QuantizedFacings: 8
|
QuantizedFacings: 8
|
||||||
RenderDetectionCircle:
|
RenderDetectionCircle:
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
|
|||||||
Reference in New Issue
Block a user