protected override void TestConditions() { switch (this.PlayerManager.Action) { case ActionType.Teetering: case ActionType.IdlePlay: case ActionType.IdleSleep: case ActionType.IdleLookAround: case ActionType.IdleYawn: case ActionType.Idle: case ActionType.Walking: case ActionType.Running: case ActionType.Sliding: if (!this.PlayerManager.Grounded || (double)this.InputManager.Movement.X == 0.0 || this.PlayerManager.LookingDirection == HorizontalDirection.None) { break; } TrileInstance trileInstance = this.PlayerManager.WallCollision.NearLow.Destination; if (trileInstance == null || !ActorTypeExtensions.IsPickable(trileInstance.Trile.ActorSettings.Type) || (trileInstance.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.AllSides || trileInstance.Hidden) || (trileInstance.PhysicsState == null || !trileInstance.PhysicsState.Grounded)) { break; } NearestTriles nearestTriles = this.LevelManager.NearestTrile(trileInstance.Position); if (nearestTriles.Surface != null && nearestTriles.Surface.Trile.ForceHugging || (double)Math.Abs(trileInstance.Center.Y - this.PlayerManager.Position.Y) > 0.5 || trileInstance.Trile.ActorSettings.Type == ActorType.Couch && FezMath.OrientationFromPhi(FezMath.ToPhi(trileInstance.Trile.ActorSettings.Face) + trileInstance.Phi) != FezMath.VisibleOrientation(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.PlayerManager.LookingDirection == HorizontalDirection.Right ? -1 : 1))) { break; } this.PlayerManager.Action = ActionType.Grabbing; this.PlayerManager.PushedInstance = trileInstance; break; } }
private void TryPushHorizontalStack(PickupState state, float elapsedSeconds) { TrileInstance trileInstance1 = state.Instance; TrileGroup trileGroup = state.Group; if (!BoxCollisionResultExtensions.AnyCollided(trileInstance1.PhysicsState.WallCollision)) { return; } Vector3 vector3_1 = -FezMath.Sign(trileInstance1.PhysicsState.WallCollision.First.Response); trileInstance1.PhysicsState.Velocity = Vector3.Zero; TrileInstance instance = trileInstance1; while (instance != null && BoxCollisionResultExtensions.AnyCollided(instance.PhysicsState.WallCollision)) { MultipleHits <CollisionResult> wallCollision = instance.PhysicsState.WallCollision; TrileInstance trileInstance2 = wallCollision.First.Destination; if (trileInstance2.PhysicsState != null && ActorTypeExtensions.IsPickable(trileInstance2.Trile.ActorSettings.Type) && (trileGroup == null || !trileGroup.Triles.Contains(trileInstance2))) { Vector3 vector = -wallCollision.First.Response; if (FezMath.Sign(vector) != vector3_1 || vector == Vector3.Zero) { instance = (TrileInstance)null; } else { instance = trileInstance2; Vector3 velocity = instance.PhysicsState.Velocity; instance.PhysicsState.Velocity = vector; Vector3 center = instance.PhysicsState.Center; if (instance.PhysicsState.Grounded) { instance.PhysicsState.Velocity += (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464) * elapsedSeconds * Vector3.Down; } this.PhysicsManager.Update((ISimplePhysicsEntity)instance.PhysicsState, false, false); if (trileInstance1.PhysicsState.Grounded) { instance.PhysicsState.Velocity = velocity; } instance.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(instance); foreach (PickupState pickupState in this.PickupStates) { if (pickupState.Instance.PhysicsState.Ground.NearLow == instance || pickupState.Instance.PhysicsState.Ground.FarHigh == instance) { Vector3 vector3_2 = (instance.PhysicsState.Center - center) / 0.85f; pickupState.Instance.PhysicsState.Velocity = vector3_2; } } } } else { instance = (TrileInstance)null; } } }
protected override void TestConditions() { if ((double)this.CollisionManager.GravityFactor < 0.0) { return; } switch (this.PlayerManager.Action) { case ActionType.IdlePlay: case ActionType.IdleSleep: case ActionType.IdleLookAround: case ActionType.IdleYawn: case ActionType.Grabbing: case ActionType.Pushing: case ActionType.Teetering: case ActionType.Idle: case ActionType.Walking: case ActionType.Running: case ActionType.Sliding: case ActionType.Landing: if (this.PlayerManager.Background || !this.PlayerManager.Grounded || this.InputManager.GrabThrow != FezButtonState.Pressed) { break; } TrileInstance key = this.PlayerManager.PushedInstance ?? this.PlayerManager.AxisCollision[VerticalDirection.Up].Deep ?? this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep; if (key == null || !ActorTypeExtensions.IsPickable(key.Trile.ActorSettings.Type) || key.Trile.ActorSettings.Type == ActorType.Couch || !key.PhysicsState.Grounded) { break; } Vector3 halfSize = key.TransformedSize / 2f - new Vector3(0.004f); if (BoxCollisionResultExtensions.AnyCollided(this.CollisionManager.CollideEdge(key.Center, key.Trile.Size.Y * Vector3.Up * (float)Math.Sign(this.CollisionManager.GravityFactor), halfSize, Direction2D.Vertical))) { break; } TrileInstance trileInstance = this.LevelManager.ActualInstanceAt(key.Center + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)); TrileGroup trileGroup; if (trileInstance != null && trileInstance.PhysicsState != null && trileInstance.PhysicsState.Ground.First == key || this.LevelManager.PickupGroups.TryGetValue(key, out trileGroup) && trileGroup.Triles.Count > 1) { break; } ActionType actionType = ActorTypeExtensions.IsLight(key.Trile.ActorSettings.Type) ? ActionType.Lifting : ActionType.LiftingHeavy; if (this.PlayerManager.Action == ActionType.Grabbing) { this.PlayerManager.CarriedInstance = key; this.PlayerManager.Action = actionType; break; } else { this.PlayerManager.PushedInstance = key; this.WalkTo.Destination = new Func <Vector3>(this.GetDestination); this.WalkTo.NextAction = actionType; this.PlayerManager.Action = ActionType.WalkingTo; break; } } }
public override void Initialize() { base.Initialize(); lock (GlitchyRespawner.StaticLock) { if (GlitchyRespawner.FullbrightEffect == null) { DefaultEffect.Textured local_0 = new DefaultEffect.Textured(); local_0.Fullbright = true; GlitchyRespawner.FullbrightEffect = (DefaultEffect)local_0; } if (GlitchyRespawner.CubemappedEffect == null) { GlitchyRespawner.CubemappedEffect = new CubemappedEffect(); } } this.SpawnMesh = new Mesh() { SamplerState = SamplerState.PointClamp, DepthWrites = false, Effect = (BaseEffect)GlitchyRespawner.CubemappedEffect }; ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> geometry = this.Instance.Trile.Geometry; IndexedUserPrimitives <VertexPositionNormalTextureInstance> indexedUserPrimitives = new IndexedUserPrimitives <VertexPositionNormalTextureInstance>(geometry.Vertices, geometry.Indices, geometry.PrimitiveType); Group group = this.SpawnMesh.AddGroup(); group.Geometry = (IIndexedPrimitiveCollection)indexedUserPrimitives; group.Texture = (Texture)this.LevelMaterializer.TrilesMesh.Texture; if (ActorTypeExtensions.IsPickable(this.Instance.Trile.ActorSettings.Type)) { this.Instance.Phi = (float)FezMath.Round((double)this.Instance.Phi / 1.57079637050629) * 1.570796f; } group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, this.Instance.Phi); if (this.Instance.Trile.ActorSettings.Type == ActorType.CubeShard || this.Instance.Trile.ActorSettings.Type == ActorType.SecretCube || this.Instance.Trile.ActorSettings.Type == ActorType.PieceOfHeart) { group.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Left, (float)Math.Asin(Math.Sqrt(2.0) / Math.Sqrt(3.0))) * Quaternion.CreateFromAxisAngle(Vector3.Down, 0.7853982f) * group.Rotation; } this.Instance.Foreign = true; this.StarsTexture = this.CMProvider.Global.Load <Texture2D>("Other Textures/black_hole/Stars"); if (this.EmitOrNot) { SoundEmitter soundEmitter = SoundEffectExtensions.EmitAt(this.CMProvider.Global.Load <SoundEffect>("Sounds/MiscActors/GlitchyRespawn"), this.Instance.Center); soundEmitter.PauseViewTransitions = true; soundEmitter.FactorizeVolume = true; } this.LightingPostProcess.DrawOnTopLights += new Action(this.DrawLights); this.LevelManager.LevelChanging += new Action(this.Kill); }
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.Instance.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.25) { return; } this.Instance.Hidden = false; this.Instance.Enabled = true; if (ActorTypeExtensions.IsPickable(this.Instance.Trile.ActorSettings.Type)) { this.Instance.PhysicsState.Respawned = true; this.Instance.PhysicsState.Vanished = false; } this.LevelManager.RestoreTrile(this.Instance); this.LevelMaterializer.UpdateInstance(this.Instance); ServiceHelper.RemoveComponent <GlitchyRespawner>(this); }
public override void Update(GameTime gameTime) { if (this.CameraManager.Viewpoint == Viewpoint.Perspective || !this.CameraManager.ActionRunning || (this.GameState.Paused || this.GameState.InMap) || (this.CameraManager.RequestedViewpoint != Viewpoint.None || this.GameState.Loading)) { return; } foreach (BombsHost.DestructibleGroup destructibleGroup1 in this.destructibleGroups) { if (destructibleGroup1.RespawnIn.HasValue) { BombsHost.DestructibleGroup destructibleGroup2 = destructibleGroup1; float?nullable1 = destructibleGroup2.RespawnIn; float num = (float)gameTime.ElapsedGameTime.TotalSeconds; float?nullable2 = nullable1.HasValue ? new float?(nullable1.GetValueOrDefault() - num) : new float?(); destructibleGroup2.RespawnIn = nullable2; if ((double)destructibleGroup1.RespawnIn.Value <= 0.0) { bool flag = true; foreach (TrileInstance instance in destructibleGroup1.AllTriles) { if (!instance.Enabled || instance.Hidden || instance.Removed) { instance.Enabled = false; instance.Hidden = true; ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, instance, flag || RandomHelper.Probability(0.25))); flag = false; } } destructibleGroup1.RespawnIn = new float?(); } } } TrileInstance carriedInstance = this.PlayerManager.CarriedInstance; if (carriedInstance != null && ActorTypeExtensions.IsBomb(carriedInstance.Trile.ActorSettings.Type) && !this.bombStates.ContainsKey(carriedInstance)) { carriedInstance.Foreign = carriedInstance.PhysicsState.Respawned = false; this.bombStates.Add(carriedInstance, new BombsHost.BombState()); } bool flag1 = false; bool flag2 = false; foreach (TrileInstance instance in this.bombStates.Keys) { BombsHost.BombState state = this.bombStates[instance]; if (!ActionTypeExtensions.IsEnteringDoor(this.PlayerManager.Action)) { state.SincePickup += gameTime.ElapsedGameTime; } bool flag3 = instance.Trile.ActorSettings.Type == ActorType.BigBomb; bool flag4 = instance.Trile.ActorSettings.Type == ActorType.TntBlock || instance.Trile.ActorSettings.Type == ActorType.TntPickup; if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && instance.Hidden) { this.bsToRemove.Add(instance); if (state.Flash != null) { this.flashesMesh.RemoveGroup(state.Flash); state.Flash = (Group)null; } if (state.Emitter != null && state.Emitter.Cue != null) { state.Emitter.Cue.Stop(false); } } else { if (state.SincePickup > this.FlashTime && state.Explosion == null) { if (state.Flash == null) { state.Flash = this.flashesMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, this.FlashColor, true); if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && !state.IsChainsploding) { state.Emitter = SoundEffectExtensions.EmitAt(this.countdownSound, instance.Center); state.Emitter.PauseViewTransitions = true; } } double totalSeconds = state.SincePickup.TotalSeconds; if (totalSeconds > this.ExplodeStart.TotalSeconds - 1.0) { totalSeconds *= 2.0; } state.Flash.Enabled = FezMath.Frac(totalSeconds) < 0.5; if (state.Flash.Enabled) { state.Flash.Position = instance.Center; state.Flash.Rotation = this.CameraManager.Rotation; } } if (state.SincePickup > this.ExplodeStart && state.Explosion == null) { if (flag4 && !flag1 || !flag4 && !flag2) { SoundEffectExtensions.EmitAt(flag4 ? this.crystalsplodeSound : this.explodeSound, instance.Center, RandomHelper.Centered(0.025)); if (flag4) { flag1 = true; } else { flag2 = true; } } if (state.ChainsplodedBy != null && state.ChainsplodedBy.Emitter != null) { state.ChainsplodedBy.Emitter.FadeOutAndDie(0.0f); } float num1 = (flag3 ? 0.6f : 0.3f) * FezMath.Saturate((float)(1.0 - (double)(instance.Center - this.PlayerManager.Center).Length() / 15.0)); if (CamShake.CurrentCamShake == null) { ServiceHelper.AddComponent((IGameComponent) new CamShake(this.Game) { Duration = TimeSpan.FromSeconds(0.75), Distance = num1 }); } else { CamShake.CurrentCamShake.Reset(); } this.ParticleSystemManager.PropagateEnergy(instance.Center, flag3 ? 6f : 3f); this.flashesMesh.RemoveGroup(state.Flash); state.Flash = (Group)null; switch (instance.Trile.ActorSettings.Type) { case ActorType.BigBomb: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.bigBombAnimation) { ActorType = ActorType.Bomb }; break; case ActorType.TntBlock: case ActorType.TntPickup: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.tntAnimation) { ActorType = ActorType.Bomb }; break; default: state.Explosion = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.bombAnimation) { ActorType = ActorType.Bomb }; break; } state.Explosion.Timing.Loop = false; state.Explosion.Billboard = true; state.Explosion.Fullbright = true; state.Explosion.OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)RandomHelper.Random.Next(0, 4) * 1.570796f); state.Explosion.Timing.Restart(); this.LevelManager.AddPlane(state.Explosion); state.Flare = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)this.flare) { AlwaysOnTop = true, LightMap = true, AllowOverbrightness = true, Billboard = true }; this.LevelManager.AddPlane(state.Flare); state.Flare.Scale = Vector3.One * (flag3 ? 3f : 1.5f); state.Explosion.Position = state.Flare.Position = instance.Center + (RandomHelper.Centered(1.0 / 1000.0) - 0.5f) * FezMath.ForwardVector(this.CameraManager.Viewpoint); float num2 = flag3 ? 3f : 1.5f; float num3 = ((this.PlayerManager.Position - instance.Center) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint)).Length(); if ((this.PlayerManager.CarriedInstance == instance || (double)num3 < (double)num2) && this.PlayerManager.Action != ActionType.Dying) { this.PlayerManager.Action = ActionType.Suffering; } if ((instance.Trile.ActorSettings.Type == ActorType.TntBlock || state.IsChainsploding) && instance.InstanceId != -1) { this.ParticleSystemManager.Add(new TrixelParticleSystem(this.Game, new TrixelParticleSystem.Settings() { ExplodingInstance = instance, EnergySource = new Vector3?(instance.Center), MaximumSize = 7, Energy = flag4 ? 3f : 1.5f, Darken = true, ParticleCount = 4 + 12 / Math.Max(1, this.TrixelParticleSystems.Count - 3) })); } if (ActorTypeExtensions.IsPickable(instance.Trile.ActorSettings.Type)) { instance.Enabled = false; this.LevelMaterializer.GetTrileMaterializer(instance.Trile).UpdateInstance(instance); } else { this.ClearDestructible(instance, false); } this.DropSupportedTriles(instance); this.DestroyNeighborhood(instance, state); } if (state.Explosion != null) { state.Flare.Filter = Color.Lerp(flag4 ? new Color(0.5f, 1f, 0.25f) : new Color(1f, 0.5f, 0.25f), Color.Black, state.Explosion.Timing.NormalizedStep); if (state.Explosion.Timing.Ended) { this.bsToRemove.Add(instance); if (instance.PhysicsState != null) { instance.PhysicsState.ShouldRespawn = ActorTypeExtensions.IsPickable(instance.Trile.ActorSettings.Type); } this.LevelManager.RemovePlane(state.Explosion); this.LevelManager.RemovePlane(state.Flare); } } } } foreach (TrileInstance key in this.bsToRemove) { this.bombStates.Remove(key); } this.bsToRemove.Clear(); foreach (KeyValuePair <TrileInstance, BombsHost.BombState> keyValuePair in this.bsToAdd) { if (!this.bombStates.ContainsKey(keyValuePair.Key)) { this.bombStates.Add(keyValuePair.Key, keyValuePair.Value); } } this.bsToAdd.Clear(); }
private void AddSupportedTrile(TrileInstance instance) { if (this.AttachedTriles.Contains(instance) || this.Group.Triles.Contains(instance) || instance.PhysicsState == null && !ActorTypeExtensions.IsPickable(instance.Trile.ActorSettings.Type)) { return; } this.AttachedTriles.Add(instance); this.AddSupportedTrilesOver(instance); TrileGroup trileGroup; if (!this.LevelManager.PickupGroups.TryGetValue(instance, out trileGroup)) { return; } foreach (TrileInstance instance1 in trileGroup.Triles) { this.AddSupportedTrile(instance1); } }
public override void Rebuild() { this.OnSkyChanged(); this.LevelMaterializer.ClearBatches(); this.LevelMaterializer.RebuildTriles(this.levelData.TrileSet, this.levelData.TrileSet == this.oldLevel.TrileSet); this.LevelMaterializer.RebuildInstances(); if (!this.Quantum) { this.LevelMaterializer.CleanUp(); } this.LevelMaterializer.InitializeArtObjects(); foreach (BackgroundPlane backgroundPlane in this.levelData.BackgroundPlanes.Values) { backgroundPlane.HostMesh = backgroundPlane.Animated ? this.LevelMaterializer.AnimatedPlanesMesh : this.LevelMaterializer.StaticPlanesMesh; backgroundPlane.Initialize(); } if (!this.levelData.BackgroundPlanes.ContainsKey(-1) && this.GomezHaloName != null) { this.levelData.BackgroundPlanes.Add(-1, new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, this.GomezHaloName, false) { Id = -1, LightMap = true, AlwaysOnTop = true, Billboard = true, Filter = this.HaloFiltering ? new Color(0.425f, 0.425f, 0.425f, 1f) : new Color(0.5f, 0.5f, 0.5f, 1f), PixelatedLightmap = !this.HaloFiltering }); } this.pickupGroups.Clear(); foreach (TrileGroup trileGroup in (IEnumerable <TrileGroup>) this.Groups.Values) { if (trileGroup.ActorType != ActorType.SuckBlock && Enumerable.All <TrileInstance>((IEnumerable <TrileInstance>)trileGroup.Triles, (Func <TrileInstance, bool>)(x => { if (ActorTypeExtensions.IsPickable(x.Trile.ActorSettings.Type)) { return(x.Trile.ActorSettings.Type != ActorType.Couch); } else { return(false); } }))) { foreach (TrileInstance key in trileGroup.Triles) { this.pickupGroups.Add(key, trileGroup); } } } this.SongChanged = this.Song == null != (this.SoundManager.CurrentlyPlayingSong == null) || this.Song != null && this.SoundManager.CurrentlyPlayingSong != null && this.Song.Name != this.SoundManager.CurrentlyPlayingSong.Name; if (this.SongChanged) { this.SoundManager.ScriptChangedSong = false; if (!this.GameState.InCutscene || this.GameState.IsTrialMode) { Waiters.Wait((Func <bool>)(() => { if (!this.GameState.Loading) { return(!this.GameState.FarawaySettings.InTransition); } else { return(false); } }), (Action)(() => { if (!this.SoundManager.ScriptChangedSong) { this.SoundManager.PlayNewSong(8f); } this.SoundManager.ScriptChangedSong = false; })); } } else if (this.Song != null) { if (!this.GameState.DotLoading) { this.SoundManager.UpdateSongActiveTracks(); } else { Waiters.Wait((Func <bool>)(() => !this.GameState.Loading), (Action)(() => this.SoundManager.UpdateSongActiveTracks())); } } this.SoundManager.FadeFrequencies(this.LowPass, 2f); this.SoundManager.UnmuteAmbienceTracks(); if (!this.GameState.InCutscene || this.GameState.IsTrialMode) { Waiters.Wait((Func <bool>)(() => { if (!this.GameState.Loading) { return(!this.GameState.FarawaySettings.InTransition); } else { return(false); } }), (Action)(() => this.SoundManager.PlayNewAmbience())); } this.oldLevel = (Level)null; this.FullPath = this.Name; }
protected override bool Act(TimeSpan elapsed) { if (this.PlayerManager.PushedInstance == null || this.PlayerManager.PushedInstance.Hidden || this.PlayerManager.PushedInstance.PhysicsState == null) { this.PlayerManager.Action = ActionType.Idle; this.PlayerManager.PushedInstance = (TrileInstance)null; return(false); } else { Vector3 b = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); TrileInstance pushedInstance = this.PlayerManager.PushedInstance; InstancePhysicsState physicsState = pushedInstance.PhysicsState; this.eCratePush.Position = pushedInstance.Center; this.eGomezPush.Position = this.PlayerManager.Center; if (!physicsState.Grounded) { this.PlayerManager.PushedInstance = (TrileInstance)null; this.PlayerManager.Action = ActionType.Idle; return(false); } else { int stackSize = this.FindStackSize(pushedInstance, 0); if (stackSize <= 2) { this.movementHelper.Entity = (IPhysicsEntity)physicsState; float num = this.InputManager.Movement.X; if (BoxCollisionResultExtensions.AnyCollided(physicsState.WallCollision) && ActorTypeExtensions.IsPickable(physicsState.WallCollision.First.Destination.Trile.ActorSettings.Type)) { num *= 5f; } if (pushedInstance.Trile.ActorSettings.Type == ActorType.Couch) { num *= 2f; } this.movementHelper.Update((float)elapsed.TotalSeconds, num / (float)(stackSize + 1)); if (this.pickupGroup != null) { pushedInstance.PhysicsState.Puppet = false; foreach (TrileInstance trileInstance in this.pickupGroup.Triles) { if (trileInstance != pushedInstance) { trileInstance.PhysicsState.Velocity = pushedInstance.PhysicsState.Velocity; trileInstance.PhysicsState.Puppet = true; } } } this.PlayerManager.Center = Vector3.Up * this.PlayerManager.Center + (FezMath.DepthMask(this.CameraManager.Viewpoint) + b) * physicsState.Center + -vector3 * (pushedInstance.TransformedSize / 2f + this.PlayerManager.Size / 2f); this.eCratePush.VolumeFactor = FezMath.Saturate(Math.Abs(FezMath.Dot(physicsState.Velocity, b)) / 0.024f); if (FezMath.AlmostEqual(FezMath.Dot(physicsState.Velocity, b), 0.0f)) { this.PlayerManager.Action = ActionType.Grabbing; return(false); } } else { this.PlayerManager.Action = ActionType.Grabbing; this.eCratePush.Cue.Pause(); this.eGomezPush.Cue.Pause(); } return(this.PlayerManager.Action == ActionType.Pushing); } } }
private void InitializePickups() { this.sinceLevelChanged = 0.0f; if (this.LevelManager.TrileSet == null) { this.initLock.Reset(); this.PickupStates = (List <PickupState>)null; this.initLock.Set(); } else { this.initLock.Reset(); if (this.PickupStates != null) { foreach (PickupState pickupState in this.PickupStates) { pickupState.Instance.PhysicsState.ShouldRespawn = false; } } this.PickupStates = new List <PickupState>(Enumerable.Select <TrileInstance, PickupState>(Enumerable.SelectMany <Trile, TrileInstance>(Enumerable.Where <Trile>((IEnumerable <Trile>) this.LevelManager.TrileSet.Triles.Values, (Func <Trile, bool>)(t => ActorTypeExtensions.IsPickable(t.ActorSettings.Type))), (Func <Trile, IEnumerable <TrileInstance> >)(t => (IEnumerable <TrileInstance>)t.Instances)), (Func <TrileInstance, PickupState>)(t => new PickupState(t, this.LevelManager.PickupGroups.ContainsKey(t) ? this.LevelManager.PickupGroups[t] : (TrileGroup)null)))); foreach (PickupState pickupState in Enumerable.Where <PickupState>((IEnumerable <PickupState>) this.PickupStates, (Func <PickupState, bool>)(x => x.Group != null))) { int groupId = pickupState.Group.Id; pickupState.AttachedAOs = Enumerable.ToArray <ArtObjectInstance>(Enumerable.Where <ArtObjectInstance>((IEnumerable <ArtObjectInstance>) this.LevelMaterializer.LevelArtObjects, (Func <ArtObjectInstance, bool>)(x => { int?local_0 = x.ActorSettings.AttachedGroup; int local_1 = groupId; if (local_0.GetValueOrDefault() == local_1) { return(local_0.HasValue); } else { return(false); } }))); if (pickupState.Group.Triles.Count == 1) { pickupState.Group = (TrileGroup)null; } } foreach (TrileInstance instance in Enumerable.Select <PickupState, TrileInstance>(Enumerable.Where <PickupState>((IEnumerable <PickupState>) this.PickupStates, (Func <PickupState, bool>)(x => x.Instance.PhysicsState == null)), (Func <PickupState, TrileInstance>)(x => x.Instance))) { instance.PhysicsState = new InstancePhysicsState(instance) { Ground = new MultipleHits <TrileInstance>() { NearLow = this.LevelManager.ActualInstanceAt(instance.Center - instance.Trile.Size.Y * Vector3.UnitY) } } } ; bool flag = this.LevelManager.WaterType == LiquidType.Sewer && !FezMath.In <string>(this.LevelManager.Name, "SEWER_PIVOT", "SEWER_TREASURE_TWO"); foreach (TrileGroup trileGroup in Enumerable.Distinct <TrileGroup>(Enumerable.Where <TrileGroup>((IEnumerable <TrileGroup>) this.LevelManager.PickupGroups.Values, (Func <TrileGroup, bool>)(g => Enumerable.All <TrileInstance>((IEnumerable <TrileInstance>)g.Triles, (Func <TrileInstance, bool>)(t => !t.PhysicsState.Puppet)))))) { foreach (TrileInstance instance in trileGroup.Triles) { instance.PhysicsState.IgnoreCollision = flag; instance.PhysicsState.Center += 1.0 / 500.0 * FezMath.XZMask; instance.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(instance); instance.PhysicsState.Puppet = true; } trileGroup.Triles[trileGroup.Triles.Count / 2].PhysicsState.Puppet = false; trileGroup.InMidAir = true; } this.PauseGroupOverlaps(true); this.DetectBackground(); this.initLock.Set(); } }