protected override void OnDisappear(TrileInstance crystal) { if (this.PlayerManager.HeldInstance != crystal) return; this.PlayerManager.HeldInstance = (TrileInstance) null; this.PlayerManager.Action = ActionType.Idle; }
public BridgeState(TrileInstance instance) { this.Instance = instance; this.OriginalPosition = instance.Position; if (instance.PhysicsState != null) return; instance.PhysicsState = new InstancePhysicsState(instance) { Sticky = true }; }
public GlitchyRespawner(Game game, TrileInstance instance, bool soundEmitter) : base(game) { this.UpdateOrder = -2; this.DrawOrder = 10; this.Instance = instance; this.EmitOrNot = soundEmitter; this.TargetRenderer = ServiceHelper.Get<ITargetRenderingManager>(); this.LightingPostProcess = ServiceHelper.Get<ILightingPostProcess>(); this.LevelMaterializer = ServiceHelper.Get<ILevelMaterializer>(); this.GameState = ServiceHelper.Get<IGameStateManager>(); this.CameraManager = ServiceHelper.Get<IDefaultCameraManager>(); this.LevelManager = ServiceHelper.Get<IGameLevelManager>(); this.CMProvider = ServiceHelper.Get<IContentManagerProvider>(); }
private void AddDownforce(TrileInstance instance, float factor, bool apply, bool propagate) { if (instance == null || instance.TrileId != 286) return; BridgeState bridgeState; if (!this.ActiveBridgeParts.TryGetValue(instance, out bridgeState)) this.ActiveBridgeParts.Add(instance, bridgeState = new BridgeState(instance)); else if (apply && bridgeState.Dirty) return; Vector3 vector3 = FezMath.SideMask(this.CameraManager.Viewpoint); if (apply) { bridgeState.Downforce = MathHelper.Clamp(bridgeState.Downforce + factor, 0.0f, 1f); bridgeState.Dirty = true; } if (!propagate) return; TrileEmplacement id = new TrileEmplacement(bridgeState.OriginalPosition - vector3); this.AddDownforce(this.LevelManager.TrileInstanceAt(ref id), factor / 2f, true, true); id = new TrileEmplacement(bridgeState.OriginalPosition + vector3); this.AddDownforce(this.LevelManager.TrileInstanceAt(ref id), factor / 2f, true, true); }
private void TryInitialize() { if (this.LevelManager.Name == null || !this.LevelManager.Name.StartsWith("HOLE")) return; this.GameState.SkipFadeOut = true; this.PlayerManager.CanControl = false; this.CameraManager.Constrained = true; this.CameraManager.PixelsPerTrixel = 3f; this.CameraManager.Center = new Vector3(13f, 20f, 27.875f); this.PlayerManager.Position = new Vector3(13.5f, 15.47f, 28.5f); this.PlayerManager.Ground = new MultipleHits<TrileInstance>(); this.PlayerManager.Velocity = 0.007875f * -Vector3.UnitY; this.PhysicsManager.Update((IComplexPhysicsEntity) this.PlayerManager); this.PlayerManager.Velocity = 0.007875f * -Vector3.UnitY; this.PlayerManager.RecordRespawnInformation(true); this.PlayerManager.Position = new Vector3(13.5f, 50f, 28.5f); this.PlayerManager.Ground = new MultipleHits<TrileInstance>(); this.PlayerManager.Action = ActionType.FreeFalling; for (int index = 0; index < 4; ++index) { TrileInstance trileInstance = new TrileInstance(new Vector3(13.5f, (float) (30 + index * 5), (float) (27 - index)), 354); TrixelParticleSystem system = new TrixelParticleSystem(this.Game, new TrixelParticleSystem.Settings() { ExplodingInstance = trileInstance, EnergySource = new Vector3?(trileInstance.Center), ParticleCount = 25, MinimumSize = 1, MaximumSize = 6, GravityModifier = 1.5f, Darken = true, Energy = (float) (index + 2) / 4f }); this.ParticleSystems.Add(system); system.Initialize(); } this.Enabled = true; }
public override void Update(GameTime gameTime) { if (this.GameState.Paused || this.GameState.InMap || (!this.CameraManager.ActionRunning || !FezMath.IsOrthographic(this.CameraManager.Viewpoint))) return; this.SinceAlive += gameTime.ElapsedGameTime; this.SpawnMesh.Position = this.IsArtObject ? this.AoInstance.Position : this.TrileInstance.Center; if (this.sinceColorSwapped++ >= this.nextSwapIn) { int num1 = RandomHelper.Random.Next(0, 4); this.redVisible = num1 == 0; this.greenVisible = num1 == 1; this.blueVisible = num1 == 2; if (num1 == 3) { int num2 = RandomHelper.Random.Next(0, 3); if (num2 == 0) this.blueVisible = this.redVisible = true; if (num2 == 1) this.greenVisible = this.redVisible = true; if (num2 == 2) this.blueVisible = this.greenVisible = true; } this.sinceColorSwapped = 0; this.nextSwapIn = RandomHelper.Random.Next(1, 6); } if (this.SinceAlive.TotalSeconds > 2.0 && !this.hasCreatedTreasure && this.CreateTreasure) { if (!this.IsArtObject) { this.TrileInstance.PhysicsState = (InstancePhysicsState) null; this.LevelManager.ClearTrile(this.TrileInstance); } if (this.FlashOnSpawn) ServiceHelper.AddComponent((IGameComponent) new ScreenFade(this.Game) { FromColor = Color.White, ToColor = ColorEx.TransparentWhite, Duration = 0.4f }); Trile trile = Enumerable.FirstOrDefault<Trile>(this.LevelManager.ActorTriles(this.ActorToSpawn)); if (trile != null) { Vector3 position = this.TreasureCenter - 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); } else Logger.Log("Glitchy Despawner", Common.LogSeverity.Warning, "No secret cube trile in trileset!"); this.hasCreatedTreasure = true; } if (this.SinceAlive.TotalSeconds <= 2.5) return; if (this.IsArtObject) { this.LevelManager.RemoveArtObject(this.AoInstance); } else { this.TrileInstance.PhysicsState = (InstancePhysicsState) null; this.LevelManager.ClearTrile(this.TrileInstance); } ServiceHelper.RemoveComponent<GlitchyDespawner>(this); }
private void TryAssembleCube() { if (this.AssembleScheduled || this.GameState.SaveData.CollectedParts != 8) return; this.AssembleScheduled = true; Waiters.Wait((Func<bool>) (() => { if (!this.GameState.Loading && ActionTypeExtensions.AllowsLookingDirectionChange(this.PlayerManager.Action) && (this.SpeechBubble.Hidden && !this.GameState.ForceTimePaused) && (this.PlayerManager.CanControl && !ActionTypeExtensions.DisallowsRespawn(this.PlayerManager.Action) && (this.CameraManager.ViewTransitionReached && !this.PlayerManager.InDoorTransition))) return this.PlayerManager.CarriedInstance == null; else return false; }), (Action) (() => Waiters.Wait(0.0, (Action) (() => { Vector3 local_0 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 local_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint); TrileInstance local_3 = new TrileInstance((this.PlayerManager.Position + Vector3.UnitY * (float) (Math.Sin(this.timeAcc.TotalSeconds * 3.14159274101257) * 0.100000001490116 + 2.0) - FezMath.HalfVector) * (Vector3.One - local_0) - local_1 * (this.LevelManager.Size / 2f - local_0 * 2f) + local_0 * this.LevelManager.Size / 2f, Enumerable.Last<Trile>((IEnumerable<Trile>) this.LevelManager.TrileSet.Triles.Values, (Func<Trile, bool>) (x => x.ActorSettings.Type == ActorType.CubeShard)).Id); this.LevelManager.RestoreTrile(local_3); this.LevelMaterializer.CullInstanceIn(local_3); this.PlayerManager.ForcedTreasure = local_3; this.PlayerManager.Action = ActionType.FindingTreasure; this.AssembleScheduled = false; })))); }
private bool TestObstruction(TrileInstance trile, float hitDistance, Vector3 hitStart, bool isBlackHole) { Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); if (this.PlayerManager.Background) b *= -1f; if (trile != null && trile.Enabled && !trile.Trile.Immaterial && (trile.Trile.ActorSettings.Type != ActorType.Hole || isBlackHole)) return (double) FezMath.Dot(trile.Emplacement.AsVector + Vector3.One / 2f + b * -0.5f - hitStart, b) <= (double) hitDistance + 0.25; else return false; }
private static Vector3 SolidCollision(Vector3 normal, TrileInstance instance, Vector3 origin, Vector3 destination, Vector3 impulse, float elasticity) { Vector3 vector3_1 = instance.TransformedSize / 2f; Vector3 vector3_2 = instance.Center + vector3_1 * normal; Vector3 vector3_3 = Vector3.Zero; Vector3 vector3_4; if (instance.PhysicsState != null) { Vector3 vector3_5 = instance.PhysicsState.Sticky ? FezMath.XZMask : Vector3.One; vector3_4 = instance.Center - instance.PhysicsState.Velocity * vector3_5 + vector3_1 * normal; vector3_3 = vector3_2 - vector3_4; } else vector3_4 = vector3_2; Vector3 a1 = origin - vector3_4; Vector3 a2 = destination - vector3_2; if ((double) FezMath.AlmostClamp(FezMath.Dot(a1, normal)) < 0.0 || (double) FezMath.AlmostClamp(FezMath.Dot(a2, normal)) > 0.0) return Vector3.Zero; Vector3 vector3_6 = FezMath.Abs(normal); return (double) elasticity <= 0.0 ? (vector3_2 - destination) * vector3_6 : (vector3_3 - impulse) * vector3_6 * (1f + elasticity); }
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 GotTrile() { if (this.waitingForTrile == null || !this.waitingForTrile.Collected) return; this.waitingForTrile = (TrileInstance) null; this.GomezService.CollectedAnti -= new Action(this.GotTrile); if (this.isMapQr) this.GameState.SaveData.MapCheatCodeDone = true; else if (this.isAchievementCode) this.GameState.SaveData.AchievementCheatCodeDone = true; this.isAchievementCode = this.isMapQr = false; }
public TrileInstance CreateNewTrile(int trileId, TrileEmplacement emplacement) { TrileInstance trile = new TrileInstance(emplacement, trileId); LevelManager.Triles[emplacement] = trile; if (CameraManager.Viewpoint.IsOrthographic()) { trile.SetPhiLight(CameraManager.Viewpoint.ToPhi()); } else { //TODO get closest viewpoint... somehow. } trile.PhysicsState = new InstancePhysicsState(trile) { Respawned = true, Vanished = false }; trile.Enabled = true; return trile; }
public void SyncCollisionSize() { if (this.carriedInstance != null && this.lastCarriedInstance == null) { this.variableSize = !ActorTypeExtensions.IsLight(this.carriedInstance.Trile.ActorSettings.Type) ? new Vector3(0.75f, 1.75f, 0.75f) : new Vector3(0.75f, 31.0 / 16.0, 0.75f); this.Position -= (this.variableSize - this.BaseSize) / 2f * Vector3.UnitY; } else if (this.carriedInstance == null && this.lastCarriedInstance != null) { this.Position += (this.variableSize - this.BaseSize) / 2f * Vector3.UnitY; this.variableSize = this.BaseSize; } this.lastCarriedInstance = this.carriedInstance; }
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))); }
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; }
public void UpdateInstance(TrileInstance instance) { int instanceId = instance.InstanceId; if (instanceId == -1 || this.geometry == null) return; Vector4 vector4 = instance.Enabled ? instance.Data.PositionPhi : TrileMaterializer.OutOfSight; if (instanceId < this.geometry.Instances.Length) this.geometry.Instances[instanceId] = vector4; if (instanceId >= this.tempInstances.Count) return; this.tempInstances[instanceId] = vector4; }
public void RemoveFromBatch(TrileInstance instance) { int instanceId = instance.InstanceId; if (instance != this.tempInstanceIds[instanceId]) { int num; while ((num = this.tempInstanceIds.IndexOf(instance)) != -1) { instance.InstanceId = num; this.RemoveFromBatch(instance); } } else { this.BatchNeedsCommit = true; for (int index = instanceId + 1; index < this.tempInstanceIds.Count; ++index) { TrileInstance trileInstance = this.tempInstanceIds[index]; if (trileInstance.InstanceId >= 0) --trileInstance.InstanceId; } this.tempInstances.RemoveAt(instanceId); this.tempInstanceIds.RemoveAt(instanceId); instance.InstanceId = -1; } }
public void AddToBatch(TrileInstance instance) { this.BatchNeedsCommit = true; instance.InstanceId = this.tempInstances.Count; this.tempInstances.Add(instance.Enabled ? instance.Data.PositionPhi : TrileMaterializer.OutOfSight); this.tempInstanceIds.Add(instance); }
public SwooshingCube(TrileInstance instance, Mesh destinationMesh, Vector3 Offset, Quaternion Rotation) { this.CameraManager = ServiceHelper.Get<IGameCameraManager>(); this.LevelManager = ServiceHelper.Get<ILevelManager>(); this.LevelMaterializer = ServiceHelper.Get<ILevelMaterializer>(); this.rotation = Rotation; this.positionOffset = Offset; this.color = this.StandardTrail; switch (this.LevelManager.WaterType) { case LiquidType.Lava: this.color = this.RedTrail; break; case LiquidType.Sewer: this.color = this.SewerTrail; break; } if (this.LevelManager.BlinkingAlpha) this.color = this.CMYTrail; this.Trail = new Mesh() { Effect = (BaseEffect) new DefaultEffect.VertexColored(), Culling = CullMode.None, Blending = new BlendingMode?(BlendingMode.Additive), AlwaysOnTop = true }; this.Cube = new Mesh() { Texture = this.LevelMaterializer.TrilesMesh.Texture }; if (this.LevelManager.WaterType == LiquidType.Sewer || this.LevelManager.WaterType == LiquidType.Lava || this.LevelManager.BlinkingAlpha) { Mesh mesh = this.Cube; DefaultEffect.Textured textured1 = new DefaultEffect.Textured(); textured1.AlphaIsEmissive = true; DefaultEffect.Textured textured2 = textured1; mesh.Effect = (BaseEffect) textured2; } else { Mesh mesh = this.Cube; DefaultEffect.LitTextured litTextured1 = new DefaultEffect.LitTextured(); litTextured1.Specular = true; litTextured1.Emissive = 0.5f; litTextured1.AlphaIsEmissive = true; DefaultEffect.LitTextured litTextured2 = litTextured1; mesh.Effect = (BaseEffect) litTextured2; } ShaderInstancedIndexedPrimitives<VertexPositionNormalTextureInstance, Vector4> geometry = instance.Trile.Geometry; this.Cube.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionNormalTextureInstance>(geometry.Vertices, geometry.Indices, geometry.PrimitiveType); this.Trail.AddGroup().Geometry = (IIndexedPrimitiveCollection) (this.TrailGeometry = new IndexedUserPrimitives<FezVertexPositionColor>(this.TrailVertices = new FezVertexPositionColor[0], this.TrailIndices = new int[0], PrimitiveType.TriangleList)); this.Instance = instance; this.lastPoint = instance.Center; this.DestinationMesh = destinationMesh; this.sideDirection = (RandomHelper.Probability(0.5) ? -1f : 1f) * FezMath.RightVector(this.CameraManager.Viewpoint); this.Spline = new Vector3SplineInterpolation(TimeSpan.FromSeconds(3.0), new Vector3[10]); this.Spline.Start(); this.AddSegment(); }
public void AddTrile(TrileInstance trile) { if (LevelManager.TrileExists(trile.Emplacement)) { TrileEmplacement emplacement = trile.Emplacement; LevelMaterializer.RemoveInstance(LevelManager.TrileInstanceAt(ref emplacement)); } if (LevelManager.Triles.ContainsKey(trile.Emplacement)) { //TODO investigate: Probably an empty trile. LevelManager.Triles.Remove(trile.Emplacement); } trile.Update(); trile.OriginalEmplacement = trile.Emplacement; trile.RefreshTrile(); LevelMaterializer.AddInstance(trile); LevelManager.Triles.Add(trile.Emplacement, trile); trile.Removed = false; if (LevelMaterializer.GetTrileMaterializer(trile.Trile) == null) { LevelMaterializer.RebuildTrile(trile.Trile); LevelMaterializer.RebuildInstances(); } LevelManager.RecullAt(trile); trile.PhysicsState.UpdateInstance(); LevelMaterializer.UpdateInstance(trile); if (LevelManager.Triles.Count == 1) { PlayerManager.CheckpointGround = trile; PlayerManager.RespawnAtCheckpoint(); } CameraManager.RebuildView(); if (CameraManager is DefaultCameraManager) { ((DefaultCameraManager) CameraManager).RebuildProjection(); } }
public InstanceFace(TrileInstance instance, FaceOrientation face) { this.Instance = instance; this.Face = face; }
private bool NoTop(TrileInstance instance) { FaceOrientation face = FaceOrientation.Top; TrileEmplacement traversal = instance.Emplacement.GetTraversal(ref face); TrileInstance trileInstance = this.LevelManager.TrileInstanceAt(ref traversal); if (trileInstance != null && trileInstance.Enabled) return trileInstance.Trile.Immaterial; else return true; }
public void RecordRespawnInformation(bool markCheckpoint) { if (!this.Grounded && !this.Climbing && (this.action != ActionType.GrabCornerLedge && !ActionTypeExtensions.IsSwimming(this.action)) && this.action != ActionType.EnteringPipe) return; TrileInstance first = this.Ground.First; if (this.Climbing) { Vector3 vector3 = FezMath.SideMask(this.CameraManager.Viewpoint); this.LeaveGroundPosition = vector3 * FezMath.Floor(this.Position) + vector3 * 0.5f + Vector3.UnitY * ((float) (int) Math.Ceiling((double) this.Position.Y) + 0.5f) + (Vector3.One - vector3 - Vector3.UnitY) * this.Position; } else this.LeaveGroundPosition = this.action == ActionType.GrabCornerLedge || ActionTypeExtensions.IsSwimming(this.action) || this.action == ActionType.EnteringPipe ? this.Position : first.Center + (float) ((double) first.TransformedSize.Y / 2.0 + (double) this.Size.Y / 2.0) * Vector3.UnitY * (float) Math.Sign(this.CollisionManager.GravityFactor); if (!ActionTypeExtensions.DisallowsRespawn(this.Action) && this.CarriedInstance == null && !this.Background && (!this.Grounded || first.PhysicsState == null && !first.Unsafe) && (this.HeldInstance == null || this.HeldInstance.PhysicsState == null) && (this.Grounded && ActorTypeExtensions.IsSafe(first.Trile.ActorSettings.Type) || this.Action == ActionType.GrabCornerLedge && this.HeldInstance != null && (!this.HeldInstance.Unsafe && ActorTypeExtensions.IsSafe(this.HeldInstance.Trile.ActorSettings.Type)))) { this.LastGroundedAction = this.Action; this.LastGroundedView = this.CameraManager.Viewpoint; this.LastGroundedLookingDirection = this.LookingDirection; this.RespawnPosition = this.LeaveGroundPosition; this.lastGround = this.Ground; this.lastHeldInstance = this.HeldInstance; } if (!markCheckpoint && this.LastGroundedView != Viewpoint.None) return; this.GameState.SaveData.View = this.CameraManager.Viewpoint; this.GameState.SaveData.TimeOfDay = this.TimeManager.CurrentTime.TimeOfDay; this.CheckpointGround = first; this.GameState.SaveData.Ground = this.CheckpointGround.Center; this.GameState.SaveData.Level = this.LevelManager.Name; }
public PickupState(TrileInstance ti, TrileGroup group) { this.Instance = ti; this.OriginalCenter = ti.Center; this.Group = group; }
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; }
private void SpawnDust(TrileInstance instance, float opacity, AnimatedTexture animation, bool onRight, bool onLeft) { float num1 = (float) ((double) instance.Center.Y - (double) instance.TransformedSize.Y / 2.0 * (double) Math.Sign(this.CollisionManager.GravityFactor) + (double) animation.FrameHeight / 32.0 * (double) Math.Sign(this.CollisionManager.GravityFactor)); float num2 = (float) ((double) FezMath.Dot(instance.TransformedSize, FezMath.SideMask(this.CameraManager.Viewpoint)) / 2.0 + (double) animation.FrameWidth / 32.0 * 2.0 / 3.0); if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type)) num2 -= 0.25f; opacity = 1f; Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint); bool b = (double) this.CollisionManager.GravityFactor < 0.0; if (onRight) { BackgroundPlane backgroundPlane; this.LevelManager.AddPlane(backgroundPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation) { OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float) FezMath.AsNumeric(b) * 3.141593f), Doublesided = true, Loop = false, Opacity = opacity, Timing = { Step = 0.0f } }); backgroundPlane.Position = instance.Center * FezMath.XZMask + vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2; backgroundPlane.Billboard = true; } if (!onLeft) return; BackgroundPlane backgroundPlane1; this.LevelManager.AddPlane(backgroundPlane1 = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation) { OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f) * Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float) FezMath.AsNumeric(b) * 3.141593f), Doublesided = true, Loop = false, Opacity = opacity, Timing = { Step = 0.0f } }); backgroundPlane1.Position = instance.Center * FezMath.XZMask - vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2; backgroundPlane1.Billboard = true; }
public override void Initialize() { base.Initialize(); this.LevelManager.LevelChanged += (Action) (() => { this.waitingForTrile = (TrileInstance) null; this.Input.Clear(); this.isMapQr = this.isAchievementCode = 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(); } }
private static CollisionResult CollideWithInstance(Vector3 origin, Vector3 destination, Vector3 impulse, TrileInstance instance, QueryOptions options, float elasticity, Viewpoint viewpoint, bool invertedGravity) { CollisionResult collisionResult = new CollisionResult(); Vector3 normal = -FezMath.Sign(impulse); FaceOrientation faceOrientation = FezMath.VisibleOrientation(viewpoint); if ((options & QueryOptions.Background) == QueryOptions.Background) faceOrientation = FezMath.GetOpposite(faceOrientation); CollisionType rotatedFace = instance.GetRotatedFace(faceOrientation); if (rotatedFace != CollisionType.None) { collisionResult.Destination = instance; collisionResult.NearestDistance = instance.Center; collisionResult.Response = CollisionManager.SolidCollision(normal, instance, origin, destination, impulse, elasticity); if (collisionResult.Response != Vector3.Zero) collisionResult.Collided = rotatedFace == CollisionType.AllSides || (rotatedFace == CollisionType.TopNoStraightLedge || rotatedFace == CollisionType.TopOnly) && (invertedGravity ? (double) normal.Y < 0.0 : (double) normal.Y > 0.0); } return collisionResult; }
private void ShineOnYouCrazyDiamonds(float elapsedTime) { this.UntilNextShine -= elapsedTime; if ((double) this.UntilNextShine <= 0.0 && this.TrackedBits.Count > 0 && (this.PlayerManager.CanControl && this.CameraManager.ViewTransitionReached)) { this.UntilNextShine = 7f; this.ChimeOutline.Scale = new Vector3(0.1f); this.ChimeOutline.Groups[0].Scale = Vector3.One; this.ChimeOutline.Groups[1].Scale = Vector3.One; this.ChimeOutline.Groups[2].Scale = Vector3.One; this.ChimeOutline.Groups[3].Scale = Vector3.One; this.ShineOn = RandomHelper.InList<TrileInstance>(this.TrackedBits); SoundEffectExtensions.EmitAt(this.sBitChime, this.ShineOn.Center); } if (this.ShineOn == null) return; this.ChimeOutline.Position = this.ShineOn.Center; this.ChimeOutline.Rotation = this.CameraManager.Rotation; this.ChimeOutline.Scale = new Vector3((float) ((double) Easing.EaseInOut((double) FezMath.Saturate(7f - this.UntilNextShine), EasingType.Quadratic) * 10.0 + (double) Easing.EaseIn(7.0 - (double) this.UntilNextShine, EasingType.Quadratic) * 7.0)) * 0.75f; this.ChimeOutline.Groups[0].Scale /= 1.002f; this.ChimeOutline.Groups[1].Scale /= 1.006f; this.ChimeOutline.Groups[2].Scale /= 1.012f; this.ChimeOutline.Groups[3].Scale /= 1.018f; this.ChimeOutline.Material.Diffuse = new Vector3((float) ((double) Easing.EaseIn((double) FezMath.Saturate((float) (1.0 - (double) this.ChimeOutline.Scale.X / 40.0)), EasingType.Quadratic) * (1.0 - (double) this.TimeManager.NightContribution * 0.649999976158142) * (1.0 - (double) this.TimeManager.DawnContribution * 0.699999988079071) * (1.0 - (double) this.TimeManager.DuskContribution * 0.699999988079071))); this.ChimeOutline.Blending = new BlendingMode?(BlendingMode.Additive); if ((double) this.ChimeOutline.Scale.X <= 40.0) return; this.ShineOn = (TrileInstance) null; }
public void OnDeserialization() { _init(); foreach (TrileEmplacement key in Triles.Keys) { TrileInstance trile = Triles[key]; /*if (Triles[key].Emplacement != key) { * Triles[key].Emplacement = key; * }*/ //trile.Update(); trile.OriginalEmplacement = key; //FIXME remove trile.OverlappedTriles != null if (trile.OverlappedTriles != null && trile.OverlappedTriles.Count > 0) { foreach (TrileInstance trileOverlapping in trile.OverlappedTriles) { trileOverlapping.OriginalEmplacement = key; } } } foreach (int id in Scripts.Keys) { Scripts[id].Id = id; } foreach (int id in Volumes.Keys) { Volumes[id].Id = id; } foreach (int id in NonPlayerCharacters.Keys) { NonPlayerCharacters[id].Id = id; } foreach (int id in ArtObjects.Keys) { ArtObjects[id].Id = id; } foreach (int id in BackgroundPlanes.Keys) { BackgroundPlanes[id].Id = id; } foreach (int id in Paths.Keys) { Paths[id].Id = id; } foreach (int id in Groups.Keys) { TrileGroup trileGroup = Groups[id]; trileGroup.Id = id; /*TrileEmplacement[] trileEmplacementArray = new TrileEmplacement[trileGroup.Triles.Count]; * for (int i = 0; i < trileEmplacementArray.Length; i++) { * trileEmplacementArray[i] = trileGroup.Triles[i].Emplacement; * } * trileGroup.Triles.Clear(); * //FIXME crashes here as key cannot be found in Triles * foreach (TrileEmplacement key in trileEmplacementArray) { * trileGroup.Triles.Add(Triles[key]); * }*/ } }
public GlitchyDespawner(Game game, TrileInstance instance) : this(game) { this.UpdateOrder = -2; this.DrawOrder = 10; this.TrileInstance = instance; this.CreateTreasure = false; instance.Hidden = true; this.IsArtObject = false; }