Merge pull request #10222 from teees/withvoxelturret-fix

Disable WithVoxelTurret until build/transform complete
This commit is contained in:
Paul Chote
2015-12-28 18:55:48 +00:00

View File

@@ -45,12 +45,15 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
public class WithVoxelTurret : UpgradableTrait<WithVoxelTurretInfo> public class WithVoxelTurret : UpgradableTrait<WithVoxelTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform
{ {
readonly Actor self; readonly Actor self;
readonly Turreted turreted; readonly Turreted turreted;
readonly BodyOrientation body; 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) public WithVoxelTurret(Actor self, WithVoxelTurretInfo info)
: base(info) : base(info)
{ {
@@ -58,11 +61,12 @@ namespace OpenRA.Mods.Common.Traits
body = self.Trait<BodyOrientation>(); body = self.Trait<BodyOrientation>();
turreted = self.TraitsImplementing<Turreted>() turreted = self.TraitsImplementing<Turreted>()
.First(tt => tt.Name == Info.Turret); .First(tt => tt.Name == Info.Turret);
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>(); // always render instantly for units
var rv = self.Trait<RenderVoxels>(); var rv = self.Trait<RenderVoxels>();
rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence), rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence),
() => turreted.Position(self), TurretRotation, () => turreted.Position(self), TurretRotation,
() => IsTraitDisabled, () => 0)); () => IsTraitDisabled || !buildComplete, () => 0));
} }
IEnumerable<WRot> TurretRotation() IEnumerable<WRot> TurretRotation()
@@ -72,5 +76,12 @@ namespace OpenRA.Mods.Common.Traits
yield return turreted.LocalOrientation(self) + WRot.FromYaw(b.Yaw - qb.Yaw); yield return turreted.LocalOrientation(self) + WRot.FromYaw(b.Yaw - qb.Yaw);
yield return qb; 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) { }
} }
} }