private TrileInstance IsOnLadder(out ClimbingApproach approach) { Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 vector3 = FezMath.RightVector(this.CameraManager.Viewpoint); float num1 = float.MaxValue; bool flag1 = false; TrileInstance trileInstance1 = (TrileInstance)null; bool flag2 = true; if (this.currentApproach == ClimbingApproach.None) { NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Center, this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None); flag2 = nearestTriles.Surface != null && nearestTriles.Surface.Trile.ActorSettings.Type == ActorType.Ladder; } foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values) { if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, true)) { TrileInstance trileInstance2 = nearestTriles.Surface; float num2 = FezMath.Dot(trileInstance2.Position, b); if (flag2 && (double)num2 < (double)num1) { num1 = num2; trileInstance1 = trileInstance2; } } } if (trileInstance1 == null) { foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values) { if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, false)) { TrileInstance trileInstance2 = nearestTriles.Surface; float num2 = FezMath.Dot(trileInstance2.Position, b); if (flag2 && (double)num2 < (double)num1) { flag1 = true; num1 = num2; trileInstance1 = trileInstance2; } } } } if (trileInstance1 != null) { float num2 = FezMath.Dot(FezMath.AsVector(FezMath.OrientationFromPhi(FezMath.WrapAngle(FezMath.ToPhi(trileInstance1.Trile.ActorSettings.Face) + trileInstance1.Phi))), flag1 ? vector3 : b); approach = !flag1 ? ((double)num2 > 0.0 ? ClimbingApproach.Front : ClimbingApproach.Back) : ((double)num2 > 0.0 ? ClimbingApproach.Left : ClimbingApproach.Right); } else { approach = ClimbingApproach.None; } return(trileInstance1); }
private void Initialize() { this.Trixels = new HashSet <TrixelEmplacement>(); this.tangentFace = FezMath.GetTangent(this.Orientation); this.bitangentFace = FezMath.GetBitangent(this.Orientation); this.tangentFaces = new FaceOrientation[4] { this.tangentFace, this.bitangentFace, FezMath.GetOpposite(this.tangentFace), FezMath.GetOpposite(this.bitangentFace) }; this.normal = FezMath.AsVector(this.Orientation); this.Tangent = FezMath.AsVector(this.tangentFace); this.Bitangent = FezMath.AsVector(this.bitangentFace); }
private void DoLoad(bool dummy) { this.LevelManager.ChangeLevel(this.PlayerManager.WarpPanel.Destination); this.Phase = GateWarp.Phases.FadeIn; this.GameState.SaveData.View = this.PlayerManager.OriginWarpViewpoint; this.GameState.SaveData.Ground = Enumerable.First <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObject.ActorType == ActorType.WarpGate)).Position - Vector3.UnitY + FezMath.AsVector(FezMath.VisibleOrientation(this.GameState.SaveData.View)) * 2f; this.PlayerManager.CheckpointGround = (TrileInstance)null; this.PlayerManager.RespawnAtCheckpoint(); this.CameraManager.Center = this.PlayerManager.Position + Vector3.Up * this.PlayerManager.Size.Y / 2f + Vector3.UnitY; this.CameraManager.SnapInterpolation(); this.LevelMaterializer.CullInstances(); this.PlayerManager.Hidden = false; this.GameState.ScheduleLoadEnd = true; this.SinceStarted = TimeSpan.Zero; this.PlayerManager.WarpPanel = (WarpPanel)null; this.particles = (PlaneParticleSystem)null; }
public PhysicsManager.WallHuggingResult HugWalls(IPhysicsEntity entity, bool determineBackground, bool postRotation, bool keepInFront) { Vector3 vector3_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint); if (!entity.Background) { vector3_1 = -vector3_1; } float num1 = 1.0 / 500.0; if (entity is ISimplePhysicsEntity) { num1 = 1.0 / 16.0; } PhysicsManager.WallHuggingResult wallHuggingResult = new PhysicsManager.WallHuggingResult(); Vector3 vector3_2 = new Vector3(); if (entity.Background && entity.Grounded) { return(wallHuggingResult); } foreach (PointCollision pointCollision in entity.CornerCollision) { TrileInstance trileInstance1 = (TrileInstance)null; if (this.IsHuggable(pointCollision.Instances.Surface, entity)) { FaceOrientation face = FaceOrientation.Down; TrileEmplacement traversal = pointCollision.Instances.Surface.Emplacement.GetTraversal(ref face); TrileInstance trileInstance2 = this.LevelManager.TrileInstanceAt(ref traversal); if (trileInstance2 != null && trileInstance2.Enabled && trileInstance2.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None) { trileInstance1 = pointCollision.Instances.Surface; } } if (trileInstance1 == null && this.IsHuggable(pointCollision.Instances.Deep, entity)) { trileInstance1 = pointCollision.Instances.Deep; } if (trileInstance1 != null && (!(entity is ISimplePhysicsEntity) || trileInstance1.PhysicsState == null || !trileInstance1.PhysicsState.Puppet) && trileInstance1.PhysicsState != entity) { Vector3 vector3_3 = trileInstance1.Center + vector3_1 * trileInstance1.TransformedSize / 2f; Vector3 vector1 = entity.Center - vector3_1 * entity.Size / 2f - vector3_3 + num1 * -vector3_1; float x = Vector3.Dot(vector1, vector3_1); if ((double)FezMath.AlmostClamp(x) < 0.0) { if (determineBackground && (!trileInstance1.Trile.Thin || trileInstance1.Trile.ForceHugging)) { float num2 = Math.Abs(FezMath.Dot(trileInstance1.TransformedSize / 2f + entity.Size / 2f, vector3_1)); // ISSUE: explicit reference operation // ISSUE: variable of a reference type PhysicsManager.WallHuggingResult& local = @wallHuggingResult; // ISSUE: explicit reference operation int num3 = (^ local).Behind | (double)Math.Abs(x) > (double)num2 ? 1 : 0; // ISSUE: explicit reference operation (^ local).Behind = num3 != 0; } else if (keepInFront) { Vector3 vector3_4 = vector1 * FezMath.Abs(vector3_1); vector3_2 -= vector3_4; entity.Center -= vector3_4; wallHuggingResult.Hugged = true; } } } if (postRotation) { Vector3 vector3_3 = FezMath.AsVector(FezMath.VisibleOrientation(this.CameraManager.LastViewpoint)); TrileInstance instance = this.LevelManager.ActualInstanceAt(pointCollision.Point + vector3_2); if (this.IsHuggable(instance, entity)) { Vector3 vector3_4 = instance.Center + vector3_3 * FezMath.ZYX(instance.TransformedSize) / 2f; Vector3 vector1 = entity.Center - vector3_3 * entity.Size / 2f - vector3_4 + 1.0 / 500.0 * vector3_3; float x = Vector3.Dot(vector1, vector3_3); if ((double)FezMath.AlmostClamp(x) < 0.0 && (double)x > -1.0 && keepInFront) { Vector3 vector3_5 = vector1 * FezMath.Abs(vector3_3); vector3_2 -= vector3_5; entity.Center -= vector3_5; wallHuggingResult.Hugged = true; } } } } return(wallHuggingResult); }
public override void Update(GameTime gameTime) { if (this.GameState.Paused || this.GameState.InMap || (!this.CameraManager.ActionRunning || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) || (this.GameState.Loading || this.TrackedSuckBlocks.Count == 0)) { return; } FaceOrientation visibleOrientation = this.CameraManager.VisibleOrientation; Vector3 vector3_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); Vector3 vector3_4 = vector3_3 / 2f; bool flag1 = false; foreach (SuckBlocksHost.SuckBlockState suckBlockState in this.TrackedSuckBlocks) { TrileInstance instance = suckBlockState.Instance; if (this.PlayerManager.HeldInstance != instance) { int num1 = instance.ActorSettings.HostVolume.Value; Vector3 vector3_5 = instance.Center * (Vector3.One - vector3_2) + this.CameraManager.Position * vector3_2; this.cornerRays[0] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(1f, 0.499f, 1f), Direction = vector3_1 }; this.cornerRays[1] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(1f, -1f, 1f), Direction = vector3_1 }; this.cornerRays[2] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(-1f, 0.499f, -1f), Direction = vector3_1 }; this.cornerRays[3] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(-1f, -1f, -1f), Direction = vector3_1 }; suckBlockState.Update(gameTime.ElapsedGameTime); this.eCratePush.Position = instance.Center; bool flag2 = false; foreach (Volume volume in this.HostingVolumes) { if (volume.Orientations.Contains(visibleOrientation)) { bool flag3 = false; foreach (Ray ray in this.cornerRays) { flag3 = flag3 | volume.BoundingBox.Intersects(ray).HasValue; } if (flag3) { flag2 = true; if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking && (this.eSuck == null || this.eSuck.Dead)) { this.eSuck = SoundEffectExtensions.EmitAt(this.sSuck, instance.Center, true); } flag1 = ((flag1 ? 1 : 0) | (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking ? 1 : (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Processing ? 1 : 0))) != 0; Vector3 vector3_6 = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f; Vector3 vector3_7 = (vector3_6 - instance.Center) * vector3_3; float num2 = vector3_7.Length(); if ((double)num2 < 0.00999999977648258) { if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking) { suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Processing; this.PlayerManager.CanRotate = false; this.eCratePush.VolumeFactor = 0.5f; this.eCratePush.Cue.Pitch = -0.4f; } if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Processing) { Vector3 vector3_8 = (volume.BoundingBox.Max - volume.BoundingBox.Min) / 2f; Vector3 vector3_9 = volume.BoundingBox.Min * vector3_3 + vector3_6 * vector3_2 + vector3_8 * vector3_1 - vector3_1 * 0.5f - vector3_2 * 0.5f; Vector3 vector3_10 = vector3_9 - vector3_1; instance.Position = Vector3.Lerp(vector3_10, vector3_9, (float)suckBlockState.SinceActionChanged.Ticks / (float)SuckBlocksHost.SuckBlockState.ProcessingTime.Ticks); this.LevelManager.UpdateInstance(instance); if (suckBlockState.SinceActionChanged > SuckBlocksHost.SuckBlockState.ProcessingTime) { this.PlayerManager.CanRotate = true; if (volume.Id == num1) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type SuckBlocksHost.\u003C\u003Ec__DisplayClassb cDisplayClassb = new SuckBlocksHost.\u003C\u003Ec__DisplayClassb(); SuckBlocksHost.DisableTrile(instance); suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Accepted; if (this.eCratePush.Cue.State != SoundState.Paused) { this.eCratePush.Cue.Pause(); } this.SuckBlockService.OnSuck(suckBlockState.Group.Id); SoundEffectExtensions.Emit(this.sAccept[4 - this.TrackedSuckBlocks.Count]); Texture2D texture2D = this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/suck_blocks/four_highlight_" + instance.Trile.CubemapPath.Substring(instance.Trile.CubemapPath.Length - 1).ToLower(CultureInfo.InvariantCulture)); // ISSUE: reference to a compiler-generated field cDisplayClassb.plane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)texture2D) { Position = instance.Center + FezMath.AsVector(visibleOrientation) * (17.0 / 32.0), Rotation = this.CameraManager.Rotation, Doublesided = true, Fullbright = true, Opacity = 0.0f }; // ISSUE: reference to a compiler-generated field this.highlightPlanes.Add(cDisplayClassb.plane); // ISSUE: reference to a compiler-generated field this.LevelManager.AddPlane(cDisplayClassb.plane); // ISSUE: reference to a compiler-generated method Waiters.Interpolate(1.0, new Action <float>(cDisplayClassb.\u003CUpdate\u003Eb__6)); if (this.TrackedSuckBlocks.Count == 1) { Waiters.Wait(2.0, (Action)(() => Waiters.Interpolate(1.0, (Action <float>)(s => { foreach (BackgroundPlane item_3 in this.highlightPlanes) { item_3.Opacity = 1f - s; } }), (Action)(() => this.eSuck = (SoundEmitter)null)))); this.eSuck.FadeOutAndDie(1f); } } else { suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Rejected; } } } if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Rejected && FezMath.XZ(instance.PhysicsState.Velocity) == Vector2.Zero) { int num3 = RandomHelper.Probability(0.5) ? -1 : 1; Vector3 vector3_8 = new Vector3((float)num3, 0.75f, (float)num3) * vector3_3; ServiceHelper.AddComponent((IGameComponent) new CamShake(this.Game) { Distance = 0.1f, Duration = TimeSpan.FromSeconds(0.25) }); SoundEffectExtensions.Emit(this.sDenied); if (this.eCratePush.Cue.State != SoundState.Paused) { this.eCratePush.Cue.Pause(); } instance.PhysicsState.Velocity += 6f * vector3_8 * (float)gameTime.ElapsedGameTime.TotalSeconds; } } else if (suckBlockState.Action != SuckBlocksHost.SuckBlockAction.Rejected) { if (instance.PhysicsState.Grounded && this.eCratePush.Cue.State != SoundState.Playing) { this.eCratePush.Cue.Pitch = 0.0f; this.eCratePush.Cue.Resume(); } else if (!instance.PhysicsState.Grounded && this.eCratePush.Cue.State != SoundState.Paused) { this.eCratePush.Cue.Pause(); } if (this.eCratePush.Cue.State == SoundState.Playing) { this.eCratePush.VolumeFactor = FezMath.Saturate(Math.Abs(FezMath.Dot(instance.PhysicsState.Velocity, FezMath.XZMask) / 0.1f)); } suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Sucking; instance.PhysicsState.Velocity += 0.25f * vector3_7 / num2 * (float)gameTime.ElapsedGameTime.TotalSeconds; } } } } if (!flag2) { suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Idle; } } } if (!flag1 && this.eSuck != null && !this.eSuck.Dead) { this.eSuck.FadeOutAndDie(0.1f); this.eSuck = (SoundEmitter)null; } for (int index = 0; index < this.TrackedSuckBlocks.Count; ++index) { if (this.TrackedSuckBlocks[index].Action == SuckBlocksHost.SuckBlockAction.Accepted) { this.TrackedSuckBlocks.RemoveAt(index); --index; } } }
private void TryInitialize() { this.DoorAo = (ArtObjectInstance)null; this.AttachedGroup = (TrileGroup)null; this.AssociatedVolume = (Volume)null; this.Enabled = false; this.sRumble = (SoundEffect)null; this.sLightUp = (SoundEffect)null; this.sFadeOut = (SoundEffect)null; if (this.eRumble != null && !this.eRumble.Dead) { this.eRumble.Cue.Stop(false); } this.eRumble = (SoundEmitter)null; foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values) { if (artObjectInstance.ArtObject.ActorType == ActorType.SecretPassage) { this.DoorAo = artObjectInstance; this.Enabled = true; break; } } if (!this.Enabled) { if (this.GlowPlane != null) { this.GlowPlane.Dispose(); } this.GlowPlane = (BackgroundPlane)null; } if (!this.Enabled) { return; } this.AttachedGroup = this.LevelManager.Groups[this.DoorAo.ActorSettings.AttachedGroup.Value]; this.AssociatedVolume = Enumerable.FirstOrDefault <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(x => { if (x.ActorSettings != null) { return(x.ActorSettings.IsSecretPassage); } else { return(false); } })); string key = (string)null; foreach (Script script in (IEnumerable <Script>) this.LevelManager.Scripts.Values) { foreach (ScriptAction scriptAction in script.Actions) { if (scriptAction.Object.Type == "Level" && scriptAction.Operation.Contains("Level")) { foreach (ScriptTrigger scriptTrigger in script.Triggers) { if (scriptTrigger.Object.Type == "Volume" && scriptTrigger.Event == "Enter" && scriptTrigger.Object.Identifier.HasValue) { key = scriptAction.Arguments[0]; } } } } } this.Accessible = this.GameState.SaveData.World.ContainsKey(key); this.sRumble = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/Rumble"); this.sLightUp = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitLightUp"); this.sFadeOut = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitFadeOut"); if (!this.Accessible) { this.Enabled = false; } else { this.GlowPlane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/glow/secret_passage")) { Fullbright = true, Opacity = 0.0f, Position = this.DoorAo.Position + FezMath.AsVector(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations)) / (65.0 / 32.0), Rotation = FezMath.QuaternionFromPhi(FezMath.ToPhi(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations))), AttachedGroup = new int?(this.AttachedGroup.Id) }; this.LevelManager.AddPlane(this.GlowPlane); this.ExpectedViewpoint = FezMath.AsViewpoint(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations)); if (!this.LevelManager.WentThroughSecretPassage) { return; } this.MoveUp = true; this.GlowPlane.Opacity = 1f; this.SinceStarted = TimeSpan.Zero; this.AoOrigin = this.DoorAo.Position; this.PlaneOrigin = this.GlowPlane.Position; } }
public void TraverseInto(FaceOrientation face) { this.Position += FezMath.AsVector(face); }
public TrixelEmplacement GetTraversal(FaceOrientation face) { return(new TrixelEmplacement(this.Position + FezMath.AsVector(face))); }
private void DoLoad(bool dummy) { this.LevelManager.ChangeLevel(this.GateAo.ActorSettings.DestinationLevel); this.Phase = LesserWarp.Phases.FadeIn; this.GameState.SaveData.Ground = Enumerable.First <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObject.ActorType == ActorType.WarpGate)).Position + Vector3.Down + FezMath.AsVector(FezMath.VisibleOrientation(this.GameState.SaveData.View)) * 2f; this.DotManager.PreventPoI = false; this.PlayerManager.Hidden = false; this.PlayerManager.CheckpointGround = (TrileInstance)null; this.PlayerManager.RespawnAtCheckpoint(); this.CameraManager.Center = this.PlayerManager.Position + Vector3.Up * this.PlayerManager.Size.Y / 2f + Vector3.UnitY; this.CameraManager.SnapInterpolation(); this.LevelMaterializer.CullInstances(); this.GameState.ScheduleLoadEnd = true; this.SinceStarted = TimeSpan.Zero; }
private void UpdateParallax(TimeSpan elapsed) { if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint)) { return; } this.InterpolatedCenter = Vector3.Lerp(this.InterpolatedCenter, this.CameraManager.Center, MathHelper.Clamp((float)elapsed.TotalSeconds * this.CameraManager.InterpolationSpeed, 0.0f, 1f)); Vector3 forward = this.CameraManager.View.Forward; forward.Z *= -1f; Vector3 right = this.CameraManager.View.Right; Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = (this.InterpolatedCenter - this.warpGateAo.Position) / 2.5f; Vector3 a = (this.CameraManager.InterpolatedCenter - this.warpGateAo.Position) * vector3_1; foreach (WarpDestinations index in this.panels.Keys) { WarpPanel warpPanel = this.panels[index]; if (warpPanel.Enabled && (double)FezMath.Dot(FezMath.AsVector(warpPanel.Face), forward) > 0.0) { warpPanel.Timer += elapsed; Vector3 vector3_3 = vector3_2 * vector3_1; switch (index) { case WarpDestinations.First: warpPanel.Layers.Groups[3].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds * 0.25 % 16.0 - 8.0) * right; warpPanel.Layers.Groups[4].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds * 0.5 % 16.0 - 8.0) * right; warpPanel.Layers.Groups[5].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds % 16.0 - 8.0) * right; continue; case WarpDestinations.Mechanical: warpPanel.Layers.Groups[3].Position = vector3_3 + new Vector3(0.0f, 2f, 0.0f) + (float)(warpPanel.Timer.TotalSeconds % 16.0 - 8.0) * right; warpPanel.Layers.Groups[4].Position = vector3_3 - new Vector3(0.0f, 2f, 0.0f) + (float)((warpPanel.Timer.TotalSeconds + 8.0) % 16.0 - 8.0) * right; continue; case WarpDestinations.Graveyard: float m31_1 = (float)(((double)a.X + (double)a.Z) / 16.0); float m32_1 = a.Y / 16f; warpPanel.Layers.Groups[0].TextureMatrix.Set(new Matrix?(new Matrix(1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f, 0.0f, 0.0f, m31_1, m32_1, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f))); warpPanel.Layers.Groups[4].TextureMatrix.Set(new Matrix?(new Matrix(2f, 0.0f, 0.0f, 0.0f, 0.0f, 2f, 0.0f, 0.0f, m31_1 / 2f, (float)((double)m32_1 / 2.0 - warpPanel.Timer.TotalSeconds * 5.0), 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f))); warpPanel.Layers.Groups[1].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds * 0.5 % 16.0 - 8.0) * right; warpPanel.Layers.Groups[2].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds % 16.0 - 8.0) * right; warpPanel.Layers.Groups[3].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds * 2.0 % 16.0 - 8.0) * right; continue; case WarpDestinations.Sewers: Matrix matrix = new Matrix(4f, 0.0f, 0.0f, 0.0f, 0.0f, 4f, 0.0f, 0.0f, (float)(((double)a.X + (double)a.Z) / 8.0), a.Y / 8f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f); warpPanel.Layers.Groups[0].TextureMatrix.Set(new Matrix?(matrix)); warpPanel.Layers.Groups[1].TextureMatrix.Set(new Matrix?(matrix)); warpPanel.Layers.Groups[2].TextureMatrix.Set(new Matrix?(matrix)); warpPanel.Layers.Groups[3].Position = vector3_3 + new Vector3(0.0f, -8f, 0.0f); continue; case WarpDestinations.Zu: float m31_2 = (float)(-(double)FezMath.Dot(a, right) / 16.0); float m32_2 = a.Y / 32f; warpPanel.Layers.Groups[0].TextureMatrix.Set(new Matrix?(new Matrix(1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f, 0.0f, 0.0f, m31_2, m32_2, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f))); warpPanel.Layers.Groups[1].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds * 0.25 % 16.0 - 8.0) * right; warpPanel.Layers.Groups[2].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds * 0.5 % 16.0 - 8.0) * right; warpPanel.Layers.Groups[3].Position = vector3_3 - Vector3.UnitY * 1.5f + (float)(warpPanel.Timer.TotalSeconds % 16.0 - 8.0) * right; continue; default: continue; } } } }
private void TryInitialize() { this.ThisLevelMesh.ClearGroups(); this.NextLevelMesh.ClearGroups(); lock (FarawayPlaceHost.FarawayWaterMutex) this.FarawayWaterMesh = (Mesh)null; (this.NextLevelMesh.Effect as FarawayEffect).CleanUp(); foreach (Script script1 in Enumerable.Where <Script>((IEnumerable <Script>) this.LevelManager.Scripts.Values, (Func <Script, bool>)(x => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)x.Actions, (Func <ScriptAction, bool>)(y => y.Operation == "ChangeToFarAwayLevel"))))) { Volume volume1; if (this.LevelManager.Volumes.TryGetValue(Enumerable.FirstOrDefault <ScriptTrigger>((IEnumerable <ScriptTrigger>)script1.Triggers, (Func <ScriptTrigger, bool>)(x => { if (x.Object.Type == "Volume") { return(x.Event == "Enter"); } else { return(false); } })).Object.Identifier.Value, out volume1)) { FaceOrientation faceOrientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume1.Orientations); ScriptAction scriptAction1 = Enumerable.FirstOrDefault <ScriptAction>((IEnumerable <ScriptAction>)script1.Actions, (Func <ScriptAction, bool>)(x => x.Operation == "ChangeToFarAwayLevel")); string str1 = scriptAction1.Arguments[0]; int num1 = 0; string songName; FaceOrientation orientation; Vector2 vector2; bool flag; float num2; float num3; float num4; using (MemoryContentManager memoryContentManager = new MemoryContentManager((IServiceProvider)this.Game.Services, this.Game.Content.RootDirectory)) { string str2 = str1; if (!MemoryContentManager.AssetExists("Levels" + (object)'\\' + str1.Replace('/', '\\'))) { str2 = this.LevelManager.FullPath.Substring(0, this.LevelManager.FullPath.LastIndexOf("/") + 1) + str1.Substring(str1.LastIndexOf("/") + 1); } LevelReader.MinimalRead = true; Level level; try { level = memoryContentManager.Load <Level>("Levels/" + str2); } catch (Exception ex) { Logger.Log("FarawayPlaceHost", Common.LogSeverity.Warning, "Couldn't load faraway place destination level : " + str1); continue; } LevelReader.MinimalRead = false; songName = level.SongName; int key; try { key = int.Parse(scriptAction1.Arguments[1]); } catch (Exception ex) { key = -1; } Volume volume2 = key == -1 || !level.Volumes.ContainsKey(key) ? level.Volumes[Enumerable.First <ScriptTrigger>((IEnumerable <ScriptTrigger>)Enumerable.First <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a => { if (a.Object.Type == "Level" && a.Operation.Contains("Level")) { return(a.Arguments[0] == this.LevelManager.Name); } else { return(false); } })))).Triggers, (Func <ScriptTrigger, bool>)(t => { if (t.Object.Type == "Volume") { return(t.Event == "Enter"); } else { return(false); } })).Object.Identifier.Value] : level.Volumes[key]; orientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume2.Orientations); Vector3 vector3 = (level.Size / 2f - (volume2.From + volume2.To) / 2f) * (FezMath.RightVector(FezMath.AsViewpoint(orientation)) + Vector3.Up); vector2 = new Vector2(vector3.X + vector3.Z, vector3.Y); flag = level.WaterType != LiquidType.None; num2 = level.WaterHeight - (volume2.From + volume2.To).Y / 2f + this.EngineState.WaterLevelOffset; num3 = this.LevelManager.WaterHeight - (volume1.From + volume1.To).Y / 2f - num2 / 4f; num4 = level.Size.Y; Script script2 = Enumerable.FirstOrDefault <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s => { if (Enumerable.Any <ScriptTrigger>((IEnumerable <ScriptTrigger>)s.Triggers, (Func <ScriptTrigger, bool>)(t => { if (t.Event == "Start") { return(t.Object.Type == "Level"); } else { return(false); } }))) { return(Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a => { if (a.Object.Type == "Camera") { return a.Operation == "SetPixelsPerTrixel"; } else { return false; } }))); } else { return(false); } })); if (script2 != null) { ScriptAction scriptAction2 = Enumerable.First <ScriptAction>((IEnumerable <ScriptAction>)script2.Actions, (Func <ScriptAction, bool>)(a => { if (a.Object.Type == "Camera") { return(a.Operation == "SetPixelsPerTrixel"); } else { return(false); } })); try { num1 = int.Parse(scriptAction2.Arguments[0]); } catch (Exception ex) { } } num2 = level.WaterHeight; } Texture2D texture; try { string assetName = "Other Textures/faraway_thumbs/" + (object)str1 + " (" + (string)(object)FezMath.AsViewpoint(orientation) + ")"; texture = this.CMProvider.CurrentLevel.Load <Texture2D>(assetName); texture.Name = assetName; } catch (Exception ex) { Logger.Log("FarawayPlacesHost", Common.LogSeverity.Warning, "Couldn't load faraway thumbnail for " + (object)str1 + " (viewpoint = " + (string)(object)FezMath.AsViewpoint(orientation) + ")"); continue; } if (!Enumerable.Any <Group>((IEnumerable <Group>) this.ThisLevelMesh.Groups, (Func <Group, bool>)(x => x.Texture == texture))) { if (num1 == 0) { num1 = (int)this.CameraManager.PixelsPerTrixel; } Group group1 = this.ThisLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true); Group group2 = this.NextLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true); FarawayPlaceData farawayPlaceData = new FarawayPlaceData() { OriginalCenter = (volume1.From + volume1.To) / 2f, Viewpoint = FezMath.AsViewpoint(faceOrientation), Volume = volume1, DestinationOffset = vector2.X * FezMath.RightVector(FezMath.AsViewpoint(faceOrientation)) + Vector3.Up * vector2.Y, WaterLevelOffset = new float?(num3), DestinationLevelName = str1, DestinationWaterLevel = num2, DestinationLevelSize = num4 }; if (this.LevelManager.WaterType == LiquidType.None && flag) { if (this.HorizontalGradientTex == null || this.HorizontalGradientTex.IsDisposed) { this.HorizontalGradientTex = this.CMProvider.Global.Load <Texture2D>("Other Textures/WaterHorizGradient"); } lock (FarawayPlaceHost.FarawayWaterMutex) { FarawayPlaceHost temp_380 = this; // ISSUE: explicit reference operation // ISSUE: variable of a reference type FarawayPlaceData& temp_381 = @farawayPlaceData; Mesh local_28 = new Mesh(); Mesh temp_383 = local_28; DefaultEffect.Textured local_29 = new DefaultEffect.Textured(); local_29.AlphaIsEmissive = false; DefaultEffect.Textured temp_387 = local_29; temp_383.Effect = (BaseEffect)temp_387; Mesh temp_388; Mesh local_43 = temp_388 = local_28; // ISSUE: explicit reference operation (^ temp_381).WaterBodyMesh = temp_388; Mesh temp_389 = local_43; temp_380.FarawayWaterMesh = temp_389; this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material(); this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material(); } } group2.CustomData = group1.CustomData = (object)farawayPlaceData; group2.Position = group1.Position = farawayPlaceData.OriginalCenter; group2.Texture = group1.Texture = (Texture)texture; group2.Material = new Material() { Opacity = 0.125f }; group1.Material = new Material() { Opacity = 0.125f }; if (volume1.ActorSettings == null) { volume1.ActorSettings = new VolumeActorSettings(); } volume1.ActorSettings.DestinationSong = songName; switch (num1) { case 1: volume1.ActorSettings.DestinationRadius = 80f; break; case 2: volume1.ActorSettings.DestinationRadius = 40f; break; case 3: volume1.ActorSettings.DestinationRadius = 26.66667f; break; case 4: volume1.ActorSettings.DestinationRadius = 20f; break; case 5: volume1.ActorSettings.DestinationRadius = 16f; break; } volume1.ActorSettings.DestinationPixelsPerTrixel = (float)num1; volume1.ActorSettings.DestinationOffset = vector2; } } } }
private void BuildMesh() { Vector3 a = (this.Volume.To - this.Volume.From) / 2f; float num1 = a.Y * 2f; Mesh mesh1 = new Mesh(); Mesh mesh2 = new Mesh(); FaceOrientation[] faceOrientationArray = new FaceOrientation[4] { FaceOrientation.Front, FaceOrientation.Right, FaceOrientation.Back, FaceOrientation.Left }; foreach (FaceOrientation faceOrientation in faceOrientationArray) { Vector3 vector3_1 = FezMath.AsVector(FezMath.IsSide(FezMath.GetTangent(faceOrientation)) ? FezMath.GetTangent(faceOrientation) : FezMath.GetBitangent(faceOrientation)); Vector3 origin = this.Center + FezMath.AsVector(faceOrientation) * a; float num2 = Math.Abs(FezMath.Dot(a, vector3_1)) * 2f; Vector3 vector3_2 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY); Vector3 vector3_3 = origin + (a - new Vector3(0.5f)) * (-vector3_1 + Vector3.UnitY); for (int index = 0; (double)index < (double)num2; ++index) { Vector3 p = vector3_2 + (float)index * vector3_1; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } p = vector3_3 + (float)index * vector3_1; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } } Vector3 vector3_4 = origin + (a - new Vector3(0.5f)) * (-vector3_1 - Vector3.UnitY); Vector3 vector3_5 = origin + (a - new Vector3(0.5f)) * (vector3_1 - Vector3.UnitY); for (int index = 0; (double)index < (double)num1; ++index) { Vector3 p = vector3_4 + (float)index * Vector3.UnitY; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } p = vector3_5 + (float)index * Vector3.UnitY; if (!Enumerable.Any <Group>((IEnumerable <Group>)mesh1.Groups, (Func <Group, bool>)(g => FezMath.AlmostEqual(g.Position, p)))) { mesh1.AddFace(Vector3.One * 2f, Vector3.Zero, faceOrientation, true).Position = p; } } mesh2.AddFace(num2 * FezMath.Abs(vector3_1) + num1 * Vector3.UnitY, origin, faceOrientation, Color.White, true); } foreach (Group group in mesh1.Groups) { group.TextureMatrix = (Dirtyable <Matrix?>) new Matrix?(new Matrix(0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 0.5 > this.Host.random.NextDouble() ? 0.5f : 0.0f, 1f, 0.0f, 0.0f, 0.0f, 0.0f, 1f)); } mesh2.Collapse <VertexPositionNormalColor>(); IndexedUserPrimitives <VertexPositionNormalColor> indexedUserPrimitives1 = mesh2.FirstGroup.Geometry as IndexedUserPrimitives <VertexPositionNormalColor>; mesh1.CollapseWithNormalTexture <FezVertexPositionNormalTexture>(); IndexedUserPrimitives <FezVertexPositionNormalTexture> indexedUserPrimitives2 = mesh1.FirstGroup.Geometry as IndexedUserPrimitives <FezVertexPositionNormalTexture>; this.instanceIndex = this.Host.HolesBodyMesh.Groups.Count; this.Host.HolesBodyMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionInstance>(Enumerable.ToArray <VertexPositionInstance>(Enumerable.Select <VertexPositionNormalColor, VertexPositionInstance>((IEnumerable <VertexPositionNormalColor>)indexedUserPrimitives1.Vertices, (Func <VertexPositionNormalColor, VertexPositionInstance>)(x => new VertexPositionInstance(x.Position) { InstanceIndex = (float)this.instanceIndex }))), indexedUserPrimitives1.Indices, PrimitiveType.TriangleList); this.Host.HolesFringeMesh.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionTextureInstance>(Enumerable.ToArray <VertexPositionTextureInstance>(Enumerable.Select <FezVertexPositionNormalTexture, VertexPositionTextureInstance>((IEnumerable <FezVertexPositionNormalTexture>)indexedUserPrimitives2.Vertices, (Func <FezVertexPositionNormalTexture, VertexPositionTextureInstance>)(x => new VertexPositionTextureInstance(x.Position, x.TextureCoordinate) { InstanceIndex = (float)this.instanceIndex }))), indexedUserPrimitives2.Indices, PrimitiveType.TriangleList); }