private void SpawnDust(TrileInstance instance, float opacity, AnimatedTexture animation, bool onRight, bool onLeft) { float num1 = (float)((double)instance.Center.Y - (double)instance.TransformedSize.Y / 2.0 * (double)Math.Sign(this.CollisionManager.GravityFactor) + (double)animation.FrameHeight / 32.0 * (double)Math.Sign(this.CollisionManager.GravityFactor)); float num2 = (float)((double)FezMath.Dot(instance.TransformedSize, FezMath.SideMask(this.CameraManager.Viewpoint)) / 2.0 + (double)animation.FrameWidth / 32.0 * 2.0 / 3.0); if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type)) { num2 -= 0.25f; } opacity = 1f; Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint); bool b = (double)this.CollisionManager.GravityFactor < 0.0; if (onRight) { BackgroundPlane backgroundPlane; this.LevelManager.AddPlane(backgroundPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation) { OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)FezMath.AsNumeric(b) * 3.141593f), Doublesided = true, Loop = false, Opacity = opacity, Timing = { Step = 0.0f } }); backgroundPlane.Position = instance.Center * FezMath.XZMask + vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2; backgroundPlane.Billboard = true; } if (!onLeft) { return; } BackgroundPlane backgroundPlane1; this.LevelManager.AddPlane(backgroundPlane1 = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation) { OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f) * Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)FezMath.AsNumeric(b) * 3.141593f), Doublesided = true, Loop = false, Opacity = opacity, Timing = { Step = 0.0f } }); backgroundPlane1.Position = instance.Center * FezMath.XZMask - vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2; backgroundPlane1.Billboard = true; }
private bool TryExplodeAt(BombsHost.BombState state, TrileInstance nearestNeighbor, ref bool chainsploded, ref bool needsRecull) { if (nearestNeighbor != null && nearestNeighbor.Enabled && !nearestNeighbor.Trile.Immaterial) { if (!ActorTypeExtensions.IsChainsploding(nearestNeighbor.Trile.ActorSettings.Type) && !ActorTypeExtensions.IsDestructible(nearestNeighbor.Trile.ActorSettings.Type)) { return(true); } if (!this.bombStates.ContainsKey(nearestNeighbor)) { if (ActorTypeExtensions.IsBomb(nearestNeighbor.Trile.ActorSettings.Type)) { nearestNeighbor.PhysicsState.Respawned = false; } if (!chainsploded) { this.bsToAdd.Add(new KeyValuePair <TrileInstance, BombsHost.BombState>(nearestNeighbor, new BombsHost.BombState() { SincePickup = state.SincePickup - this.ChainsplodeDelay, IsChainsploding = true, ChainsplodedBy = state })); chainsploded = true; } else { this.ClearDestructible(nearestNeighbor, true); this.LevelMaterializer.CullInstanceOut(nearestNeighbor); this.DropSupportedTriles(nearestNeighbor); needsRecull = true; } return(true); } } return(false); }
private bool IsHuggable(TrileInstance instance, IPhysicsEntity entity) { if (instance != null && instance.Enabled && !instance.Trile.Immaterial && ((!instance.Trile.Thin || instance.Trile.ForceHugging) && (instance != this.PlayerManager.CarriedInstance && instance != this.PlayerManager.PushedInstance)) && (!ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && (instance.PhysicsState == null || instance.PhysicsState != entity))) { return(!FezMath.In <CollisionType>(instance.GetRotatedFace(entity.Background ? FezMath.GetOpposite(this.CameraManager.VisibleOrientation) : this.CameraManager.VisibleOrientation), CollisionType.Immaterial, CollisionType.TopNoStraightLedge, CollisionType.AllSides, (IEqualityComparer <CollisionType>)CollisionTypeComparer.Default)); } else { return(false); } }
public override void Update(GameTime gameTime) { if (this.CameraManager.Viewpoint == Viewpoint.Perspective || !this.CameraManager.ActionRunning || (this.GameState.Paused || this.GameState.InMap) || (this.CameraManager.RequestedViewpoint != Viewpoint.None || this.GameState.Loading)) { return; } foreach (BombsHost.DestructibleGroup destructibleGroup1 in this.destructibleGroups) { if (destructibleGroup1.RespawnIn.HasValue) { BombsHost.DestructibleGroup destructibleGroup2 = destructibleGroup1; float?nullable1 = destructibleGroup2.RespawnIn; float num = (float)gameTime.ElapsedGameTime.TotalSeconds; float?nullable2 = nullable1.HasValue ? new float?(nullable1.GetValueOrDefault() - num) : new float?(); destructibleGroup2.RespawnIn = nullable2; if ((double)destructibleGroup1.RespawnIn.Value <= 0.0) { bool flag = true; foreach (TrileInstance instance in destructibleGroup1.AllTriles) { if (!instance.Enabled || instance.Hidden || instance.Removed) { instance.Enabled = false; instance.Hidden = true; ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, instance, flag || RandomHelper.Probability(0.25))); flag = false; } } destructibleGroup1.RespawnIn = new float?(); } } } TrileInstance carriedInstance = this.PlayerManager.CarriedInstance; if (carriedInstance != null && ActorTypeExtensions.IsBomb(carriedInstance.Trile.ActorSettings.Type) && !this.bombStates.ContainsKey(carriedInstance)) { carriedInstance.Foreign = carriedInstance.PhysicsState.Respawned = false; this.bombStates.Add(carriedInstance, new BombsHost.BombState()); } bool flag1 = false; bool flag2 = false; foreach (TrileInstance instance in this.bombStates.Keys) { BombsHost.BombState state = this.bombStates[instance]; if (!ActionTypeExtensions.IsEnteringDoor(this.PlayerManager.Action)) { state.SincePickup += gameTime.ElapsedGameTime; } bool flag3 = instance.Trile.ActorSettings.Type == ActorType.BigBomb; bool flag4 = instance.Trile.ActorSettings.Type == ActorType.TntBlock || instance.Trile.ActorSettings.Type == ActorType.TntPickup; if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && instance.Hidden) { this.bsToRemove.Add(instance); if (state.Flash != null) { this.flashesMesh.RemoveGroup(state.Flash); state.Flash = (Group)null; } if (state.Emitter != null && state.Emitter.Cue != null) { state.Emitter.Cue.Stop(false); } } else { if (state.SincePickup > this.FlashTime && state.Explosion == null) { if (state.Flash == null) { state.Flash = this.flashesMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, this.FlashColor, true); if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && !state.IsChainsploding) { state.Emitter = SoundEffectExtensions.EmitAt(this.countdownSound, instance.Center); state.Emitter.PauseViewTransitions = true; } } double totalSeconds = state.SincePickup.TotalSeconds; if (totalSeconds > this.ExplodeStart.TotalSeconds - 1.0) { totalSeconds *= 2.0; } state.Flash.Enabled = FezMath.Frac(totalSeconds) < 0.5; if (state.Flash.Enabled) { state.Flash.Position = instance.Center; state.Flash.Rotation = this.CameraManager.Rotation; } } if (state.SincePickup > this.ExplodeStart && state.Explosion == null) { if (flag4 && !flag1 || !flag4 && !flag2) { SoundEffectExtensions.EmitAt(flag4 ? this.crystalsplodeSound : this.explodeSound, instance.Center, RandomHelper.Centered(0.025)); if (flag4) { flag1 = true; } else { flag2 = true; } } if (state.ChainsplodedBy != null && state.ChainsplodedBy.Emitter != null) { state.ChainsplodedBy.Emitter.FadeOutAndDie(0.0f); } float num1 = (flag3 ? 0.6f : 0.3f) * FezMath.Saturate((float)(1.0 - (double)(instance.Center - this.PlayerManager.Center).Length() / 15.0)); if (CamShake.CurrentCamShake == null) { ServiceHelper.AddComponent((IGameComponent) new CamShake(this.Game) { Duration = TimeSpan.FromSeconds(0.75), Distance = num1 }); } else { CamShake.CurrentCamShake.Reset(); } this.ParticleSystemManager.PropagateEnergy(instance.Center, flag3 ? 6f : 3f); this.flashesMesh.RemoveGroup(state.Flash); state.Flash = (Group)null; switch (instance.Trile.ActorSettings.Type) { case ActorType.BigBomb: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.bigBombAnimation) { ActorType = ActorType.Bomb }; break; case ActorType.TntBlock: case ActorType.TntPickup: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.tntAnimation) { ActorType = ActorType.Bomb }; break; default: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.bombAnimation) { ActorType = ActorType.Bomb }; break; } state.Explosion.Timing.Loop = false; state.Explosion.Billboard = true; state.Explosion.Fullbright = true; state.Explosion.OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)RandomHelper.Random.Next(0, 4) * 1.570796f); state.Explosion.Timing.Restart(); this.LevelManager.AddPlane(state.Explosion); state.Flare = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)this.flare) { AlwaysOnTop = true, LightMap = true, AllowOverbrightness = true, Billboard = true }; this.LevelManager.AddPlane(state.Flare); state.Flare.Scale = Vector3.One * (flag3 ? 3f : 1.5f); state.Explosion.Position = state.Flare.Position = instance.Center + (RandomHelper.Centered(1.0 / 1000.0) - 0.5f) * FezMath.ForwardVector(this.CameraManager.Viewpoint); float num2 = flag3 ? 3f : 1.5f; float num3 = ((this.PlayerManager.Position - instance.Center) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint)).Length(); if ((this.PlayerManager.CarriedInstance == instance || (double)num3 < (double)num2) && this.PlayerManager.Action != ActionType.Dying) { this.PlayerManager.Action = ActionType.Suffering; } if ((instance.Trile.ActorSettings.Type == ActorType.TntBlock || state.IsChainsploding) && instance.InstanceId != -1) { this.ParticleSystemManager.Add(new TrixelParticleSystem(this.Game, new TrixelParticleSystem.Settings() { ExplodingInstance = instance, EnergySource = new Vector3?(instance.Center), MaximumSize = 7, Energy = flag4 ? 3f : 1.5f, Darken = true, ParticleCount = 4 + 12 / Math.Max(1, this.TrixelParticleSystems.Count - 3) })); } if (ActorTypeExtensions.IsPickable(instance.Trile.ActorSettings.Type)) { instance.Enabled = false; this.LevelMaterializer.GetTrileMaterializer(instance.Trile).UpdateInstance(instance); } else { this.ClearDestructible(instance, false); } this.DropSupportedTriles(instance); this.DestroyNeighborhood(instance, state); } if (state.Explosion != null) { state.Flare.Filter = Color.Lerp(flag4 ? new Color(0.5f, 1f, 0.25f) : new Color(1f, 0.5f, 0.25f), Color.Black, state.Explosion.Timing.NormalizedStep); if (state.Explosion.Timing.Ended) { this.bsToRemove.Add(instance); if (instance.PhysicsState != null) { instance.PhysicsState.ShouldRespawn = ActorTypeExtensions.IsPickable(instance.Trile.ActorSettings.Type); } this.LevelManager.RemovePlane(state.Explosion); this.LevelManager.RemovePlane(state.Flare); } } } } foreach (TrileInstance key in this.bsToRemove) { this.bombStates.Remove(key); } this.bsToRemove.Clear(); foreach (KeyValuePair <TrileInstance, BombsHost.BombState> keyValuePair in this.bsToAdd) { if (!this.bombStates.ContainsKey(keyValuePair.Key)) { this.bombStates.Add(keyValuePair.Key, keyValuePair.Value); } } this.bsToAdd.Clear(); }