public LongRunningAction RaiseWater(float unitsPerSecond, float toHeight) { float sign = (float)Math.Sign(toHeight - this.LevelManager.WaterHeight); TrileInstance[] buoyantTriles = Enumerable.ToArray <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.LevelManager.Triles.Values, (Func <TrileInstance, bool>)(x => ActorTypeExtensions.IsBuoyant(x.Trile.ActorSettings.Type)))); if ((double)this.LevelManager.WaterSpeed != 0.0) { this.waterStopStack.Push(new object()); } bool flag = false; if (this.LevelManager.WaterType == LiquidType.Sewer || this.LevelManager.Name == "WATER_WHEEL") { if (this.sewageLevelEmitter != null && !this.sewageLevelEmitter.Dead) { this.sewageLevelEmitter.Cue.Stop(false); flag = true; } if (this.sewageLevelSound == null) { this.sewageLevelSound = this.CMProvider.Global.Load <SoundEffect>("Sounds/Sewer/SewageLevelChange"); } this.sewageLevelEmitter = SoundEffectExtensions.Emit(this.sewageLevelSound, true, !flag); if (!flag) { this.sewageLevelEmitter.VolumeFactor = 0.0f; this.sewageLevelEmitter.Cue.Play(); } } return(new LongRunningAction((Func <float, float, bool>)((elapsed, __) => { if (this.GameState.Paused || this.GameState.InMap || (this.GameState.ForceTimePaused || !this.CameraManager.ActionRunning) || this.CameraManager.Viewpoint == Viewpoint.Perspective) { return false; } if ((double)Math.Sign(toHeight - this.LevelManager.WaterHeight) != (double)sign || this.waterStopStack.Count > 0) { return true; } if (this.sewageLevelEmitter != null && !this.sewageLevelEmitter.Dead) { this.sewageLevelEmitter.VolumeFactor = FezMath.Saturate(this.sewageLevelEmitter.VolumeFactor + elapsed * 1.25f); } this.LevelManager.WaterSpeed = unitsPerSecond * sign; IGameLevelManager temp_142 = this.LevelManager; double temp_150 = (double)temp_142.WaterHeight + (double)this.LevelManager.WaterSpeed * (double)elapsed; temp_142.WaterHeight = (float)temp_150; foreach (TrileInstance item_0 in buoyantTriles) { if (!item_0.PhysicsState.Floating && item_0.PhysicsState.Static && (double)item_0.Center.Y < (double)this.LevelManager.WaterHeight - 0.5) { item_0.PhysicsState.ForceNonStatic = true; item_0.PhysicsState.Ground = new MultipleHits <TrileInstance>(); } } return false; }), (Action)(() => { this.LevelManager.WaterSpeed = 0.0f; if (this.LevelManager.WaterType == LiquidType.Water) { this.GameState.SaveData.GlobalWaterLevelModifier = new float?(this.LevelManager.WaterHeight - this.LevelManager.OriginalWaterHeight); } else { this.GameState.SaveData.ThisLevel.LastStableLiquidHeight = new float?(this.LevelManager.WaterHeight); } if (this.waterStopStack.Count == 0) { if (this.sewageLevelEmitter != null && !this.sewageLevelEmitter.Dead) { this.sewageLevelEmitter.FadeOutAndDie(0.75f); } this.sewageLevelEmitter = (SoundEmitter)null; } if (this.waterStopStack.Count <= 0) { return; } this.waterStopStack.Pop(); }))); }
public LongRunningAction SetWaterHeight(float height) { float sign = (float)Math.Sign(height - this.LevelManager.WaterHeight); TrileInstance[] buoyantTriles = Enumerable.ToArray <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.LevelManager.Triles.Values, (Func <TrileInstance, bool>)(x => ActorTypeExtensions.IsBuoyant(x.Trile.ActorSettings.Type)))); return(new LongRunningAction((Func <float, float, bool>)((elapsed, __) => { if (this.GameState.Paused || this.GameState.InMap || (!this.CameraManager.ActionRunning || this.CameraManager.Viewpoint == Viewpoint.Perspective)) { return false; } if ((double)Math.Sign(height - this.LevelManager.WaterHeight) != (double)sign) { return true; } this.LevelManager.WaterSpeed = 1.2f * sign; IGameLevelManager temp_76 = this.LevelManager; double temp_84 = (double)temp_76.WaterHeight + (double)this.LevelManager.WaterSpeed * (double)elapsed; temp_76.WaterHeight = (float)temp_84; if (this.LevelManager.WaterType != LiquidType.Lava) { foreach (TrileInstance item_0 in buoyantTriles) { if ((double)item_0.Center.Y < (double)this.LevelManager.WaterHeight) { item_0.PhysicsState.Velocity = new Vector3(0.0f, 0.01f, 0.0f); } } } return false; }), (Action)(() => { this.LevelManager.WaterSpeed = 0.0f; if (this.LevelManager.WaterType == LiquidType.Water) { this.GameState.SaveData.GlobalWaterLevelModifier = new float?(this.LevelManager.WaterHeight - this.LevelManager.OriginalWaterHeight); } else { this.GameState.SaveData.ThisLevel.LastStableLiquidHeight = new float?(this.LevelManager.WaterHeight); } }))); }
private void UpdatePickups(float elapsedSeconds) { Vector3 vector3 = Vector3.UnitY * this.CameraManager.Radius / this.CameraManager.AspectRatio; foreach (PickupState pickupState in this.PickupStates) { TrileInstance trileInstance = pickupState.Instance; InstancePhysicsState physicsState = trileInstance.PhysicsState; ActorType type = trileInstance.Trile.ActorSettings.Type; if (!physicsState.Paused && (physicsState.ShouldRespawn || trileInstance.Enabled && trileInstance != this.PlayerManager.CarriedInstance && (!physicsState.Static || pickupState.TouchesWater))) { this.TryFloat(pickupState, elapsedSeconds); if (!physicsState.Vanished && (!pickupState.TouchesWater || !ActorTypeExtensions.IsBuoyant(type))) { physicsState.Velocity += (float)(3.15000009536743 * (double)this.CollisionManager.GravityFactor * 0.150000005960464) * elapsedSeconds * Vector3.Down; } bool grounded = trileInstance.PhysicsState.Grounded; Vector3 center = physicsState.Center; this.PhysicsManager.Update((ISimplePhysicsEntity)physicsState, false, pickupState.Group == null && (!physicsState.Floating || !FezMath.AlmostEqual(physicsState.Velocity.X, 0.0f) || !FezMath.AlmostEqual(physicsState.Velocity.Z, 0.0f))); pickupState.LastMovement = physicsState.Center - center; if (physicsState.NoVelocityClamping) { physicsState.NoVelocityClamping = false; physicsState.Velocity = Vector3.Zero; } if (pickupState.AttachedAOs != null) { foreach (ArtObjectInstance artObjectInstance in pickupState.AttachedAOs) { artObjectInstance.Position += pickupState.LastMovement; } } if (((double)pickupState.LastGroundedCenter.Y - (double)trileInstance.Position.Y) * (double)Math.Sign(this.CollisionManager.GravityFactor) > (double)vector3.Y) { physicsState.Vanished = true; } else if (this.LevelManager.Loops) { while ((double)trileInstance.Position.Y < 0.0) { trileInstance.Position += this.LevelManager.Size * Vector3.UnitY; } while ((double)trileInstance.Position.Y > (double)this.LevelManager.Size.Y) { trileInstance.Position -= this.LevelManager.Size * Vector3.UnitY; } } if (physicsState.Floating && physicsState.Grounded && !physicsState.PushedUp) { physicsState.Floating = pickupState.TouchesWater = (double)trileInstance.Position.Y <= (double)this.LevelManager.WaterHeight - 13.0 / 16.0 + (double)pickupState.FloatMalus; } physicsState.ForceNonStatic = false; if (ActorTypeExtensions.IsFragile(type)) { if (!trileInstance.PhysicsState.Grounded) { pickupState.FlightApex = Math.Max(pickupState.FlightApex, trileInstance.Center.Y); } else if (!trileInstance.PhysicsState.Respawned && (double)pickupState.FlightApex - (double)trileInstance.Center.Y > (double)PickupsHost.BreakHeight(type)) { this.PlayBreakSound(type, trileInstance.Position); trileInstance.PhysicsState.Vanished = true; this.ParticleSystemManager.Add(new TrixelParticleSystem(this.Game, new TrixelParticleSystem.Settings() { ExplodingInstance = trileInstance, EnergySource = new Vector3?(trileInstance.Center - Vector3.Normalize(pickupState.LastVelocity) * trileInstance.TransformedSize / 2f), ParticleCount = 30, MinimumSize = 1, MaximumSize = 8, GravityModifier = 1f, Energy = 0.25f, BaseVelocity = pickupState.LastVelocity * 0.5f })); this.LevelMaterializer.CullInstanceOut(trileInstance); if (type == ActorType.Vase) { trileInstance.PhysicsState = (InstancePhysicsState)null; this.LevelManager.ClearTrile(trileInstance); break; } else { trileInstance.Enabled = false; trileInstance.PhysicsState.ShouldRespawn = true; } } } this.TryPushHorizontalStack(pickupState, elapsedSeconds); if (physicsState.Static) { pickupState.LastMovement = pickupState.LastVelocity = physicsState.Velocity = Vector3.Zero; physicsState.Respawned = false; } if (physicsState.Vanished) { physicsState.ShouldRespawn = true; } if (physicsState.ShouldRespawn && this.PlayerManager.Action != ActionType.FreeFalling) { physicsState.Center = pickupState.OriginalCenter + new Vector3(1.0 / 1000.0); physicsState.UpdateInstance(); physicsState.Velocity = Vector3.Zero; physicsState.ShouldRespawn = false; pickupState.LastVelocity = Vector3.Zero; pickupState.TouchesWater = false; physicsState.Floating = false; physicsState.PushedDownBy = (TrileInstance)null; trileInstance.Enabled = false; trileInstance.Hidden = true; physicsState.Ground = new MultipleHits <TrileInstance>() { NearLow = this.LevelManager.ActualInstanceAt(physicsState.Center - trileInstance.Trile.Size.Y * Vector3.UnitY) }; ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, trileInstance)); } physicsState.UpdateInstance(); this.LevelManager.UpdateInstance(trileInstance); if (!grounded && trileInstance.PhysicsState.Grounded && (double)Math.Abs(pickupState.LastVelocity.Y) > 0.0500000007450581) { float num1 = FezMath.Dot(pickupState.LastVelocity, FezMath.RightVector(this.CameraManager.Viewpoint)); float val1 = FezMath.Saturate(pickupState.LastVelocity.Y / (-0.2f * (float)Math.Sign(this.CollisionManager.GravityFactor))); AnimatedTexture animation; if (ActorTypeExtensions.IsHeavy(trileInstance.Trile.ActorSettings.Type)) { if ((double)val1 > 0.5) { animation = this.largeDust; } else { animation = this.smallDust; val1 *= 2f; } } else { animation = this.smallDust; } float num2 = Math.Max(val1, 0.4f); this.SpawnDust(trileInstance, num2, animation, (double)num1 >= 0.0, (double)num1 <= 0.0); if (animation == this.largeDust && (double)num1 != 0.0) { this.SpawnDust(trileInstance, num2, this.smallDust, (double)num1 <0.0, (double)num1> 0.0); } SoundEffectExtensions.EmitAt(this.thudSound, trileInstance.Position, (float)((double)num2 * -0.600000023841858 + 0.300000011920929), num2); } if (physicsState.Grounded && physicsState.Ground.First.PhysicsState != null) { physicsState.Ground.First.PhysicsState.PushedDownBy = trileInstance; } pickupState.LastVelocity = trileInstance.PhysicsState.Velocity; } } }