Exemple #1
0
 private void CorrectWallOverlap(bool overcompensate)
 {
     foreach (PointCollision pointCollision in this.PlayerManager.CornerCollision)
     {
         TrileInstance trileInstance = pointCollision.Instances.Deep;
         if (trileInstance != null && trileInstance != this.PlayerManager.CarriedInstance && trileInstance.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.AllSides)
         {
             Vector3 vector = (pointCollision.Point - trileInstance.Center + FezMath.Sign(this.PlayerManager.Position - pointCollision.Point) * trileInstance.TransformedSize / 2f) * FezMath.SideMask(this.CameraManager.Viewpoint);
             this.PlayerManager.Position -= vector;
             if (overcompensate)
             {
                 this.PlayerManager.Position -= FezMath.Sign(vector) * (1.0 / 1000.0) * 2f;
             }
             if (!(FezMath.Sign(this.PlayerManager.Velocity) == FezMath.Sign(vector)))
             {
                 break;
             }
             Vector3 vector3_1 = FezMath.Abs(FezMath.Sign(vector));
             this.PlayerManager.Position -= this.PlayerManager.Velocity * vector3_1;
             IPlayerManager playerManager = this.PlayerManager;
             Vector3        vector3_2     = playerManager.Velocity * (Vector3.One - vector3_1);
             playerManager.Velocity = vector3_2;
             break;
         }
     }
 }
Exemple #2
0
            private static bool TestFace(ICollection <TrixelEmplacement> subChunk, ICollection <TrixelEmplacement> boxTrixels, Vector3 normal, bool partial, TrixelCluster.Box box, ref int trixelsToRollback)
            {
                Vector3 vector3_1 = FezMath.Abs(normal);
                Vector3 vector2_1 = (double)normal.Z != 0.0 ? Vector3.UnitX : Vector3.UnitZ;
                Vector3 vector2_2 = (double)normal.Z != 0.0 ? Vector3.UnitY : new Vector3(1f, 1f, 0.0f) - vector3_1;
                Vector3 vector3_2 = ((double)Vector3.Dot(normal, Vector3.One) > 0.0 ? box.End.Position : box.Start.Position) * vector3_1;
                int     num1      = (int)Vector3.Dot(box.Start.Position, vector2_1);
                int     num2      = (int)Vector3.Dot(box.End.Position, vector2_1);
                int     num3      = (int)Vector3.Dot(box.Start.Position, vector2_2);
                int     num4      = (int)Vector3.Dot(box.End.Position, vector2_2);

                if (partial)
                {
                    ++num1;
                    --num2;
                }
                for (int index1 = num1; index1 <= num2; ++index1)
                {
                    for (int index2 = num3; index2 <= num4; ++index2)
                    {
                        TrixelEmplacement trixelEmplacement = new TrixelEmplacement((float)index1 * vector2_1 + (float)index2 * vector2_2 + vector3_2);
                        if (!subChunk.Contains(trixelEmplacement))
                        {
                            return(false);
                        }
                        ++trixelsToRollback;
                        boxTrixels.Add(trixelEmplacement);
                    }
                }
                return(true);
            }
Exemple #3
0
            public bool Update(TimeSpan elapsed)
            {
                this.SinceChanged += elapsed;
                switch (this.State)
                {
                case SpinAction.Idle:
                    Vector3 vector = (this.PlayerManager.Position - this.ArtObject.Position - new Vector3(0.0f, 1f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
                    vector.X += vector.Z;
                    Vector3 vector3 = FezMath.Abs(vector);
                    if (FezMath.AlmostEqual(FezMath.Abs(Vector3.Transform(Vector3.UnitZ, this.ArtObject.Rotation)), FezMath.DepthMask(this.CameraManager.Viewpoint)) && ((double)vector3.X < 0.899999976158142 && (double)vector3.Y < 1.0) && (this.PlayerManager.CarriedInstance == null && this.PlayerManager.Grounded) && (this.PlayerManager.Action != ActionType.GrabTombstone && this.InputManager.GrabThrow == FezButtonState.Pressed && this.PlayerManager.Action != ActionType.ReadingSign))
                    {
                        this.SinceChanged = TimeSpan.Zero;
                        return(true);
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Spinning:
                    double     num           = FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.75);
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, Easing.EaseIn(num < 0.949999999254942 ? num / 0.949999999254942 : 1.0 + Math.Sin((num - 0.949999999254942) / 0.0500000007450581 * 6.28318548202515 * 2.0) * 0.00999999977648258 * (1.0 - num) / 0.0500000007450581, EasingType.Linear) * 1.570796f * (float)this.SpinSign);
                    this.ArtObject.Rotation     = this.OriginalAoRotation * fromAxisAngle;
                    this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - this.ArtObject.Position, fromAxisAngle) + this.ArtObject.Position;
                    if (this.SinceChanged.TotalSeconds >= 0.75)
                    {
                        this.LastViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.ArtObject.Rotation))));
                        int count = Enumerable.Count <TombstonesHost.TombstoneState>((IEnumerable <TombstonesHost.TombstoneState>) this.Host.TrackedStones, (Func <TombstonesHost.TombstoneState, bool>)(x => x.LastViewpoint == this.LastViewpoint));
                        this.TombstoneService.UpdateAlignCount(count);
                        if (count > 1)
                        {
                            this.TombstoneService.OnMoreThanOneAligned();
                        }
                        this.Host.StopSkullRotations = count == 4;
                        this.PlayerManager.Action    = ActionType.GrabTombstone;
                        this.PlayerManager.Position += 0.5f * Vector3.UnitY;
                        this.PlayerManager.Velocity  = Vector3.Down;
                        this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                        this.SinceChanged -= TimeSpan.FromSeconds(0.75);
                        this.State         = SpinAction.Grabbed;
                        break;
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Grabbed:
                    if (this.PlayerManager.Action != ActionType.GrabTombstone)
                    {
                        this.State = SpinAction.Idle;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                return(false);
            }
Exemple #4
0
        private static Vector3 SolidCollision(Vector3 normal, TrileInstance instance, Vector3 origin, Vector3 destination, Vector3 impulse, float elasticity)
        {
            Vector3 vector3_1 = instance.TransformedSize / 2f;
            Vector3 vector3_2 = instance.Center + vector3_1 * normal;
            Vector3 vector3_3 = Vector3.Zero;
            Vector3 vector3_4;

            if (instance.PhysicsState != null)
            {
                Vector3 vector3_5 = instance.PhysicsState.Sticky ? FezMath.XZMask : Vector3.One;
                vector3_4 = instance.Center - instance.PhysicsState.Velocity * vector3_5 + vector3_1 * normal;
                vector3_3 = vector3_2 - vector3_4;
            }
            else
            {
                vector3_4 = vector3_2;
            }
            Vector3 a1 = origin - vector3_4;
            Vector3 a2 = destination - vector3_2;

            if ((double)FezMath.AlmostClamp(FezMath.Dot(a1, normal)) < 0.0 || (double)FezMath.AlmostClamp(FezMath.Dot(a2, normal)) > 0.0)
            {
                return(Vector3.Zero);
            }
            Vector3 vector3_6 = FezMath.Abs(normal);

            return((double)elasticity <= 0.0 ? (vector3_2 - destination) * vector3_6 : (vector3_3 - impulse) * vector3_6 * (1f + elasticity));
        }
Exemple #5
0
 public override void Draw(GameTime gameTime)
 {
     if (this.EngineState.Loading || this.EngineState.InMap)
     {
         return;
     }
     GraphicsDeviceExtensions.PrepareStencilWrite(this.GraphicsDevice, new StencilMask?(StencilMask.FarawayPlaces));
     this.ThisLevelMesh.Draw();
     lock (FarawayPlaceHost.FarawayWaterMutex)
     {
         if (this.FarawayWaterMesh != null)
         {
             this.FarawayWaterMesh.Draw();
             Vector3 local_0 = this.FarawayWaterMesh.Position;
             Vector3 local_1 = this.FarawayWaterMesh.Scale;
             this.FarawayWaterMesh.Blending     = new BlendingMode?(BlendingMode.Alphablending);
             this.FarawayWaterMesh.SamplerState = SamplerState.LinearClamp;
             this.FarawayWaterMesh.Texture      = (Dirtyable <Texture>)((Texture)this.HorizontalGradientTex);
             this.FarawayWaterMesh.Position    -= Math.Abs(this.FarawayWaterMesh.Groups[0].Scale.X) * this.waterRightVector;
             this.FarawayWaterMesh.Draw();
             this.FarawayWaterMesh.Scale     = FezMath.Abs(this.waterRightVector) * -1f + Vector3.One - FezMath.Abs(this.waterRightVector);
             this.FarawayWaterMesh.Culling   = CullMode.CullClockwiseFace;
             this.FarawayWaterMesh.Position += Math.Abs(this.FarawayWaterMesh.Groups[0].Scale.X) * this.waterRightVector * 2f;
             this.FarawayWaterMesh.Draw();
             this.FarawayWaterMesh.Culling  = CullMode.CullCounterClockwiseFace;
             this.FarawayWaterMesh.Position = local_0;
             this.FarawayWaterMesh.Scale    = local_1;
             this.FarawayWaterMesh.Texture  = (Dirtyable <Texture>)null;
         }
     }
     GraphicsDeviceExtensions.PrepareStencilRead(this.GraphicsDevice, CompareFunction.Always, StencilMask.None);
 }
Exemple #6
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;
                    }
                }
            }
Exemple #7
0
        private Vector3 GetDestination()
        {
            TrileInstance pushedInstance = this.PlayerManager.PushedInstance;
            Vector3       vector         = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection);
            Vector3       vector3_1      = FezMath.Abs(vector);
            Vector3       vector3_2      = FezMath.DepthMask(this.CameraManager.Viewpoint);

            return((pushedInstance.Center * vector3_1 + this.PlayerManager.Position * vector3_2) * FezMath.XZMask + -pushedInstance.TransformedSize / 2f * vector + -7.0 / 16.0 * vector + this.PlayerManager.Position * Vector3.UnitY);
        }
Exemple #8
0
        public void UpdateBounds()
        {
            if (!this.boundsDirty)
            {
                return;
            }
            Vector3 vector3 = FezMath.Abs(Vector3.Transform(this.Size / 2f * this.scale, this.rotation));

            this.Bounds      = FezMath.Enclose(this.position - vector3, this.position + vector3);
            this.boundsDirty = false;
        }
Exemple #9
0
        public void RebuildParts()
        {
            this.Dirty = false;
            this.RectangularParts.Clear();
            Queue <HashSet <TrixelEmplacement> > queue = new Queue <HashSet <TrixelEmplacement> >();

            if (this.Trixels.Count > 0)
            {
                queue.Enqueue(new HashSet <TrixelEmplacement>((IEnumerable <TrixelEmplacement>) this.Trixels));
            }
            while (queue.Count > 0)
            {
                HashSet <TrixelEmplacement> hashSet1 = queue.Dequeue();
                TrixelEmplacement           center   = new TrixelEmplacement();
                foreach (TrixelEmplacement trixelEmplacement in hashSet1)
                {
                    center.Position += trixelEmplacement.Position;
                }
                center.Position = FezMath.Floor(center.Position / (float)hashSet1.Count);
                if ((double)Vector3.Dot(center.Position, this.normal) != (double)this.depth)
                {
                    center.Position = center.Position * (Vector3.One - FezMath.Abs(this.normal)) + (float)this.depth * this.normal;
                }
                if (!hashSet1.Contains(center))
                {
                    center = this.FindNearestTrixel(center, (ICollection <TrixelEmplacement>)hashSet1);
                }
                Rectangle rectangle;
                List <TrixelEmplacement> biggestRectangle = this.FindBiggestRectangle(center, (ICollection <TrixelEmplacement>)hashSet1, out rectangle);
                rectangle.Offset((int)Vector3.Dot(center.Position, this.Tangent), (int)Vector3.Dot(center.Position, this.Bitangent));
                this.RectangularParts.Add(new RectangularTrixelSurfacePart()
                {
                    Orientation   = this.Orientation,
                    Start         = new TrixelEmplacement((float)rectangle.X * this.Tangent + (float)rectangle.Y * this.Bitangent + (float)this.depth * this.normal),
                    TangentSize   = rectangle.Width,
                    BitangentSize = rectangle.Height
                });
                hashSet1.ExceptWith((IEnumerable <TrixelEmplacement>)biggestRectangle);
                while (hashSet1.Count > 0)
                {
                    HashSet <TrixelEmplacement> hashSet2 = this.TraverseSurface(Enumerable.First <TrixelEmplacement>((IEnumerable <TrixelEmplacement>)hashSet1), (ICollection <TrixelEmplacement>)hashSet1);
                    queue.Enqueue(hashSet2);
                    if (hashSet1.Count == hashSet2.Count)
                    {
                        hashSet1.Clear();
                    }
                    else
                    {
                        hashSet1.ExceptWith((IEnumerable <TrixelEmplacement>)hashSet2);
                    }
                }
            }
        }
Exemple #10
0
        private void DetermineIsClose()
        {
            this.close = false;
            if (!this.AoInstance.Visible || this.AoInstance.ActorSettings.Inactive || (this.CameraManager.Viewpoint != this.ExpectedViewpoint || this.PlayerManager.Background))
            {
                return;
            }
            Vector3 vector3_1 = this.AoInstance.Position + Vector3.Transform(Vector3.Transform(new Vector3(0.0f, 0.0f, 1f), this.AoInstance.Rotation), this.AoInstance.Rotation);
            Vector3 vector3_2 = FezMath.Abs(vector3_1 - this.PlayerManager.Position) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

            this.close = (double)vector3_2.X + (double)vector3_2.Z < 2.0 && (double)vector3_2.Y < 2.0 && (double)FezMath.Dot(vector3_1 - this.PlayerManager.Position, FezMath.ForwardVector(this.CameraManager.Viewpoint)) >= 0.0;
        }
Exemple #11
0
        public override void Update(GameTime gameTime)
        {
            if (this.GameState.Loading || this.GameState.Paused || (this.GameState.InMap || !this.CameraManager.ActionRunning) || (this.Solved || this.CameraManager.ProjectionTransition || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)))
            {
                return;
            }
            this.SinceHit += gameTime.ElapsedGameTime;
            Vector3 vector = (this.PlayerManager.Position - this.BellAo.Position - new Vector3(0.0f, 1f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

            vector.X += vector.Z;
            Vector3 vector3_1 = FezMath.Abs(vector);

            if (this.InputManager.GrabThrow == FezButtonState.Pressed && ((double)vector3_1.X < 2.0 && (double)vector3_1.Y < 1.5) && (this.PlayerManager.CarriedInstance == null && this.PlayerManager.Grounded) && this.PlayerManager.Action != ActionType.ReadingSign)
            {
                if (this.wutex1 != null || this.wutex2 != null)
                {
                    if (this.stackedHits < 10)
                    {
                        ++this.stackedHits;
                    }
                }
                else
                {
                    this.PlayerManager.Action = ActionType.TurnToBell;
                    this.ScheduleTurnTo();
                }
            }
            if (this.wutex1 == null && this.wutex2 == null && this.stackedHits > 0)
            {
                this.ScheduleTurnTo();
                --this.stackedHits;
            }
            this.AngularVelocity *= MathHelper.Clamp((float)(0.995000004768372 - this.SinceHit.TotalSeconds * (1.0 / 400.0)), 0.0f, 1f);
            this.Angle           += this.AngularVelocity * 0.1f;
            this.AngularVelocity += -this.Angle * 0.01f;
            Vector3    scale;
            Quaternion rotation;
            Vector3    translation;

            (Matrix.CreateTranslation(0.0f, -3.5f, 0.0f) * Matrix.CreateFromYawPitchRoll(RandomHelper.Centered(FezMath.Saturate((3.0 - this.SinceHit.TotalSeconds) / 3.0) * 0.0125000001862645), this.Angle.X, this.Angle.Y) * Matrix.CreateTranslation(this.OriginalPosition.X, this.OriginalPosition.Y + 3.5f, this.OriginalPosition.Z)).Decompose(out scale, out rotation, out translation);
            this.BellAo.Position = translation;
            this.BellAo.Rotation = rotation;
            double             max           = FezMath.Saturate((1.5 - this.SinceHit.TotalSeconds) / 1.5) * 0.0750000029802322;
            IGameCameraManager cameraManager = this.CameraManager;
            Vector3            vector3_2     = cameraManager.InterpolatedCenter + new Vector3(RandomHelper.Between(-max, max), RandomHelper.Between(-max, max), RandomHelper.Between(-max, max));

            cameraManager.InterpolatedCenter = vector3_2;
        }
Exemple #12
0
        public override void Update(GameTime gameTime)
        {
            if (this.GameState.Paused || this.GameState.Loading || (this.GameState.InMap || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)))
            {
                return;
            }
            this.SinceChanged += gameTime.ElapsedGameTime;
            if (this.SinceChanged >= this.CurrentDuration)
            {
                ++this.CurrentIndex;
                if (this.CurrentIndex >= this.ArtObject.ActorSettings.VibrationPattern.Length || this.CurrentIndex < 0)
                {
                    this.CurrentIndex = 0;
                }
                this.SinceChanged -= this.CurrentDuration;
                this.CurrentSignal = this.ArtObject.ActorSettings.VibrationPattern.Length != 0 ? this.ArtObject.ActorSettings.VibrationPattern[this.CurrentIndex] : VibrationMotor.None;
            }
            float num = FezMath.Saturate(1f - FezMath.Saturate((FezMath.Abs((this.PlayerManager.Center - this.ArtObject.Position) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint)) - new Vector3(0.5f, 2f, 0.5f)) / 3f).Length());

            if (this.CurrentSignal == VibrationMotor.None)
            {
                this.eForkRumble.VolumeFactor      *= Math.Max((float)(1.0 - Math.Pow(this.SinceChanged.TotalSeconds / this.CurrentDuration.TotalSeconds, 4.0)), 0.75f);
                this.SoundManager.MusicVolumeFactor = (float)(1.0 - (double)num * 0.600000023841858 - (double)this.eForkRumble.VolumeFactor * 0.200000002980232);
            }
            else
            {
                this.eForkRumble.VolumeFactor       = num;
                this.eForkRumble.Pan                = this.CurrentSignal == VibrationMotor.RightHigh ? 1f : -1f;
                this.SoundManager.MusicVolumeFactor = (float)(1.0 - (double)num * 0.800000011920929);
                if ((double)num != 1.0)
                {
                    num *= 0.5f;
                }
                if (this.CurrentSignal == VibrationMotor.LeftLow)
                {
                    num *= 0.5f;
                }
                if ((double)num > 0.0)
                {
                    this.InputManager.ActiveGamepad.Vibrate(this.CurrentSignal, (double)num, this.CurrentDuration - this.SinceChanged, EasingType.None);
                }
                else
                {
                    this.Input.Clear();
                }
            }
        }
Exemple #13
0
 public override void Update(GameTime gameTime)
 {
     if (this.GameState.Loading)
     {
         return;
     }
     if (this.MoveUp)
     {
         if (this.eRumble == null)
         {
             this.eRumble = SoundEffectExtensions.EmitAt(this.sRumble, this.DoorAo.Position, true, 0.0f, 0.625f);
             Waiters.Wait(1.25, (Action)(() => this.eRumble.FadeOutAndDie(0.25f))).AutoPause = true;
         }
         this.DoMoveUp(gameTime.ElapsedGameTime);
     }
     else
     {
         if (!this.DoorAo.Visible || this.DoorAo.ActorSettings.Inactive || (this.CameraManager.Viewpoint != this.ExpectedViewpoint || this.PlayerManager.Background))
         {
             return;
         }
         Vector3 vector3 = FezMath.Abs(this.DoorAo.Position - this.PlayerManager.Position) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
         bool    b       = (double)vector3.X + (double)vector3.Z < 0.75 && (double)vector3.Y < 2.0 && (double)FezMath.Dot(this.DoorAo.Position - this.PlayerManager.Position, FezMath.ForwardVector(this.CameraManager.Viewpoint)) >= 0.0;
         float   opacity = this.GlowPlane.Opacity;
         this.GlowPlane.Opacity = MathHelper.Lerp(this.GlowPlane.Opacity, (float)FezMath.AsNumeric(b), 0.05f);
         if ((double)this.GlowPlane.Opacity > (double)opacity && (double)opacity > 0.100000001490116 && this.loop)
         {
             SoundEffectExtensions.EmitAt(this.sLightUp, this.DoorAo.Position);
             this.loop = false;
         }
         else if ((double)this.GlowPlane.Opacity < (double)opacity && !this.loop)
         {
             SoundEffectExtensions.EmitAt(this.sFadeOut, this.DoorAo.Position);
             this.loop = true;
         }
         if (!b || !this.PlayerManager.Grounded || this.InputManager.ExactUp != FezButtonState.Pressed)
         {
             return;
         }
         this.Open();
     }
 }
Exemple #14
0
        private bool LoopVisible()
        {
            if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint))
            {
                return(true);
            }
            Vector3         vector3_1   = FezMath.Abs(FezMath.RightVector(this.CameraManager.Viewpoint));
            BoundingFrustum frustum     = this.CameraManager.Frustum;
            BoundingBox     boundingBox = new BoundingBox()
            {
                Min =
                {
                    X = -frustum.Left.D * frustum.Left.DotNormal(vector3_1),
                    Y = -frustum.Bottom.D * frustum.Bottom.Normal.Y
                },
                Max =
                {
                    X = -frustum.Right.D * frustum.Right.DotNormal(vector3_1),
                    Y = -frustum.Top.D * frustum.Top.Normal.Y
                }
            };
            Vector3   vector3_2 = FezMath.Min(boundingBox.Min, boundingBox.Max);
            Vector3   vector3_3 = FezMath.Max(boundingBox.Min, boundingBox.Max);
            Rectangle rectangle = new Rectangle()
            {
                X      = (int)Math.Floor((double)vector3_2.X),
                Y      = (int)Math.Floor((double)vector3_2.Y),
                Width  = (int)Math.Ceiling((double)vector3_3.X - (double)vector3_2.X),
                Height = (int)Math.Ceiling((double)vector3_3.Y - (double)vector3_2.Y)
            };

            if (rectangle.Y >= 0)
            {
                return((double)(rectangle.Y + rectangle.Height) >= (double)this.LevelManager.Size.Y);
            }
            else
            {
                return(true);
            }
        }
Exemple #15
0
 protected override void Begin()
 {
     if (this.PlayerManager.CarriedInstance == null && this.PlayerManager.PushedInstance == null)
     {
         this.PlayerManager.Action = ActionType.Idle;
     }
     else
     {
         Vector3 vector    = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection);
         Vector3 mask      = FezMath.GetMask(FezMath.VisibleAxis(this.CameraManager.Viewpoint));
         Vector3 vector3_1 = FezMath.Abs(vector);
         if (this.PlayerManager.PushedInstance != null)
         {
             this.PlayerManager.CarriedInstance = this.PlayerManager.PushedInstance;
             this.PlayerManager.PushedInstance  = (TrileInstance)null;
         }
         TrileInstance carriedInstance = this.PlayerManager.CarriedInstance;
         TrileInstance first           = this.PlayerManager.Ground.First;
         Vector3       vector3_2       = carriedInstance.Center * vector3_1 + this.PlayerManager.Position * mask + (first.Center.Y + (float)((double)first.Trile.Size.Y / 2.0 + (double)carriedInstance.Trile.Size.Y / 2.0) * (float)Math.Sign(this.CollisionManager.GravityFactor)) * Vector3.UnitY;
         this.PlayerManager.CarriedInstance.PhysicsState.Center = vector3_2;
         this.PlayerManager.CarriedInstance.PhysicsState.UpdateInstance();
         this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - vector3_1) + vector3_2 * vector3_1 + -carriedInstance.TransformedSize / 2f * vector + -3.0 / 16.0 * vector;
         if (ActorTypeExtensions.IsHeavy(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type))
         {
             SoundEffectExtensions.EmitAt(this.liftHeavySound, this.PlayerManager.Position);
         }
         else
         {
             SoundEffectExtensions.EmitAt(this.liftLightSound, this.PlayerManager.Position);
         }
         this.GomezService.OnLiftObject();
         IPlayerManager playerManager = this.PlayerManager;
         Vector3        vector3_3     = playerManager.Velocity * Vector3.UnitY;
         playerManager.Velocity = vector3_3;
     }
 }
Exemple #16
0
        public PhysicsManager.WallHuggingResult HugWalls(IPhysicsEntity entity, bool determineBackground, bool postRotation, bool keepInFront)
        {
            Vector3 vector3_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint);

            if (!entity.Background)
            {
                vector3_1 = -vector3_1;
            }
            float num1 = 1.0 / 500.0;

            if (entity is ISimplePhysicsEntity)
            {
                num1 = 1.0 / 16.0;
            }
            PhysicsManager.WallHuggingResult wallHuggingResult = new PhysicsManager.WallHuggingResult();
            Vector3 vector3_2 = new Vector3();

            if (entity.Background && entity.Grounded)
            {
                return(wallHuggingResult);
            }
            foreach (PointCollision pointCollision in entity.CornerCollision)
            {
                TrileInstance trileInstance1 = (TrileInstance)null;
                if (this.IsHuggable(pointCollision.Instances.Surface, entity))
                {
                    FaceOrientation  face           = FaceOrientation.Down;
                    TrileEmplacement traversal      = pointCollision.Instances.Surface.Emplacement.GetTraversal(ref face);
                    TrileInstance    trileInstance2 = this.LevelManager.TrileInstanceAt(ref traversal);
                    if (trileInstance2 != null && trileInstance2.Enabled && trileInstance2.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None)
                    {
                        trileInstance1 = pointCollision.Instances.Surface;
                    }
                }
                if (trileInstance1 == null && this.IsHuggable(pointCollision.Instances.Deep, entity))
                {
                    trileInstance1 = pointCollision.Instances.Deep;
                }
                if (trileInstance1 != null && (!(entity is ISimplePhysicsEntity) || trileInstance1.PhysicsState == null || !trileInstance1.PhysicsState.Puppet) && trileInstance1.PhysicsState != entity)
                {
                    Vector3 vector3_3 = trileInstance1.Center + vector3_1 * trileInstance1.TransformedSize / 2f;
                    Vector3 vector1   = entity.Center - vector3_1 * entity.Size / 2f - vector3_3 + num1 * -vector3_1;
                    float   x         = Vector3.Dot(vector1, vector3_1);
                    if ((double)FezMath.AlmostClamp(x) < 0.0)
                    {
                        if (determineBackground && (!trileInstance1.Trile.Thin || trileInstance1.Trile.ForceHugging))
                        {
                            float num2 = Math.Abs(FezMath.Dot(trileInstance1.TransformedSize / 2f + entity.Size / 2f, vector3_1));
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            PhysicsManager.WallHuggingResult& local = @wallHuggingResult;
                            // ISSUE: explicit reference operation
                            int num3 = (^ local).Behind | (double)Math.Abs(x) > (double)num2 ? 1 : 0;
                            // ISSUE: explicit reference operation
                            (^ local).Behind = num3 != 0;
                        }
                        else if (keepInFront)
                        {
                            Vector3 vector3_4 = vector1 * FezMath.Abs(vector3_1);
                            vector3_2               -= vector3_4;
                            entity.Center           -= vector3_4;
                            wallHuggingResult.Hugged = true;
                        }
                    }
                }
                if (postRotation)
                {
                    Vector3       vector3_3 = FezMath.AsVector(FezMath.VisibleOrientation(this.CameraManager.LastViewpoint));
                    TrileInstance instance  = this.LevelManager.ActualInstanceAt(pointCollision.Point + vector3_2);
                    if (this.IsHuggable(instance, entity))
                    {
                        Vector3 vector3_4 = instance.Center + vector3_3 * FezMath.ZYX(instance.TransformedSize) / 2f;
                        Vector3 vector1   = entity.Center - vector3_3 * entity.Size / 2f - vector3_4 + 1.0 / 500.0 * vector3_3;
                        float   x         = Vector3.Dot(vector1, vector3_3);
                        if ((double)FezMath.AlmostClamp(x) < 0.0 && (double)x > -1.0 && keepInFront)
                        {
                            Vector3 vector3_5 = vector1 * FezMath.Abs(vector3_3);
                            vector3_2               -= vector3_5;
                            entity.Center           -= vector3_5;
                            wallHuggingResult.Hugged = true;
                        }
                    }
                }
            }
            return(wallHuggingResult);
        }
Exemple #17
0
        private void Fly(TimeSpan elapsed)
        {
            if (!this.flyRight.HasValue)
            {
                this.flyRight = new Vector3?(Vector3.Transform(Vector3.Right, this.Group.Rotation));
            }
            if ((!this.FlyingBack || this.Npc.ActorType != ActorType.Owl) && FezMath.AlmostEqual(FezMath.Dot(FezMath.Abs(Vector3.Transform(Vector3.Right, this.Group.Rotation)), FezMath.Abs(this.flyRight.Value)), 0.0f, 0.1f))
            {
                NpcState npcState  = this;
                Vector3? nullable1 = npcState.flyRight;
                Vector3  vector3   = Vector3.Transform(Vector3.Right, this.Group.Rotation);
                Vector3? nullable2 = nullable1.HasValue ? new Vector3?(nullable1.GetValueOrDefault() + vector3) : new Vector3?();
                npcState.flyRight = nullable2;
            }
            this.flySpeed = Vector2.Lerp(this.flySpeed, new Vector2(4f, 3f), 0.03333334f);
            Vector2 vector2 = this.flySpeed * ((1f - FezMath.Frac(this.CurrentTiming.Step + 0.75f)) * new Vector2(0.4f, 0.6f) + new Vector2(0.6f, 0.4f));

            this.Position += (float)elapsed.TotalSeconds * (vector2.X * this.flyRight.Value + Vector3.Up * vector2.Y * (this.FlyingBack ? -1f : 1f));
            if (FezMath.IsOrthographic(this.CameraManager.Viewpoint) && this.CameraManager.ViewTransitionReached)
            {
                Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint);
                if (this.InBackground)
                {
                    b *= -1f;
                }
                NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.Position, QueryOptions.Simple);
                TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep;
                if (trileInstance != null)
                {
                    Vector3 a       = trileInstance.Center + trileInstance.TransformedSize / 2f * -b;
                    Vector3 vector3 = FezMath.DepthMask(this.CameraManager.Viewpoint);
                    if ((double)FezMath.Dot(this.Position, b) > (double)FezMath.Dot(a, b))
                    {
                        this.Position = this.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + a * vector3 - b;
                    }
                }
            }
            if (this.CurrentTiming.Frame == 0 && this.lastFrame != 0)
            {
                SoundEffectExtensions.EmitAt(this.flySound, this.Position);
            }
            this.lastFrame = this.CurrentTiming.Frame;
            if (this.FlyingBack)
            {
                if ((double)this.Position.Y > (double)this.Npc.Position.Y)
                {
                    return;
                }
                this.Position      = this.Npc.Position;
                this.CurrentAction = NpcAction.Land;
                this.flySpeed      = Vector2.Zero;
                this.UpdateAction();
                this.FlyingBack = false;
                this.flyRight   = new Vector3?();
            }
            else
            {
                if (this.CameraManager.Frustum.Contains(new BoundingBox(this.Position - Vector3.One, this.Position + Vector3.One)) != ContainmentType.Disjoint)
                {
                    return;
                }
                if (this.MayComeBack)
                {
                    this.OwlInvisible  = true;
                    this.MayComeBack   = false;
                    this.CurrentAction = NpcAction.Idle;
                    this.flySpeed      = Vector2.Zero;
                    this.flyRight      = new Vector3?();
                    this.UpdateAction();
                }
                else
                {
                    ServiceHelper.RemoveComponent <NpcState>(this);
                }
            }
        }
Exemple #18
0
            public bool Update(TimeSpan elapsed)
            {
                if (this.MovingToHeight)
                {
                    return(false);
                }
                this.SinceChanged += elapsed;
                Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

                switch (this.State)
                {
                case SpinAction.Idle:
                    Vector3 vector = (this.PlayerManager.Position - this.ArtObject.Position - new Vector3(0.0f, 1f, 0.0f) + this.CenterOffset) * vector3_1;
                    vector.X += vector.Z;
                    Vector3 vector3_2 = FezMath.Abs(vector);
                    bool    flag      = this.IsBolt || this.IsTimeswitch ? (double)vector3_2.X > 0.75 && (double)vector3_2.X < 1.75 && (double)vector3_2.Y < 1.0 : (double)vector3_2.X < 1.0 && (double)vector3_2.Y < 1.0;
                    if (this.LevelManager.Flat)
                    {
                        flag = (double)vector3_2.X < 1.5 && (double)vector3_2.Y < 1.0;
                    }
                    if (flag && this.PlayerManager.CarriedInstance == null && (this.PlayerManager.Grounded && this.PlayerManager.Action != ActionType.GrabTombstone) && (this.InputManager.GrabThrow == FezButtonState.Pressed && this.PlayerManager.Action != ActionType.ReadingSign && (this.PlayerManager.Action != ActionType.Dying && this.PlayerManager.Action != ActionType.FreeFalling)))
                    {
                        Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
                        Vector3 vector3_4 = FezMath.DepthMask(this.CameraManager.Viewpoint);
                        Vector3 vector3_5 = (this.ArtObject.Position + this.CenterOffset) * vector3_4;
                        this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + vector3_4 * vector3_5 - vector3_3 * 1.5f;
                        this.SinceChanged           = TimeSpan.Zero;
                        return(true);
                    }
                    else if (this.IsTimeswitch && (double)this.ScrewHeight >= 0.0 && (double)this.ScrewHeight <= 2.0)
                    {
                        float num1 = (double)this.ArtObject.ActorSettings.TimeswitchWindBackSpeed == 0.0 ? 4f : this.ArtObject.ActorSettings.TimeswitchWindBackSpeed;
                        float num2 = (float)(elapsed.TotalSeconds / ((double)num1 - 0.25) * 2.0);
                        this.RewindSpeed = this.SinceChanged.TotalSeconds < 0.5 ? MathHelper.Lerp(0.0f, num2, (float)this.SinceChanged.TotalSeconds * 2f) : num2;
                        float num3 = this.ScrewHeight;
                        this.ScrewHeight = MathHelper.Clamp(this.ScrewHeight - this.RewindSpeed, 0.0f, 2f);
                        float num4 = num3 - this.ScrewHeight;
                        if ((double)this.ScrewHeight == 0.0 && (double)num4 != 0.0)
                        {
                            SoundEffectExtensions.EmitAt(this.Host.TimeswitchEndWindBackSound, this.ArtObject.Position);
                            this.TimeswitchService.OnHitBase(this.ArtObject.Id);
                            if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
                            {
                                this.eTimeswitchWindBack.Cue.Pause();
                            }
                        }
                        else if ((double)num4 != 0.0)
                        {
                            if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Paused)
                            {
                                this.eTimeswitchWindBack.Cue.Resume();
                            }
                            this.eTimeswitchWindBack.VolumeFactor = FezMath.Saturate(num4 * 20f * this.ArtObject.ActorSettings.TimeswitchWindBackSpeed);
                        }
                        else
                        {
                            this.eTimeswitchWindBack.VolumeFactor = 0.0f;
                            if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
                            {
                                this.eTimeswitchWindBack.Cue.Pause();
                            }
                        }
                        this.TimeswitchScrewAo.Position -= Vector3.UnitY * num4;
                        this.TimeswitchScrewAo.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float)((double)num4 * 1.57079637050629 * -4.0));
                        break;
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Spinning:
                    float      num5          = (float)FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.75);
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, num5 * 1.570796f * (float)this.SpinSign);
                    this.ArtObject.Rotation     = this.OriginalAoRotation * fromAxisAngle;
                    this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - this.ArtObject.Position, fromAxisAngle) + this.ArtObject.Position;
                    if (this.IsBolt)
                    {
                        Vector3 vector3_3 = num5 * (this.SpinSign == 1 ? 1f : -1f) * Vector3.Up;
                        this.ArtObject.Position = this.OriginalAoPosition + vector3_3;
                        int num1 = 0;
                        foreach (TrileInstance instance in this.AttachedGroup.Triles)
                        {
                            instance.Position = this.OriginalGroupTrilePositions[num1++] + vector3_3;
                            this.LevelManager.UpdateInstance(instance);
                        }
                        this.PlayerManager.Position += vector3_3;
                    }
                    if (this.IsTimeswitch)
                    {
                        float num1 = num5;
                        if (this.SpinSign == -1 && (double)this.ScrewHeight <= 0.5)
                        {
                            num1 = Math.Min(this.ScrewHeight, num5 / 2f) * 2f;
                        }
                        else if (this.SpinSign == 1 && (double)this.ScrewHeight >= 1.5)
                        {
                            num1 = Math.Min(2f - this.ScrewHeight, num5 / 2f) * 2f;
                        }
                        this.TimeswitchScrewAo.Position = this.OriginalAoPosition + num1 * (this.SpinSign == 1 ? 1f : -1f) * Vector3.Up / 2f;
                        this.TimeswitchScrewAo.Rotation = this.OriginalScrewRotation * Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float)((double)num1 * 1.57079637050629 * (double)this.SpinSign * 2.0));
                    }
                    if (this.SinceChanged.TotalSeconds >= 0.75)
                    {
                        this.PlayerManager.Position += 0.5f * Vector3.UnitY;
                        IPlayerManager playerManager = this.PlayerManager;
                        Vector3        vector3_3     = playerManager.Velocity - Vector3.UnitY;
                        playerManager.Velocity = vector3_3;
                        this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                        FezMath.ForwardVector(this.CameraManager.Viewpoint);
                        Vector3 vector3_4 = (this.ArtObject.Position + this.CenterOffset) * FezMath.DepthMask(this.CameraManager.Viewpoint);
                        this.ScrewHeight = MathHelper.Clamp(this.ScrewHeight + (float)this.SpinSign / 2f, 0.0f, 2f);
                        if ((double)this.ScrewHeight == 0.0 && this.SpinSign == -1)
                        {
                            this.TimeswitchService.OnHitBase(this.ArtObject.Id);
                        }
                        this.PlayerManager.Action = ActionType.GrabTombstone;
                        this.SinceChanged        -= TimeSpan.FromSeconds(0.75);
                        this.State = SpinAction.Grabbed;
                        break;
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Grabbed:
                    this.RewindSpeed = 0.0f;
                    if (this.PlayerManager.Action != ActionType.GrabTombstone)
                    {
                        this.State = SpinAction.Idle;
                    }
                    if (this.IsTimeswitch)
                    {
                        this.SinceChanged = TimeSpan.Zero;
                        this.eTimeswitchWindBack.VolumeFactor = 0.0f;
                        if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
                        {
                            this.eTimeswitchWindBack.Cue.Pause();
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                return(false);
            }
Exemple #19
0
        private void TryInitialize()
        {
            this.ThisLevelMesh.ClearGroups();
            this.NextLevelMesh.ClearGroups();
            lock (FarawayPlaceHost.FarawayWaterMutex)
                this.FarawayWaterMesh = (Mesh)null;
            (this.NextLevelMesh.Effect as FarawayEffect).CleanUp();
            foreach (Script script1 in Enumerable.Where <Script>((IEnumerable <Script>) this.LevelManager.Scripts.Values, (Func <Script, bool>)(x => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)x.Actions, (Func <ScriptAction, bool>)(y => y.Operation == "ChangeToFarAwayLevel")))))
            {
                Volume volume1;
                if (this.LevelManager.Volumes.TryGetValue(Enumerable.FirstOrDefault <ScriptTrigger>((IEnumerable <ScriptTrigger>)script1.Triggers, (Func <ScriptTrigger, bool>)(x =>
                {
                    if (x.Object.Type == "Volume")
                    {
                        return(x.Event == "Enter");
                    }
                    else
                    {
                        return(false);
                    }
                })).Object.Identifier.Value, out volume1))
                {
                    FaceOrientation faceOrientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume1.Orientations);
                    ScriptAction    scriptAction1   = Enumerable.FirstOrDefault <ScriptAction>((IEnumerable <ScriptAction>)script1.Actions, (Func <ScriptAction, bool>)(x => x.Operation == "ChangeToFarAwayLevel"));
                    string          str1            = scriptAction1.Arguments[0];
                    int             num1            = 0;
                    string          songName;
                    FaceOrientation orientation;
                    Vector2         vector2;
                    bool            flag;
                    float           num2;
                    float           num3;
                    float           num4;
                    using (MemoryContentManager memoryContentManager = new MemoryContentManager((IServiceProvider)this.Game.Services, this.Game.Content.RootDirectory))
                    {
                        string str2 = str1;
                        if (!MemoryContentManager.AssetExists("Levels" + (object)'\\' + str1.Replace('/', '\\')))
                        {
                            str2 = this.LevelManager.FullPath.Substring(0, this.LevelManager.FullPath.LastIndexOf("/") + 1) + str1.Substring(str1.LastIndexOf("/") + 1);
                        }
                        LevelReader.MinimalRead = true;
                        Level level;
                        try
                        {
                            level = memoryContentManager.Load <Level>("Levels/" + str2);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log("FarawayPlaceHost", Common.LogSeverity.Warning, "Couldn't load faraway place destination level : " + str1);
                            continue;
                        }
                        LevelReader.MinimalRead = false;
                        songName = level.SongName;
                        int key;
                        try
                        {
                            key = int.Parse(scriptAction1.Arguments[1]);
                        }
                        catch (Exception ex)
                        {
                            key = -1;
                        }
                        Volume volume2 = key == -1 || !level.Volumes.ContainsKey(key) ? level.Volumes[Enumerable.First <ScriptTrigger>((IEnumerable <ScriptTrigger>)Enumerable.First <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
                        {
                            if (a.Object.Type == "Level" && a.Operation.Contains("Level"))
                            {
                                return(a.Arguments[0] == this.LevelManager.Name);
                            }
                            else
                            {
                                return(false);
                            }
                        })))).Triggers, (Func <ScriptTrigger, bool>)(t =>
                        {
                            if (t.Object.Type == "Volume")
                            {
                                return(t.Event == "Enter");
                            }
                            else
                            {
                                return(false);
                            }
                        })).Object.Identifier.Value] : level.Volumes[key];
                        orientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume2.Orientations);
                        Vector3 vector3 = (level.Size / 2f - (volume2.From + volume2.To) / 2f) * (FezMath.RightVector(FezMath.AsViewpoint(orientation)) + Vector3.Up);
                        vector2 = new Vector2(vector3.X + vector3.Z, vector3.Y);
                        flag    = level.WaterType != LiquidType.None;
                        num2    = level.WaterHeight - (volume2.From + volume2.To).Y / 2f + this.EngineState.WaterLevelOffset;
                        num3    = this.LevelManager.WaterHeight - (volume1.From + volume1.To).Y / 2f - num2 / 4f;
                        num4    = level.Size.Y;
                        Script script2 = Enumerable.FirstOrDefault <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s =>
                        {
                            if (Enumerable.Any <ScriptTrigger>((IEnumerable <ScriptTrigger>)s.Triggers, (Func <ScriptTrigger, bool>)(t =>
                            {
                                if (t.Event == "Start")
                                {
                                    return(t.Object.Type == "Level");
                                }
                                else
                                {
                                    return(false);
                                }
                            })))
                            {
                                return(Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
                                {
                                    if (a.Object.Type == "Camera")
                                    {
                                        return a.Operation == "SetPixelsPerTrixel";
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                })));
                            }
                            else
                            {
                                return(false);
                            }
                        }));
                        if (script2 != null)
                        {
                            ScriptAction scriptAction2 = Enumerable.First <ScriptAction>((IEnumerable <ScriptAction>)script2.Actions, (Func <ScriptAction, bool>)(a =>
                            {
                                if (a.Object.Type == "Camera")
                                {
                                    return(a.Operation == "SetPixelsPerTrixel");
                                }
                                else
                                {
                                    return(false);
                                }
                            }));
                            try
                            {
                                num1 = int.Parse(scriptAction2.Arguments[0]);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        num2 = level.WaterHeight;
                    }
                    Texture2D texture;
                    try
                    {
                        string assetName = "Other Textures/faraway_thumbs/" + (object)str1 + " (" + (string)(object)FezMath.AsViewpoint(orientation) + ")";
                        texture      = this.CMProvider.CurrentLevel.Load <Texture2D>(assetName);
                        texture.Name = assetName;
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("FarawayPlacesHost", Common.LogSeverity.Warning, "Couldn't load faraway thumbnail for " + (object)str1 + " (viewpoint = " + (string)(object)FezMath.AsViewpoint(orientation) + ")");
                        continue;
                    }
                    if (!Enumerable.Any <Group>((IEnumerable <Group>) this.ThisLevelMesh.Groups, (Func <Group, bool>)(x => x.Texture == texture)))
                    {
                        if (num1 == 0)
                        {
                            num1 = (int)this.CameraManager.PixelsPerTrixel;
                        }
                        Group            group1           = this.ThisLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true);
                        Group            group2           = this.NextLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true);
                        FarawayPlaceData farawayPlaceData = new FarawayPlaceData()
                        {
                            OriginalCenter        = (volume1.From + volume1.To) / 2f,
                            Viewpoint             = FezMath.AsViewpoint(faceOrientation),
                            Volume                = volume1,
                            DestinationOffset     = vector2.X * FezMath.RightVector(FezMath.AsViewpoint(faceOrientation)) + Vector3.Up * vector2.Y,
                            WaterLevelOffset      = new float?(num3),
                            DestinationLevelName  = str1,
                            DestinationWaterLevel = num2,
                            DestinationLevelSize  = num4
                        };
                        if (this.LevelManager.WaterType == LiquidType.None && flag)
                        {
                            if (this.HorizontalGradientTex == null || this.HorizontalGradientTex.IsDisposed)
                            {
                                this.HorizontalGradientTex = this.CMProvider.Global.Load <Texture2D>("Other Textures/WaterHorizGradient");
                            }
                            lock (FarawayPlaceHost.FarawayWaterMutex)
                            {
                                FarawayPlaceHost temp_380 = this;
                                // ISSUE: explicit reference operation
                                // ISSUE: variable of a reference type
                                FarawayPlaceData& temp_381 = @farawayPlaceData;
                                Mesh local_28 = new Mesh();
                                Mesh temp_383 = local_28;
                                DefaultEffect.Textured local_29 = new DefaultEffect.Textured();
                                local_29.AlphaIsEmissive = false;
                                DefaultEffect.Textured temp_387 = local_29;
                                temp_383.Effect = (BaseEffect)temp_387;
                                Mesh temp_388;
                                Mesh local_43 = temp_388 = local_28;
                                // ISSUE: explicit reference operation
                                (^ temp_381).WaterBodyMesh = temp_388;
                                Mesh temp_389 = local_43;
                                temp_380.FarawayWaterMesh = temp_389;
                                this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material();
                                this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material();
                            }
                        }
                        group2.CustomData = group1.CustomData = (object)farawayPlaceData;
                        group2.Position   = group1.Position = farawayPlaceData.OriginalCenter;
                        group2.Texture    = group1.Texture = (Texture)texture;
                        group2.Material   = new Material()
                        {
                            Opacity = 0.125f
                        };
                        group1.Material = new Material()
                        {
                            Opacity = 0.125f
                        };
                        if (volume1.ActorSettings == null)
                        {
                            volume1.ActorSettings = new VolumeActorSettings();
                        }
                        volume1.ActorSettings.DestinationSong = songName;
                        switch (num1)
                        {
                        case 1:
                            volume1.ActorSettings.DestinationRadius = 80f;
                            break;

                        case 2:
                            volume1.ActorSettings.DestinationRadius = 40f;
                            break;

                        case 3:
                            volume1.ActorSettings.DestinationRadius = 26.66667f;
                            break;

                        case 4:
                            volume1.ActorSettings.DestinationRadius = 20f;
                            break;

                        case 5:
                            volume1.ActorSettings.DestinationRadius = 16f;
                            break;
                        }
                        volume1.ActorSettings.DestinationPixelsPerTrixel = (float)num1;
                        volume1.ActorSettings.DestinationOffset          = vector2;
                    }
                }
            }
        }
Exemple #20
0
            public bool Update(TimeSpan elapsed)
            {
                this.SinceChanged += elapsed;
                switch (this.State)
                {
                case SpinAction.Idle:
                    bool flag;
                    if (this.HandleAo.ArtObject.ActorType == ActorType.Bookcase)
                    {
                        Vector3 vector3 = this.PlayerManager.Position - this.HandleAo.Position;
                        flag = (double)vector3.Z <2.75 && (double)vector3.Z> -0.25 && ((double)vector3.Y <-3.0 && (double)vector3.Y> -4.0) && this.CameraManager.Viewpoint == Viewpoint.Left;
                    }
                    else
                    {
                        Vector3 vector = (this.PlayerManager.Position - this.HandleAo.Position - new Vector3(0.0f, 1.5f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
                        vector.X += vector.Z;
                        Vector3 vector3 = FezMath.Abs(vector);
                        flag = (double)vector3.X > 0.75 && (double)vector3.X < 1.75 && (double)vector3.Y < 1.0;
                    }
                    if (this.HandleAo.Enabled && flag && (this.PlayerManager.Grounded && this.PlayerManager.Action != ActionType.PushingPivot) && (FezButtonStateExtensions.IsDown(this.InputManager.GrabThrow) && this.PlayerManager.Action != ActionType.ReadingSign && (this.PlayerManager.Action != ActionType.FreeFalling && this.PlayerManager.Action != ActionType.Dying)))
                    {
                        this.SinceChanged = TimeSpan.Zero;
                        return(true);
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Spinning:
                    double     num           = FezMath.Saturate(this.SinceChanged.TotalSeconds / 1.5);
                    float      angle         = Easing.EaseIn(num < 0.799999997019768 ? num / 0.799999997019768 : 1.0 + Math.Sin((num - 0.799999997019768) / 0.200000002980232 * 6.28318548202515 * 2.0) * 0.00999999977648258 * (1.0 - num) / 0.200000002980232, EasingType.Quartic) * 1.570796f * (float)this.SpinSign;
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, angle);
                    Vector3    position      = this.HandleAo.Position;
                    for (int index = 0; index < this.OriginalStates.Length; ++index)
                    {
                        TrileInstance instance = index < this.Group.Triles.Count ? this.Group.Triles[index] : this.AttachedTriles[index - this.Group.Triles.Count];
                        Vector4       vector   = this.OriginalStates[index];
                        instance.Position = Vector3.Transform(FezMath.XYZ(vector) + new Vector3(0.5f) - position, fromAxisAngle) + position - new Vector3(0.5f);
                        instance.Phi      = FezMath.WrapAngle(vector.W + angle);
                        this.LevelMaterializer.GetTrileMaterializer(instance.Trile).UpdateInstance(instance);
                    }
                    if (!this.HasShaken && num > 0.799999997019768)
                    {
                        ServiceHelper.AddComponent((IGameComponent) new CamShake(ServiceHelper.Game)
                        {
                            Distance = 0.25f,
                            Duration = TimeSpan.FromSeconds(0.200000002980232)
                        });
                        this.HasShaken = true;
                    }
                    this.HandleAo.Rotation = this.OriginalAoRotation * fromAxisAngle;
                    for (int index = 0; index < this.AttachedArtObjects.Length; ++index)
                    {
                        this.AttachedArtObjects[index].Rotation = this.AttachedAoRotations[index] * fromAxisAngle;
                        this.AttachedArtObjects[index].Position = Vector3.Transform(this.AttachedAoOrigins[index] - position, fromAxisAngle) + position;
                    }
                    if (this.SinceChanged.TotalSeconds >= 1.5)
                    {
                        this.RotateTriles();
                        this.SinceChanged -= TimeSpan.FromSeconds(1.5);
                        this.State         = SpinAction.Idle;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                return(false);
            }
Exemple #21
0
        protected override void TestConditions()
        {
            if (this.PlayerManager.Action == ActionType.LesserWarp || this.GateAo == null || this.Phase == LesserWarp.Phases.FadeIn)
            {
                return;
            }
            Vector3 b = FezMath.SideMask(this.CameraManager.Viewpoint);
            Vector3 a = FezMath.Abs(this.OriginalPosition - this.PlayerManager.Position);

            if (this.LevelManager.Name == "ZU_CODE_LOOP" && this.GameState.SaveData.ThisLevel.ScriptingState == "NOT_COLLECTED")
            {
                this.HasCubeShard = true;
            }
            bool flag = (double)FezMath.Dot(a, b) < 3.0 && (double)a.Y < 4.0 && !this.HasCubeShard;

            if (flag && (this.Phase == LesserWarp.Phases.None || this.Phase == LesserWarp.Phases.Lower))
            {
                if (this.Phase != LesserWarp.Phases.Lower)
                {
                    this.RiseAxis     = FezMath.RightVector(this.CameraManager.Viewpoint);
                    this.RisePhi      = FezMath.ToPhi(this.CameraManager.Viewpoint);
                    this.SinceRisen   = TimeSpan.Zero;
                    this.SinceStarted = TimeSpan.Zero;
                }
                this.Phase = LesserWarp.Phases.Rise;
                SoundEffectExtensions.EmitAt(this.sRise, this.GateAo.Position);
            }
            else if (!flag && this.Phase != LesserWarp.Phases.Lower && this.Phase != LesserWarp.Phases.None)
            {
                if (this.Phase != LesserWarp.Phases.Rise)
                {
                    this.RiseAxis = FezMath.RightVector(this.CameraManager.Viewpoint);
                    this.RisePhi  = FezMath.ToPhi(this.CameraManager.Viewpoint);
                }
                this.Phase        = this.Phase == LesserWarp.Phases.Rise ? LesserWarp.Phases.Lower : LesserWarp.Phases.Decelerate;
                this.SinceStarted = TimeSpan.Zero;
                if (this.Phase == LesserWarp.Phases.Lower)
                {
                    SoundEffectExtensions.EmitAt(this.sLower, this.GateAo.Position);
                }
            }
            else if (!flag && this.Phase == LesserWarp.Phases.None && (this.eIdleSpin != null && !this.eIdleSpin.Dead) && this.eIdleSpin.Cue.State == SoundState.Playing)
            {
                this.eIdleSpin.Cue.Pause();
            }
            if (this.HasCubeShard && (double)FezMath.Dot(a, b) < 3.0 && ((double)a.Y < 4.0 && this.PlayerManager.LastAction == ActionType.FindingTreasure))
            {
                this.HasCubeShard = false;
            }
            if (!this.PlayerManager.Grounded || !flag || (this.InputManager.Up != FezButtonState.Pressed || !this.SpeechBubble.Hidden))
            {
                return;
            }
            this.PlayerManager.Action = ActionType.LesserWarp;
            if (this.Phase == LesserWarp.Phases.None)
            {
                this.RiseAxis     = FezMath.RightVector(this.CameraManager.Viewpoint);
                this.RisePhi      = FezMath.ToPhi(this.CameraManager.Viewpoint);
                this.SinceRisen   = TimeSpan.Zero;
                this.SinceStarted = TimeSpan.Zero;
                this.Phase        = LesserWarp.Phases.Rise;
                SoundEffectExtensions.EmitAt(this.sRise, this.GateAo.Position);
            }
            else
            {
                if (this.Phase != LesserWarp.Phases.SpinWait)
                {
                    return;
                }
                if (this.eIdleSpin.Cue.State == SoundState.Playing)
                {
                    if (this.fader != null)
                    {
                        this.fader.Cancel();
                    }
                    this.eIdleSpin.FadeOutAndPause(1f);
                }
                this.DotManager.PreventPoI = true;
                this.DotManager.Burrow();
                foreach (SoundEmitter soundEmitter in this.SoundManager.Emitters)
                {
                    soundEmitter.FadeOutAndDie(2f);
                }
                this.SoundManager.FadeFrequencies(true, 2f);
                this.SoundManager.FadeVolume(this.SoundManager.MusicVolumeFactor, 0.0f, 3f);
                SoundEffectExtensions.EmitAt(this.sActivate, this.GateAo.Position);
                this.Phase = LesserWarp.Phases.Accelerate;
                this.CameraManager.Constrained      = true;
                this.OriginalCenter                 = this.CameraManager.Center;
                this.PlayerManager.LookingDirection = HorizontalDirection.Left;
                this.PlayerManager.Velocity         = Vector3.Zero;
            }
        }
Exemple #22
0
 private void TryInitialize()
 {
     foreach (WaterfallsHost.WaterfallState waterfallState in this.Waterfalls)
     {
         waterfallState.Dispose();
     }
     this.Waterfalls.Clear();
     foreach (BackgroundPlane plane in Enumerable.ToArray <BackgroundPlane>((IEnumerable <BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values))
     {
         if (plane.ActorType == ActorType.Waterfall || plane.ActorType == ActorType.Trickle)
         {
             Vector3 vector3_1    = Vector3.Transform(plane.Size * plane.Scale * Vector3.UnitX / 2f, plane.Rotation);
             Vector3 vector       = Vector3.Transform(Vector3.UnitZ, plane.Rotation);
             Vector3 vector3_2    = FezMath.XZMask - FezMath.Abs(vector);
             Vector3 vector3_3    = plane.Position + plane.Size * plane.Scale * Vector3.UnitY / 2f - new Vector3(0.0f, 1.0 / 32.0, 0.0f) - vector * 2f / 16f;
             Game    game         = this.Game;
             int     maximumCount = 25;
             PlaneParticleSystemSettings particleSystemSettings1 = new PlaneParticleSystemSettings();
             particleSystemSettings1.SpawnVolume = new BoundingBox()
             {
                 Min = vector3_3 - vector3_1,
                 Max = vector3_3 + vector3_1
             };
             PlaneParticleSystemSettings particleSystemSettings2 = particleSystemSettings1;
             VaryingVector3 varyingVector3_1 = new VaryingVector3();
             varyingVector3_1.Base      = Vector3.Up * 1.6f + vector / 4f;
             varyingVector3_1.Variation = Vector3.Up * 0.8f + vector / 4f + vector3_2 / 2f;
             VaryingVector3 varyingVector3_2 = varyingVector3_1;
             particleSystemSettings2.Velocity           = varyingVector3_2;
             particleSystemSettings1.Gravity            = new Vector3(0.0f, -0.15f, 0.0f);
             particleSystemSettings1.SpawningSpeed      = 5f;
             particleSystemSettings1.RandomizeSpawnTime = true;
             particleSystemSettings1.ParticleLifetime   = 2f;
             particleSystemSettings1.FadeInDuration     = 0.0f;
             particleSystemSettings1.FadeOutDuration    = 0.1f;
             particleSystemSettings1.SizeBirth          = (VaryingVector3) new Vector3(1.0 / 16.0);
             particleSystemSettings1.ColorLife          = (VaryingColor)(this.LevelManager.WaterType == LiquidType.Sewer ? new Color(215, 232, 148) : new Color(1f, 1f, 1f, 0.75f));
             particleSystemSettings1.Texture            = this.CMProvider.Global.Load <Texture2D>("Background Planes/white_square");
             particleSystemSettings1.BlendingMode       = BlendingMode.Alphablending;
             particleSystemSettings1.ClampToTrixels     = true;
             particleSystemSettings1.Billboarding       = true;
             particleSystemSettings1.FullBright         = this.LevelManager.WaterType == LiquidType.Sewer;
             particleSystemSettings1.UseCallback        = true;
             PlaneParticleSystemSettings settings            = particleSystemSettings1;
             PlaneParticleSystem         planeParticleSystem = new PlaneParticleSystem(game, maximumCount, settings);
             if (this.LevelManager.WaterType == LiquidType.Sewer)
             {
                 planeParticleSystem.DrawOrder            = 20;
                 planeParticleSystem.Settings.StencilMask = new StencilMask?(StencilMask.Level);
             }
             this.PlaneParticleSystems.Add(planeParticleSystem);
             this.Waterfalls.Add(new WaterfallsHost.WaterfallState(plane, planeParticleSystem, this));
         }
         else if (plane.ActorType == ActorType.Drips)
         {
             Vector3 vector3_1    = new Vector3(plane.Size.X, 0.0f, plane.Size.X) / 2f;
             Vector3 vector3_2    = Vector3.Transform(Vector3.UnitZ, plane.Rotation);
             Vector3 vector3_3    = FezMath.XZMask - FezMath.Abs(vector3_2);
             Vector3 vector3_4    = plane.Position - new Vector3(0.0f, 0.125f, 0.0f);
             bool    flag         = plane.Crosshatch || plane.Billboard;
             Game    game         = this.Game;
             int     maximumCount = 25;
             PlaneParticleSystemSettings particleSystemSettings1 = new PlaneParticleSystemSettings();
             particleSystemSettings1.SpawnVolume = new BoundingBox()
             {
                 Min = vector3_4 - vector3_1,
                 Max = vector3_4 + vector3_1
             };
             PlaneParticleSystemSettings particleSystemSettings2 = particleSystemSettings1;
             VaryingVector3 varyingVector3_1 = new VaryingVector3();
             varyingVector3_1.Base      = Vector3.Zero;
             varyingVector3_1.Variation = Vector3.Zero;
             VaryingVector3 varyingVector3_2 = varyingVector3_1;
             particleSystemSettings2.Velocity           = varyingVector3_2;
             particleSystemSettings1.Gravity            = new Vector3(0.0f, -0.15f, 0.0f);
             particleSystemSettings1.SpawningSpeed      = 2f;
             particleSystemSettings1.RandomizeSpawnTime = true;
             particleSystemSettings1.ParticleLifetime   = 2f;
             particleSystemSettings1.FadeInDuration     = 0.0f;
             particleSystemSettings1.FadeOutDuration    = 0.0f;
             particleSystemSettings1.SizeBirth          = (VaryingVector3) new Vector3(1.0 / 16.0);
             particleSystemSettings1.ColorLife          = (VaryingColor)(this.LevelManager.WaterType == LiquidType.Sewer ? new Color(215, 232, 148) : Color.White);
             particleSystemSettings1.Texture            = this.CMProvider.Global.Load <Texture2D>("Background Planes/white_square");
             particleSystemSettings1.BlendingMode       = BlendingMode.Alphablending;
             particleSystemSettings1.ClampToTrixels     = true;
             particleSystemSettings1.FullBright         = true;
             PlaneParticleSystemSettings settings = particleSystemSettings1;
             PlaneParticleSystem         system   = new PlaneParticleSystem(game, maximumCount, settings);
             if (this.LevelManager.WaterType == LiquidType.Sewer)
             {
                 system.DrawOrder            = 20;
                 system.Settings.StencilMask = new StencilMask?(StencilMask.Level);
             }
             if (flag)
             {
                 system.Settings.Billboarding = true;
                 system.Settings.SpawnVolume  = new BoundingBox()
                 {
                     Min = vector3_4 - vector3_1,
                     Max = vector3_4 + vector3_1
                 };
             }
             else
             {
                 system.Settings.Doublesided = plane.Doublesided;
                 system.Settings.SpawnVolume = new BoundingBox()
                 {
                     Min = vector3_4 - vector3_1 * vector3_3,
                     Max = vector3_4 + vector3_1 * vector3_3
                 };
                 system.Settings.Orientation = new FaceOrientation?(FezMath.OrientationFromDirection(vector3_2));
             }
             this.PlaneParticleSystems.Add(system);
         }
     }
 }
Exemple #23
0
        private void AlignMesh(Viewpoint viewpoint)
        {
            float   num = this.CameraManager.Radius / SettingsManager.GetViewScale(this.GraphicsDevice);
            Vector3 interpolatedCenter = this.CameraManager.InterpolatedCenter;
            Vector3 vector1            = FezMath.ForwardVector(viewpoint);
            Vector3 vector2            = FezMath.RightVector(viewpoint);

            this.Meshes[viewpoint].Position = new Vector3(0.0f, interpolatedCenter.Y + num / 2f / this.CameraManager.AspectRatio, 0.0f) + interpolatedCenter * FezMath.Abs(vector2) + this.LevelManager.Size / 2f * FezMath.Abs(vector1) + num * vector1;
        }
Exemple #24
0
        protected override void TryFlee()
        {
            if (this.PlayerManager.Action == ActionType.IdleSleep)
            {
                return;
            }
            float num1 = FezMath.Dot(FezMath.Abs(this.Position - this.PlayerManager.Position), FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint));

            this.Npc.WalkSpeed = this.originalSpeed * (float)(1.0 + (1.0 - (double)FezMath.Saturate(num1 / 3f)));
            switch (this.CurrentAction)
            {
            case NpcAction.Turn:
                break;

            case NpcAction.Burrow:
                break;

            case NpcAction.ComeOut:
                break;

            case NpcAction.TakeOff:
                break;

            case NpcAction.Fly:
                break;

            default:
                Vector3 vector3 = Vector3.UnitY + FezMath.SideMask(this.CameraManager.Viewpoint) * 3f + FezMath.DepthMask(this.CameraManager.Viewpoint) * float.MaxValue;
                if (new BoundingBox(this.Position - vector3, this.Position + vector3).Contains(this.PlayerManager.Position) == ContainmentType.Disjoint)
                {
                    if (this.CurrentAction != NpcAction.Hide)
                    {
                        break;
                    }
                    this.CurrentAction = NpcAction.ComeOut;
                    this.UpdateAction();
                    break;
                }
                else
                {
                    float     num2      = FezMath.Dot(this.PlayerManager.Position - this.Position, FezMath.RightVector(this.CameraManager.Viewpoint)) * (float)Math.Sign(FezMath.Dot(this.Npc.DestinationOffset, FezMath.RightVector(this.CameraManager.Viewpoint)));
                    NpcAction npcAction = this.CurrentAction;
                    if ((double)num1 < 1.0)
                    {
                        this.Hide();
                    }
                    else if (this.CurrentAction == NpcAction.Hide)
                    {
                        this.CurrentAction = NpcAction.ComeOut;
                        SoundEffectExtensions.EmitAt(this.comeOutSound, this.Position);
                        this.UpdateAction();
                        break;
                    }
                    else
                    {
                        HorizontalDirection horizontalDirection = FezMath.DirectionFromMovement(-num2);
                        if (this.LookingDirection != horizontalDirection)
                        {
                            if (this.CanTurn)
                            {
                                this.CurrentAction = NpcAction.Turn;
                            }
                            else
                            {
                                this.LookingDirection = horizontalDirection;
                                this.CurrentAction    = this.CanWalk ? NpcAction.Walk : NpcAction.Idle;
                            }
                        }
                        else
                        {
                            this.CurrentAction = this.CanWalk ? NpcAction.Walk : NpcAction.Idle;
                        }
                    }
                    if (npcAction == this.CurrentAction)
                    {
                        break;
                    }
                    this.UpdateAction();
                    break;
                }
            }
        }
Exemple #25
0
        public override void Update(GameTime gameTime)
        {
            if (this.CameraManager.Viewpoint == Viewpoint.Perspective || this.GameState.InMap || (this.GameState.Paused || this.GameState.Loading) || this.watchers.Count == 0)
            {
                return;
            }
            Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint);
            Vector3 vector3_2 = FezMath.Abs(vector3_1);
            Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);

            foreach (TrileInstance index in this.watchers.Keys)
            {
                WatchersHost.WatcherState watcherState = this.watchers[index];
                Vector3 vector3_4 = index.PhysicsState.Center + vector3_2 * -5f / 16f + Vector3.UnitY * -2f / 16f - 0.5f * vector3_3;
                watcherState.Eyes.Groups[0].Position = vector3_4 + watcherState.EyeOffset;
                watcherState.Eyes.Groups[1].Position = vector3_4 + vector3_2 * 9f / 16f + watcherState.EyeOffset;
                watcherState.Eyes.Groups[0].Enabled  = true;
                watcherState.Eyes.Groups[1].Enabled  = true;
            }
            if (!this.CameraManager.ActionRunning || !this.CameraManager.ViewTransitionReached)
            {
                return;
            }
            Vector3     center1   = this.PlayerManager.Center;
            BoundingBox box       = FezMath.Enclose(center1 - this.PlayerManager.Size / 2f, center1 + this.PlayerManager.Size / 2f);
            Vector3     vector3_5 = vector3_1 * 8f;
            Vector3     vector3_6 = vector3_3 * this.LevelManager.Size;
            Vector3     vector3_7 = Vector3.Up * 8f;

            this.lastCrushDirections.Clear();
            bool flag1 = false;

            foreach (TrileInstance index in this.watchers.Keys)
            {
                WatchersHost.WatcherState watcherState1 = this.watchers[index];
                Vector3     vector1      = FezMath.Sign(center1 - index.Position) * vector3_2;
                Vector3     vector3_4    = FezMath.Sign(center1 - index.Position) * Vector3.UnitY;
                BoundingBox boundingBox1 = (double)Vector3.Dot(vector1, vector3_1) > 0.0 ? FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_6, index.Position + vector3_5 + vector3_6 + new Vector3(0.9f)) : FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_6 - vector3_5, index.Position + vector3_6 + new Vector3(0.9f));
                BoundingBox boundingBox2 = FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_7 - vector3_6, index.Position + vector3_7 + new Vector3(0.9f) + vector3_6);
                switch (watcherState1.Action)
                {
                case WatchersHost.WatcherAction.Idle:
                    bool flag2 = boundingBox1.Intersects(box);
                    bool flag3 = boundingBox2.Intersects(box);
                    watcherState1.EyeOffset             = !flag2 ? (!flag3 ? Vector3.Lerp(watcherState1.EyeOffset, Vector3.Zero, 0.1f) : Vector3.Lerp(watcherState1.EyeOffset, vector3_4 * 1f / 16f, 0.25f)) : Vector3.Lerp(watcherState1.EyeOffset, vector1 * 1f / 16f, 0.25f);
                    watcherState1.CrushDirection        = flag2 ? vector1 : (flag3 ? vector3_4 : Vector3.Zero);
                    watcherState1.Eyes.Material.Opacity = 1f;
                    WatchersHost.WatcherState watcherState2;
                    if (this.LevelManager.NearestTrile(index.Position + new Vector3(0.5f)).Deep == index && (flag2 || flag3) && (!FezMath.In <ActionType>(this.PlayerManager.Action, ActionType.GrabCornerLedge, ActionType.Suffering, ActionType.Dying, (IEqualityComparer <ActionType>)ActionTypeComparer.Default) && (watcherState2 = this.HasPair(index)) != null))
                    {
                        watcherState1.Action    = WatchersHost.WatcherAction.Spotted;
                        watcherState2.StartTime = watcherState1.StartTime = gameTime.TotalGameTime;
                        if (!watcherState1.SkipNextSound)
                        {
                            SoundEffectExtensions.EmitAt(this.seeSound, index.Center);
                            watcherState2.SkipNextSound = true;
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }

                case WatchersHost.WatcherAction.Spotted:
                    watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, watcherState1.CrushDirection * 1f / 16f, 0.25f);
                    if ((gameTime.TotalGameTime - watcherState1.StartTime).TotalSeconds > 1.0)
                    {
                        watcherState1.Action        = WatchersHost.WatcherAction.Crushing;
                        watcherState1.StartTime     = gameTime.TotalGameTime;
                        index.PhysicsState.Velocity = watcherState1.OriginalCenter - index.Center;
                        this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false);
                        index.PhysicsState.UpdateInstance();
                        this.LevelManager.UpdateInstance(index);
                        watcherState1.MoveEmitter = watcherState1.SkipNextSound ? (SoundEmitter)null : SoundEffectExtensions.EmitAt(this.moveSound, index.Center);
                        break;
                    }
                    else
                    {
                        Vector3 vector3_8 = watcherState1.CrushDirection * RandomHelper.Unit() * 0.5f / 16f;
                        index.PhysicsState.Sticky   = true;
                        index.PhysicsState.Velocity = watcherState1.OriginalCenter + vector3_8 - index.Center;
                        this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false);
                        index.PhysicsState.UpdateInstance();
                        this.LevelManager.UpdateInstance(index);
                        break;
                    }

                case WatchersHost.WatcherAction.Crushing:
                    if (index.PhysicsState.Sticky)
                    {
                        index.PhysicsState.Sticky   = false;
                        index.PhysicsState.Velocity = Vector3.Zero;
                    }
                    watcherState1.EyeOffset = watcherState1.CrushDirection * 1f / 16f;
                    Vector3 vector3_9  = watcherState1.CrushDirection * (float)gameTime.ElapsedGameTime.TotalSeconds * 15f;
                    Vector3 vector3_10 = Vector3.Lerp(index.PhysicsState.Velocity, vector3_9, 0.025f);
                    index.PhysicsState.Velocity = vector3_10 * watcherState1.CrashAttenuation;
                    if (FezMath.VisibleAxis(this.CameraManager.Viewpoint) != FezMath.AsAxis(FezMath.OrientationFromDirection(watcherState1.CrushDirection)))
                    {
                        this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, false, false);
                    }
                    Vector3 vector3_11 = vector3_10 * watcherState1.CrashAttenuation - index.PhysicsState.Velocity;
                    if (watcherState1.MoveEmitter != null)
                    {
                        watcherState1.MoveEmitter.Position = index.Center;
                    }
                    index.PhysicsState.UpdateInstance();
                    this.LevelManager.UpdateInstance(index);
                    this.PlayerManager.ForceOverlapsDetermination();
                    bool flag4 = this.PlayerManager.HeldInstance == index || this.PlayerManager.WallCollision.FarHigh.Destination == index || (this.PlayerManager.WallCollision.NearLow.Destination == index || this.PlayerManager.Ground.NearLow == index) || this.PlayerManager.Ground.FarHigh == index;
                    if (!flag4)
                    {
                        foreach (PointCollision pointCollision in this.PlayerManager.CornerCollision)
                        {
                            if (pointCollision.Instances.Deep == index)
                            {
                                flag4 = true;
                                break;
                            }
                        }
                    }
                    if (flag1 && flag4 && this.lastCrushDirections.Contains(-watcherState1.CrushDirection))
                    {
                        this.PlayerManager.Position    = index.Center + Vector3.One / 2f * watcherState1.CrushDirection + -FezMath.SideMask(this.CameraManager.Viewpoint) * FezMath.Abs(watcherState1.CrushDirection) * 1.5f / 16f;
                        this.PlayerManager.Velocity    = Vector3.Zero;
                        this.PlayerManager.Action      = (double)watcherState1.CrushDirection.Y == 0.0 ? ActionType.CrushHorizontal : ActionType.CrushVertical;
                        watcherState1.CrashAttenuation = this.PlayerManager.Action == ActionType.CrushVertical ? 0.5f : 0.75f;
                    }
                    flag1 = flag1 | flag4;
                    if (flag4 && this.PlayerManager.Action != ActionType.CrushHorizontal && this.PlayerManager.Action != ActionType.CrushVertical)
                    {
                        this.lastCrushDirections.Add(watcherState1.CrushDirection);
                        if ((double)watcherState1.CrushDirection.Y == 0.0)
                        {
                            this.PlayerManager.Position += index.PhysicsState.Velocity;
                        }
                    }
                    if ((double)vector3_11.LengthSquared() > 4.99999987368938E-05 || (double)Math.Abs(Vector3.Dot(index.Center - watcherState1.OriginalCenter, FezMath.Abs(watcherState1.CrushDirection))) >= 8.0)
                    {
                        if (watcherState1.MoveEmitter != null && !watcherState1.MoveEmitter.Dead)
                        {
                            watcherState1.MoveEmitter.Cue.Stop(false);
                        }
                        watcherState1.MoveEmitter = (SoundEmitter)null;
                        if (!watcherState1.SkipNextSound)
                        {
                            SoundEffectExtensions.EmitAt(this.collideSound, index.Center);
                        }
                        watcherState1.Action           = WatchersHost.WatcherAction.Wait;
                        index.PhysicsState.Velocity    = Vector3.Zero;
                        watcherState1.StartTime        = TimeSpan.Zero;
                        watcherState1.CrashAttenuation = 1f;
                        break;
                    }
                    else
                    {
                        break;
                    }

                case WatchersHost.WatcherAction.Wait:
                    watcherState1.StartTime += gameTime.ElapsedGameTime;
                    if (watcherState1.StartTime.TotalSeconds > 1.5)
                    {
                        watcherState1.Action          = WatchersHost.WatcherAction.Withdrawing;
                        watcherState1.StartTime       = gameTime.TotalGameTime;
                        watcherState1.WithdrawEmitter = watcherState1.SkipNextSound ? (SoundEmitter)null : SoundEffectExtensions.EmitAt(this.withdrawSound, index.Center, true);
                        break;
                    }
                    else
                    {
                        break;
                    }

                case WatchersHost.WatcherAction.Withdrawing:
                    watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, -watcherState1.CrushDirection * 0.5f / 16f, 0.05f);
                    Vector3 vector3_12 = -watcherState1.CrushDirection * (float)gameTime.ElapsedGameTime.TotalSeconds * 2f;
                    index.PhysicsState.Velocity = Vector3.Lerp(index.PhysicsState.Velocity, vector3_12, 0.025f);
                    if (watcherState1.WithdrawEmitter != null)
                    {
                        watcherState1.WithdrawEmitter.VolumeFactor = 0.0f;
                    }
                    bool flag5 = false;
                    if (FezMath.DepthMask(this.CameraManager.Viewpoint) == FezMath.GetMask(FezMath.AsAxis(FezMath.OrientationFromDirection(watcherState1.CrushDirection))))
                    {
                        flag5 = true;
                    }
                    if (watcherState1.WithdrawEmitter != null)
                    {
                        watcherState1.WithdrawEmitter.VolumeFactor = 1f;
                    }
                    Vector3 center2  = index.PhysicsState.Center;
                    Vector3 velocity = index.PhysicsState.Velocity;
                    this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false);
                    index.PhysicsState.Center = center2 + velocity;
                    if (watcherState1.WithdrawEmitter != null)
                    {
                        watcherState1.WithdrawEmitter.Position = index.Center;
                    }
                    if (flag5 ? (double)Math.Abs(Vector3.Dot(index.Center - watcherState1.OriginalCenter, vector3_1 + Vector3.Up)) <= 1.0 / 32.0 : (double)Vector3.Dot(index.Center - watcherState1.OriginalCenter, watcherState1.CrushDirection) <= 1.0 / 1000.0)
                    {
                        if (watcherState1.WithdrawEmitter != null)
                        {
                            watcherState1.WithdrawEmitter.FadeOutAndDie(0.1f);
                            watcherState1.WithdrawEmitter = (SoundEmitter)null;
                        }
                        watcherState1.SkipNextSound  = false;
                        watcherState1.Action         = WatchersHost.WatcherAction.Cooldown;
                        watcherState1.CrushDirection = Vector3.Zero;
                        watcherState1.StartTime      = TimeSpan.Zero;
                    }
                    index.PhysicsState.UpdateInstance();
                    this.LevelManager.UpdateInstance(index);
                    break;

                case WatchersHost.WatcherAction.Cooldown:
                    index.PhysicsState.Velocity = watcherState1.OriginalCenter - index.Center;
                    this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false);
                    index.PhysicsState.UpdateInstance();
                    this.LevelManager.UpdateInstance(index);
                    watcherState1.EyeOffset             = Vector3.Lerp(watcherState1.EyeOffset, Vector3.Zero, 0.05f);
                    watcherState1.Eyes.Material.Opacity = 0.5f;
                    watcherState1.StartTime            += gameTime.ElapsedGameTime;
                    if (watcherState1.StartTime.TotalSeconds > 0.5)
                    {
                        index.PhysicsState.Velocity = Vector3.Zero;
                        watcherState1.Action        = WatchersHost.WatcherAction.Idle;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                Vector3 vector3_13 = index.PhysicsState.Center + vector3_2 * -5f / 16f + Vector3.UnitY * -2f / 16f - 0.5f * vector3_3;
                watcherState1.Eyes.Groups[0].Position = vector3_13 + watcherState1.EyeOffset;
                watcherState1.Eyes.Groups[1].Position = vector3_13 + vector3_2 * 9f / 16f + watcherState1.EyeOffset;
                watcherState1.Eyes.Groups[2].Position = watcherState1.Eyes.Groups[0].Position;
                watcherState1.Eyes.Groups[3].Position = watcherState1.Eyes.Groups[1].Position;
                watcherState1.Eyes.Groups[0].Enabled  = false;
                watcherState1.Eyes.Groups[1].Enabled  = false;
            }
        }
Exemple #26
0
            private void BuildMesh()
            {
                Vector3 a     = (this.Volume.To - this.Volume.From) / 2f;
                float   num1  = a.Y * 2f;
                Mesh    mesh1 = new Mesh();
                Mesh    mesh2 = new Mesh();

                FaceOrientation[] faceOrientationArray = new FaceOrientation[4]
                {
                    FaceOrientation.Front,
                    FaceOrientation.Right,
                    FaceOrientation.Back,
                    FaceOrientation.Left
                };
                foreach (FaceOrientation faceOrientation in faceOrientationArray)
                {
                    Vector3 vector3_1 = FezMath.AsVector(FezMath.IsSide(FezMath.GetTangent(faceOrientation)) ? FezMath.GetTangent(faceOrientation) : FezMath.GetBitangent(faceOrientation));
                    Vector3 origin    = this.Center + FezMath.AsVector(faceOrientation) * a;
                    float   num2      = Math.Abs(FezMath.Dot(a, vector3_1)) * 2f;
                    Vector3 vector3_2 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY);
                    Vector3 vector3_3 = origin + (a - new Vector3(0.5f)) * (-vector3_1 + Vector3.UnitY);
                    for (int index = 0; (double)index < (double)num2; ++index)
                    {
                        Vector3 p = vector3_2 + (float)index * vector3_1;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                        p = vector3_3 + (float)index * vector3_1;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                    }
                    Vector3 vector3_4 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY);
                    Vector3 vector3_5 = origin + (a - new Vector3(0.5f)) * (vector3_1 - Vector3.UnitY);
                    for (int index = 0; (double)index < (double)num1; ++index)
                    {
                        Vector3 p = vector3_4 + (float)index * Vector3.UnitY;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                        p = vector3_5 + (float)index * Vector3.UnitY;
                        if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p))))
                        {
                            mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p;
                        }
                    }
                    mesh2.AddFace(num2 * FezMath.Abs(vector3_1) + num1 * Vector3.UnitY, origin, faceOrientation, Color.White, true);
                }
                foreach (Group group in mesh1.Groups)
                {
                    group.TextureMatrix = (Dirtyable <Matrix?>) new Matrix?(new Matrix(0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f));
                }
                mesh2.Collapse <VertexPositionNormalColor>();
                IndexedUserPrimitives <VertexPositionNormalColor> indexedUserPrimitives1 = mesh2.FirstGroup.Geometry as IndexedUserPrimitives <VertexPositionNormalColor>;

                mesh1.CollapseWithNormalTexture <FezVertexPositionNormalTexture>();
                IndexedUserPrimitives <FezVertexPositionNormalTexture> indexedUserPrimitives2 = mesh1.FirstGroup.Geometry as IndexedUserPrimitives <FezVertexPositionNormalTexture>;

                this.instanceIndex = this.Host.HolesBodyMesh.Groups.Count;
                this.Host.HolesBodyMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionInstance>(Enumerable.ToArray <VertexPositionInstance>(Enumerable.Select <VertexPositionNormalColor, VertexPositionInstance>((IEnumerable <VertexPositionNormalColor>)indexedUserPrimitives1.Vertices, (Func <VertexPositionNormalColor, VertexPositionInstance>)(x => new VertexPositionInstance(x.Position)
                {
                    InstanceIndex = (float)this.instanceIndex
                }))), indexedUserPrimitives1.Indices, PrimitiveType.TriangleList);
                this.Host.HolesFringeMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionTextureInstance>(Enumerable.ToArray <VertexPositionTextureInstance>(Enumerable.Select <FezVertexPositionNormalTexture, VertexPositionTextureInstance>((IEnumerable <FezVertexPositionNormalTexture>)indexedUserPrimitives2.Vertices, (Func <FezVertexPositionNormalTexture, VertexPositionTextureInstance>)(x => new VertexPositionTextureInstance(x.Position, x.TextureCoordinate)
                {
                    InstanceIndex = (float)this.instanceIndex
                }))), indexedUserPrimitives2.Indices, PrimitiveType.TriangleList);
            }