public override void DoAction(Item item, BasePlayer player) { if (!item.hasCondition) { return; } if (item.conditionNormalized == 0f) { return; } if (player == null) { return; } if (player.WaterFactor() < 1f) { return; } if (item.parent == null) { return; } if (item.parent != player.inventory.containerWear) { return; } Effect.server.Run((!this.inhaled ? this.inhaleEffect.resourcePath : this.exhaleEffect.resourcePath), player, StringPool.Get("jaw"), Vector3.zero, Vector3.forward, null, false); this.inhaled = !this.inhaled; if (!this.inhaled && WaterLevel.GetWaterDepth(player.eyes.position) > 3f) { Effect.server.Run(this.bubblesEffect.resourcePath, player, StringPool.Get("jaw"), Vector3.zero, Vector3.forward, null, false); } item.LoseCondition((float)this.amountToConsume); player.metabolism.oxygen.Add(1f); }
private static float _WaterDepth(Vector3 pos, float maxDepth) { float waterDepth = WaterLevel.GetWaterDepth(pos); if (Mathf.Approximately(waterDepth, 0.0f)) { return(1f); } return((float)(1.0 - (double)Mathf.Min(waterDepth, maxDepth) / (double)maxDepth)); }
private static float _WaterDepth(Vector3 pos, float maxDepth) { float waterDepth = WaterLevel.GetWaterDepth(pos); if (Mathf.Approximately(waterDepth, 0f)) { return(1f); } waterDepth = Mathf.Min(waterDepth, maxDepth); return(1f - waterDepth / maxDepth); }
public override void DoAction(Item item, BasePlayer player) { if (item.hasCondition && item.conditionNormalized != 0f && !(player == null) && !(player.WaterFactor() < 1f) && item.parent != null && item.parent == player.inventory.containerWear) { Effect.server.Run((!inhaled) ? inhaleEffect.resourcePath : exhaleEffect.resourcePath, player, StringPool.Get("jaw"), Vector3.zero, Vector3.forward); inhaled = !inhaled; if (!inhaled && WaterLevel.GetWaterDepth(player.eyes.position, player) > 3f) { Effect.server.Run(bubblesEffect.resourcePath, player, StringPool.Get("jaw"), Vector3.zero, Vector3.forward); } item.LoseCondition(amountToConsume); player.metabolism.oxygen.Add(1f); } }
public override void DoAction(Item item, BasePlayer player) { if (!item.hasCondition || (double)item.conditionNormalized == 0.0 || (Object.op_Equality((Object)player, (Object)null) || (double)player.WaterFactor() < 1.0) || (item.parent == null || item.parent != player.inventory.containerWear)) { return; } Effect.server.Run(!this.inhaled ? this.inhaleEffect.resourcePath : this.exhaleEffect.resourcePath, (BaseEntity)player, StringPool.Get("jaw"), Vector3.get_zero(), Vector3.get_forward(), (Connection)null, false); this.inhaled = !this.inhaled; if (!this.inhaled && (double)WaterLevel.GetWaterDepth(player.eyes.position) > 3.0) { Effect.server.Run(this.bubblesEffect.resourcePath, (BaseEntity)player, StringPool.Get("jaw"), Vector3.get_zero(), Vector3.get_forward(), (Connection)null, false); } item.LoseCondition((float)this.amountToConsume); player.metabolism.oxygen.Add(1f); }
public override float GetScore(BaseContext c, Vector3 position) { return(WaterLevel.GetWaterDepth(position) / this.MaxDepth); }
public static void ImpactEffect(HitInfo info) { if (!info.DoHitEffects) { return; } string str = StringPool.Get(info.HitMaterial); if (TerrainMeta.WaterMap != null && info.HitMaterial != Projectile.WaterMaterialID() && info.HitMaterial != Projectile.FleshMaterialID() && info.HitPositionWorld.y < WaterLevel.GetWaterDepth(info.HitPositionWorld)) { return; } string particle = EffectDictionary.GetParticle(info.damageTypes.GetMajorityDamageType(), str); string decal = EffectDictionary.GetDecal(info.damageTypes.GetMajorityDamageType(), str); if (!info.HitEntity.IsValid()) { Effect.server.Run(particle, info.HitPositionWorld, info.HitNormalWorld, info.Predicted, false); Effect.server.Run(decal, info.HitPositionWorld, info.HitNormalWorld, info.Predicted, false); } else { GameObjectRef impactEffect = info.HitEntity.GetImpactEffect(info); if (impactEffect.isValid) { particle = impactEffect.resourcePath; } Effect.server.Run(particle, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal, info.Predicted, false); Effect.server.Run(decal, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal, info.Predicted, false); } if (info.WeaponPrefab) { BaseMelee weaponPrefab = info.WeaponPrefab as BaseMelee; if (weaponPrefab != null) { string strikeEffectPath = weaponPrefab.GetStrikeEffectPath(str); if (!info.HitEntity.IsValid()) { Effect.server.Run(strikeEffectPath, info.HitPositionWorld, info.HitNormalWorld, info.Predicted, false); } else { Effect.server.Run(strikeEffectPath, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal, info.Predicted, false); } } } if (info.damageTypes.Has(DamageType.Explosion)) { Effect.server.DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/explosion.prefab"); } if (info.damageTypes.Has(DamageType.Heat)) { Effect.server.DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/fire.prefab"); } }