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; } } }