Exemple #1
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);
            }
        public void AlterTransition(Viewpoint newTo)
        {
            Viewpoint rotatedView = FezMath.GetRotatedView(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[0])), FezMath.GetDistance(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[2])), newTo));
            Vector3   from        = this.predefinedViews[rotatedView].Direction;
            Vector3   to          = this.predefinedViews[newTo].Direction;

            this.directionTransition.Points[0] = from;
            this.directionTransition.Points[1] = DefaultCameraManager.GetIntemediateVector(from, to);
            this.directionTransition.Points[2] = to;
            this.current       = this.predefinedViews[newTo];
            this.lastViewpoint = rotatedView;
            this.viewpoint     = newTo;
        }
Exemple #3
0
            public TombstoneState(TombstonesHost host, ArtObjectInstance ao)
            {
                ServiceHelper.InjectServices((object)this);
                this.Host      = host;
                this.ArtObject = ao;
                int num1;

                if (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0)
                {
                    int num2 = Math.Abs(num1);
                    for (int index = 0; index < num2; ++index)
                    {
                        this.OriginalAoRotation  = this.ArtObject.Rotation;
                        this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)Math.Sign(num1));
                    }
                }
                this.LastViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.ArtObject.Rotation))));
            }
Exemple #4
0
        public BitDoorState(ArtObjectInstance artObject)
        {
            ServiceHelper.InjectServices((object)this);
            this.AoInstance = artObject;
            switch (artObject.ArtObject.ActorType)
            {
            case ActorType.FourBitDoor:
            case ActorType.TwoBitDoor:
            case ActorType.SixteenBitDoor:
            case ActorType.EightBitDoor:
            case ActorType.OneBitDoor:
                this.BitTexture     = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/GLOWBIT");
                this.AntiBitTexture = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/GLOWBIT_anti");
                break;

            case ActorType.ThirtyTwoBitDoor:
                this.BitTexture     = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/small_glowbit");
                this.AntiBitTexture = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/small_glowbit_anti");
                break;

            default:
                this.BitTexture     = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/code_machine_glowbit");
                this.AntiBitTexture = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/code_machine_glowbit_anti");
                for (int index = 0; index < 64; ++index)
                {
                    this.SixtyFourOffsets[index] /= 16f;
                }
                break;
            }
            this.RumbleSound       = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/Rumble");
            this.sLightUp          = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitLightUp");
            this.sFadeOut          = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitFadeOut");
            this.ExpectedViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClamp(Vector3.Transform(Vector3.UnitZ, this.AoInstance.Rotation))));
            this.lastBits          = 0;
            this.InitBitPlanes();
        }
Exemple #5
0
        private void CheckForUp()
        {
            if (this.GameState.Loading || this.GameState.InMap || (this.GameState.Paused || !this.CameraManager.ActionRunning) || (!this.PlayerManager.Grounded || this.InputManager.GrabThrow != FezButtonState.Pressed || this.CameraManager.Viewpoint != FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.AlmostClamp(Vector3.Transform(Vector3.Left, this.TelescopeAo.Rotation))))))
            {
                return;
            }
            Vector3 vector3 = Vector3.Transform(this.PlayerManager.Position - this.TelescopeAo.Position, this.TelescopeAo.Rotation);

            if ((double)Math.Abs(vector3.Z) >= 0.5 || (double)Math.Abs(vector3.Y) >= 0.5)
            {
                return;
            }
            this.Visible                  = true;
            this.State                    = TelescopeHost.StateType.In;
            this.BitTimer                 = 0.0f;
            this.MessageIndex             = -3;
            this.Fader                    = TimeSpan.Zero;
            this.NowViewing               = this.CameraManager.Viewpoint;
            this.PlayerManager.CanControl = false;
            this.PlayerManager.Action     = ActionType.ReadTurnAround;
            this.DotManager.Hidden        = true;
            this.DotManager.PreventPoI    = true;
        }
Exemple #6
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 #7
0
            public void Update(TimeSpan elapsed)
            {
                if (!this.Enabled || this.Path.NeedsTrigger)
                {
                    return;
                }
                if (this.justStarted)
                {
                    this.originalViewpoint       = this.CameraManager.Viewpoint;
                    this.originalCenter          = this.CameraManager.Center;
                    this.originalDirection       = this.CameraManager.Direction;
                    this.originalPixelsPerTrixel = this.CameraManager.PixelsPerTrixel;
                    this.originalRadius          = this.CameraManager.Radius;
                    bool perspective = (this.Nodes[0].CustomData as CameraNodeData).Perspective;
                    if (this.Path.InTransition)
                    {
                        this.nodeIndex = 1;
                        this.Nodes.Insert(0, new PathSegment()
                        {
                            Destination = this.originalCenter,
                            Orientation = Quaternion.Inverse(this.CameraManager.Rotation),
                            CustomData  = (ICloneable) new CameraNodeData()
                            {
                                PixelsPerTrixel = (int)this.originalPixelsPerTrixel,
                                Perspective     = perspective
                            }
                        });
                    }
                    if (this.Path.OutTransition)
                    {
                        this.Nodes.Add(new PathSegment()
                        {
                            Destination = this.originalCenter,
                            Orientation = Quaternion.Inverse(this.CameraManager.Rotation),
                            CustomData  = (ICloneable) new CameraNodeData()
                            {
                                PixelsPerTrixel = (int)this.originalPixelsPerTrixel,
                                Perspective     = perspective
                            }
                        });
                    }
                    if (this.Nodes.Count < 2)
                    {
                        this.EndPath();
                        return;
                    }
                    else
                    {
                        CameraNodeData cameraNodeData = this.Nodes[0].CustomData as CameraNodeData;
                        this.firstNodeViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.Nodes[0].Orientation))));
                        this.CameraManager.ChangeViewpoint(cameraNodeData.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint);
                        if (cameraNodeData.Perspective)
                        {
                            this.CameraManager.Radius = 1.0 / 1000.0;
                        }
                        if (cameraNodeData.PixelsPerTrixel != 0 && (double)this.CameraManager.PixelsPerTrixel != (double)cameraNodeData.PixelsPerTrixel)
                        {
                            this.CameraManager.PixelsPerTrixel = (float)cameraNodeData.PixelsPerTrixel;
                        }
                        this.StartNewSegment();
                        this.justStarted = false;
                    }
                }
                if (this.CameraManager.ActionRunning)
                {
                    this.sinceSegmentStarted += elapsed;
                }
                if (this.sinceSegmentStarted >= this.CurrentNode.Duration + this.CurrentNode.WaitTimeOnFinish)
                {
                    this.ChangeSegment();
                }
                if (!this.Enabled || this.Path.NeedsTrigger)
                {
                    return;
                }
                float       num1         = (float)FezMath.Saturate(this.sinceSegmentStarted.TotalSeconds / this.CurrentNode.Duration.TotalSeconds);
                float       amount       = (double)this.CurrentNode.Deceleration != 0.0 || (double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Deceleration != 0.0 ? Easing.EaseInOut((double)num1, EasingType.Sine, this.CurrentNode.Acceleration, EasingType.Sine, this.CurrentNode.Deceleration) : Easing.Ease((double)num1, this.CurrentNode.Acceleration, EasingType.Quadratic)) : Easing.Ease((double)num1, -this.CurrentNode.Deceleration, EasingType.Quadratic)) : num1;
                PathSegment pathSegment1 = this.Nodes[Math.Max(this.nodeIndex - 1, 0)];
                PathSegment currentNode  = this.CurrentNode;
                Vector3     vector3_1;
                Quaternion  quat;

                if (this.Path.IsSpline)
                {
                    PathSegment pathSegment2 = this.Nodes[Math.Max(this.nodeIndex - 2, 0)];
                    PathSegment pathSegment3 = this.Nodes[Math.Min(this.nodeIndex + 1, this.Nodes.Count - 1)];
                    vector3_1 = Vector3.CatmullRom(pathSegment2.Destination, pathSegment1.Destination, currentNode.Destination, pathSegment3.Destination, amount);
                    quat      = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount);
                }
                else
                {
                    vector3_1 = Vector3.Lerp(pathSegment1.Destination, currentNode.Destination, amount);
                    quat      = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount);
                }
                float num2 = MathHelper.Lerp(pathSegment1.JitterFactor, currentNode.JitterFactor, amount);

                if ((double)num2 > 0.0)
                {
                    vector3_1 += new Vector3(RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f);
                }
                Vector3        vector3_2       = Vector3.Transform(Vector3.Forward, quat);
                CameraNodeData cameraNodeData1 = pathSegment1.CustomData as CameraNodeData;
                CameraNodeData cameraNodeData2 = currentNode.CustomData as CameraNodeData;

                if (!cameraNodeData2.Perspective)
                {
                    this.CameraManager.PixelsPerTrixel = MathHelper.Lerp(cameraNodeData1.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData1.PixelsPerTrixel, cameraNodeData2.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData2.PixelsPerTrixel, amount);
                }
                Viewpoint view = cameraNodeData2.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint;

                if (view != this.CameraManager.Viewpoint)
                {
                    if (view == Viewpoint.Perspective)
                    {
                        this.CameraManager.Radius = 1.0 / 1000.0;
                    }
                    this.CameraManager.ChangeViewpoint(view);
                }
                this.CameraManager.Center    = vector3_1;
                this.CameraManager.Direction = vector3_2;
                if (!cameraNodeData2.Perspective)
                {
                    return;
                }
                if (this.nodeIndex == 1)
                {
                    this.CameraManager.Radius = MathHelper.Lerp(this.originalRadius, 1.0 / 1000.0, amount);
                }
                else if (this.nodeIndex == this.Nodes.Count - 1)
                {
                    this.CameraManager.Radius = MathHelper.Lerp(1.0 / 1000.0, this.originalRadius, amount);
                }
                else
                {
                    this.CameraManager.Radius = 1.0 / 1000.0;
                }
            }
Exemple #8
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);
         }
     }
 }