public override void OnUpdate() { base.OnUpdate(); if (this.m_AI.m_ID == AI.AIID.Spearman && FPPController.Get().m_Dodge&& this.m_CurrentAction == this.m_Attack) { this.m_AI.m_DamageModule.m_BlockDamage = true; } this.UpdateRotation(); }
private void SetActive(bool set) { if (this.m_Active == set) { return; } this.m_Active = set; if (!this.m_Active) { FPPController.Get().OnDeactivateHUDItem(); } }
protected override bool ShouldShow() { if (GreenHellGame.Instance.m_GameMode != GameMode.Story) { return(false); } if (ScenarioManager.Get().IsBoolVariableTrue("PlayerMechGameEnding")) { return(false); } if (ChallengesManager.Get() && ChallengesManager.Get().IsChallengeActive()) { return(false); } if (ConsciousnessController.Get().IsActive()) { return(false); } if (SleepController.Get().IsActive()) { return(false); } if (HUDReadableItem.Get().enabled) { return(false); } if (Player.Get().m_Animator.GetBool(Player.Get().m_CleanUpHash)) { return(false); } if (Time.time - SwimController.Get().m_LastDisableTime < 0.5f) { return(false); } if (Player.Get().m_IsInAir) { return(false); } if (HUDWheel.Get().enabled) { return(false); } if (FPPController.Get().m_Dodge) { return(false); } int shortNameHash = Player.Get().m_Animator.GetCurrentAnimatorStateInfo(1).shortNameHash; return(shortNameHash != this.m_MapWatchHideHash && shortNameHash != this.m_MapWatchIdleHash && shortNameHash != this.m_MapWatchShowHash && shortNameHash != this.m_MapZoomHash && shortNameHash != this.m_MapHideHash && shortNameHash != this.m_MapIdleHash && shortNameHash != this.m_ShowMapHash && (!DeathController.Get().IsActive() && !InsectsController.Get().IsActive() && !ScenarioManager.Get().IsDreamOrPreDream() && !Inventory3DManager.Get().IsActive() && !CutscenesManager.Get().IsCutscenePlaying() && !SwimController.Get().IsActive() && !BodyInspectionController.Get().IsActive() && !HarvestingAnimalController.Get().IsActive() && !HarvestingSmallAnimalController.Get().IsActive() && !VomitingController.Get().IsActive() && !MapController.Get().IsActive() && !NotepadController.Get().IsActive() && !MudMixerController.Get().IsActive()) && !MakeFireController.Get().IsActive()); }
private void UpdateHydration() { if (this.m_Player.m_DreamActive) { return; } FPPController fppcontroller = this.m_Player.m_FPPController; if (!fppcontroller) { return; } float num = 0f; float num2 = 1f; if (!Cheats.m_GodMode || this.m_LossParametersBlocked) { float deltaTime = Time.deltaTime; if (fppcontroller.IsRunning()) { num2 *= this.m_HydrationConsumptionRunMul; } num = this.m_HydrationConsumptionPerSecond * deltaTime * num2; if (PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.Fever).IsActive()) { num += this.m_HydrationConsumptionDuringFeverPerSecond * deltaTime; } for (int i = 0; i < this.m_InjuryModule.m_Injuries.Count; i++) { Injury injury = this.m_InjuryModule.m_Injuries[i]; if (injury.m_Type == InjuryType.VenomBite || injury.m_Type == InjuryType.SnakeBite) { num += Injury.s_PoisonedWoundHydrationDecPerSec * deltaTime; } } } GameDifficulty gameDifficulty = GreenHellGame.Instance.m_GameDifficulty; if (gameDifficulty == GameDifficulty.Normal) { num *= GreenHellGame.s_NormalModeLossMul; } else if (gameDifficulty == GameDifficulty.Easy) { num *= GreenHellGame.s_EasyModeLossMul; } this.DecreaseHydration(num); }
private void UpdateEnergy() { if (this.m_Player.m_DreamActive) { return; } float deltaTime = Time.deltaTime; FPPController fppcontroller = this.m_Player.m_FPPController; if (!fppcontroller) { return; } DeathController deathController = this.m_Player.m_DeathController; if (deathController.IsActive()) { return; } ConsciousnessController component = this.m_Player.GetComponent <ConsciousnessController>(); if (component.IsActive()) { return; } if (!Cheats.m_GodMode && !this.m_LossParametersBlocked) { this.m_Energy -= this.m_EnergyConsumptionPerSecond * deltaTime; if (this.IsNutritionCarboCriticalLevel() || this.IsNutritionFatCriticalLevel() || this.IsNutritionProteinsCriticalLevel()) { this.m_Energy -= this.m_EnergyConsumptionPerSecondNoNutrition * deltaTime; } if (this.m_DiseasesModule.GetDisease(ConsumeEffect.Fever).IsActive()) { this.m_Energy -= this.m_EnergyConsumptionPerSecondFever * deltaTime; } if (this.m_DiseasesModule.GetDisease(ConsumeEffect.FoodPoisoning).IsActive()) { this.m_Energy -= this.m_EnergyConsumptionPerSecondFoodPoison * deltaTime; } } this.m_Energy = Mathf.Clamp(this.m_Energy, 0f, this.m_MaxEnergy); if (this.m_Energy <= PlayerSanityModule.Get().m_LowEnegryWhispersLevel) { PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.LowEnergy); } }
private void UpdateStamina() { float deltaTime = Time.deltaTime; FPPController fppcontroller = this.m_Player.m_FPPController; if (!fppcontroller) { return; } if (Cheats.m_GodMode) { this.m_Stamina = this.m_MaxStamina; return; } float num = this.m_Stamina; if (fppcontroller.IsActive() && fppcontroller.IsWalking()) { num -= this.m_StaminaConsumptionWalkPerSecond * deltaTime * ((!PlayerCocaineModule.Get().m_Active) ? 1f : PlayerCocaineModule.Get().m_StaminaConsumptionMul); } else if (fppcontroller.IsActive() && fppcontroller.IsRunning()) { num -= this.m_StaminaConsumptionRunPerSecond * deltaTime * ((!PlayerCocaineModule.Get().m_Active) ? 1f : PlayerCocaineModule.Get().m_StaminaConsumptionMul); } else if (fppcontroller.IsActive() && fppcontroller.IsDepleted()) { num -= this.m_StaminaConsumptionDepletedPerSecond * deltaTime * ((!PlayerCocaineModule.Get().m_Active) ? 1f : PlayerCocaineModule.Get().m_StaminaConsumptionMul); } else if (!MakeFireController.Get().IsActive()) { num += this.m_StaminaRegenerationPerSecond * deltaTime; } if (num < this.m_Stamina || Time.time - this.m_LastDecreaseStaminaTime >= this.m_StaminaRenerationDelay) { this.m_Stamina = num; } float num2 = this.m_Stamina - this.m_PrevStamina; if (num2 < 0f) { this.m_LastDecreaseStaminaTime = Time.time; } this.m_Stamina = Mathf.Clamp(this.m_Stamina, 0f, this.m_MaxStamina); this.m_PrevStamina = this.m_Stamina; }
public void Respawn(Being obj) { if (!obj) { return; } RespawnPoint bestRespawnPoint = this.GetBestRespawnPoint(obj.transform.position); DebugUtils.Assert(bestRespawnPoint, true); if (bestRespawnPoint) { obj.transform.position = bestRespawnPoint.transform.position; } Collider componentDeepChild = General.GetComponentDeepChild <Collider>(obj.gameObject); Vector3 position = obj.transform.position; position.y += ((!componentDeepChild) ? 0f : componentDeepChild.bounds.size.y); RaycastHit raycastHit; if (Physics.Raycast(position, Vector3.down, out raycastHit)) { obj.transform.position = raycastHit.point; } if (obj.IsPlayer()) { Vector3 vector = (!bestRespawnPoint) ? Vector3.forward : bestRespawnPoint.transform.forward; vector.y = 0f; float num = Vector3.Angle(vector, Vector3.forward); Vector2 zero = Vector2.zero; if (Vector3.Dot(Vector3.right, vector) < 0f) { num *= -1f; } zero.x = num; FPPController fppcontroller = Player.Get().m_FPPController; fppcontroller.SetLookDev(zero); Vector3 position2 = obj.transform.position; position2.y += Player.Get().GetComponent <CharacterController>().height * 0.5f; obj.transform.position = position2; } }
private void LateUpdate() { if (this.m_StoreStartPosition && this.m_PlayableDirectorEx && this.m_PlayableDirectorEx.m_FollowOffsetHelper) { this.m_StartPos = this.m_PlayableDirectorEx.m_Transform.position - this.m_PlayableDirectorEx.m_RefTransform.position; this.m_StoreStartPosition = false; this.m_PrevPos = this.m_StartPos; this.m_LastPos = this.m_StartPos; this.m_StartRot = Quaternion.Inverse(this.m_PlayableDirectorEx.m_RefTransform.rotation) * this.m_PlayableDirectorEx.m_Transform.rotation; this.m_PrevRot = this.m_StartRot; this.m_LastRot = this.m_StartRot; this.m_CharacterController.detectCollisions = false; } if (this.m_PlayableDirectorEx && this.m_PlayableDirectorEx.m_FollowOffsetHelper && this.m_CurrentCutscene.time >= (double)this.m_PlayTime) { this.m_PrevPos = this.m_LastPos; this.m_LastPos = this.m_PlayableDirectorEx.m_Transform.position - this.m_PlayableDirectorEx.m_RefTransform.position; this.m_PrevRot = this.m_LastRot; this.m_LastRot = Quaternion.Inverse(this.m_PlayableDirectorEx.m_RefTransform.rotation) * this.m_PlayableDirectorEx.m_Transform.rotation; Vector3 b = this.m_LastPos - this.m_PrevPos; this.m_CharacterController.gameObject.transform.position += b; this.m_CharacterController.gameObject.transform.rotation *= Quaternion.Inverse(this.m_PrevRot) * this.m_LastRot; float num = Vector3.Angle(this.m_CharacterController.transform.forward, Vector3.forward); Vector2 zero = Vector2.zero; if (Vector3.Dot(Vector3.right, this.m_CharacterController.transform.forward) < 0f) { num *= -1f; } zero.x = num; FPPController fppcontroller = Player.Get().m_FPPController; fppcontroller.SetLookDev(zero); } if (this.m_PlayableDirectorEx && !this.m_PlayableDirectorEx.m_Looped && this.m_CurrentCutscene && (this.m_CurrentCutscene.time >= this.m_CurrentCutscene.duration || this.m_CurrentCutscene.time < (double)this.m_PlayTime)) { this.StopCutscene(); } if (this.m_CurrentCutscene) { this.m_PlayTime = (float)this.m_CurrentCutscene.time; } }
protected override void OnDisable() { base.OnDisable(); this.m_Animator.CrossFade(this.m_Idle, 0.2f, 0); this.m_Animator.CrossFade(this.m_UnarmedIdle, 0.2f, 1); if (this.m_Trigger && Player.Get()) { Collider[] componentsInChildren = this.m_Trigger.GetComponentsInChildren <Collider>(); for (int i = 0; i < componentsInChildren.Length; i++) { Physics.IgnoreCollision(componentsInChildren[i], Player.Get().m_Collider, false); } } if (this.m_State == AnimationTriggerController.State.Animation && this.m_Trigger) { ScenarioManager.Get().SetBoolVariable(this.m_Trigger.m_ScenarioBoolVariable, true); } LookController.Get().m_LookDev.y = 0f; LookController.Get().m_WantedLookDev.y = 0f; base.ResetBodyRotationBonesParams(); FPPController.Get().ResetBodyRotationBonesParams(); }
protected override void OnDisable() { base.OnDisable(); LookController.Get().m_WantedLookDev.y = 0f; this.m_Player.m_AudioModule.StopHarvestAnimalSound(); if (this.m_Animator.isInitialized) { this.m_Animator.SetBool(this.m_MudMixerHash, false); } Collider collider = Player.Get().m_Collider; Physics.IgnoreCollision(collider, this.m_Mixer.m_BoxCollider, false); foreach (Collider collider2 in this.m_Mixer.gameObject.GetComponentsInChildren <Collider>()) { Physics.IgnoreCollision(collider, collider2, false); } this.m_Mixer.OnFinishMixing(); LookController.Get().m_LookDev.y = 0f; LookController.Get().m_WantedLookDev.y = 0f; base.ResetBodyRotationBonesParams(); FPPController.Get().ResetBodyRotationBonesParams(); }
private void UpdateEnterState() { Vector3 vector = this.m_Trigger.m_TransformObject.transform.position - base.transform.position; Vector3 a = vector.normalized * this.m_Speed; float f = Vector3.Angle(Player.Get().transform.forward.GetNormalized2D(), this.m_Trigger.m_TransformObject.transform.forward.GetNormalized2D()); Vector3 motion = a * Time.deltaTime; if (vector.To2D().magnitude > motion.magnitude || Mathf.Abs(f) > 1f) { if (vector.To2D().magnitude > motion.magnitude) { this.m_CharacterController.Move(motion, true); } else { this.m_CharacterController.Move(vector, true); } LookController.Get().UpdateWantedLookDir(); FPPController.Get().UpdateBodyRotation(); return; } this.m_CharacterController.Move(vector, true); this.SetState(AnimationTriggerController.State.Animation); }
private void UpdateNutrition() { if (this.m_ParasiteSickness == null) { this.m_ParasiteSickness = (ParasiteSickness)PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.ParasiteSickness); } if (this.m_Player.m_DreamActive) { return; } if (Cheats.m_GodMode || this.m_LossParametersBlocked) { return; } FPPController fppcontroller = this.m_Player.m_FPPController; if (!fppcontroller) { return; } WeaponController weaponController = this.m_Player.m_WeaponController; bool flag = false; if (weaponController && weaponController.IsAttack()) { flag = true; } if (!flag && this.m_Player.GetCurrentItem(Hand.Right) && this.m_Player.GetCurrentItem(Hand.Right).m_Info.IsHeavyObject()) { flag = true; } float deltaTime = Time.deltaTime; float num = 1f; float num2 = 1f; float num3 = 1f; if (fppcontroller.IsRunning()) { num *= this.m_NutritionCarbohydratesConsumptionRunMul; num2 *= this.m_NutritionFatConsumptionRunMul; num3 *= this.m_NutritionProteinsConsumptionRunMul; } if (flag) { num *= this.m_NutritionCarbohydratesConsumptionActionMul; num2 *= this.m_NutritionFatConsumptionActionMul; num3 *= this.m_NutritionProteinsConsumptionActionMul; } if (this.IsNutritionCarboCriticalLevel()) { num2 *= this.m_NutritionFatConsumptionMulNoCarbs; num3 *= this.m_NutritionProteinsConsumptionMulNoCarbs; } if (InventoryBackpack.Get().IsCriticalOverload()) { num *= this.m_NutritionCarbohydratesConsumptionWeightCriticalMul; num2 *= this.m_NutritionFatConsumptionWeightCriticalMul; num3 *= this.m_NutritionProteinsConsumptionWeightCriticalMul; } else if (InventoryBackpack.Get().IsOverload()) { num *= this.m_NutritionCarbohydratesConsumptionWeightOverloadMul; num2 *= this.m_NutritionFatConsumptionWeightOverloadMul; num3 *= this.m_NutritionProteinsConsumptionWeightOverloadMul; } else { num *= this.m_NutritionCarbohydratesConsumptionWeightNormalMul; num2 *= this.m_NutritionFatConsumptionWeightNormalMul; num3 *= this.m_NutritionProteinsConsumptionWeightNormalMul; } if (this.m_ParasiteSickness.IsActive()) { num *= this.m_ParasiteSickness.m_MacroNutricientCarboLossMul * (float)this.m_ParasiteSickness.m_Level; num2 *= this.m_ParasiteSickness.m_MacroNutricientFatLossMul * (float)this.m_ParasiteSickness.m_Level; num3 *= this.m_ParasiteSickness.m_MacroNutricientProteinsLossMul * (float)this.m_ParasiteSickness.m_Level; } GameDifficulty gameDifficulty = GreenHellGame.Instance.m_GameDifficulty; if (gameDifficulty == GameDifficulty.Normal) { float s_NormalModeLossMul = GreenHellGame.s_NormalModeLossMul; num *= s_NormalModeLossMul; num2 *= s_NormalModeLossMul; num3 *= s_NormalModeLossMul; } else if (gameDifficulty == GameDifficulty.Easy) { float s_EasyModeLossMul = GreenHellGame.s_EasyModeLossMul; num *= s_EasyModeLossMul; num2 *= s_EasyModeLossMul; num3 *= s_EasyModeLossMul; } this.m_NutritionCarbo -= this.m_NutritionCarbohydratesConsumptionPerSecond * deltaTime * num * ((!PlayerCocaineModule.Get().m_Active) ? 1f : PlayerCocaineModule.Get().m_CarboConsumptionMul); this.m_NutritionCarbo = Mathf.Clamp(this.m_NutritionCarbo, 0f, this.m_MaxNutritionCarbo); this.m_NutritionFat -= this.m_NutritionFatConsumptionPerSecond * deltaTime * num2 * ((!PlayerCocaineModule.Get().m_Active) ? 1f : PlayerCocaineModule.Get().m_FatConsumptionMul); this.m_NutritionFat = Mathf.Clamp(this.m_NutritionFat, 0f, this.m_MaxNutritionFat); this.m_NutritionProteins -= this.m_NutritionProteinsConsumptionPerSecond * deltaTime * num3 * ((!PlayerCocaineModule.Get().m_Active) ? 1f : PlayerCocaineModule.Get().m_ProteinsConsumptionMul); this.m_NutritionProteins = Mathf.Clamp(this.m_NutritionProteins, 0f, this.m_MaxNutritionProteins); }
private void UpdateHP() { if (this.m_Player.m_DreamActive) { return; } float deltaTime = Time.deltaTime; FPPController fppcontroller = this.m_Player.m_FPPController; if (!fppcontroller) { return; } DeathController deathController = this.m_Player.m_DeathController; if (deathController.IsActive()) { return; } ConsciousnessController component = this.m_Player.GetComponent <ConsciousnessController>(); if (component.IsActive()) { return; } if (!Cheats.m_GodMode) { if (this.IsNutritionCarboCriticalLevel() || this.IsNutritionFatCriticalLevel() || this.IsNutritionProteinsCriticalLevel()) { this.IncreaseHP(-this.m_HealthLossPerSecondNoNutrition * deltaTime); } if (this.IsHydrationCriticalLevel()) { this.IncreaseHP(-this.m_HealthLossPerSecondNoHydration * deltaTime); } bool flag = true; List <Injury> injuriesList = this.m_InjuryModule.GetInjuriesList(); for (int i = 0; i < injuriesList.Count; i++) { if (injuriesList[i].m_ParentInjury == null) { if (injuriesList[i].m_Type != InjuryType.Worm && injuriesList[i].m_Type != InjuryType.Rash && injuriesList[i].m_Type != InjuryType.Leech) { flag = false; break; } } } if (flag) { float num = MainLevel.Instance.m_TODTime.m_DayLengthInMinutes + MainLevel.Instance.m_TODTime.m_NightLengthInMinutes; float num2 = num * 60f; this.IncreaseHP(this.m_MaxHP * this.m_HealthRecoveryPerDay / num2 * deltaTime); } if (this.m_Oxygen <= 0f) { this.IncreaseHP(-this.m_HealthLossPerSecondNoOxygen * deltaTime); } } this.m_HP = Mathf.Clamp(this.m_HP, 0f, this.m_MaxHP); if (this.m_HP < 10f) { if (!this.m_AudioModule.IsHeartBeatSoundPlaying()) { this.m_AudioModule.PlayHeartBeatSound(1f, true); } } else if (this.m_AudioModule.IsHeartBeatSoundPlaying()) { this.m_AudioModule.StopHeartBeatSound(); } }
public void PlayFootstepSound() { if ((Player.Get().GetFPPController().m_LastCollisionFlags & CollisionFlags.Below) == CollisionFlags.None) { return; } Vector3 wantedSpeed = this.m_FPPController.m_WantedSpeed; wantedSpeed.y = 0f; if (wantedSpeed.magnitude < 0.1f) { return; } if (Time.time - this.m_LastFootstepSound < 0.1f) { return; } List <AudioClip> list = null; bool flag = Player.Get().GetFPPController().IsRunning(); EObjectMaterial eobjectMaterial = EObjectMaterial.Unknown; if (this.m_Player.IsInWater() && !this.m_Player.m_SwimController.IsActive()) { list = ((!flag) ? this.m_ShallowWaterWalkSounds : this.m_ShallowWaterRunSounds); } else { eobjectMaterial = Player.Get().GetMaterial(); switch (eobjectMaterial) { case EObjectMaterial.Unknown: case EObjectMaterial.Sand: list = ((!flag) ? this.m_SandStepWalkSounds : this.m_SandStepRunSounds); break; case EObjectMaterial.Bush: case EObjectMaterial.Grass: list = ((!flag) ? this.m_GrassStepWalkSounds : this.m_GrassStepRunSounds); break; case EObjectMaterial.Stone: list = ((!flag) ? this.m_StoneStepWalkSounds : this.m_StoneStepRunSounds); break; case EObjectMaterial.DryLeaves: list = ((!flag) ? this.m_DryLeavesStepWalkSounds : this.m_DryLeavesStepRunSounds); break; case EObjectMaterial.Mud: list = ((!flag) ? this.m_MudStepWalkSounds : this.m_MudStepRunSounds); break; case EObjectMaterial.Soil: list = ((!flag) ? this.m_SoilStepWalkSounds : this.m_SoilStepRunSounds); break; } } Noise.Type noise_type = Noise.Type.None; if (FPPController.Get().IsWalking()) { noise_type = ((!FPPController.Get().IsDuck()) ? Noise.Type.Walk : Noise.Type.Sneak); } else if (flag) { noise_type = ((!FPPController.Get().IsDuck()) ? Noise.Type.Run : Noise.Type.Sneak); } else if (SwimController.Get().IsSwimming()) { noise_type = Noise.Type.Swim; } if (list == null) { Debug.Log("ERROR PlayerAudioModule PlayFootstepSound no sounds clips player_pos=" + Player.Get().transform.position.ToString() + " Material = " + eobjectMaterial.ToString()); } this.PlayRandomSound(list, 1f, false, noise_type); this.m_LastFootstepSound = Time.time; }
private void UpdateState() { switch (this.m_Animator.GetInteger(this.m_StateHash)) { case 1: if (FPPController.Get().IsWalking()) { this.SetState(FishingController.State.Walk); return; } if (FPPController.Get().IsRunning()) { this.SetState(FishingController.State.Run); return; } break; case 2: if (FPPController.Get().IsRunning()) { this.SetState(FishingController.State.Run); return; } if (!FPPController.Get().IsWalking()) { this.SetState(FishingController.State.Idle); return; } break; case 3: if (FPPController.Get().IsWalking()) { this.SetState(FishingController.State.Walk); return; } if (!FPPController.Get().IsRunning()) { this.SetState(FishingController.State.Idle); return; } break; case 4: if (this.IsAnimFinish(this.m_FishingJumpHash)) { this.SetState(FishingController.State.Idle); return; } break; case 5: this.UpdateAim(); return; case 6: case 8: case 9: case 10: case 12: break; case 7: { Vector3 normalized2D = (this.m_FishingRod.m_Float.transform.position - base.transform.position).GetNormalized2D(); if (Vector3.Dot(base.transform.forward.GetNormalized2D(), normalized2D) < 0.2f) { this.Cancel(); return; } break; } case 11: if (this.IsAnimFinish(this.m_FishingFailHash)) { this.SetState(FishingController.State.Idle); } break; default: return; } }