Merge pull request #9193 from Mailaender/quanbo-fixup

Fixed BodyOrientation refactor regressions
This commit is contained in:
reaperrr
2015-08-31 20:12:53 +02:00
4 changed files with 12 additions and 5 deletions

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new BodyOrientation(init, this); } public object Create(ActorInitializer init) { return new BodyOrientation(init, this); }
} }
public class BodyOrientation : IBodyOrientation public class BodyOrientation : IBodyOrientation, ISync
{ {
readonly BodyOrientationInfo info; readonly BodyOrientationInfo info;
readonly Lazy<int> quantizedFacings; readonly Lazy<int> quantizedFacings;
@@ -73,12 +73,16 @@ namespace OpenRA.Mods.Common.Traits
return info.QuantizedFacings; return info.QuantizedFacings;
var qboi = self.Info.Traits.GetOrDefault<IQuantizeBodyOrientationInfo>(); var qboi = self.Info.Traits.GetOrDefault<IQuantizeBodyOrientationInfo>();
var isb = self.HasTrait<ISpriteBody>();
// If a sprite actor has neither custom QuantizedFacings nor a trait implementing IQuantizeBodyOrientationInfo, throw // If a sprite actor has neither custom QuantizedFacings nor a trait implementing IQuantizeBodyOrientationInfo, throw
if (qboi == null && isb) if (qboi == null)
throw new InvalidOperationException("Actor" + self.Info.Name + "has a sprite body but no facing quantization." {
if (self.HasTrait<ISpriteBody>())
throw new InvalidOperationException("Actor '" + self.Info.Name + "' has a sprite body but no facing quantization."
+ " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation."); + " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation.");
else
throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation.");
}
return qboi.QuantizedBodyFacings(self.Info, self.World.Map.SequenceProvider, faction); return qboi.QuantizedBodyFacings(self.Info, self.World.Map.SequenceProvider, faction);
}); });

View File

@@ -691,6 +691,7 @@
DamagedSounds: xplos.aud DamagedSounds: xplos.aud
DestroyedSounds: xplobig4.aud DestroyedSounds: xplobig4.aud
BodyOrientation: BodyOrientation:
QuantizedFacings: 1
ScriptTriggers: ScriptTriggers:
^Crate: ^Crate:

View File

@@ -636,6 +636,7 @@
Type: Concrete Type: Concrete
AutoTargetIgnore: AutoTargetIgnore:
BodyOrientation: BodyOrientation:
QuantizedFacings: 1
ScriptTriggers: ScriptTriggers:
^Rock: ^Rock:

View File

@@ -200,6 +200,7 @@ camera.paradrop:
ProximityCaptor: ProximityCaptor:
Types: Camera Types: Camera
BodyOrientation: BodyOrientation:
QuantizedFacings: 1
SONAR: SONAR:
AlwaysVisible: AlwaysVisible: