public void AddPlane(BackgroundPlane plane) { int key = IdentifierPool.FirstAvailable <BackgroundPlane>(this.BackgroundPlanes); plane.Id = key; this.BackgroundPlanes.Add(key, plane); }
public GeyserState(TrileGroup group, GeysersHost host) { ServiceHelper.InjectServices((object)this); this.Host = host; this.Group = group; this.SinceStateChange = TimeSpan.FromSeconds(-(double)group.GeyserOffset); Vector3 position = Enumerable.Aggregate <TrileInstance, Vector3>((IEnumerable <TrileInstance>) this.Group.Triles, Vector3.Zero, (Func <Vector3, TrileInstance, Vector3>)((a, b) => a + b.Center)) / (float)group.Triles.Count; int key1 = IdentifierPool.FirstAvailable <BackgroundPlane>(this.LevelManager.BackgroundPlanes); this.TopPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, "sewer/sewer_geyser_top", true) { Id = key1, Position = position, YTextureRepeat = true, Crosshatch = true, Doublesided = true }; this.LevelManager.BackgroundPlanes.Add(key1, this.TopPlane); int key2 = IdentifierPool.FirstAvailable <BackgroundPlane>(this.LevelManager.BackgroundPlanes); this.TilePlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, "sewer/sewer_geyser_tile", true) { Id = key2, Position = position, YTextureRepeat = true, Billboard = true }; this.LevelManager.BackgroundPlanes.Add(key2, this.TilePlane); this.TopPlane.Timing.Step = this.TilePlane.Timing.Step; this.loopEmitter = SoundEffectExtensions.EmitAt(this.Host.LoopSound, position, true, 0.0f, 0.0f); foreach (TrileInstance trileInstance in group.Triles) { trileInstance.PhysicsState.IgnoreCollision = true; trileInstance.PhysicsState.IgnoreClampToWater = true; } }
private void TryInitialize() { if (this.isHooked) { this.Gomez.EnteredDoor -= new Action(this.CheckWinCondition); this.isHooked = false; } if (this.LevelManager.Name != "CRYPT") { this.TraversedVolumes.Clear(); } else { if (this.LevelManager.LastLevelName == "CRYPT") { this.TraversedVolumes.Add(this.PlayerManager.DoorVolume.Value); if (this.TraversedVolumes.Count > 4) { this.TraversedVolumes.RemoveAt(0); } for (int index = 0; index < this.TraversedVolumes.Count; ++index) { if (CryptHost.VolumeSequence[this.TraversedVolumes.Count - 1 - index] != this.TraversedVolumes[this.TraversedVolumes.Count - 1 - index]) { this.TraversedVolumes.Clear(); break; } } } else { this.TraversedVolumes.Clear(); } ICollection <int> keys = this.LevelManager.Scripts.Keys; int[] numArray = new int[4] { 0, 1, 2, 3 }; foreach (int key in Enumerable.ToArray <int>(Enumerable.Except <int>((IEnumerable <int>)keys, (IEnumerable <int>)numArray))) { this.LevelManager.Scripts.Remove(key); } foreach (Volume volume in (IEnumerable <Volume>) this.LevelManager.Volumes.Values) { if (volume.Id > 1 && (volume.Id != 14 || this.TraversedVolumes.Count != 3)) { int key = IdentifierPool.FirstAvailable <Script>(this.LevelManager.Scripts); int num = RandomHelper.InList <int>(Enumerable.Except <int>((IEnumerable <int>) this.LevelManager.Volumes.Keys, (IEnumerable <int>) new int[3] { 0, 1, volume.Id })); Script script1 = new Script(); script1.Id = key; List <ScriptTrigger> triggers = script1.Triggers; ScriptTrigger scriptTrigger1 = new ScriptTrigger(); scriptTrigger1.Event = "Enter"; scriptTrigger1.Object = new Entity() { Type = "Volume", Identifier = new int?(volume.Id) }; ScriptTrigger scriptTrigger2 = scriptTrigger1; triggers.Add(scriptTrigger2); List <ScriptAction> actions = script1.Actions; ScriptAction scriptAction1 = new ScriptAction(); scriptAction1.Operation = "ChangeLevelToVolume"; scriptAction1.Arguments = new string[4] { "CRYPT", num.ToString(), "True", "False" }; scriptAction1.Object = new Entity() { Type = "Level" }; ScriptAction scriptAction2 = scriptAction1; actions.Add(scriptAction2); Script script2 = script1; foreach (ScriptAction scriptAction3 in script2.Actions) { scriptAction3.Process(); } this.LevelManager.Scripts.Add(key, script2); } } this.LevelManager.Scripts[2].Disabled = this.TraversedVolumes.Count != 3; } }
private void TryInitialize() { this.Destroy(); this.Visible = this.Enabled = this.LevelManager.Name == "HEX_REBUILD"; if (!this.Enabled) { return; } this.GameState.HideHUD = true; this.CameraManager.ChangeViewpoint(Viewpoint.Right, 0.0f); this.PlayerManager.Background = false; ArtObject artObject = this.CMProvider.CurrentLevel.Load <ArtObject>("Art Objects/NEW_HEXAO"); int key = IdentifierPool.FirstAvailable <ArtObjectInstance>(this.LevelManager.ArtObjects); this.HexahedronAo = new ArtObjectInstance(artObject) { Id = key }; this.LevelManager.ArtObjects.Add(key, this.HexahedronAo); this.HexahedronAo.Initialize(); this.HexahedronAo.Hidden = true; this.WhiteCube = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored(), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false }; this.WhiteCube.Rotation = this.CameraManager.Rotation * Quaternion.CreateFromRotationMatrix(Matrix.CreateLookAt(Vector3.One, Vector3.Zero, Vector3.Up)); this.WhiteCube.AddColoredBox(new Vector3(4f), Vector3.Zero, Color.White, true); FinalRebuildHost finalRebuildHost = this; Mesh mesh1 = new Mesh(); Mesh mesh2 = mesh1; DefaultEffect.LitTextured litTextured1 = new DefaultEffect.LitTextured(); litTextured1.Specular = true; litTextured1.Emissive = 0.5f; litTextured1.AlphaIsEmissive = true; DefaultEffect.LitTextured litTextured2 = litTextured1; mesh2.Effect = (BaseEffect)litTextured2; mesh1.Blending = new BlendingMode?(BlendingMode.Opaque); Mesh mesh3 = mesh1; finalRebuildHost.SolidCubes = mesh3; this.OriginalCubeRotation = this.SolidCubes.Rotation = this.WhiteCube.Rotation; ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> geometry1 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.CubeShard)).Geometry; ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> geometry2 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)).Geometry; this.sHexAppear = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/HexAppear"); this.sCubeAppear = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/CubeAppear"); this.sMotorSpin1 = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStart1"); this.sMotorSpin2 = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStart2"); this.sMotorSpinAOK = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStartAOK"); this.sMotorSpinCrash = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/MotorStartCrash"); this.sRayWhiteout = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/RayWhiteout"); this.sAku = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/Aku"); this.sZoomIn = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/ZoomIn"); this.sAmbientDrone = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/AmbientDrone"); for (int index = 0; index < Math.Min(this.GameState.SaveData.CubeShards + this.GameState.SaveData.SecretCubes, 64); ++index) { Vector3 vector3 = this.CubeOffsets[index]; ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> indexedPrimitives = index < this.GameState.SaveData.CubeShards ? geometry1 : geometry2; Group group = this.SolidCubes.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionNormalTextureInstance>(Enumerable.ToArray <VertexPositionNormalTextureInstance>((IEnumerable <VertexPositionNormalTextureInstance>)indexedPrimitives.Vertices), indexedPrimitives.Indices, indexedPrimitives.PrimitiveType); group.Position = vector3; group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float)RandomHelper.Random.Next(0, 4) * 1.570796f); group.Enabled = false; group.Material = new Material(); } this.SolidCubes.Texture = this.LevelMaterializer.TrilesMesh.Texture; this.InvertEffect = new InvertEffect(); this.RaysMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored(), Blending = new BlendingMode?(BlendingMode.Additive), DepthWrites = false }; this.FlareMesh = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/flare_alpha")), Blending = new BlendingMode?(BlendingMode.Alphablending), SamplerState = SamplerState.AnisotropicClamp, DepthWrites = false, AlwaysOnTop = true }; this.FlareMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, true); this.RtHandle = this.TargetRenderer.TakeTarget(); this.TargetRenderer.ScheduleHook(this.DrawOrder, this.RtHandle.Target); ServiceHelper.AddComponent((IGameComponent)(this.Glitches = new NesGlitches(this.Game))); }
private void TryInitialize() { this.BatchedInstances.Clear(); this.BatchedInstancesSet.Clear(); this.CleanInstances.Clear(); this.AllEmplacements.Clear(); this.AllEmplacements.TrimExcess(); this.CleanInstances.TrimExcess(); this.BatchedInstances.TrimExcess(); this.RandomTrileIds = (int[])null; if (this.Enabled) { this.LevelMaterializer.TrileInstanceBatched -= new Action <TrileInstance>(this.BatchInstance); } this.Enabled = false; if (!this.LevelManager.Quantum || this.LevelManager.TrileSet == null) { return; } this.Enabled = true; List <int> list1 = Enumerable.ToList <int>(Enumerable.Select <Trile, int>(Enumerable.Where <Trile>(this.LevelMaterializer.MaterializedTriles, (Func <Trile, bool>)(x => { if (x.Geometry != null && !x.Geometry.Empty && !ActorTypeExtensions.IsTreasure(x.ActorSettings.Type)) { return(x.ActorSettings.Type != ActorType.SplitUpCube); } else { return(false); } })), (Func <Trile, int>)(x => x.Id))); this.RandomTrileIds = new int[250]; int num = 0; for (int index1 = 0; index1 < 250; ++index1) { int index2 = Quantumizer.Random.Next(0, list1.Count); int index3 = list1[index2]; this.RandomTrileIds[num++] = index3; this.LevelManager.TrileSet[index3].ForceKeep = true; list1.RemoveAt(index2); } Trile trile = Enumerable.FirstOrDefault <Trile>((IEnumerable <Trile>) this.LevelManager.TrileSet.Triles.Values, (Func <Trile, bool>)(x => x.Name == "__QIPT")); if (trile == null) { trile = new Trile(CollisionType.None) { Name = "__QIPT", Immaterial = true, SeeThrough = true, Thin = true, TrileSet = this.LevelManager.TrileSet, MissingTrixels = (TrixelCluster)null, Id = IdentifierPool.FirstAvailable <Trile>((IDictionary <int, Trile>) this.LevelManager.TrileSet.Triles) }; this.LevelManager.TrileSet.Triles.Add(trile.Id, trile); this.LevelMaterializer.RebuildTrile(trile); } List <int> list2 = new List <int>(); bool flag = (double)this.LevelManager.Size.X > (double)this.LevelManager.Size.Z; float[] numArray = new float[4] { 0.0f, 1.570796f, 3.141593f, 4.712389f }; for (int y = 0; (double)y < (double)this.LevelManager.Size.Y; ++y) { if (flag) { list2.Clear(); list2.AddRange(Enumerable.Range(0, (int)this.LevelManager.Size.Z)); for (int x = 0; (double)x < (double)this.LevelManager.Size.X; ++x) { int z; if (list2.Count > 0) { int index = RandomHelper.Random.Next(0, list2.Count); z = list2[index]; list2.RemoveAt(index); } else { z = RandomHelper.Random.Next(0, (int)this.LevelManager.Size.Z); } this.LevelManager.RestoreTrile(new TrileInstance(new TrileEmplacement(x, y, z), trile.Id) { Phi = numArray[Quantumizer.Random.Next(0, 4)] }); } while (list2.Count > 0) { int index = RandomHelper.Random.Next(0, list2.Count); int z = list2[index]; list2.RemoveAt(index); this.LevelManager.RestoreTrile(new TrileInstance(new TrileEmplacement(RandomHelper.Random.Next(0, (int)this.LevelManager.Size.X), y, z), trile.Id) { Phi = numArray[Quantumizer.Random.Next(0, 4)] }); } } else { list2.Clear(); list2.AddRange(Enumerable.Range(0, (int)this.LevelManager.Size.X)); for (int z = 0; (double)z < (double)this.LevelManager.Size.Z; ++z) { int x; if (list2.Count > 0) { int index = RandomHelper.Random.Next(0, list2.Count); x = list2[index]; list2.RemoveAt(index); } else { x = RandomHelper.Random.Next(0, (int)this.LevelManager.Size.X); } this.LevelManager.RestoreTrile(new TrileInstance(new TrileEmplacement(x, y, z), trile.Id) { Phi = numArray[Quantumizer.Random.Next(0, 4)] }); } while (list2.Count > 0) { int index = RandomHelper.Random.Next(0, list2.Count); int x = list2[index]; list2.RemoveAt(index); this.LevelManager.RestoreTrile(new TrileInstance(new TrileEmplacement(x, y, RandomHelper.Random.Next(0, (int)this.LevelManager.Size.Z)), trile.Id) { Phi = numArray[Quantumizer.Random.Next(0, 4)] }); } } } foreach (TrileInstance trileInstance in (IEnumerable <TrileInstance>) this.LevelManager.Triles.Values) { trileInstance.VisualTrileId = new int?(this.RandomTrileIds[Quantumizer.Random.Next(0, this.RandomTrileIds.Length)]); trileInstance.RefreshTrile(); trileInstance.NeedsRandomCleanup = true; } this.LevelMaterializer.CleanUp(); this.LevelMaterializer.TrileInstanceBatched += new Action <TrileInstance>(this.BatchInstance); }