public static Mesh TrileToMesh(Trile t) { Mesh m = new Mesh(); Vector3[] vertices = new Vector3[t.Geometry.Vertices.Length]; int[] triangles = new int[t.Geometry.Indices.Length]; Vector2[] uv = new Vector2[vertices.Length]; for (int i = 0; i < vertices.Length; i++) { vertices[i] = t.Geometry.Vertices[i].Position; uv[i] = t.Geometry.Vertices[i].TextureCoordinate; } for (int i = 0; i < triangles.Length; i += 3) { triangles[i] = t.Geometry.Indices[i + 2]; triangles[i + 1] = t.Geometry.Indices[i + 1]; triangles[i + 2] = t.Geometry.Indices[i]; } m.vertices = vertices; m.triangles = triangles; m.uv = uv; m.RecalculateNormals(); m.Optimize(); return(m); }
public Mesh GenMesh(Trile trile) { Mesh mesh = GenMesh(trile.Geometry); mesh.name = trile.Name; return(mesh); }
public IEnumerator SetTrileData(Trile t) { model.SetMeshCollider(t); yield return(new WaitForEndOfFrame()); model.GenerateDataFromTrile(); }
private static void DisableTrile(TrileInstance instance) { Trile trile = instance.Trile; trile.ActorSettings.Type = ActorType.None; trile.Faces[FaceOrientation.Left] = trile.Faces[FaceOrientation.Right] = trile.Faces[FaceOrientation.Back] = trile.Faces[FaceOrientation.Front] = CollisionType.None; }
private static void EnableTrile(TrileInstance instance) { Trile trile = instance.Trile; trile.ActorSettings.Type = ActorType.SinkPickup; trile.Faces[FaceOrientation.Left] = trile.Faces[FaceOrientation.Right] = trile.Faces[FaceOrientation.Back] = trile.Faces[FaceOrientation.Front] = CollisionType.AllSides; }
public void SpawnTrileAt(int id, string actorTypeName) { BoundingBox boundingBox = this.LevelManager.Volumes[id].BoundingBox; Vector3 position1 = (boundingBox.Min + boundingBox.Max) / 2f; Trile trile = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles((ActorType)Enum.Parse(typeof(ActorType), actorTypeName, true))); if (trile == null) { return; } Vector3 vector3 = position1 - Vector3.One / 2f; NearestTriles nearestTriles = this.LevelManager.NearestTrile(position1); TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep; if (trileInstance != null) { vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) * vector3 + trileInstance.Center * FezMath.DepthMask(this.CameraManager.Viewpoint) - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f; } Vector3 position2 = Vector3.Clamp(vector3, Vector3.Zero, this.LevelManager.Size - Vector3.One); ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, new TrileInstance(position2, trile.Id) { OriginalEmplacement = new TrileEmplacement(position2) })); }
public static void SetMeshCollider(Trile trile) { Mesh trileMesh = FezToUnity.TrileToMesh(trile); importerCollider.gameObject.SetActive(true); importerCollider.sharedMesh = null; importerCollider.sharedMesh = trileMesh; }
private bool InstanceMaterialForQuery(TrileInstance instance, QueryOptions options, out LevelManager.QueryResult queryResult) { Trile trile = instance.Trile; CollisionType rotatedFace = instance.GetRotatedFace((options & QueryOptions.Background) == QueryOptions.Background ? FezMath.GetOpposite(this.CameraManager.VisibleOrientation) : this.CameraManager.VisibleOrientation); queryResult = trile.Immaterial || instance.PhysicsState != null && instance.PhysicsState.UpdatingPhysics || rotatedFace == CollisionType.Immaterial ? LevelManager.QueryResult.Nothing : (trile.Thin ? LevelManager.QueryResult.Thin : LevelManager.QueryResult.Full); return(queryResult != LevelManager.QueryResult.Nothing); }
public override void RebuildTrile(Trile trile) { TrileMaterializer trileMaterializer = new TrileMaterializer(trile, this.TrilesMesh, false); this.trileMaterializers.Add(trile, trileMaterializer); trileMaterializer.Geometry = trile.Geometry; trileMaterializer.DetermineFlags(); }
public void SwapTrile(TrileInstance instance, Trile newTrile) { this.LevelMaterializer.CullInstanceOut(instance); this.LevelMaterializer.RemoveInstance(instance); instance.TrileId = newTrile.Id; instance.RefreshTrile(); this.LevelMaterializer.AddInstance(instance); this.LevelMaterializer.CullInstanceIn(instance); }
protected override void TestConditions() { switch (this.PlayerManager.Action) { case ActionType.Jumping: case ActionType.Falling: HorizontalDirection lookingDirection = this.PlayerManager.LookingDirection; if (lookingDirection == HorizontalDirection.None) { break; } Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); Vector3 b = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(lookingDirection); if ((double)FezMath.Dot(this.PlayerManager.Velocity, b) <= 0.025000000372529 && (double)(this.InputManager.Movement.X * (float)FezMath.Sign(lookingDirection)) <= 0.100000001490116) { break; } MultipleHits <CollisionResult> wallCollision = this.PlayerManager.WallCollision; FaceOrientation visibleOrientation = this.CameraManager.VisibleOrientation; TrileInstance trileInstance1 = wallCollision.NearLow.Destination ?? this.PlayerManager.CornerCollision[1 + (lookingDirection == HorizontalDirection.Left ? 2 : 0)].Instances.Deep; TrileInstance trileInstance2 = wallCollision.FarHigh.Destination ?? this.PlayerManager.CornerCollision[lookingDirection == HorizontalDirection.Left ? 2 : 0].Instances.Deep; Trile trile = trileInstance1 == null ? (Trile)null : trileInstance1.Trile; if (trileInstance1 == null || trileInstance1.GetRotatedFace(visibleOrientation) == CollisionType.None || (trile.ActorSettings.Type == ActorType.Ladder || trileInstance1 == trileInstance2) || (trileInstance2 != null && trileInstance2.GetRotatedFace(visibleOrientation) == CollisionType.AllSides || !trileInstance1.Enabled)) { break; } TrileInstance trileInstance3 = this.LevelManager.ActualInstanceAt(trileInstance1.Center - b); TrileInstance trileInstance4 = this.LevelManager.NearestTrile(trileInstance1.Center - b).Deep; if (trileInstance4 != null && trileInstance4.Enabled && trileInstance4.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None || trileInstance3 != null && trileInstance3.Enabled && !trileInstance3.Trile.Immaterial || this.PlayerManager.Action == ActionType.Jumping && (double)((trileInstance1.Center - this.PlayerManager.LeaveGroundPosition) * vector3_1).Length() < 1.25 || trileInstance1.GetRotatedFace(visibleOrientation) != CollisionType.AllSides && BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(trileInstance1.Center, Vector3.Down * (float)Math.Sign(this.CollisionManager.GravityFactor), this.PlayerManager.Size * FezMath.XZMask / 2f, Direction2D.Vertical))) { break; } Vector3 vector3_2 = (-b + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * trileInstance1.TransformedSize / 2f; if ((double)(this.PlayerManager.Center * vector3_1 - trileInstance1.Center * vector3_1 + vector3_2).Length() >= 0.349999994039536) { break; } this.PlayerManager.HeldInstance = trileInstance1; this.PlayerManager.Action = ActionType.GrabCornerLedge; Waiters.Wait(0.1, (Action)(() => { if (this.PlayerManager.HeldInstance == null) { return; } SoundEffectExtensions.EmitAt(this.sound, this.PlayerManager.Position); this.InputManager.ActiveGamepad.Vibrate(VibrationMotor.LeftLow, 0.100000001490116, TimeSpan.FromSeconds(0.200000002980232)); this.InputManager.ActiveGamepad.Vibrate(VibrationMotor.RightHigh, 0.400000005960464, TimeSpan.FromSeconds(0.200000002980232)); })); break; } }
protected LevelManager(Game game) : base(game) { this.levelData = new Level() { SkyName = "Blue" }; this.fallbackTrile = new Trile(CollisionType.TopOnly) { Id = -1 }; this.UpdateOrder = -2; }
private void TryInitialize() { this.sBellHit = (SoundEffect[])null; this.BellAo = Enumerable.FirstOrDefault <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObject.ActorType == ActorType.Bell)); this.Enabled = this.BellAo != null; if (!this.Enabled) { return; } this.OriginalPosition = this.BellAo.Position; this.Hits.Clear(); this.Hits.Add(Viewpoint.Front, 0); this.Hits.Add(Viewpoint.Back, 0); this.Hits.Add(Viewpoint.Left, 0); this.Hits.Add(Viewpoint.Right, 0); this.sBellHit = new SoundEffect[4] { this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/BellHit1"), this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/BellHit2"), this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/BellHit3"), this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/BellHit4") }; this.Solved = this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.BellAo.Id); if (!this.Solved) { return; } this.LevelManager.ArtObjects.Remove(this.BellAo.Id); this.BellAo.Dispose(); this.LevelMaterializer.RegisterSatellites(); if (!this.GameState.SaveData.ThisLevel.DestroyedTriles.Contains(new TrileEmplacement(this.OriginalPosition))) { Trile trile = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)); if (trile != null) { Vector3 position = this.OriginalPosition - Vector3.One / 2f; this.LevelManager.ClearTrile(new TrileEmplacement(position)); TrileInstance toAdd; this.LevelManager.RestoreTrile(toAdd = new TrileInstance(position, trile.Id) { OriginalEmplacement = new TrileEmplacement(position) }); toAdd.Foreign = true; if (toAdd.InstanceId == -1) { this.LevelMaterializer.CullInstanceIn(toAdd); } } } this.Enabled = false; }
private void TryInitialize() { this.Blocks = (List <TrileInstance>)null; if (this.LevelManager.Name == "ZU_TETRIS") { if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(0)) { foreach (TrileInstance instance in Enumerable.ToArray <TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.LevelManager.Triles.Values, (Func <TrileInstance, bool>)(x => x.Trile.ActorSettings.Type == ActorType.SinkPickup)))) { instance.PhysicsState = (InstancePhysicsState)null; this.LevelManager.ClearTrile(instance); } if (!this.GameState.SaveData.ThisLevel.DestroyedTriles.Contains(new TrileEmplacement(TetrisPuzzleHost.PuzzleCenter + Vector3.UnitY - FezMath.HalfVector))) { Trile trile = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)); if (trile != null) { Vector3 position = TetrisPuzzleHost.PuzzleCenter + Vector3.UnitY - FezMath.HalfVector; this.LevelManager.ClearTrile(new TrileEmplacement(position)); TrileInstance toAdd; this.LevelManager.RestoreTrile(toAdd = new TrileInstance(position, trile.Id) { OriginalEmplacement = new TrileEmplacement(position) }); if (toAdd.InstanceId == -1) { this.LevelMaterializer.CullInstanceIn(toAdd); } } } this.Enabled = false; } else { this.Enabled = true; } } else { this.Enabled = false; } if (!this.Enabled) { return; } this.Blocks = new List <TrileInstance>(); this.Blocks.AddRange(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.LevelManager.Triles.Values, (Func <TrileInstance, bool>)(x => x.Trile.ActorSettings.Type == ActorType.SinkPickup))); }
protected override void TestConditions() { if (this.PlayerManager.Background) { return; } switch (this.PlayerManager.Action) { case ActionType.Teetering: case ActionType.IdlePlay: case ActionType.IdleSleep: case ActionType.IdleLookAround: case ActionType.IdleYawn: case ActionType.Idle: case ActionType.LookingLeft: case ActionType.LookingRight: case ActionType.LookingUp: case ActionType.LookingDown: case ActionType.Walking: case ActionType.Running: case ActionType.Sliding: case ActionType.Landing: if (!this.PlayerManager.Grounded || this.InputManager.Down != FezButtonState.Pressed) { break; } TrileInstance trileInstance1 = this.PlayerManager.Ground.NearLow; TrileInstance trileInstance2 = this.PlayerManager.Ground.FarHigh; Trile trile = trileInstance1 == null ? (Trile)null : trileInstance1.Trile; Vector3 vector3 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); TrileInstance trileInstance3 = this.PlayerManager.Ground.NearLow ?? this.PlayerManager.Ground.FarHigh; if (BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(trileInstance3.Center + trileInstance3.TransformedSize * (Vector3.UnitY * 0.498f + vector3 * 0.5f), Vector3.Down * (float)Math.Sign(this.CollisionManager.GravityFactor), this.PlayerManager.Size * FezMath.XZMask / 2f, Direction2D.Vertical)) || trileInstance1 == null || (trileInstance1.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.None || trile.ActorSettings.Type == ActorType.Ladder) || (trileInstance1 == trileInstance2 || trileInstance2 != null && trileInstance2.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None)) { break; } TrileInstance trileInstance4 = this.LevelManager.ActualInstanceAt(trileInstance1.Position + vector3 + new Vector3(0.5f)); TrileInstance trileInstance5 = this.LevelManager.NearestTrile(trileInstance1.Position + vector3 + new Vector3(0.5f)).Deep; if (trileInstance5 != null && trileInstance5.Enabled && trileInstance5.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None || trileInstance4 != null && trileInstance4.Enabled && (!trileInstance4.Trile.Immaterial && trileInstance4.Trile.ActorSettings.Type != ActorType.Vine)) { break; } this.WalkTo.Destination = new Func <Vector3>(this.GetDestination); this.WalkTo.NextAction = ActionType.LowerToCornerLedge; this.PlayerManager.Action = ActionType.WalkingTo; this.PlayerManager.HeldInstance = trileInstance1; break; } }
public static Mesh GetUnityMesh(this Trile trile) { FezUnityTrileSet trileSet; FezUnityLevel level = FezUnityLevel.Current; // Microoptimization: TrileSet.TrileSet - direct access if (level != null && level.TrileSet != null && level.TrileSet.TrileSet.Name == trile.TrileSet.Name) { trileSet = level.TrileSet; } else { // Automatically generates if required trileSet = FezManager.Instance.GetUnityTrileSet(trile.TrileSet.Name); } return(trileSet.Triles[trile.Id]); }
private bool TestSignCollision(VerticalDirection direction) { TrileInstance trileInstance = this.PlayerManager.AxisCollision[direction].Surface; if (trileInstance == null) { return(false); } Trile trile = trileInstance.Trile; FaceOrientation faceOrientation = FezMath.OrientationFromPhi(FezMath.ToPhi(trile.ActorSettings.Face) + trileInstance.Phi); bool flag = trile.ActorSettings.Type == ActorType.Sign && faceOrientation == this.CameraManager.VisibleOrientation && trileInstance.ActorSettings != (InstanceActorSettings)null && !string.IsNullOrEmpty(trileInstance.ActorSettings.SignText); if (flag) { this.signText = trileInstance.ActorSettings.SignText; } return(flag); }
private bool TestObstruction(Vector3 hitStart, float hitDistance) { Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); foreach (TrileInstance trileInstance in (IEnumerable <TrileInstance>) this.LevelManager.Triles.Values) { if (trileInstance.InstanceId != -1 && (double)((trileInstance.Center - hitStart) * vector3).LengthSquared() < 0.5) { Trile trile = trileInstance.Trile; if (trileInstance.Enabled && !trile.Immaterial && !trile.SeeThrough) { return((double)FezMath.Dot(trileInstance.Position + Vector3.One / 2f + b * -0.5f - hitStart, b) <= (double)hitDistance + 0.25); } } } return(false); }
public TrileMaterializer(Trile trile, Mesh levelMesh, bool mutableSurfaces) { ServiceHelper.InjectServices((object)this); this.trile = trile; if (mutableSurfaces) { this.surfaces = new List <TrixelSurface>(); this.added = new HashSet <TrixelFace>(); this.removed = new HashSet <TrixelFace>(); } if (levelMesh == null) { return; } this.group = levelMesh.AddGroup(); this.tempInstances = new List <Vector4>(); this.tempInstanceIds = new List <TrileInstance>(); this.group.Geometry = (IIndexedPrimitiveCollection)this.geometry; }
protected override void TestConditions() { if (!this.PlayerManager.Grounded) { this.UnDotize(); } else if (this.PlayerManager.CarriedInstance != null) { this.UnDotize(); } else { bool flag = false; foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values) { TrileInstance trileInstance = nearestTriles.Surface; if (trileInstance != null) { Trile trile = trileInstance.Trile; FaceOrientation faceOrientation = FezMath.OrientationFromPhi(FezMath.ToPhi(trile.ActorSettings.Face) + trileInstance.Phi); if (ActorTypeExtensions.IsDoor(trile.ActorSettings.Type) && faceOrientation == FezMath.VisibleOrientation(this.CameraManager.Viewpoint)) { flag = this.GameState.SaveData.Keys > 0 && this.LevelManager.Name != "VILLAGEVILLE_2D" || trile.ActorSettings.Type == ActorType.UnlockedDoor; this.isUnlocked = trile.ActorSettings.Type == ActorType.UnlockedDoor; this.doorBottom = trileInstance; break; } } } if (!flag) { this.UnDotize(); } else if (this.doorBottom.ActorSettings.Inactive) { this.UnDotize(); } else { if (!this.PlayerManager.HideFez && this.PlayerManager.CanControl && (!this.DotManager.PreventPoI && this.doorBottom.Trile.ActorSettings.Type == ActorType.Door)) { this.DotManager.Behaviour = DotHost.BehaviourType.ThoughtBubble; this.DotManager.FaceButton = DotFaceButton.Up; this.DotManager.ComeOut(); if (this.DotManager.Owner != this) { this.DotManager.Hey(); } this.DotManager.Owner = (object)this; } if (this.GameState.IsTrialMode && this.LevelManager.Name == "trial/VILLAGEVILLE_2D" || this.InputManager.ExactUp != FezButtonState.Pressed) { return; } TrileGroup trileGroup1 = (TrileGroup)null; this.aoInstance = (ArtObjectInstance)null; foreach (TrileGroup trileGroup2 in (IEnumerable <TrileGroup>) this.LevelManager.Groups.Values) { if (trileGroup2.Triles.Contains(this.doorBottom)) { trileGroup1 = trileGroup2; break; } } if (trileGroup1 != null) { foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values) { int?attachedGroup = artObjectInstance.ActorSettings.AttachedGroup; int id = trileGroup1.Id; if ((attachedGroup.GetValueOrDefault() != id ? 0 : (attachedGroup.HasValue ? 1 : 0)) != 0) { this.aoInstance = artObjectInstance; break; } } if (this.aoInstance != null) { this.aoInitialRotation = this.aoInstance.Rotation; this.initialAoPosition = this.aoInstance.Position; } } this.WalkTo.Destination = new Func <Vector3>(this.GetDestination); this.PlayerManager.Action = ActionType.WalkingTo; this.WalkTo.NextAction = ActionType.OpeningDoor; } } }
private void TryInitialize() { this.Enabled = false; this.ArtObject = Enumerable.FirstOrDefault <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => { if (x.ArtObject.ActorType == ActorType.QrCode) { return(x.ActorSettings.VibrationPattern != null); } else { return(false); } })); if (this.ArtObject != null) { this.Enabled = true; if (this.GameService.IsSewerQrResolved) { if (this.ArtObject.ActorSettings.AttachedGroup.HasValue) { int key = this.ArtObject.ActorSettings.AttachedGroup.Value; foreach (TrileInstance instance in this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value].Triles.ToArray()) { this.LevelManager.ClearTrile(instance); } this.LevelManager.Groups.Remove(key); } this.LevelManager.Volumes[1].Enabled = false; this.LevelManager.ArtObjects.Remove(this.ArtObject.Id); this.ArtObject.Dispose(); this.LevelMaterializer.RegisterSatellites(); Vector3 position1 = this.ArtObject.Position; if (this.GameState.SaveData.ThisLevel.ScriptingState == "NOT_COLLECTED") { Trile trile = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)); if (trile != null) { Vector3 position2 = position1 - Vector3.One / 2f; this.LevelManager.ClearTrile(new TrileEmplacement(position2)); TrileInstance toAdd; this.LevelManager.RestoreTrile(toAdd = new TrileInstance(position2, trile.Id) { OriginalEmplacement = new TrileEmplacement(position2) }); this.GomezService.CollectedAnti += (Action)(() => this.GameState.SaveData.ThisLevel.ScriptingState = (string)null); if (toAdd.InstanceId == -1) { this.LevelMaterializer.CullInstanceIn(toAdd); } } } this.Enabled = false; } } if (!this.Enabled) { return; } this.ArtObject.ActorSettings.VibrationPattern = Util.JoinArrays <VibrationMotor>(this.ArtObject.ActorSettings.VibrationPattern, new VibrationMotor[3]); }
private void TestInput() { CodeInput codeInput = CodeInput.None; if (this.InputManager.Jump == FezButtonState.Pressed) { codeInput = CodeInput.Jump; } else if (this.InputManager.RotateRight == FezButtonState.Pressed) { codeInput = CodeInput.SpinRight; } else if (this.InputManager.RotateLeft == FezButtonState.Pressed) { codeInput = CodeInput.SpinLeft; } else if (this.InputManager.Left == FezButtonState.Pressed) { codeInput = CodeInput.Left; } else if (this.InputManager.Right == FezButtonState.Pressed) { codeInput = CodeInput.Right; } else if (this.InputManager.Up == FezButtonState.Pressed) { codeInput = CodeInput.Up; } else if (this.InputManager.Down == FezButtonState.Pressed) { codeInput = CodeInput.Down; } if (codeInput == CodeInput.None) { return; } this.Input.Add(codeInput); if (this.Input.Count > 16) { this.Input.RemoveAt(0); } if (!this.isAchievementCode && !this.GameState.SaveData.AchievementCheatCodeDone && (!this.GameState.SaveData.FezHidden && PatternTester.Test((IList <CodeInput>) this.Input, GameWideCodes.AchievementCode)) && this.LevelManager.Name != "ELDERS") { this.Input.Clear(); this.isAchievementCode = true; this.LevelService.ResolvePuzzleSoundOnly(); Waiters.Wait((Func <bool>)(() => { if (this.CameraManager.ViewTransitionReached && this.PlayerManager.Grounded) { return(!this.PlayerManager.Background); } else { return(false); } }), (Action)(() => { Vector3 local_0 = this.PlayerManager.Center + new Vector3(0.0f, 2f, 0.0f); Trile local_1 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)); if (local_1 == null) { return; } Vector3 local_2 = local_0 - Vector3.One / 2f; NearestTriles local_3 = this.LevelManager.NearestTrile(local_0); TrileInstance local_4 = local_3.Surface ?? local_3.Deep; if (local_4 != null) { local_2 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) * local_2 + local_4.Center * FezMath.DepthMask(this.CameraManager.Viewpoint) - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f; } ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(this.Game, this.waitingForTrile = new TrileInstance(Vector3.Clamp(local_2, Vector3.Zero, this.LevelManager.Size - Vector3.One), local_1.Id))); this.GomezService.CollectedAnti += new Action(this.GotTrile); })); } if (!this.isMapQr && !this.GameState.SaveData.MapCheatCodeDone && (this.GameState.SaveData.Maps.Contains("MAP_MYSTERY") && this.LevelManager.Name != "WATERTOWER_SECRET") && PatternTester.Test((IList <CodeInput>) this.Input, GameWideCodes.MapCode)) { this.Input.Clear(); this.GameState.SaveData.AnyCodeDeciphered = true; this.isMapQr = true; if (this.GameState.SaveData.World.ContainsKey("WATERTOWER_SECRET")) { this.GameState.SaveData.World["WATERTOWER_SECRET"].FilledConditions.SecretCount = 1; } this.LevelService.ResolvePuzzleSoundOnly(); Waiters.Wait((Func <bool>)(() => { if (this.CameraManager.ViewTransitionReached && this.PlayerManager.Grounded) { return(!this.PlayerManager.Background); } else { return(false); } }), (Action)(() => { Vector3 local_0 = this.PlayerManager.Center + new Vector3(0.0f, 2f, 0.0f); Trile local_1 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)); if (local_1 == null) { return; } Vector3 local_2 = local_0 - Vector3.One / 2f; NearestTriles local_3 = this.LevelManager.NearestTrile(local_0); TrileInstance local_4 = local_3.Surface ?? local_3.Deep; if (local_4 != null) { local_2 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) * local_2 + local_4.Center * FezMath.DepthMask(this.CameraManager.Viewpoint) - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f; } ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(this.Game, this.waitingForTrile = new TrileInstance(Vector3.Clamp(local_2, Vector3.Zero, this.LevelManager.Size - Vector3.One), local_1.Id))); this.GomezService.CollectedAnti += new Action(this.GotTrile); })); } if (this.GameState.SaveData.HasNewGamePlus && PatternTester.Test((IList <CodeInput>) this.Input, GameWideCodes.JetpackCode)) { this.Input.Clear(); this.GameState.JetpackMode = true; } this.SinceInput = TimeSpan.Zero; }
public void SetToTrile(int trileID) { isTrile = true; trile = LevelManager.Instance.GetTrile(trileID); UpdateFields(); }
private void TryInitialize() { this.Enabled = this.Visible = this.LevelManager.Name == "TEMPLE_OF_LOVE"; this.Destroy(); if (this.Enabled && this.GameState.SaveData.HasDoneHeartReboot) { foreach (BackgroundPlane plane in Enumerable.ToArray <BackgroundPlane>((IEnumerable <BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values)) { if (plane.ActorType == ActorType.Waterfall || plane.ActorType == ActorType.Trickle || (plane.TextureName.Contains("water") || plane.TextureName.Contains("fountain")) || plane.AttachedPlane.HasValue) { this.LevelManager.RemovePlane(plane); } } this.Enabled = this.Visible = false; } if (!this.Enabled) { return; } this.sRayWhiteout = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Ending/HexRebuild/RayWhiteout"); this.WireHeart = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored() }; TempleOfLoveHost templeOfLoveHost = 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; Mesh mesh3 = mesh1; templeOfLoveHost.CrumblingHeart = mesh3; Color pink = Color.Pink; this.WireHeart.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <FezVertexPositionColor>(new FezVertexPositionColor[12] { new FezVertexPositionColor(new Vector3(-1f, -1f, -0.5f), pink), new FezVertexPositionColor(new Vector3(-1f, 0.0f, -0.5f), pink), new FezVertexPositionColor(new Vector3(0.0f, 0.0f, -0.5f), pink), new FezVertexPositionColor(new Vector3(0.0f, 1f, -0.5f), pink), new FezVertexPositionColor(new Vector3(1f, 1f, -0.5f), pink), new FezVertexPositionColor(new Vector3(1f, -1f, -0.5f), pink), new FezVertexPositionColor(new Vector3(-1f, -1f, 0.5f), pink), new FezVertexPositionColor(new Vector3(-1f, 0.0f, 0.5f), pink), new FezVertexPositionColor(new Vector3(0.0f, 0.0f, 0.5f), pink), new FezVertexPositionColor(new Vector3(0.0f, 1f, 0.5f), pink), new FezVertexPositionColor(new Vector3(1f, 1f, 0.5f), pink), new FezVertexPositionColor(new Vector3(1f, -1f, 0.5f), pink) }, new int[36] { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 6, 0, 6, 1, 7, 2, 8, 3, 9, 4, 10, 5, 11 }, PrimitiveType.LineList); foreach (Vector3 origin in this.PieceOffsets) { this.WireHeart.AddWireframeBox(Vector3.One, origin, new Color(new Vector4(Color.DeepPink.ToVector3(), 0.125f)), true); } Trile[] trileArray = new Trile[8] { this.LevelManager.TrileSet.Triles[244], this.LevelManager.TrileSet.Triles[245], this.LevelManager.TrileSet.Triles[251], this.LevelManager.TrileSet.Triles[246], this.LevelManager.TrileSet.Triles[247], this.LevelManager.TrileSet.Triles[248], this.LevelManager.TrileSet.Triles[249], this.LevelManager.TrileSet.Triles[250] }; int num = 0; foreach (Vector3 vector3 in this.PieceOffsets) { foreach (Trile trile in trileArray) { Group group = this.CrumblingHeart.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionNormalTextureInstance>(Enumerable.ToArray <VertexPositionNormalTextureInstance>((IEnumerable <VertexPositionNormalTextureInstance>)trile.Geometry.Vertices), trile.Geometry.Indices, trile.Geometry.PrimitiveType); group.Position = vector3; group.Enabled = this.GameState.SaveData.PiecesOfHeart > num; group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, 1.570796f); } ++num; } this.CrumblingHeart.Texture = this.LevelMaterializer.TrilesMesh.Texture; this.WireHeart.Rotation = this.CrumblingHeart.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, -0.7853982f); this.WireHeart.BakeTransform <FezVertexPositionColor>(); this.CrumblingHeart.BakeTransform <VertexPositionNormalTextureInstance>(); foreach (Group group in this.CrumblingHeart.Groups) { IndexedUserPrimitives <VertexPositionNormalTextureInstance> indexedUserPrimitives = group.Geometry as IndexedUserPrimitives <VertexPositionNormalTextureInstance>; Vector3 zero = Vector3.Zero; foreach (VertexPositionNormalTextureInstance normalTextureInstance in indexedUserPrimitives.Vertices) { zero += normalTextureInstance.Position; } group.CustomData = (object)(zero / (float)indexedUserPrimitives.Vertices.Length); } 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.WireHeart.Position = this.CrumblingHeart.Position = TempleOfLoveHost.HeartCenter; }
public BackgroundTrileMaterializer(Trile trile, Mesh levelMesh) : base(trile, levelMesh) { }
public TrileMaterializer(Trile trile) : this(trile, (Mesh)null) { }
public TrileMaterializer(Trile trile, Mesh levelMesh) : this(trile, levelMesh, false) { }
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(); } }
public static bool[,,] GetModelDataFromTrile(Trile trile) { int size = 16; TrixelState[,,] states = new TrixelState[size, size, size]; bool[,,] returnArray = new bool[size, size, size]; Vector3[] dirs = new Vector3[] { Vector3.up, Vector3.down, Vector3.right, Vector3.left, Vector3.forward, Vector3.back }; //Pass 1, put the mesh collider into the array's data. for (int x = -1; x < size + 2; x++) { for (int y = -1; y < size + 2; y++) { for (int z = -1; z < size + 2; z++) { try { states[x, y, z] = TrixelState.Unchecked; } catch { } foreach (Vector3 d in dirs) { Vector3 pos = (((new Vector3(x, y, z) - Vector3.one / 2) / size) - Vector3.one / 2) + importerCollider.transform.position; RaycastHit rh; if (Physics.Raycast(new Ray(pos, d), out rh, 1f / size)) { rh.point -= importerCollider.transform.position; IntPos hitPos = IntPos.Vector3ToIntPos((rh.point * 16) - rh.normal / 2) + (size / 2); try { states[hitPos.x, hitPos.y, hitPos.z] = TrixelState.isCollider; } catch { } } } } } } //Pass 2, check if each trixel exposed to in any of the 6 cardinal directions. for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int z = 0; z < size; z++) { int blockCount = 0; foreach (Vector3 d in dirs) { Vector3 currPos = new Vector3(x, y, z); IntPos currPosInt = new IntPos(x, y, z); bool isBlocked = false; while (currPosInt.isContained(0, size)) { TrixelState getState = states[currPosInt.x, currPosInt.y, currPosInt.z]; if (getState == TrixelState.isCollider || getState == TrixelState.isNotExposedToEdge) { isBlocked = true; break; } currPos += d; currPosInt = IntPos.Vector3ToIntPos(currPos); } if (isBlocked) { blockCount++; } } if (blockCount == 6) { states[x, y, z] = TrixelState.isNotExposedToEdge; } else { states[x, y, z] = TrixelState.isExposedToEdge; } } } } //Pass 3, check if each trixel is exposed to a trixel that's exposed to air. //This is actually done twice, just in case. for (int i = 0; i < 2; i++) { TrixelState[,,] tempStates = new TrixelState[16, 16, 16]; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int z = 0; z < size; z++) { tempStates[x, y, z] = states[x, y, z]; } } } for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int z = 0; z < size; z++) { if (states[x, y, z] != TrixelState.isNotExposedToEdge) { continue; } bool isBlocked = true; foreach (Vector3 d in dirs) { Vector3 currPos = new Vector3(x, y, z); IntPos currPosInt = new IntPos(x, y, z); while (currPosInt.isContained(0, size)) { TrixelState getState = states[currPosInt.x, currPosInt.y, currPosInt.z]; if (getState == TrixelState.isExposedToEdge) { isBlocked = false; break; } else if (getState == TrixelState.isCollider || getState == TrixelState.isNotExposedToEdge) { break; } currPos += d; currPosInt = IntPos.Vector3ToIntPos(currPos); } if (!isBlocked) { tempStates[x, y, z] = TrixelState.isExposedToEdge; break; } } } } } states = tempStates; } for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int z = 0; z < size; z++) { if (states[x, y, z] == TrixelState.isCollider || states[x, y, z] == TrixelState.isNotExposedToEdge) { returnArray[x, y, z] = true; } else if (states[x, y, z] == TrixelState.isExposedToEdge) { returnArray[x, y, z] = false; } } } } importerCollider.gameObject.SetActive(false); return(returnArray); }
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); }