private static void LoadHex(NowLoadingHexahedron nlh) { ServiceHelper.AddComponent((IGameComponent) nlh); }
public override void Initialize() { base.Initialize(); NowLoadingHexahedron.Phase = NowLoadingHexahedron.Phases.VectorOutline; TimeSpan timeSpan; NowLoadingHexahedron.SinceTurning = timeSpan = TimeSpan.Zero; NowLoadingHexahedron.SinceWavesStarted = timeSpan; NowLoadingHexahedron.SincePhaseStarted = timeSpan; this.PlayerManager.CanControl = false; this.WarpSound = this.CMProvider.GetForLevel(this.GameState.IsTrialMode ? "trial/ELDERS" : "ELDERS").Load <SoundEffect>("Sounds/Zu/HexaWarpIn"); this.Dot.Hidden = false; this.Dot.Behaviour = DotHost.BehaviourType.ClampToTarget; this.Dot.Target = this.Center; this.Dot.ScalePulsing = 0.0f; this.Dot.Opacity = 0.0f; Waiters.Wait((Func <bool>)(() => this.PlayerManager.Grounded), (Action)(() => { this.WalkTo.Destination = (Func <Vector3>)(() => this.PlayerManager.Position * Vector3.UnitY + this.Center * FezMath.XZMask); this.WalkTo.NextAction = ActionType.Idle; this.PlayerManager.Action = ActionType.WalkingTo; })); this.TimeManager.TimeFactor = this.TimeManager.DefaultTimeFactor; NowLoadingHexahedron loadingHexahedron1 = this; Mesh mesh1 = new Mesh(); Mesh mesh2 = mesh1; DefaultEffect.VertexColored vertexColored1 = new DefaultEffect.VertexColored(); vertexColored1.Fullbright = true; vertexColored1.AlphaIsEmissive = false; DefaultEffect.VertexColored vertexColored2 = vertexColored1; mesh2.Effect = (BaseEffect)vertexColored2; mesh1.DepthWrites = false; mesh1.AlwaysOnTop = true; Mesh mesh3 = mesh1; loadingHexahedron1.Outline = mesh3; this.Outline.AddWireframePolygon(Color.White, new Vector3(0.0f, 0.8660254f, 0.0f), new Vector3(0.7071068f, 0.2886752f, 0.0f), new Vector3(0.7071068f, -0.2886752f, 0.0f), new Vector3(0.0f, -0.8660254f, 0.0f), new Vector3(-0.7071068f, -0.2886752f, 0.0f), new Vector3(-0.7071068f, 0.2886752f, 0.0f), new Vector3(0.0f, 0.8660254f, 0.0f)); this.Outline.Scale = new Vector3(4f); this.Outline.BakeTransform <FezVertexPositionColor>(); Group firstGroup = this.Outline.FirstGroup; firstGroup.Material = new Material(); firstGroup.Enabled = false; for (int index = 0; index < 1024; ++index) { this.Outline.CloneGroup(firstGroup); } firstGroup.Enabled = true; NowLoadingHexahedron loadingHexahedron2 = this; Mesh mesh4 = new Mesh(); Mesh mesh5 = mesh4; DefaultEffect.VertexColored vertexColored3 = new DefaultEffect.VertexColored(); vertexColored3.Fullbright = true; vertexColored3.AlphaIsEmissive = false; DefaultEffect.VertexColored vertexColored4 = vertexColored3; mesh5.Effect = (BaseEffect)vertexColored4; mesh4.DepthWrites = false; mesh4.AlwaysOnTop = true; mesh4.Material.Opacity = 0.0f; Mesh mesh6 = mesh4; loadingHexahedron2.WireCube = mesh6; this.WireCube.AddWireframeBox(Vector3.One * 4f, Vector3.Zero, Color.White, true); this.WireCube.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Right, (float)Math.Asin(Math.Sqrt(2.0) / Math.Sqrt(3.0))) * Quaternion.CreateFromAxisAngle(Vector3.Up, 0.7853982f); this.WireCube.BakeTransform <FezVertexPositionColor>(); NowLoadingHexahedron loadingHexahedron3 = this; Mesh mesh7 = new Mesh(); Mesh mesh8 = mesh7; DefaultEffect.LitVertexColored litVertexColored1 = new DefaultEffect.LitVertexColored(); litVertexColored1.Fullbright = false; litVertexColored1.AlphaIsEmissive = false; DefaultEffect.LitVertexColored litVertexColored2 = litVertexColored1; mesh8.Effect = (BaseEffect)litVertexColored2; mesh7.AlwaysOnTop = true; mesh7.Material.Opacity = 0.0f; Mesh mesh9 = mesh7; loadingHexahedron3.SolidCube = mesh9; this.SolidCube.AddFlatShadedBox(Vector3.One * 4f, Vector3.Zero, Color.White, true); this.SolidCube.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Right, (float)Math.Asin(Math.Sqrt(2.0) / Math.Sqrt(3.0))) * Quaternion.CreateFromAxisAngle(Vector3.Up, 0.7853982f); this.SolidCube.BakeTransform <VertexPositionNormalColor>(); NowLoadingHexahedron loadingHexahedron4 = this; Mesh mesh10 = new Mesh(); Mesh mesh11 = mesh10; DefaultEffect.Textured textured1 = new DefaultEffect.Textured(); textured1.Fullbright = true; textured1.AlphaIsEmissive = false; DefaultEffect.Textured textured2 = textured1; mesh11.Effect = (BaseEffect)textured2; mesh10.DepthWrites = false; mesh10.Material.Opacity = 0.0f; mesh10.Blending = new BlendingMode?(BlendingMode.Alphablending); mesh10.SamplerState = SamplerState.LinearClamp; Mesh mesh12 = mesh10; loadingHexahedron4.Flare = mesh12; this.Flare.AddFace(Vector3.One * 4f, Vector3.Zero, FaceOrientation.Front, true); this.Flare.Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/flare_alpha")); this.Rays = new Mesh() { Effect = (BaseEffect) new DefaultEffect.Textured(), Texture = (Dirtyable <Texture>)((Texture)this.CMProvider.Global.Load <Texture2D>("Other Textures/smooth_ray")), Blending = new BlendingMode?(BlendingMode.Additive), SamplerState = SamplerState.AnisotropicClamp, DepthWrites = false, AlwaysOnTop = true }; for (int index = 0; index < 128; ++index) { float x = 0.75f; float num = 0.0075f; Group group = this.Rays.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <FezVertexPositionTexture>(new FezVertexPositionTexture[6] { new FezVertexPositionTexture(new Vector3(0.0f, (float)((double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(0.0f, 0.0f)), new FezVertexPositionTexture(new Vector3(x, num / 2f, 0.0f), new Vector2(1f, 0.0f)), new FezVertexPositionTexture(new Vector3(x, (float)((double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(1f, 0.45f)), new FezVertexPositionTexture(new Vector3(x, (float)(-(double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(1f, 0.55f)), new FezVertexPositionTexture(new Vector3(x, (float)(-(double)num / 2.0), 0.0f), new Vector2(1f, 1f)), new FezVertexPositionTexture(new Vector3(0.0f, (float)(-(double)num / 2.0 * 0.100000001490116), 0.0f), new Vector2(0.0f, 1f)) }, new int[12] { 0, 1, 2, 0, 2, 5, 5, 2, 3, 5, 3, 4 }, PrimitiveType.TriangleList); group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Forward, RandomHelper.Between(0.0, 6.28318548202515)); group.Material = new Material() { Diffuse = new Vector3(0.0f) }; } ServiceHelper.AddComponent((IGameComponent)(this.TheDarkening = new NowLoadingHexahedron.Darkener(this.Game))); this.LevelManager.LevelChanged += new Action(this.Kill); SoundEffectExtensions.Emit(this.WarpSound).Persistent = true; }
public LongRunningAction LoadHexahedronAt(int id, string toLevel) { Volume volume = this.LevelManager.Volumes[id]; Vector3 center = (volume.From + volume.To) / 2f; Worker<NowLoadingHexahedron> worker = this.ThreadPool.Take<NowLoadingHexahedron>(new Action<NowLoadingHexahedron>(VolumeService.LoadHex)); NowLoadingHexahedron context = new NowLoadingHexahedron(ServiceHelper.Game, center, toLevel); worker.Start(context); worker.Finished += (Action) (() => this.ThreadPool.Return<NowLoadingHexahedron>(worker)); bool disposed = false; context.Disposed += (EventHandler<EventArgs>) ((_, __) => disposed = true); return new LongRunningAction((Func<float, float, bool>) ((_, __) => disposed)); }