Example #1
0
 private void TryInitialize()
 {
     this.flashesMesh.ClearGroups();
     this.bombStates.Clear();
     this.indexedDg.Clear();
     this.destructibleGroups.Clear();
     foreach (TrileGroup trileGroup in (IEnumerable <TrileGroup>) this.LevelManager.Groups.Values)
     {
         if (trileGroup.Triles.Count != 0 && ActorTypeExtensions.IsDestructible(trileGroup.Triles[0].Trile.ActorSettings.Type) && ActorTypeExtensions.IsDestructible(trileGroup.Triles[trileGroup.Triles.Count - 1].Trile.ActorSettings.Type))
         {
             BombsHost.DestructibleGroup destructibleGroup = new BombsHost.DestructibleGroup()
             {
                 AllTriles = new List <TrileInstance>((IEnumerable <TrileInstance>)trileGroup.Triles),
                 Group     = trileGroup
             };
             this.destructibleGroups.Add(destructibleGroup);
             FaceOrientation face = FaceOrientation.Down;
             foreach (TrileInstance key in trileGroup.Triles)
             {
                 this.indexedDg.Add(key, destructibleGroup);
                 TrileEmplacement traversal = key.Emplacement.GetTraversal(ref face);
                 TrileInstance    instance  = this.LevelManager.TrileInstanceAt(ref traversal);
                 if (instance != null && !ActorTypeExtensions.IsDestructible(instance.Trile.ActorSettings.Type) && instance.PhysicsState == null)
                 {
                     instance.PhysicsState = new InstancePhysicsState(instance);
                 }
             }
         }
     }
 }
Example #2
0
        private void AddDownforce(TrileInstance instance, float factor, bool apply, bool propagate)
        {
            if (instance == null || instance.TrileId != 286)
            {
                return;
            }
            BridgeState bridgeState;

            if (!this.ActiveBridgeParts.TryGetValue(instance, out bridgeState))
            {
                this.ActiveBridgeParts.Add(instance, bridgeState = new BridgeState(instance));
            }
            else if (apply && bridgeState.Dirty)
            {
                return;
            }
            Vector3 vector3 = FezMath.SideMask(this.CameraManager.Viewpoint);

            if (apply)
            {
                bridgeState.Downforce = MathHelper.Clamp(bridgeState.Downforce + factor, 0.0f, 1f);
                bridgeState.Dirty     = true;
            }
            if (!propagate)
            {
                return;
            }
            TrileEmplacement id = new TrileEmplacement(bridgeState.OriginalPosition - vector3);

            this.AddDownforce(this.LevelManager.TrileInstanceAt(ref id), factor / 2f, true, true);
            id = new TrileEmplacement(bridgeState.OriginalPosition + vector3);
            this.AddDownforce(this.LevelManager.TrileInstanceAt(ref id), factor / 2f, true, true);
        }
Example #3
0
    bool isVisible(TrileEmplacement atPos)
    {
        TrileEmplacement[] checkPos = new TrileEmplacement[6];

        checkPos[0] = new TrileEmplacement(atPos.X, atPos.Y, atPos.Z + 1);
        checkPos[1] = new TrileEmplacement(atPos.X, atPos.Y, atPos.Z - 1);

        checkPos[2] = new TrileEmplacement(atPos.X, atPos.Y + 1, atPos.Z);
        checkPos[3] = new TrileEmplacement(atPos.X, atPos.Y - 1, atPos.Z);

        checkPos[4] = new TrileEmplacement(atPos.X + 1, atPos.Y, atPos.Z);
        checkPos[5] = new TrileEmplacement(atPos.X - 1, atPos.Y, atPos.Z);

        foreach (TrileEmplacement t in checkPos)
        {
            if (!loaded.Triles.ContainsKey(t))
            {
                return(true);
            }
            else if (s.Triles[loaded.Triles[t].TrileId].SeeThrough)
            {
                return(true);
            }
        }

        return(false);
    }
Example #4
0
    void GenerateTrile(TrileEmplacement atPos)
    {
        if (!loaded.Triles.ContainsKey(atPos))
        {
            return;
        }

        bool visible = isVisible(atPos);

        if (!visible)
        {
            if (trileObjects.ContainsKey(atPos))
            {
                GameObject toRemove = trileObjects[atPos];

                trileObjects.Remove(atPos);

                Destroy(toRemove);
            }
        }
        else
        {
            if (trileObjects.ContainsKey(atPos))
            {
                return;
            }
            else
            {
                GameObject g = NewTrileObject(atPos);
            }
        }
    }
Example #5
0
        public bool ClearTrile(TrileEmplacement emplacement)
        {
            TrileInstance trileInstance;

            if (!this.Triles.TryGetValue(emplacement, out trileInstance))
            {
                return(false);
            }
            this.LevelMaterializer.RemoveInstance(trileInstance);
            bool flag1 = this.Triles.Remove(emplacement);

            trileInstance.Removed = true;
            this.LevelMaterializer.CullInstanceOut(trileInstance, true);
            bool flag2 = false;

            foreach (TrileGroup trileGroup in (IEnumerable <TrileGroup>) this.Groups.Values)
            {
                flag2 = flag2 | trileGroup.Triles.Remove(trileInstance);
            }
            if (flag2)
            {
                foreach (int key in Enumerable.ToArray <int>((IEnumerable <int>) this.Groups.Keys))
                {
                    if (this.Groups[key].Triles.Count == 0)
                    {
                        this.Groups.Remove(key);
                    }
                }
            }
            if (flag1 && trileInstance.Overlaps)
            {
                this.RestoreTrile(trileInstance.PopOverlap());
            }
            return(true);
        }
Example #6
0
    public void AddTrile(TrileEmplacement trilePos)
    {
        if (loaded.Triles.ContainsKey(trilePos))
        {
            return;
        }

        TrileInstance newInstance = new TrileInstance();

        newInstance.TrileId  = currTrileID;
        newInstance.Position = new Vector3(trilePos.X, trilePos.Y, trilePos.Z);

        loaded.Triles.Add(trilePos, newInstance);

        GameObject newTrile = Instantiate(trilePrefab);

        MeshFilter   mf = newTrile.GetComponent <MeshFilter>();
        MeshRenderer mr = newTrile.GetComponent <MeshRenderer>();
        BoxCollider  bc = newTrile.GetComponent <BoxCollider>();

        mr.material = setMat;
        mf.mesh     = trilesetCache[s.Triles[newInstance.TrileId]];

        bc.size   = mf.mesh.bounds.size;
        bc.center = mf.mesh.bounds.center;

        newTrile.transform.position = new Vector3(trilePos.X, trilePos.Y, trilePos.Z);
        newTrile.transform.rotation = Quaternion.Euler(0, 0, 0);

        newTrile.name             = s.Triles[newInstance.TrileId].Name;
        newTrile.transform.parent = transform.FindChild("Triles");
        trileObjects.Add(trilePos, newTrile);
    }
Example #7
0
        public TrileInstance ActualInstanceAt(Vector3 position)
        {
            Vector3          vector3             = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            bool             depthIsZ            = (double)vector3.Z != 0.0;
            bool             flag                = depthIsZ;
            int              forwardSign         = depthIsZ ? (int)vector3.Z : (int)vector3.X;
            Vector3          screenSpacePosition = new Vector3(flag ? position.X : position.Z, position.Y, depthIsZ ? position.Z : position.X);
            TrileEmplacement emplacement         = new TrileEmplacement((int)Math.Floor((double)position.X), (int)Math.Floor((double)position.Y), (int)Math.Floor((double)position.Z));
            float            num = FezMath.Frac(screenSpacePosition.Z);

            LevelManager.QueryResult queryResult;
            TrileInstance            trileInstance = this.OffsetInstanceAt(emplacement, screenSpacePosition, depthIsZ, forwardSign, false, false, QueryOptions.None, out queryResult);

            if (trileInstance != null)
            {
                return(trileInstance);
            }
            if ((double)num >= 0.5)
            {
                return(this.OffsetInstanceAt(emplacement.GetOffset(depthIsZ ? 0 : 1, 0, depthIsZ ? 1 : 0), screenSpacePosition, depthIsZ, forwardSign, false, false, QueryOptions.None, out queryResult));
            }
            else
            {
                return(this.OffsetInstanceAt(emplacement.GetOffset(depthIsZ ? 0 : -1, 0, depthIsZ ? -1 : 0), screenSpacePosition, depthIsZ, forwardSign, false, false, QueryOptions.None, out queryResult));
            }
        }
Example #8
0
    public void RemoveTrile(TrileEmplacement atPos)
    {
        if (!loaded.Triles.ContainsKey(atPos))
        {
            return;
        }
        loaded.Triles.Remove(atPos);

        CacheTrile(trileObjects[atPos]);
        trileObjects.Remove(atPos);

        TrileEmplacement[] checkPos = new TrileEmplacement[6];

        checkPos[0] = new TrileEmplacement(atPos.X, atPos.Y, atPos.Z + 1);
        checkPos[1] = new TrileEmplacement(atPos.X, atPos.Y, atPos.Z - 1);

        checkPos[2] = new TrileEmplacement(atPos.X, atPos.Y + 1, atPos.Z);
        checkPos[3] = new TrileEmplacement(atPos.X, atPos.Y - 1, atPos.Z);

        checkPos[4] = new TrileEmplacement(atPos.X + 1, atPos.Y, atPos.Z);
        checkPos[5] = new TrileEmplacement(atPos.X - 1, atPos.Y, atPos.Z);

        foreach (TrileEmplacement t in checkPos)
        {
            GenerateTrile(t);
        }
    }
Example #9
0
        private void FillScreenSpaceTile(Point p, IDictionary <Point, Limit> newLimits)
        {
            Vector3 vector3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            bool    flag1   = (double)vector3.Z != 0.0;
            bool    flag2   = flag1;
            int     num1    = flag1 ? (int)vector3.Z : (int)vector3.X;
            float   num2    = (float)(((flag1 ? (double)this.Size.Z : (double)this.Size.X) - 1.0) / 2.0);
            int     num3    = (int)((double)num2 + (double)num1 * (double)num2) + num1;
            Limit   limit   = new Limit()
            {
                Start    = (int)((double)num2 - (double)num1 * (double)num2),
                End      = num3,
                NoOffset = true
            };
            TrileEmplacement key   = new TrileEmplacement(flag2 ? p.X : limit.Start, p.Y, flag1 ? limit.Start : p.X);
            bool             flag3 = true;
            bool             flag4 = false;

            while (flag3)
            {
                TrileInstance trileInstance;
                if (this.Triles.TryGetValue(key, out trileInstance))
                {
                    // ISSUE: explicit reference operation
                    // ISSUE: variable of a reference type
                    Limit& local = @limit;
                    // ISSUE: explicit reference operation
                    int num4 = (^ local).NoOffset & trileInstance.Position == trileInstance.Emplacement.AsVector ? 1 : 0;
                    // ISSUE: explicit reference operation
                    (^ local).NoOffset = num4 != 0;
                    int num5 = flag1 ? key.Z : key.X;
                    if (!flag4)
                    {
                        limit.Start = num5;
                        flag4       = true;
                    }
                    limit.End = num5;
                }
                if (flag1)
                {
                    key.Z += num1;
                    flag3  = key.Z != num3;
                }
                else
                {
                    key.X += num1;
                    flag3  = key.X != num3;
                }
            }
            if (limit.End == num3)
            {
                return;
            }
            if (newLimits.ContainsKey(p))
            {
                newLimits.Remove(p);
            }
            newLimits.Add(p, limit);
        }
Example #10
0
 public static Vector3 ToVector(this TrileEmplacement e)
 {
     return(new Vector3(
                e.X,
                e.Y,
                e.Z
                ));
 }
Example #11
0
        protected override void Begin()
        {
            if (this.DotManager.Owner == this)
            {
                this.DotManager.Burrow();
            }
            IPlayerManager playerManager = this.PlayerManager;
            Vector3        vector3       = playerManager.Velocity * Vector3.UnitY;

            playerManager.Velocity = vector3;
            this.PlayerManager.LookingDirection = HorizontalDirection.Right;
            this.GameState.SaveData.ThisLevel.InactiveTriles.Add(this.doorBottom.Emplacement);
            this.doorBottom.ActorSettings.Inactive = true;
            TrileEmplacement id1 = this.doorBottom.Emplacement + Vector3.UnitY;

            this.doorTop         = this.LevelManager.TrileInstanceAt(ref id1);
            this.sinceOpened     = TimeSpan.FromSeconds(-1.0);
            this.initialPhi      = this.doorBottom.Phi;
            this.initialPosition = this.doorBottom.Position;
            if (this.doorBottom.Trile.ActorSettings.Type == ActorType.Door)
            {
                ++this.GameState.SaveData.ThisLevel.FilledConditions.LockedDoorCount;
                if (this.doorTop.Trile.ActorSettings.Type == ActorType.Door)
                {
                    ++this.GameState.SaveData.ThisLevel.FilledConditions.LockedDoorCount;
                }
                --this.GameState.SaveData.Keys;
                this.GameState.OnHudElementChanged();
            }
            else
            {
                ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                if (this.doorTop.Trile.ActorSettings.Type == ActorType.UnlockedDoor)
                {
                    ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                }
            }
            TrileEmplacement id2 = this.doorBottom.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint);

            this.holeBottom = this.LevelManager.TrileInstanceAt(ref id2);
            TrileEmplacement id3 = this.doorTop.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint);

            this.holeTop    = this.LevelManager.TrileInstanceAt(ref id3);
            id3             = this.doorBottom.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f;
            this.tempBottom = this.LevelManager.TrileInstanceAt(ref id3);
            id3             = this.doorTop.Emplacement + FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f;
            this.tempTop    = this.LevelManager.TrileInstanceAt(ref id3);
            if (this.tempBottom != null)
            {
                this.LevelManager.ClearTrile(this.tempBottom);
            }
            if (this.tempTop != null)
            {
                this.LevelManager.ClearTrile(this.tempTop);
            }
            SoundEffectExtensions.EmitAt(this.turnSound, this.PlayerManager.Position);
        }
Example #12
0
        public void RecullAt(TrileEmplacement emplacement)
        {
            Viewpoint viewpoint = this.CameraManager.Viewpoint;

            if (!FezMath.IsOrthographic(viewpoint))
            {
                return;
            }
            this.RecullAt(new Point(FezMath.SideMask(viewpoint) == Vector3.Right ? emplacement.X : emplacement.Z, emplacement.Y));
        }
Example #13
0
    public void MoveTrile(TrileEmplacement from, TrileEmplacement to, TrileInstance move)
    {
        Debug.Log("Removing " + new Vector3(from.X, from.Y, from.Z) + " from triles");
        loaded.Triles.Remove(from);
        loaded.Triles.Add(to, move);

        //Update the culling of the triles around the position we came from and moved to.
        UpdateCulling(from);
        UpdateCulling(to);
    }
Example #14
0
            private void StartCrumbling()
            {
                SoundEffectExtensions.EmitAt(this.Host.sCrumble, this.OriginalCenter, RandomHelper.Centered(0.00999999977648258));
                Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint);
                Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
                bool    flag1     = (double)vector3_1.X != 0.0;
                bool    flag2     = flag1;
                int     num       = flag2 ? (int)vector3_2.Z : (int)vector3_2.X;
                Point   key       = new Point(flag1 ? this.Instance.Emplacement.X : this.Instance.Emplacement.Z, this.Instance.Emplacement.Y);

                this.LevelManager.WaitForScreenInvalidation();
                Limit limit;

                if (this.LevelManager.ScreenSpaceLimits.TryGetValue(key, out limit))
                {
                    limit.End += num;
                    TrileEmplacement id = new TrileEmplacement(flag1 ? key.X : limit.Start, key.Y, flag2 ? limit.Start : key.X);
                    while ((flag2 ? id.Z : id.X) != limit.End)
                    {
                        TrileInstance toRemove = this.LevelManager.TrileInstanceAt(ref id);
                        if (toRemove != null && !toRemove.Hidden && toRemove.Trile.ActorSettings.Type == ActorType.Crumbler)
                        {
                            toRemove.Hidden = true;
                            this.LevelMaterializer.CullInstanceOut(toRemove);
                            this.InstancesToClear.Add(toRemove);
                            ITrixelParticleSystems      particleSystems = this.ParticleSystems;
                            CrumblersHost.CrumblerState crumblerState   = this;
                            Game game = ServiceHelper.Game;
                            TrixelParticleSystem.Settings settings = new TrixelParticleSystem.Settings()
                            {
                                BaseVelocity      = Vector3.Zero,
                                Energy            = 0.1f,
                                ParticleCount     = (int)(20.0 / (double)this.InstancesToClear.Count),
                                GravityModifier   = 0.6f,
                                Crumble           = true,
                                ExplodingInstance = toRemove
                            };
                            TrixelParticleSystem trixelParticleSystem1;
                            TrixelParticleSystem trixelParticleSystem2 = trixelParticleSystem1 = new TrixelParticleSystem(game, settings);
                            crumblerState.System = trixelParticleSystem1;
                            TrixelParticleSystem system = trixelParticleSystem2;
                            particleSystems.Add(system);
                        }
                        if (flag2)
                        {
                            id.Z += num;
                        }
                        else
                        {
                            id.X += num;
                        }
                    }
                }
                Waiters.Wait(1.0, new Action(this.ClearTriles)).AutoPause = true;
            }
Example #15
0
    public void RemoveTrile(TrileEmplacement trilePos)
    {
        if (!loaded.Triles.ContainsKey(trilePos))
        {
            return;
        }
        loaded.Triles.Remove(trilePos);

        Destroy(trileObjects[trilePos]);
        trileObjects.Remove(trilePos);
    }
Example #16
0
    public void RegenTrile(TrileEmplacement trilePos)
    {
        if (loaded.Triles.ContainsKey(trilePos))
        {
            return;
        }

        GameObject genTrile = NewTrileObject(trilePos);

        UpdateCulling(trilePos);
    }
Example #17
0
    GameObject NewTrileObject(TrileEmplacement atPos)
    {
        TrileInstance instance;

        if (loaded.Triles.ContainsKey(atPos))
        {
            instance = loaded.Triles[atPos];
        }
        else
        {
            instance          = new TrileInstance();
            instance.TrileId  = currTrileID;
            instance.Position = new Vector3(atPos.X, atPos.Y, atPos.Z);
            loaded.Triles.Add(atPos, instance);
        }

        GameObject newTrile;

        if (trileObjectCache.Count > 0)
        {
            newTrile = trileObjectCache[0];
            trileObjectCache.RemoveAt(0);
            newTrile.SetActive(true);
        }
        else
        {
            newTrile = Instantiate(trilePrefab);
        }

        MeshFilter    mf = newTrile.GetComponent <MeshFilter>();
        MeshRenderer  mr = newTrile.GetComponent <MeshRenderer>();
        BoxCollider   bc = newTrile.GetComponent <BoxCollider>();
        TrileImported tI = newTrile.GetComponent <TrileImported>();

        tI.myInstance = instance;

        mr.material = setMat;
        mf.mesh     = trilesetCache[s.Triles[instance.TrileId]];

        newTrile.transform.position = new Vector3(atPos.X, atPos.Y, atPos.Z);
        newTrile.transform.rotation = Quaternion.Euler(0, Mathf.Rad2Deg * instance.Data.PositionPhi.w, 0);

        newTrile.name             = s.Triles[instance.TrileId].Name;
        newTrile.transform.parent = transform.FindChild("Triles");
        if (!trileObjects.ContainsKey(atPos))
        {
            trileObjects.Add(atPos, newTrile);
        }
        else
        {
            trileObjects[atPos] = newTrile;
        }
        return(newTrile);
    }
Example #18
0
        public bool IsBorderTrile(ref TrileEmplacement id)
        {
            bool flag = false;

            for (int index = 0; index < 6 && !flag; ++index)
            {
                FaceOrientation face = (FaceOrientation)index;
                flag = flag | this.IsBorderTrileFace(ref id, ref face);
            }
            return(flag);
        }
Example #19
0
        public TrileInstance TrileInstanceAt(ref TrileEmplacement id)
        {
            TrileInstance trileInstance;

            if (!this.Triles.TryGetValue(id, out trileInstance))
            {
                return((TrileInstance)null);
            }
            else
            {
                return(trileInstance);
            }
        }
Example #20
0
        public bool IsBorderTrileFace(ref TrileEmplacement id, ref FaceOrientation face)
        {
            TrileInstance trileInstance;

            if (this.levelData.Triles.TryGetValue(id.GetTraversal(ref face), out trileInstance) && !trileInstance.Trile.SeeThrough)
            {
                return(trileInstance.ForceSeeThrough);
            }
            else
            {
                return(true);
            }
        }
Example #21
0
        public bool IsInRange(ref TrileEmplacement id)
        {
            Vector3 size = this.levelData.Size;

            if (id.X >= 0 && (double)id.X < (double)size.X && (id.Y >= 0 && (double)id.Y < (double)size.Y) && id.Z >= 0)
            {
                return((double)id.Z < (double)size.Z);
            }
            else
            {
                return(false);
            }
        }
Example #22
0
        private bool NoTop(TrileInstance instance)
        {
            FaceOrientation  face          = FaceOrientation.Top;
            TrileEmplacement traversal     = instance.Emplacement.GetTraversal(ref face);
            TrileInstance    trileInstance = this.LevelManager.TrileInstanceAt(ref traversal);

            if (trileInstance != null && trileInstance.Enabled)
            {
                return(trileInstance.Trile.Immaterial);
            }
            else
            {
                return(true);
            }
        }
Example #23
0
        private void DestroyNeighborhood(TrileInstance instance, BombsHost.BombState state)
        {
            Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint);
            Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            bool    flag1     = (double)vector3_1.X != 0.0;
            bool    flag2     = flag1;
            int     num       = flag2 ? (int)vector3_2.Z : (int)vector3_2.X;
            Point   point1    = new Point(flag1 ? instance.Emplacement.X : instance.Emplacement.Z, instance.Emplacement.Y);

            Point[] pointArray = instance.Trile.ActorSettings.Type == ActorType.BigBomb ? BombsHost.BigBombOffsets : BombsHost.SmallBombOffsets;
            this.LevelManager.WaitForScreenInvalidation();
            foreach (Point point2 in pointArray)
            {
                bool  chainsploded = false;
                bool  needsRecull  = false;
                Point key          = new Point(point1.X + point2.X, point1.Y + point2.Y);
                Limit limit;
                if (this.LevelManager.ScreenSpaceLimits.TryGetValue(key, out limit))
                {
                    limit.End += num;
                    TrileEmplacement id = new TrileEmplacement(flag1 ? key.X : limit.Start, key.Y, flag2 ? limit.Start : key.X);
                    while ((flag2 ? id.Z : id.X) != limit.End)
                    {
                        TrileInstance nearestNeighbor = this.LevelManager.TrileInstanceAt(ref id);
                        if (!this.TryExplodeAt(state, nearestNeighbor, ref chainsploded, ref needsRecull))
                        {
                            if (flag2)
                            {
                                id.Z += num;
                            }
                            else
                            {
                                id.X += num;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (needsRecull)
                    {
                        this.LevelManager.RecullAt(id);
                        this.TrixelParticleSystems.UnGroundAll();
                    }
                }
            }
        }
Example #24
0
        public bool IsCornerTrile(ref TrileEmplacement id, ref FaceOrientation face1, ref FaceOrientation face2)
        {
            TrileInstance trileInstance;

            if (!this.levelData.Triles.TryGetValue(id.GetTraversal(ref face1), out trileInstance) || trileInstance.Trile.SeeThrough || trileInstance.ForceSeeThrough)
            {
                return(true);
            }
            TrileEmplacement traversal = id.GetTraversal(ref face2);

            if (!this.levelData.Triles.TryGetValue(traversal, out trileInstance) || trileInstance.Trile.SeeThrough || trileInstance.ForceSeeThrough)
            {
                return(true);
            }
            traversal = traversal.GetTraversal(ref face1);
            return(!this.levelData.Triles.TryGetValue(traversal, out trileInstance) || trileInstance.Trile.SeeThrough || trileInstance.ForceSeeThrough);
        }
Example #25
0
    void UpdateCulling(TrileEmplacement around)
    {
        TrileEmplacement[] checkPos = new TrileEmplacement[6];

        checkPos[0] = new TrileEmplacement(around.X, around.Y, around.Z + 1);
        checkPos[1] = new TrileEmplacement(around.X, around.Y, around.Z - 1);

        checkPos[2] = new TrileEmplacement(around.X, around.Y + 1, around.Z);
        checkPos[3] = new TrileEmplacement(around.X, around.Y - 1, around.Z);

        checkPos[4] = new TrileEmplacement(around.X + 1, around.Y, around.Z);
        checkPos[5] = new TrileEmplacement(around.X - 1, around.Y, around.Z);

        foreach (TrileEmplacement t in checkPos)
        {
            GenerateTrile(t);
        }
    }
Example #26
0
 public override void Initialize()
 {
     this.LevelManager.LevelChanging += (Action)(() =>
     {
         bool local_0 = false;
         foreach (TrileEmplacement item_0 in this.GameState.SaveData.ThisLevel.InactiveTriles)
         {
             TrileEmplacement local_2 = item_0;
             TrileInstance bottom = this.LevelManager.TrileInstanceAt(ref local_2);
             if (bottom != null && ActorTypeExtensions.IsDoor(bottom.Trile.ActorSettings.Type))
             {
                 local_2 = bottom.Emplacement + Vector3.UnitY;
                 TrileInstance local_3 = this.LevelManager.TrileInstanceAt(ref local_2);
                 ArtObjectInstance local_4;
                 TrileGroup group;
                 if ((group = Enumerable.FirstOrDefault <TrileGroup>((IEnumerable <TrileGroup>) this.LevelManager.Groups.Values, (Func <TrileGroup, bool>)(x => x.Triles.Contains(bottom)))) != null && (local_4 = Enumerable.FirstOrDefault <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x =>
                 {
                     int?local_0 = x.ActorSettings.AttachedGroup;
                     int local_1 = group.Id;
                     if (local_0.GetValueOrDefault() == local_1)
                     {
                         return(local_0.HasValue);
                     }
                     else
                     {
                         return(false);
                     }
                 }))) != null)
                 {
                     this.LevelManager.RemoveArtObject(local_4);
                 }
                 this.LevelManager.ClearTrile(bottom);
                 this.LevelManager.ClearTrile(local_3);
                 local_0 = true;
             }
         }
         if (!local_0 || this.GameState.FarawaySettings.InTransition)
         {
             return;
         }
         this.LevelMaterializer.CullInstances();
     });
     base.Initialize();
 }
Example #27
0
 public void UpdateInstance(TrileInstance instance)
 {
     if (FezMath.Round(instance.LastUpdatePosition) != FezMath.Round(instance.Position))
     {
         TrileEmplacement trileEmplacement = new TrileEmplacement(instance.LastUpdatePosition);
         TrileInstance    trileInstance;
         TrileInstance    instance1;
         if (this.Triles.TryGetValue(trileEmplacement, out trileInstance))
         {
             if (trileInstance == instance)
             {
                 this.Triles.Remove(trileEmplacement);
                 if (instance.Overlaps)
                 {
                     instance1 = instance.PopOverlap();
                     this.AddInstance(trileEmplacement, instance1);
                 }
             }
             else if (trileInstance.Overlaps && trileInstance.OverlappedTriles.Contains(instance))
             {
                 trileInstance.OverlappedTriles.Remove(instance);
             }
         }
         if (this.Triles.TryGetValue(instance.Emplacement, out instance1))
         {
             instance.PushOverlap(instance1);
             this.Triles.Remove(instance.Emplacement);
         }
         this.LevelMaterializer.UpdateInstance(instance);
         this.Triles.Add(instance.Emplacement, instance);
         instance.Update();
         this.LevelMaterializer.UpdateRow(trileEmplacement, instance);
         if (!this.IsInvalidatingScreen)
         {
             this.InvalidateScreenSpaceTile(trileEmplacement);
             this.InvalidateScreenSpaceTile(instance.Emplacement);
         }
     }
     if (instance.InstanceId == -1)
     {
         return;
     }
     this.LevelMaterializer.GetTrileMaterializer(instance.VisualTrile).UpdateInstance(instance);
 }
Example #28
0
            private void AddSupportedTrilesOver(TrileInstance instance)
            {
                TrileEmplacement id        = new TrileEmplacement(instance.Emplacement.X, instance.Emplacement.Y + 1, instance.Emplacement.Z);
                TrileInstance    instance1 = this.LevelManager.TrileInstanceAt(ref id);

                if (instance1 == null)
                {
                    return;
                }
                this.AddSupportedTrile(instance1);
                if (!instance1.Overlaps)
                {
                    return;
                }
                foreach (TrileInstance instance2 in instance1.OverlappedTriles)
                {
                    this.AddSupportedTrile(instance2);
                }
            }
    public bool IsHidden(TrileEmplacement te_, int d = 0)
    {
        if (d == 0)
        {
            d = DefaultTrileVisibilityDepth;
        }

        for (int x = -d; x <= d; x++)
        {
            for (int y = -d; y <= d; y++)
            {
                for (int z = -d; z <= d; z++)
                {
                    if (x == 0 && y == 0 && z == 0)
                    {
                        continue;
                    }

                    TrileEmplacement te = new TrileEmplacement(
                        te_.X + x,
                        te_.Y + y,
                        te_.Z + z
                        );
                    TrileInstance trile;
                    if (!Level.Triles.TryGetValue(te, out trile) || trile.TrileId == -1)
                    {
                        return(false);
                    }
                    SetTrileInInstance(trile);
                    if (trile.ForceSeeThrough || trile.Trile.SeeThrough || trile.Trile.Thin)
                    {
                        return(false);
                    }
                }
            }
        }

        return(true);
    }
Example #30
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            LevelManager.Instance.LoadLevel();
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit rh;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out rh))
            {
                Debug.DrawLine(rh.point, transform.position, Color.red, 15f);

                TrileEmplacement place = new TrileEmplacement((int)rh.transform.position.x, (int)rh.transform.position.y, (int)rh.transform.position.z);
                LevelManager.Instance.RemoveTrile(place);
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            RaycastHit rh;

            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out rh))
            {
                Debug.DrawLine(rh.point, transform.position, Color.green, 15f);

                TrileEmplacement place = new TrileEmplacement((int)(rh.transform.position.x + rh.normal.x), (int)(rh.transform.position.y + rh.normal.y), (int)(rh.transform.position.z + rh.normal.z));
                LevelManager.Instance.AddTrile(place);
            }
        }
    }