コード例 #1
0
            public ValveState(ValvesBoltsTimeswitchesHost host, ArtObjectInstance ao)
            {
                ServiceHelper.InjectServices((object)this);
                this.Host         = host;
                this.ArtObject    = ao;
                this.IsBolt       = this.ArtObject.ArtObject.ActorType == ActorType.BoltHandle;
                this.IsTimeswitch = this.ArtObject.ArtObject.ActorType == ActorType.Timeswitch;
                BoundingBox boundingBox = new BoundingBox(this.ArtObject.Position - this.ArtObject.ArtObject.Size / 2f, this.ArtObject.Position + this.ArtObject.ArtObject.Size / 2f);

                if (this.ArtObject.ActorSettings.AttachedGroup.HasValue)
                {
                    this.AttachedGroup = this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value];
                }
                if (this.IsTimeswitch)
                {
                    this.eTimeswitchWindBack = SoundEffectExtensions.EmitAt(this.Host.TimeswitchWindBackSound, ao.Position, true, true);
                    foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
                    {
                        if (artObjectInstance != ao && artObjectInstance.ArtObject.ActorType == ActorType.TimeswitchMovingPart)
                        {
                            BoundingBox box = new BoundingBox(artObjectInstance.Position - artObjectInstance.ArtObject.Size / 2f, artObjectInstance.Position + artObjectInstance.ArtObject.Size / 2f);
                            if (boundingBox.Intersects(box))
                            {
                                this.TimeswitchScrewAo = artObjectInstance;
                                break;
                            }
                        }
                    }
                }
                int num1;

                if (!this.IsBolt && !this.IsTimeswitch && (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0))
                {
                    int num2 = Math.Abs(num1);
                    int num3 = Math.Sign(num1);
                    for (int index = 0; index < num2; ++index)
                    {
                        this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)num3);
                    }
                }
                if (this.IsBolt)
                {
                    foreach (TrileInstance instance in this.AttachedGroup.Triles)
                    {
                        instance.PhysicsState = new InstancePhysicsState(instance);
                    }
                }
                foreach (Volume volume in (IEnumerable <Volume>) this.LevelManager.Volumes.Values)
                {
                    Vector3 vector3 = FezMath.Abs(volume.To - volume.From);
                    if ((double)vector3.X == 3.0 && (double)vector3.Z == 3.0 && ((double)vector3.Y == 1.0 && boundingBox.Contains(volume.BoundingBox) == ContainmentType.Contains))
                    {
                        this.CenterOffset = (volume.From + volume.To) / 2f - this.ArtObject.Position;
                        break;
                    }
                }
            }
コード例 #2
0
 public ValveState(ValvesBoltsTimeswitchesHost host, ArtObjectInstance ao)
 {
   ServiceHelper.InjectServices((object) this);
   this.Host = host;
   this.ArtObject = ao;
   this.IsBolt = this.ArtObject.ArtObject.ActorType == ActorType.BoltHandle;
   this.IsTimeswitch = this.ArtObject.ArtObject.ActorType == ActorType.Timeswitch;
   BoundingBox boundingBox = new BoundingBox(this.ArtObject.Position - this.ArtObject.ArtObject.Size / 2f, this.ArtObject.Position + this.ArtObject.ArtObject.Size / 2f);
   if (this.ArtObject.ActorSettings.AttachedGroup.HasValue)
     this.AttachedGroup = this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value];
   if (this.IsTimeswitch)
   {
     this.eTimeswitchWindBack = SoundEffectExtensions.EmitAt(this.Host.TimeswitchWindBackSound, ao.Position, true, true);
     foreach (ArtObjectInstance artObjectInstance in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
     {
       if (artObjectInstance != ao && artObjectInstance.ArtObject.ActorType == ActorType.TimeswitchMovingPart)
       {
         BoundingBox box = new BoundingBox(artObjectInstance.Position - artObjectInstance.ArtObject.Size / 2f, artObjectInstance.Position + artObjectInstance.ArtObject.Size / 2f);
         if (boundingBox.Intersects(box))
         {
           this.TimeswitchScrewAo = artObjectInstance;
           break;
         }
       }
     }
   }
   int num1;
   if (!this.IsBolt && !this.IsTimeswitch && (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0))
   {
     int num2 = Math.Abs(num1);
     int num3 = Math.Sign(num1);
     for (int index = 0; index < num2; ++index)
       this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float) num3);
   }
   if (this.IsBolt)
   {
     foreach (TrileInstance instance in this.AttachedGroup.Triles)
       instance.PhysicsState = new InstancePhysicsState(instance);
   }
   foreach (Volume volume in (IEnumerable<Volume>) this.LevelManager.Volumes.Values)
   {
     Vector3 vector3 = FezMath.Abs(volume.To - volume.From);
     if ((double) vector3.X == 3.0 && (double) vector3.Z == 3.0 && ((double) vector3.Y == 1.0 && boundingBox.Contains(volume.BoundingBox) == ContainmentType.Contains))
     {
       this.CenterOffset = (volume.From + volume.To) / 2f - this.ArtObject.Position;
       break;
     }
   }
 }