Fix contrail gets rendered between loading in and loading out position

This commit is contained in:
abc013
2017-03-03 17:55:42 +01:00
parent cc3b46b580
commit b7ca740155

View File

@@ -42,10 +42,11 @@ namespace OpenRA.Mods.Common.Effects
public object Create(ActorInitializer init) { return new Contrail(init.Self, this); } public object Create(ActorInitializer init) { return new Contrail(init.Self, this); }
} }
class Contrail : ITick, IRender class Contrail : ITick, IRender, INotifyAddedToWorld
{ {
readonly ContrailInfo info; readonly ContrailInfo info;
readonly BodyOrientation body; readonly BodyOrientation body;
readonly Color color;
// This is a mutable struct, so it can't be readonly. // This is a mutable struct, so it can't be readonly.
ContrailRenderable trail; ContrailRenderable trail;
@@ -54,7 +55,7 @@ namespace OpenRA.Mods.Common.Effects
{ {
this.info = info; this.info = info;
var color = info.UsePlayerColor ? ContrailRenderable.ChooseColor(self) : info.Color; color = info.UsePlayerColor ? ContrailRenderable.ChooseColor(self) : info.Color;
trail = new ContrailRenderable(self.World, color, info.TrailWidth, info.TrailLength, 0, info.ZOffset); trail = new ContrailRenderable(self.World, color, info.TrailWidth, info.TrailLength, 0, info.ZOffset);
body = self.Trait<BodyOrientation>(); body = self.Trait<BodyOrientation>();
@@ -70,5 +71,10 @@ namespace OpenRA.Mods.Common.Effects
{ {
return new IRenderable[] { trail }; return new IRenderable[] { trail };
} }
public void AddedToWorld(Actor self)
{
trail = new ContrailRenderable(self.World, color, info.TrailWidth, info.TrailLength, 0, info.ZOffset);
}
} }
} }