Replace INotifyBuildComplete in render traits with conditions.

This commit is contained in:
Paul Chote
2018-10-05 20:16:36 +00:00
committed by abcdefg30
parent 26b0a06a17
commit 14607f55c5
28 changed files with 152 additions and 407 deletions

View File

@@ -51,15 +51,12 @@ namespace OpenRA.Mods.Common.Traits.Render
}
}
public class WithVoxelTurret : ConditionalTrait<WithVoxelTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform
public class WithVoxelTurret : ConditionalTrait<WithVoxelTurretInfo>
{
readonly Actor self;
readonly Turreted turreted;
readonly BodyOrientation body;
// TODO: This should go away once https://github.com/OpenRA/OpenRA/issues/7035 is implemented
bool buildComplete;
public WithVoxelTurret(Actor self, WithVoxelTurretInfo info)
: base(info)
{
@@ -67,12 +64,11 @@ namespace OpenRA.Mods.Common.Traits.Render
body = self.Trait<BodyOrientation>();
turreted = self.TraitsImplementing<Turreted>()
.First(tt => tt.Name == Info.Turret);
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>(); // always render instantly for units
var rv = self.Trait<RenderVoxels>();
rv.Add(new ModelAnimation(self.World.ModelCache.GetModelSequence(rv.Image, Info.Sequence),
() => turreted.Position(self), TurretRotation,
() => IsTraitDisabled || !buildComplete, () => 0, info.ShowShadow));
() => IsTraitDisabled, () => 0, info.ShowShadow));
}
IEnumerable<WRot> TurretRotation()
@@ -82,12 +78,5 @@ namespace OpenRA.Mods.Common.Traits.Render
yield return turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return qb;
}
void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; }
void INotifySold.Selling(Actor self) { buildComplete = false; }
void INotifySold.Sold(Actor self) { }
void INotifyTransform.BeforeTransform(Actor self) { buildComplete = false; }
void INotifyTransform.OnTransform(Actor self) { }
void INotifyTransform.AfterTransform(Actor toActor) { }
}
}