示例#1
0
        public BodyOrientation(ActorInitializer init, BodyOrientationInfo info)
        {
            this.info = info;
            var self    = init.Self;
            var faction = init.GetValue <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));
            });
        }
示例#2
0
        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);
            });
        }
示例#3
0
 public BodyOrientation(Actor self, BodyOrientationInfo info)
 {
     this.info = info;
     if (info.QuantizedFacings > 0)
     {
         QuantizedFacings = info.QuantizedFacings;
     }
 }
示例#4
0
		public BodyOrientation(Actor self, BodyOrientationInfo info)
		{
			this.info = info;
			if (info.QuantizedFacings > 0)
				QuantizedFacings = info.QuantizedFacings;
		}