public BodyOrientation(ActorInitializer init, BodyOrientationInfo info) { this.info = info; var self = init.Self; var faction = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : self.Owner.Faction.InternalName; quantizedFacings = Exts.Lazy(() => { // Override value is set if (info.QuantizedFacings >= 0) { return(info.QuantizedFacings); } var qboi = self.Info.TraitInfoOrDefault <IQuantizeBodyOrientationInfo>(); // If a sprite actor has neither custom QuantizedFacings nor a trait implementing IQuantizeBodyOrientationInfo, throw if (qboi == null) { if (self.Info.HasTraitInfo <WithSpriteBodyInfo>()) { 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."); } else { throw new InvalidOperationException("Actor type '" + self.Info.Name + "' does not define a quantized body orientation."); } } return(qboi.QuantizedBodyFacings(self.Info, self.World.Map.Rules.Sequences, faction)); }); }