Exemplo n.º 1
0
        public void Dispose(bool final)
        {
            int num = 0;

            if (!final)
            {
                foreach (ArtObjectInstance artObjectInstance in ArtObjectInstance.LevelMaterializer.LevelArtObjects)
                {
                    if (artObjectInstance != this && artObjectInstance.ArtObject == this.ArtObject)
                    {
                        artObjectInstance.InstanceIndex = num++;
                        artObjectInstance.drawDirty     = true;
                        artObjectInstance.Update();
                    }
                }
                ArtObjectInstance.LevelMaterializer.LevelArtObjects.Remove(this);
                this.ArtObject.InstanceCount = num;
            }
            else
            {
                this.ArtObject.InstanceCount = 0;
            }
            if (num != 0 || this.ArtObject.Group == null)
            {
                return;
            }
            this.ArtObject.Geometry.ResetBuffers();
            ArtObjectInstance.LevelMaterializer.ArtObjectsMesh.RemoveGroup(this.ArtObject.Group);
            this.ArtObject.Group = (Group)null;
            this.ArtObject       = (ArtObject)null;
        }
Exemplo n.º 2
0
 public ArtObjectMaterializer(ArtObject artObject)
 {
   this.artObject = artObject;
   ServiceHelper.InjectServices((object) this);
   artObject.Materializer = this;
   this.size = artObject.Size;
   if (artObject.MissingTrixels == null)
     return;
   this.added = new HashSet<TrixelFace>();
   this.removed = new HashSet<TrixelFace>();
   this.missingTrixels = artObject.MissingTrixels;
   if (artObject.TrixelSurfaces == null)
     artObject.TrixelSurfaces = this.surfaces = new List<TrixelSurface>();
   else
     this.surfaces = artObject.TrixelSurfaces;
 }
Exemplo n.º 3
0
 public ArtObjectInstance(ArtObject artObject)
     : this()
 {
     this.ArtObject = artObject;
 }
Exemplo n.º 4
0
 public void Dispose(bool final)
 {
   int num = 0;
   if (!final)
   {
     foreach (ArtObjectInstance artObjectInstance in ArtObjectInstance.LevelMaterializer.LevelArtObjects)
     {
       if (artObjectInstance != this && artObjectInstance.ArtObject == this.ArtObject)
       {
         artObjectInstance.InstanceIndex = num++;
         artObjectInstance.drawDirty = true;
         artObjectInstance.Update();
       }
     }
     ArtObjectInstance.LevelMaterializer.LevelArtObjects.Remove(this);
     this.ArtObject.InstanceCount = num;
   }
   else
     this.ArtObject.InstanceCount = 0;
   if (num != 0 || this.ArtObject.Group == null)
     return;
   this.ArtObject.Geometry.ResetBuffers();
   ArtObjectInstance.LevelMaterializer.ArtObjectsMesh.RemoveGroup(this.ArtObject.Group);
   this.ArtObject.Group = (Group) null;
   this.ArtObject = (ArtObject) null;
 }
Exemplo n.º 5
0
 public ArtObjectInstance(ArtObject artObject)
   : this()
 {
   this.ArtObject = artObject;
 }
Exemplo n.º 6
0
 protected override void Begin()
 {
   bool flag = this.PlayerManager.Action == ActionType.OpeningTreasure;
   this.sinceActive = flag ? TimeSpan.FromSeconds(-1.0) : TimeSpan.Zero;
   if (flag)
   {
     this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
     this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.chestAO.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + FezMath.ForwardVector(this.CameraManager.Viewpoint) * -1.5f;
     this.PlayerManager.LookingDirection = HorizontalDirection.Right;
     this.aoOrigin = this.chestAO.Position;
     this.chestAO.ActorSettings.Inactive = true;
   }
   else
   {
     if (this.PlayerManager.ForcedTreasure != null)
     {
       this.treasureIsMap = false;
       this.treasureInstance = this.PlayerManager.ForcedTreasure;
       this.treasureIsAo = false;
       this.chestAO = (ArtObjectInstance) null;
       this.treasureTrile = this.treasureInstance.Trile;
       this.treasureActorType = this.treasureTrile.ActorSettings.Type;
       this.PlayerManager.Action = ActionType.FindingTreasure;
       this.sinceCollect = TimeSpan.Zero;
       this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
       this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.treasureInstance.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + 2f * -FezMath.ForwardVector(this.CameraManager.Viewpoint);
     }
     this.aoOrigin = this.treasureIsMap ? this.treasureAoInstance.Position : this.treasureInstance.Position;
     this.sinceActive = TimeSpan.FromSeconds(OpenTreasure.OpeningDuration.TotalSeconds * 0.600000023841858);
     SoundEffectExtensions.Emit(this.assembleSound);
   }
   if (!flag)
     this.PlayerManager.Velocity = new Vector3(0.0f, 0.05f, 0.0f);
   this.WasConstrained = this.CameraManager.Constrained;
   if (this.WasConstrained)
   {
     this.OldCenter = this.CameraManager.Center;
     this.OldPixPerTrix = this.CameraManager.PixelsPerTrixel;
   }
   this.OldPan = this.CameraManager.PanningConstraints;
   this.CameraManager.Constrained = true;
   this.CameraManager.PanningConstraints = new Vector2?();
   this.CameraManager.Center = this.aoOrigin;
   if (!flag)
   {
     this.lastZoom = this.CameraManager.PixelsPerTrixel;
     this.CameraManager.PixelsPerTrixel = 4f;
   }
   if (flag)
     this.aoInitialRotation = this.lightBox.Rotation = this.solidStar.Rotation = this.fadedStar.Rotation = this.flare.Rotation = this.chestAO.Rotation;
   else
     this.solidStar.Rotation = this.fadedStar.Rotation = this.flare.Rotation = Quaternion.Inverse(this.CameraManager.Rotation);
   this.lightBox.Position = this.aoOrigin - Vector3.UnitY / 2f;
   this.reculled = this.restored = false;
   if (flag)
   {
     this.treasureAo = (ArtObject) null;
     this.treasureTrile = (Trile) null;
     this.treasureIsMap = this.treasureIsAo = false;
     this.treasureActorType = this.chestAO.ActorSettings.ContainedTrile;
     if (this.chestAO.ActorSettings.ContainedTrile == ActorType.TreasureMap)
       this.treasureIsMap = true;
     else if (this.chestAO.ActorSettings.ContainedTrile == ActorType.Mail)
       this.treasureIsMail = true;
     else if (ActorTypeExtensions.SupportsArtObjects(this.chestAO.ActorSettings.ContainedTrile))
     {
       this.treasureAo = this.CMProvider.Global.Load<ArtObject>("Art Objects/" + ActorTypeExtensions.GetArtObjectName(this.chestAO.ActorSettings.ContainedTrile));
       this.treasureIsAo = true;
     }
     else
       this.treasureTrile = Enumerable.LastOrDefault<Trile>(this.LevelManager.ActorTriles(this.chestAO.ActorSettings.ContainedTrile));
     Waiters.Wait(1.0, (Action) (() => SoundEffectExtensions.Emit(this.treasureGetSound)));
   }
   if (!flag && this.treasureIsMap)
   {
     this.treasureOrigin = this.aoOrigin - new Vector3(0.0f, 0.125f, 0.0f);
     string treasureMapName = this.treasureAoInstance.ActorSettings.TreasureMapName;
     Texture2D texture2D1 = this.CMProvider.Global.Load<Texture2D>("Other Textures/maps/" + treasureMapName + "_1");
     Texture2D texture2D2 = this.CMProvider.Global.Load<Texture2D>("Other Textures/maps/" + treasureMapName + "_2");
     for (int index = 0; index < this.map.Groups.Count; ++index)
       this.map.Groups[index].Texture = index % 2 == 0 ? (Texture) texture2D1 : (Texture) texture2D2;
     Mesh mesh = Enumerable.First<Mesh>((IEnumerable<Mesh>) this.FloatingMaps, (Func<Mesh, bool>) (x => ((OpenTreasure.TreasureActorSettings) x.CustomData).AoInstance == this.treasureAoInstance));
     this.map.Position = mesh.Position - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 0.5f;
     this.map.Rotation = mesh.Rotation;
     this.FloatingMaps.Remove(mesh);
   }
   this.oldGround = (TrileInstance) null;
   if (this.PlayerManager.Grounded)
   {
     this.oldGround = this.PlayerManager.Ground.First;
     this.oldGroundHeight = this.PlayerManager.Ground.First.Center.Y;
   }
   this.SoundManager.FadeVolume(1f, 0.125f, 2f);
 }
Exemplo n.º 7
0
 protected override void TestConditions()
 {
   if (this.PlayerManager.Action == ActionType.OpeningTreasure || this.PlayerManager.Action == ActionType.FindingTreasure || (this.PlayerManager.Action == ActionType.ReadingSign || this.PlayerManager.Action == ActionType.FreeFalling) || (this.PlayerManager.Action == ActionType.Dying || this.GameState.InFpsMode))
     return;
   TrileInstance trileInstance = this.PlayerManager.AxisCollision[VerticalDirection.Up].Surface;
   if (trileInstance != null && !trileInstance.Hidden && ActorTypeExtensions.IsTreasure(trileInstance.Trile.ActorSettings.Type))
   {
     this.treasureIsMap = this.treasureIsAo = false;
     this.treasureIsAo = false;
     this.chestAO = (ArtObjectInstance) null;
     this.treasureInstance = trileInstance;
     this.treasureTrile = trileInstance.Trile;
     this.treasureActorType = this.treasureTrile.ActorSettings.Type;
     this.PlayerManager.Action = ActionType.FindingTreasure;
     this.sinceCollect = TimeSpan.Zero;
     this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
     this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.treasureInstance.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + 2f * -FezMath.ForwardVector(this.CameraManager.Viewpoint);
   }
   else
   {
     foreach (Mesh mesh in this.FloatingMaps)
     {
       Vector3 vector3_1 = new Vector3(0.75f);
       Vector3 a = FezMath.Abs(mesh.Position - this.PlayerManager.Center);
       if ((double) FezMath.Dot(a, FezMath.SideMask(this.CameraManager.Viewpoint)) < (double) vector3_1.X && (double) a.Y < (double) vector3_1.Y)
       {
         Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint);
         NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Position);
         if (nearestTriles.Deep != null)
         {
           Vector3 vector3_2 = nearestTriles.Deep.Center - nearestTriles.Deep.TransformedSize * b / 2f;
           if ((double) FezMath.Dot(mesh.Position - b - vector3_2, b) > 0.0)
             continue;
         }
         this.treasureIsMap = true;
         this.treasureIsAo = false;
         this.chestAO = (ArtObjectInstance) null;
         this.treasureAo = ((OpenTreasure.TreasureActorSettings) mesh.CustomData).ArtObject;
         this.treasureAoInstance = ((OpenTreasure.TreasureActorSettings) mesh.CustomData).AoInstance;
         this.treasureActorType = this.treasureAo.ActorType;
         this.PlayerManager.Action = ActionType.FindingTreasure;
         this.sinceCollect = TimeSpan.Zero;
         this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
         this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + mesh.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + 2f * -FezMath.ForwardVector(this.CameraManager.Viewpoint);
         return;
       }
     }
     if (!this.PlayerManager.Grounded || this.PlayerManager.Background)
       return;
     this.chestAO = (ArtObjectInstance) null;
     foreach (ArtObjectInstance artObjectInstance in this.LevelChests)
     {
       if (artObjectInstance.Visible && !artObjectInstance.ActorSettings.Inactive)
       {
         Vector3 vector3_1 = artObjectInstance.ArtObject.Size / 2f;
         Vector3 a = FezMath.Abs(artObjectInstance.Position - this.PlayerManager.Center);
         if ((double) FezMath.Dot(a, FezMath.SideMask(this.CameraManager.Viewpoint)) < (double) vector3_1.X && (double) a.Y < (double) vector3_1.Y)
         {
           Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint);
           NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Position);
           if (nearestTriles.Deep != null)
           {
             Vector3 vector3_2 = nearestTriles.Deep.Center - nearestTriles.Deep.TransformedSize * b / 2f;
             if ((double) FezMath.Dot(artObjectInstance.Position - b - vector3_2, b) > 0.0)
               continue;
           }
           if (FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.AlmostClamp(Vector3.Transform(Vector3.UnitZ, artObjectInstance.Rotation)))) == this.CameraManager.Viewpoint)
           {
             this.chestAO = artObjectInstance;
             this.sinceCollect = TimeSpan.Zero;
             break;
           }
         }
       }
     }
     if (this.chestAO == null || this.InputManager.GrabThrow != FezButtonState.Pressed)
       return;
     this.GomezService.OnOpenTreasure();
     Volume volume;
     if ((volume = Enumerable.FirstOrDefault<Volume>((IEnumerable<Volume>) this.PlayerManager.CurrentVolumes, (Func<Volume, bool>) (x =>
     {
       if (x.ActorSettings != null && x.ActorSettings.IsPointOfInterest)
         return (double) Vector3.DistanceSquared(FezMath.GetCenter(x.BoundingBox), this.chestAO.Position) < 2.0;
       else
         return false;
     }))) != null)
     {
       volume.Enabled = false;
       this.GameState.SaveData.ThisLevel.InactiveVolumes.Add(volume.Id);
     }
     this.PlayerManager.Action = ActionType.OpeningTreasure;
   }
 }