protected override void DrawLightOccluders() { if (this.PlayerManager.Hidden || this.GameState.InFpsMode) { return; } this.PlayerManager.Mesh.Rotation = FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.LastViewpoint == Viewpoint.None ? this.CameraManager.Rotation : Quaternion.CreateFromAxisAngle(Vector3.UnitY, FezMath.ToPhi(this.CameraManager.LastViewpoint)); if (this.PlayerManager.LookingDirection == HorizontalDirection.Left) { this.PlayerManager.Mesh.Rotation *= FezMath.QuaternionFromPhi(3.141593f); } this.PlayerManager.Mesh.Draw(); }
public void DoDraw() { if (this.GameState.Loading || this.PlayerManager.Hidden || (this.GameState.InMap || FezMath.AlmostEqual(this.PlayerManager.GomezOpacity, 0.0f))) { return; } if (this.GameState.StereoMode || this.LevelManager.Quantum) { this.PlayerManager.Mesh.Rotation = FezMath.IsOrthographic(this.CameraManager.Viewpoint) || this.CameraManager.LastViewpoint == Viewpoint.None ? this.CameraManager.Rotation : Quaternion.CreateFromAxisAngle(Vector3.UnitY, FezMath.ToPhi(this.CameraManager.LastViewpoint)); if (this.PlayerManager.LookingDirection == HorizontalDirection.Left) { this.PlayerManager.Mesh.Rotation *= FezMath.QuaternionFromPhi(3.141593f); } } this.PlayerManager.Mesh.Material.Opacity = this.PlayerManager.Action == ActionType.Suffering || this.PlayerManager.Action == ActionType.Sinking ? (float)FezMath.Saturate((Math.Sin((double)this.PlayerManager.BlinkSpeed * 6.28318548202515 * 5.0) + 0.5 - (double)this.PlayerManager.BlinkSpeed * 1.25) * 2.0) : this.PlayerManager.GomezOpacity; GraphicsDevice graphicsDevice = this.GraphicsDevice; if (!ActionTypeExtensions.SkipSilhouette(this.PlayerManager.Action)) { GraphicsDeviceExtensions.PrepareStencilRead(graphicsDevice, CompareFunction.Greater, StencilMask.NoSilhouette); this.playerMesh.DepthWrites = false; this.playerMesh.AlwaysOnTop = true; this.effect.Silhouette = true; this.playerMesh.Draw(); } if (!this.PlayerManager.Background) { GraphicsDeviceExtensions.PrepareStencilRead(graphicsDevice, CompareFunction.Equal, StencilMask.Hole); this.playerMesh.AlwaysOnTop = true; this.playerMesh.DepthWrites = false; this.effect.Silhouette = false; this.playerMesh.Draw(); } GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?(StencilMask.Gomez)); this.playerMesh.AlwaysOnTop = ActionTypeExtensions.NeedsAlwaysOnTop(this.PlayerManager.Action); this.playerMesh.DepthWrites = true; this.effect.Silhouette = false; this.playerMesh.Draw(); GraphicsDeviceExtensions.PrepareStencilWrite(graphicsDevice, new StencilMask?(StencilMask.None)); }
protected void UpdateRotation() { Quaternion rotation = this.CameraManager.Rotation; if (this.oldRotation == rotation && this.oldDirection == this.LookingDirection) { return; } this.oldRotation = rotation; this.oldDirection = this.LookingDirection; int num = -Math.Sign(FezMath.Dot(this.CameraManager.InverseView.Right, FezMath.Sign(this.Npc.DestinationOffset))); if (this.LookingDirection == HorizontalDirection.Left) { num *= -1; } if (num != 0) { rotation *= FezMath.QuaternionFromPhi((float)(3.14159274101257 * ((double)num / 2.0 + 0.5))); } this.Group.Rotation = rotation; if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint)) { return; } this.InBackground = false; Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.Position, QueryOptions.Simple); TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep; if (trileInstance == null) { return; } Vector3 a = trileInstance.Center + trileInstance.TransformedSize / 2f * -b; this.InBackground = (double)FezMath.Dot(this.Position, b) > (double)FezMath.Dot(a, b); }
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; } }