Fix DynamicFacingInit not being dynamic
This commit is contained in:
committed by
Matthias Mailänder
parent
ab6dc5db32
commit
f21572d22a
@@ -69,30 +69,47 @@ namespace OpenRA.Mods.Common.Graphics
|
|||||||
|
|
||||||
WAngle facing;
|
WAngle facing;
|
||||||
|
|
||||||
// Dynamic facing takes priority
|
|
||||||
var dynamicInit = reference.GetOrDefault<DynamicFacingInit>();
|
|
||||||
if (dynamicInit != null)
|
|
||||||
{
|
|
||||||
var getFacing = dynamicInit.Value;
|
|
||||||
facing = getFacing();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Fall back to initial actor facing if an Init isn't available
|
|
||||||
var facingInit = reference.GetOrDefault<FacingInit>();
|
|
||||||
facing = facingInit != null ? facingInit.Value : facingInfo.GetInitialFacing();
|
|
||||||
}
|
|
||||||
|
|
||||||
var mobileInfo = Actor.TraitInfoOrDefault<MobileInfo>();
|
var mobileInfo = Actor.TraitInfoOrDefault<MobileInfo>();
|
||||||
var location = reference.GetOrDefault<LocationInit>();
|
var location = reference.GetOrDefault<LocationInit>();
|
||||||
if (location == null || mobileInfo == null || mobileInfo.TerrainOrientationAdjustmentMargin.Length < 0)
|
if (location == null || mobileInfo == null || mobileInfo.TerrainOrientationAdjustmentMargin.Length < 0)
|
||||||
return () => WRot.FromYaw(facing);
|
{
|
||||||
|
// Dynamic facing takes priority.
|
||||||
|
var dynamicInit = reference.GetOrDefault<DynamicFacingInit>();
|
||||||
|
if (dynamicInit != null)
|
||||||
|
{
|
||||||
|
var getFacing = dynamicInit.Value;
|
||||||
|
return () => WRot.FromYaw(getFacing());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Fall back to initial actor facing if an Init isn't available.
|
||||||
|
var facingInit = reference.GetOrDefault<FacingInit>();
|
||||||
|
facing = facingInit != null ? facingInit.Value : facingInfo.GetInitialFacing();
|
||||||
|
return () => WRot.FromYaw(facing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var orientationInit = reference.GetOrDefault<TerrainOrientationInit>();
|
var orientationInit = reference.GetOrDefault<TerrainOrientationInit>();
|
||||||
var terrainOrientation = orientationInit != null ? orientationInit.Value : World.Map.TerrainOrientation(location.Value);
|
var terrainOrientation = orientationInit != null ? orientationInit.Value : World.Map.TerrainOrientation(location.Value);
|
||||||
var terrainAdjustedFacing = new WRot(new WVec(0, 0, 1024).Rotate(terrainOrientation), facing);
|
var normalVector = new WVec(0, 0, 1024).Rotate(terrainOrientation);
|
||||||
|
|
||||||
return () => terrainOrientation + terrainAdjustedFacing;
|
// Duplicated as to make more efficient delegates.
|
||||||
|
{
|
||||||
|
// Dynamic facing takes priority.
|
||||||
|
var dynamicInit = reference.GetOrDefault<DynamicFacingInit>();
|
||||||
|
if (dynamicInit != null)
|
||||||
|
{
|
||||||
|
var getFacing = dynamicInit.Value;
|
||||||
|
return () => terrainOrientation + new WRot(normalVector, getFacing());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Fall back to initial actor facing if an Init isn't available.
|
||||||
|
var facingInit = reference.GetOrDefault<FacingInit>();
|
||||||
|
facing = facingInit != null ? facingInit.Value : facingInfo.GetInitialFacing();
|
||||||
|
return () => terrainOrientation + new WRot(normalVector, facing);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<WAngle> GetFacing()
|
public Func<WAngle> GetFacing()
|
||||||
|
|||||||
Reference in New Issue
Block a user