public override void Initialize() { base.Initialize(); ServiceHelper.AddComponent((IGameComponent)(this.trailsRenderer = new SplitUpCubeHost.TrailsRenderer(this.Game, this))); this.LevelManager.LevelChanged += new Action(this.TryInitialize); this.trailsRenderer.Visible = this.Enabled = this.Visible = false; this.SoundManager.SongChanged += new Action(this.RefreshSounds); this.LightingPostProcess.DrawGeometryLights += new Action(this.DrawLights); }
public override void Initialize() { base.Initialize(); ServiceHelper.AddComponent((IGameComponent) (this.trailsRenderer = new SplitUpCubeHost.TrailsRenderer(this.Game, this))); this.LevelManager.LevelChanged += new Action(this.TryInitialize); this.trailsRenderer.Visible = this.Enabled = this.Visible = false; this.SoundManager.SongChanged += new Action(this.RefreshSounds); this.LightingPostProcess.DrawGeometryLights += new Action(this.DrawLights); }
private void TryInitialize() { if (this.WireframeCube == null) { this.WireframeCube = new Mesh() { Effect = (BaseEffect)(this.SplitCollectorEffect = new SplitCollectorEffect()), Material = { Diffuse = Vector3.One, Opacity = 1f }, Blending = new BlendingMode?(BlendingMode.Alphablending) }; for (int index = 0; index < 7; ++index) { this.WireframeCube.AddWireframeBox(Vector3.One, Vector3.Zero, new Color(index == 0 ? 1f : (index == 1 ? 0.0f : 0.5f), index == 2 ? 1f : (index == 3 ? 0.0f : 0.5f), index == 4 ? 1f : (index == 5 ? 0.0f : 0.5f), index == 6 ? 1f : 0.0f), true); foreach (Vector3 origin in this.CubeOffsets) { this.WireframeCube.AddWireframeBox(Vector3.One / 2f, origin, new Color(index == 0 ? 1f : (index == 1 ? 0.0f : 0.5f), index == 2 ? 1f : (index == 3 ? 0.0f : 0.5f), index == 4 ? 1f : (index == 5 ? 0.0f : 0.5f), index == 6 ? 0.625f : 0.375f), true); } } this.WireframeCube.CollapseToBuffer <FezVertexPositionColor>(); } this.SolidCubesVisible = true; if (this.TrackedCollects.Count > 0) { this.GameState.SaveData.CollectedParts += this.TrackedCollects.Count; Waiters.Wait(0.5, (Action)(() => Waiters.Wait((Func <bool>)(() => { if (this.PlayerManager.CanControl) { return(this.PlayerManager.Grounded); } else { return(false); } }), (Action)(() => { this.GomezService.OnCollectedSplitUpCube(); this.GameState.OnHudElementChanged(); this.GameState.Save(); this.TryAssembleCube(); })))); } foreach (SplitUpCubeHost.SwooshingCube swooshingCube in this.TrackedCollects) { swooshingCube.Dispose(); } this.TrackedCollects.Clear(); if (this.LevelManager.TrileSet == null) { this.trailsRenderer.Visible = this.Enabled = this.Visible = false; } else { Trile goldenCubeTrile = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.GoldenCube)); IEnumerable <TrileInstance> source = Enumerable.Union <TrileInstance>((IEnumerable <TrileInstance>) this.LevelManager.Triles.Values, Enumerable.SelectMany <KeyValuePair <TrileEmplacement, TrileInstance>, TrileInstance>((IEnumerable <KeyValuePair <TrileEmplacement, TrileInstance> >) this.LevelManager.Triles, (Func <KeyValuePair <TrileEmplacement, TrileInstance>, IEnumerable <TrileInstance> >)(x => (IEnumerable <TrileInstance>)x.Value.OverlappedTriles ?? Enumerable.Empty <TrileInstance>()))); SplitUpCubeHost.TrailsRenderer trailsRenderer = this.trailsRenderer; SplitUpCubeHost splitUpCubeHost = this; bool flag1; this.Visible = flag1 = goldenCubeTrile != null && (Enumerable.Count <TrileInstance>(source, (Func <TrileInstance, bool>)(x => x.TrileId == goldenCubeTrile.Id)) != 0 || this.AssembleScheduled || this.GameState.SaveData.CollectedParts == 8); int num1; bool flag2 = (num1 = flag1 ? 1 : 0) != 0; splitUpCubeHost.Enabled = num1 != 0; int num2 = flag2 ? 1 : 0; trailsRenderer.Visible = num2 != 0; if (!this.Enabled) { return; } this.RefreshSounds(); this.TrackedBits.Clear(); this.TrackedBits.AddRange(Enumerable.Where <TrileInstance>(source, (Func <TrileInstance, bool>)(x => x.TrileId == goldenCubeTrile.Id))); this.SolidCubes.ClearGroups(); ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> geometry = goldenCubeTrile.Geometry; this.SolidCubes.Position = Vector3.Zero; this.SolidCubes.Rotation = Quaternion.Identity; foreach (Vector3 vector3 in this.CubeOffsets) { Group group = this.SolidCubes.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionNormalTextureInstance>(Enumerable.ToArray <VertexPositionNormalTextureInstance>((IEnumerable <VertexPositionNormalTextureInstance>)geometry.Vertices), geometry.Indices, geometry.PrimitiveType); group.Position = vector3; group.BakeTransform <VertexPositionNormalTextureInstance>(); } this.SolidCubes.Texture = this.LevelMaterializer.TrilesMesh.Texture; this.SolidCubes.Rotation = this.WireframeCube.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Right, (float)Math.Asin(Math.Sqrt(2.0) / Math.Sqrt(3.0))) * Quaternion.CreateFromAxisAngle(Vector3.Up, 0.7853982f); this.WireOpacityFactor = 1f; this.SinceNoTrails = 3f; this.ShineOn = (TrileInstance)null; this.UntilNextShine = 7f; if (this.LevelManager.WaterType == LiquidType.Sewer || this.LevelManager.WaterType == LiquidType.Lava || this.LevelManager.BlinkingAlpha) { if (this.SolidCubes.Effect is DefaultEffect.LitTextured) { Mesh mesh = this.SolidCubes; DefaultEffect.Textured textured1 = new DefaultEffect.Textured(); textured1.AlphaIsEmissive = true; textured1.IgnoreCache = true; DefaultEffect.Textured textured2 = textured1; mesh.Effect = (BaseEffect)textured2; } } else if (this.SolidCubes.Effect is DefaultEffect.Textured) { Mesh mesh = this.SolidCubes; DefaultEffect.LitTextured litTextured1 = new DefaultEffect.LitTextured(); litTextured1.Specular = true; litTextured1.Emissive = 0.5f; litTextured1.AlphaIsEmissive = true; litTextured1.IgnoreCache = true; DefaultEffect.LitTextured litTextured2 = litTextured1; mesh.Effect = (BaseEffect)litTextured2; } this.TryAssembleCube(); } }