Fix overlapping tracks when vehicle rotates.
Also optimize the function slightly.
This commit is contained in:
committed by
abcdefg30
parent
5220da1bae
commit
a6cb20a4ec
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -93,6 +94,10 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
bool wasStationary;
|
bool wasStationary;
|
||||||
bool isMoving;
|
bool isMoving;
|
||||||
|
|
||||||
|
bool previouslySpawned;
|
||||||
|
CPos previousSpawnCell;
|
||||||
|
WAngle previousSpawnFacing;
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
@@ -120,18 +125,26 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
if (++offset >= Info.Offsets.Length)
|
if (++offset >= Info.Offsets.Length)
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
var offsetRotation = Info.Offsets[offset].Rotate(body.QuantizeOrientation(self, self.Orientation));
|
if (!Info.TerrainTypes.Any() || Info.TerrainTypes.Contains(type))
|
||||||
var spawnPosition = Info.SpawnAtLastPosition ? cachedPosition : self.CenterPosition;
|
{
|
||||||
|
var spawnFacing = Info.SpawnAtLastPosition ? cachedFacing : facing?.Facing ?? WAngle.Zero;
|
||||||
|
|
||||||
var pos = Info.Type == TrailType.CenterPosition ? spawnPosition + body.LocalToWorld(offsetRotation) :
|
if (previouslySpawned && previousSpawnCell == spawnCell)
|
||||||
self.World.Map.CenterOfCell(spawnCell);
|
spawnFacing = previousSpawnFacing;
|
||||||
|
|
||||||
var spawnFacing = Info.SpawnAtLastPosition ? cachedFacing : facing?.Facing ?? WAngle.Zero;
|
var offsetRotation = Info.Offsets[offset].Rotate(body.QuantizeOrientation(self, self.Orientation));
|
||||||
|
var spawnPosition = Info.SpawnAtLastPosition ? cachedPosition : self.CenterPosition;
|
||||||
|
var pos = Info.Type == TrailType.CenterPosition ? spawnPosition + body.LocalToWorld(offsetRotation) :
|
||||||
|
self.World.Map.CenterOfCell(spawnCell);
|
||||||
|
|
||||||
if (Info.TerrainTypes.Count == 0 || Info.TerrainTypes.Contains(type))
|
|
||||||
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, spawnFacing, self.World, Info.Image,
|
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, spawnFacing, self.World, Info.Image,
|
||||||
Info.Sequences.Random(Game.CosmeticRandom), Info.Palette, Info.VisibleThroughFog)));
|
Info.Sequences.Random(Game.CosmeticRandom), Info.Palette, Info.VisibleThroughFog)));
|
||||||
|
|
||||||
|
previouslySpawned = true;
|
||||||
|
previousSpawnCell = spawnCell;
|
||||||
|
previousSpawnFacing = spawnFacing;
|
||||||
|
}
|
||||||
|
|
||||||
cachedPosition = self.CenterPosition;
|
cachedPosition = self.CenterPosition;
|
||||||
cachedFacing = facing?.Facing ?? WAngle.Zero;
|
cachedFacing = facing?.Facing ?? WAngle.Zero;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user