private void AddHit(Vector3 movement, WaterCollider collider) { if (movement.sqrMagnitude * collider.multiplier < 1e-8f || hitList.Count > 500) { return; } Vector3 localHit = transform.InverseTransformPoint(collider.truePosition) - Vector3.one * 5f; Vector3 hitPoint = -new Vector3(localHit.x, localHit.z, -2f * sizeMultiplier * collider.radius); hitPoint *= .1f; // scale it by standard plane size hitList.Add(hitPoint); directions.Add(transform.InverseTransformDirection(movement).normalized); // Add the amplitude on the end of the direction vector float inverseDepth = (1f - Mathf.Clamp01(-transform.InverseTransformPoint(collider.truePosition).y / (collisionDepth + collider.radius))); directions[directions.Count - 1] += new Vector4(0, 0, 0, collider.multiplier) * displacementMultiplier * Mathf.Sign(transform.InverseTransformDirection(movement).y) * transform.InverseTransformDirection(movement).magnitude *inverseDepth; // Add the location and size information after the hit information float skimmingRadius = Mathf.Clamp(collider.radius - transform.InverseTransformPoint(collider.truePosition).y, 0f, collider.radius); directions.Add(new Vector4(hitPoint.x, hitPoint.y, skimmingRadius * sizeMultiplier / transform.localScale.x, 1f)); }
public void OnExitWater(WaterCollider water) { if (this.m_CurrentWaters.Contains(water.gameObject)) { this.m_CurrentWaters.Remove(water.gameObject); } }
public void OnEnterWater(WaterCollider water) { if (!this.m_CurrentWaters.Contains(water)) { this.m_CurrentWaters.Add(water); } }
private void OnTriggerExit(Collider other) { WaterCollider component = other.gameObject.GetComponent <WaterCollider>(); if (component && this.m_WaterBoxModule) { this.m_WaterBoxModule.OnExitWater(component); } }
public void OnEnterWater(WaterCollider water) { if (!this.m_CurrentWaters.Contains(water.gameObject)) { PlayerInjuryModule.Get().CheckLeeches(); if (water.m_PlayerCanSwimIn) { this.m_CurrentWaters.Add(water.gameObject); } } }
public void OnExitWater(WaterCollider water) { if (this.m_CurrentWaters.Contains(water)) { this.m_CurrentWaters.Remove(water); } if (this.m_CurrentSwimWaters.Contains(water)) { this.m_CurrentSwimWaters.Remove(water); } }
private void DetectCollision() { for (int i = 0; i < WaterColliderManager.Instance.GetNumColliders(); i++) { WaterCollider collider = WaterColliderManager.Instance.GetWaterCollider(i); if (transform.InverseTransformPoint(collider.truePosition).y <= collider.radius && Mathf.Abs(transform.InverseTransformPoint(collider.truePosition).y) - collisionDepth < collider.radius * 2f) { AddHit(collider.velocity, collider); } } }
protected override void Update() { base.Update(); this.UpdateParticle(); this.UpdateState(); this.UpdateSounds(); if (!this.ReplIsOwner()) { return; } if (base.IsInWater() && !base.m_InInventory) { WaterCollider waterCollider = this.m_CurrentWaters[this.m_CurrentWaters.Count - 1]; this.m_LCInfo.m_LiquidType = (waterCollider.m_LiquidSource ? waterCollider.m_LiquidSource.m_LiquidType : LiquidType.UnsafeWater); this.m_LCInfo.m_Amount = this.m_LCInfo.m_Capacity; return; } if (this.m_LCInfo.m_Amount < this.m_LCInfo.m_Capacity && !base.transform.parent && base.transform.up.y > 0.45f && RainManager.Get().IsRain() && !RainManager.Get().IsInRainCutter(base.transform.position)) { bool flag = true; if (Inventory3DManager.Get().m_CarriedItem == this && RainManager.Get().IsInRainCutter(Player.Get().transform.position)) { flag = false; } if (flag) { if (this.m_LCInfo.m_LiquidType != LiquidType.Water && this.m_LCInfo.m_Amount == 0f) { this.m_LCInfo.m_LiquidType = LiquidType.Water; } if (this.m_LCInfo.m_LiquidType == LiquidType.Water) { float num = Time.deltaTime; if (SleepController.Get().IsActive() && !SleepController.Get().IsWakingUp()) { num = Player.GetSleepTimeFactor(); } this.m_LCInfo.m_Amount += num * 0.2f; this.m_LCInfo.m_Amount = Mathf.Clamp(this.m_LCInfo.m_Amount, 0f, this.m_LCInfo.m_Capacity); } } } }
protected override void Update() { base.Update(); PlayerInjuryModule playerInjuryModule = PlayerInjuryModule.Get(); PlayerConditionModule playerConditionModule = PlayerConditionModule.Get(); for (int i = 0; i < this.m_WoundParameters.Count; i++) { if (i < playerInjuryModule.m_Injuries.Count) { Injury injury = playerInjuryModule.m_Injuries[i]; this.m_WoundParameters[i].enabled = true; this.m_WoundParameters[i].text = "Type: " + injury.m_Type.ToString(); if (injury.m_Type == InjuryType.SmallWoundAbrassion) { Text text = this.m_WoundParameters[i]; text.text = text.text + " TimeToHeal:" + (injury.GetHealingDuration() - (MainLevel.Instance.GetCurrentTimeMinutes() - injury.m_HealingStartTime)).ToString(); Text text2 = this.m_WoundParameters[i]; text2.text = text2.text + " HealTimeBonus: " + injury.m_HealingTimeDec.ToString(); } else if (injury.m_Type == InjuryType.SmallWoundScratch) { Text text3 = this.m_WoundParameters[i]; text3.text = text3.text + " TimeToHeal:" + (injury.GetHealingDuration() - (MainLevel.Instance.GetCurrentTimeMinutes() - injury.m_HealingStartTime)).ToString(); Text text4 = this.m_WoundParameters[i]; text4.text = text4.text + " HealTimeBonus: " + injury.m_HealingTimeDec.ToString(); } else if (injury.m_Type == InjuryType.Laceration || injury.m_Type == InjuryType.LacerationCat) { Text text5 = this.m_WoundParameters[i]; text5.text = text5.text + " TimeToHeal:" + (injury.GetHealingDuration() - (MainLevel.Instance.GetCurrentTimeMinutes() - injury.m_HealingStartTime)).ToString(); Text text6 = this.m_WoundParameters[i]; text6.text = text6.text + " Will transform to: " + injury.m_HealingResultInjuryState.ToString(); } else if (injury.m_Type == InjuryType.VenomBite) { Text text7 = this.m_WoundParameters[i]; text7.text = text7.text + " TimeToHeal:" + (injury.GetHealingDuration() - (MainLevel.Instance.GetCurrentTimeMinutes() - injury.m_HealingStartTime)).ToString(); Text text8 = this.m_WoundParameters[i]; text8.text = text8.text + " PoisonLevel: " + injury.m_PoisonLevel.ToString(); } else if (injury.m_Type == InjuryType.SnakeBite) { Text text9 = this.m_WoundParameters[i]; text9.text = text9.text + " TimeToHeal:" + (injury.GetHealingDuration() - (MainLevel.Instance.GetCurrentTimeMinutes() - injury.m_HealingStartTime)).ToString(); Text text10 = this.m_WoundParameters[i]; text10.text = text10.text + " PoisonLevel: " + injury.m_PoisonLevel.ToString(); } else if (injury.m_Type == InjuryType.Rash) { Text text11 = this.m_WoundParameters[i]; text11.text = text11.text + " TimeToHeal:" + (injury.GetHealingDuration() - (MainLevel.Instance.GetCurrentTimeMinutes() - injury.m_StartTimeInMinutes)).ToString(); Text text12 = this.m_WoundParameters[i]; text12.text = text12.text + " HealTimeBonus: " + injury.m_HealingTimeDec.ToString(); } else if (injury.m_Type == InjuryType.WormHole) { Text text13 = this.m_WoundParameters[i]; text13.text = text13.text + " TimeToHeal:" + (injury.GetHealingDuration() - (MainLevel.Instance.GetCurrentTimeMinutes() - injury.m_HealingStartTime)).ToString(); Text text14 = this.m_WoundParameters[i]; text14.text = text14.text + " HealTimeBonus: " + injury.m_HealingTimeDec.ToString(); } } else { this.m_WoundParameters[i].enabled = false; } } WaterCollider waterPlayerInside = WaterBoxManager.Get().GetWaterPlayerInside(); this.m_LeechCooldownText.text = "Leech chance: "; if (waterPlayerInside == null) { Text leechCooldownText = this.m_LeechCooldownText; leechCooldownText.text += "None"; } else { Text leechCooldownText2 = this.m_LeechCooldownText; leechCooldownText2.text += waterPlayerInside.m_LeechChance.ToString(); } Text leechCooldownText3 = this.m_LeechCooldownText; leechCooldownText3.text = leechCooldownText3.text + " Time to next leech: " + (playerInjuryModule.GetLeechNextTime() - MainLevel.Instance.GetCurrentTimeMinutes()).ToString(); Text leechCooldownText4 = this.m_LeechCooldownText; leechCooldownText4.text = leechCooldownText4.text + " CoolDown: " + Injury.s_LeechCooldownInMinutes.ToString(); this.m_HPText.text = "HP = " + playerConditionModule.GetHP().ToString() + "/" + playerConditionModule.GetMaxHP().ToString(); this.m_ConditionText.text = "Condition = " + playerConditionModule.GetEnergy().ToString() + "/" + playerConditionModule.GetMaxEnergy().ToString(); playerConditionModule.m_NutritionProteins = this.m_Proteins.value; playerConditionModule.m_NutritionFat = this.m_Fat.value; playerConditionModule.m_NutritionCarbo = this.m_Carbo.value; playerConditionModule.m_Hydration = this.m_Hydration.value; playerConditionModule.m_HP = this.m_HP.value; playerConditionModule.m_Energy = this.m_Energy.value; PlayerSanityModule.Get().m_Sanity = (int)this.m_Sanity.value; }
public bool Unregister(WaterCollider wc) { return(_colliders.Remove(wc)); }
public void Register(WaterCollider wc) { _colliders.Add(wc); }