public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { m_subsystemTime = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true); m_subsystemNoise = base.Project.FindSubsystem <SubsystemNoise>(throwOnError: true); m_subsystemTerrain = base.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true); m_subsystemGameInfo = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); m_componentCreature = base.Entity.FindComponent <ComponentCreature>(throwOnError: true); m_componentPlayer = base.Entity.FindComponent <ComponentPlayer>(); m_componentLevel = base.Entity.FindComponent <ComponentLevel>(); m_componentClothing = base.Entity.FindComponent <ComponentClothing>(); m_componentMount = base.Entity.FindComponent <ComponentMount>(); m_componentRider = base.Entity.FindComponent <ComponentRider>(); IsCreativeFlyEnabled = valuesDictionary.GetValue <bool>("IsCreativeFlyEnabled"); AccelerationFactor = valuesDictionary.GetValue <float>("AccelerationFactor"); WalkSpeed = valuesDictionary.GetValue <float>("WalkSpeed"); LadderSpeed = valuesDictionary.GetValue <float>("LadderSpeed"); JumpSpeed = valuesDictionary.GetValue <float>("JumpSpeed"); CreativeFlySpeed = valuesDictionary.GetValue <float>("CreativeFlySpeed"); FlySpeed = valuesDictionary.GetValue <float>("FlySpeed"); SwimSpeed = valuesDictionary.GetValue <float>("SwimSpeed"); TurnSpeed = valuesDictionary.GetValue <float>("TurnSpeed"); LookSpeed = valuesDictionary.GetValue <float>("LookSpeed"); InAirWalkFactor = valuesDictionary.GetValue <float>("InAirWalkFactor"); m_walkSpeedWhenTurning = valuesDictionary.GetValue <float>("WalkSpeedWhenTurning"); m_minFrictionFactor = valuesDictionary.GetValue <float>("MinFrictionFactor"); m_lookAutoLevelX = valuesDictionary.GetValue <bool>("LookAutoLevelX"); m_lookAutoLevelY = valuesDictionary.GetValue <bool>("LookAutoLevelY"); if (base.Entity.FindComponent <ComponentPlayer>() == null) { WalkSpeed *= m_random.Float(0.85f, 1f); FlySpeed *= m_random.Float(0.85f, 1f); SwimSpeed *= m_random.Float(0.85f, 1f); } }
public void NormalMovement(float dt) { m_componentCreature.ComponentBody.IsGravityEnabled = true; m_componentCreature.ComponentBody.IsGroundDragEnabled = true; m_componentCreature.ComponentBody.IsWaterDragEnabled = true; Vector3 velocity = m_componentCreature.ComponentBody.Velocity; Vector3 right = m_componentCreature.ComponentBody.Matrix.Right; Vector3 vector = Vector3.Transform(m_componentCreature.ComponentBody.Matrix.Forward, Quaternion.CreateFromAxisAngle(right, LookAngles.Y)); if (WalkSpeed > 0f && WalkOrder.HasValue) { if (IsCreativeFlyEnabled) { Vector3 v = new Vector3(WalkOrder.Value.X, 0f, WalkOrder.Value.Y); if (FlyOrder.HasValue) { v += FlyOrder.Value; } Vector3 v2 = (!SettingsManager.HorizontalCreativeFlight || m_componentPlayer == null || m_componentPlayer.ComponentInput.IsControlledByTouch) ? Vector3.Normalize(vector + 0.1f * Vector3.UnitY) : Vector3.Normalize(vector * new Vector3(1f, 0f, 1f)); Vector3 v3 = CreativeFlySpeed * (right * v.X + Vector3.UnitY * v.Y + v2 * v.Z); float num = (v == Vector3.Zero) ? 5f : 3f; velocity += MathUtils.Saturate(num * dt) * (v3 - velocity); m_componentCreature.ComponentBody.IsGravityEnabled = false; m_componentCreature.ComponentBody.IsGroundDragEnabled = false; m_flying = true; } else { Vector2 value = WalkOrder.Value; if (m_walkSpeedWhenTurning > 0f && MathUtils.Abs(TurnOrder.X) > 0.02f) { value.Y = MathUtils.Max(value.Y, MathUtils.Lerp(0f, m_walkSpeedWhenTurning, MathUtils.Saturate(2f * MathUtils.Abs(TurnOrder.X)))); } float num2 = WalkSpeed; if (m_componentCreature.ComponentBody.ImmersionFactor > 0.2f) { num2 *= 0.66f; } if (value.Y < 0f) { num2 *= 0.6f; } if (m_componentLevel != null) { num2 *= m_componentLevel.SpeedFactor; } if (m_componentMount != null) { ComponentRider rider = m_componentMount.Rider; if (rider != null) { ComponentClothing componentClothing = rider.Entity.FindComponent <ComponentClothing>(); if (componentClothing != null) { num2 *= componentClothing.SteedMovementSpeedFactor; } } } Vector3 v4 = value.X * Vector3.Normalize(new Vector3(right.X, 0f, right.Z)) + value.Y * Vector3.Normalize(new Vector3(vector.X, 0f, vector.Z)); Vector3 vector2 = num2 * v4 + m_componentCreature.ComponentBody.StandingOnVelocity; float num4; if (m_componentCreature.ComponentBody.StandingOnValue.HasValue) { float num3 = MathUtils.Max(BlocksManager.Blocks[Terrain.ExtractContents(m_componentCreature.ComponentBody.StandingOnValue.Value)].FrictionFactor, m_minFrictionFactor); num4 = MathUtils.Saturate(dt * 6f * AccelerationFactor * num3); if (num3 < 0.25f) { SlipSpeed = num2 * value.Length(); } m_walking = true; } else { num4 = MathUtils.Saturate(dt * 6f * AccelerationFactor * InAirWalkFactor); if (m_componentCreature.ComponentBody.ImmersionFactor > 0f) { m_swimming = true; } else { m_falling = true; } } velocity.X += num4 * (vector2.X - velocity.X); velocity.Z += num4 * (vector2.Z - velocity.Z); Vector3 vector3 = value.X * right + value.Y * vector; if (m_componentLevel != null) { vector3 *= m_componentLevel.SpeedFactor; } velocity.Y += 10f * AccelerationFactor * vector3.Y * m_componentCreature.ComponentBody.ImmersionFactor * dt; m_componentCreature.ComponentBody.IsGroundDragEnabled = false; if (m_componentPlayer != null && Time.PeriodicEvent(10.0, 0.0) && (m_shoesWarningTime == 0.0 || Time.FrameStartTime - m_shoesWarningTime > 300.0) && m_componentCreature.ComponentBody.StandingOnValue.HasValue && m_componentCreature.ComponentBody.ImmersionFactor < 0.1f) { bool flag = false; int value2 = m_componentPlayer.ComponentClothing.GetClothes(ClothingSlot.Feet).LastOrDefault(); if (Terrain.ExtractContents(value2) == 203) { flag = (ClothingBlock.GetClothingData(Terrain.ExtractData(value2)).MovementSpeedFactor > 1f); } if (!flag && vector2.LengthSquared() / velocity.LengthSquared() > 0.99f && WalkOrder.Value.LengthSquared() > 0.99f) { m_componentPlayer.ComponentGui.DisplaySmallMessage(LanguageControl.Get(GetType().Name, 1), Color.White, blinking: true, playNotificationSound: true); m_shoesWarningTime = Time.FrameStartTime; } } } } if (FlySpeed > 0f && FlyOrder.HasValue) { Vector3 value3 = FlyOrder.Value; Vector3 v5 = FlySpeed * value3; velocity += MathUtils.Saturate(2f * AccelerationFactor * dt) * (v5 - velocity); m_componentCreature.ComponentBody.IsGravityEnabled = false; m_flying = true; } if (SwimSpeed > 0f && SwimOrder.HasValue && m_componentCreature.ComponentBody.ImmersionFactor > 0.5f) { Vector3 value4 = SwimOrder.Value; Vector3 v6 = SwimSpeed * value4; float num5 = 2f; if (value4.LengthSquared() >= 0.99f) { v6 *= MathUtils.Lerp(1f, 2f, m_swimBurstRemaining); num5 *= MathUtils.Lerp(1f, 4f, m_swimBurstRemaining); m_swimBurstRemaining -= dt; } velocity += MathUtils.Saturate(num5 * AccelerationFactor * dt) * (v6 - velocity); m_componentCreature.ComponentBody.IsGravityEnabled = (MathUtils.Abs(value4.Y) <= 0.07f); m_componentCreature.ComponentBody.IsWaterDragEnabled = false; m_componentCreature.ComponentBody.IsGroundDragEnabled = false; m_swimming = true; } if (JumpOrder > 0f && (m_componentCreature.ComponentBody.StandingOnValue.HasValue || m_componentCreature.ComponentBody.ImmersionFactor > 0.5f) && !m_componentCreature.ComponentBody.IsSneaking) { float num6 = JumpSpeed; if (m_componentLevel != null) { num6 *= 0.25f * (m_componentLevel.SpeedFactor - 1f) + 1f; } velocity.Y = MathUtils.Min(velocity.Y + MathUtils.Saturate(JumpOrder) * num6, num6); m_jumping = true; m_componentCreature.ComponentCreatureSounds.PlayFootstepSound(2f); m_subsystemNoise.MakeNoise(m_componentCreature.ComponentBody, 0.25f, 10f); } if (MathUtils.Abs(m_componentCreature.ComponentBody.CollisionVelocityChange.Y) > 3f) { m_componentCreature.ComponentCreatureSounds.PlayFootstepSound(2f); m_subsystemNoise.MakeNoise(m_componentCreature.ComponentBody, 0.25f, 10f); } m_componentCreature.ComponentBody.Velocity = velocity; }
public new void Update(float dt) { PlayerInput playerInput = ComponentInput.PlayerInput; if (ComponentInput.IsControlledByTouch && m_aimDirection.HasValue) { playerInput.Look = Vector2.Zero; } if (ComponentMiner.Inventory != null) { ComponentMiner.Inventory.ActiveSlotIndex = MathUtils.Clamp(ComponentMiner.Inventory.ActiveSlotIndex + playerInput.ScrollInventory, 0, 5); if (playerInput.SelectInventorySlot.HasValue) { ComponentMiner.Inventory.ActiveSlotIndex = MathUtils.Clamp(playerInput.SelectInventorySlot.Value, 0, 5); } } if (m_subsystemTime.PeriodicGameTimeEvent(0.5, 0)) { ReadOnlyList <int> readOnlyList = ComponentClothing.GetClothes(ClothingSlot.Head); if ((readOnlyList.Count > 0 && ClothingBlock.GetClothingData(readOnlyList[readOnlyList.Count - 1]).DisplayName == Utils.Get("DZˮͷ¿ø")) || (ComponentBody.ImmersionFluidBlock != null && ComponentBody.ImmersionFluidBlock.BlockIndex == RottenMeatBlock.Index)) { //if (ComponentBody.ImmersionDepth > 0.8f) //ComponentScreenOverlays.BlackoutFactor = 1f; ComponentHealth.Air = 1f; } } ComponentMount mount = ComponentRider.Mount; if (mount != null) { var componentSteedBehavior = mount.Entity.FindComponent <ComponentSteedBehavior>(); if (componentSteedBehavior != null) { if (playerInput.Move.Z > 0.5f && !m_speedOrderBlocked) { if (PlayerData.PlayerClass == PlayerClass.Male) { m_subsystemAudio.PlayRandomSound("Audio/Creatures/MaleYellFast", 0.75f, 0f, ComponentBody.Position, 2f, false); } else { m_subsystemAudio.PlayRandomSound("Audio/Creatures/FemaleYellFast", 0.75f, 0f, ComponentBody.Position, 2f, false); } componentSteedBehavior.SpeedOrder = 1; m_speedOrderBlocked = true; } else if (playerInput.Move.Z < -0.5f && !m_speedOrderBlocked) { if (PlayerData.PlayerClass == PlayerClass.Male) { m_subsystemAudio.PlayRandomSound("Audio/Creatures/MaleYellSlow", 0.75f, 0f, ComponentBody.Position, 2f, false); } else { m_subsystemAudio.PlayRandomSound("Audio/Creatures/FemaleYellSlow", 0.75f, 0f, ComponentBody.Position, 2f, false); } componentSteedBehavior.SpeedOrder = -1; m_speedOrderBlocked = true; } else if (MathUtils.Abs(playerInput.Move.Z) <= 0.25f) { m_speedOrderBlocked = false; } componentSteedBehavior.TurnOrder = playerInput.Move.X; componentSteedBehavior.JumpOrder = playerInput.Jump ? 1 : 0; ComponentLocomotion.LookOrder = new Vector2(playerInput.Look.X, 0f); } else { var componentBoat = mount.Entity.FindComponent <ComponentBoat>(); if (componentBoat != null || mount.Entity.FindComponent <ComponentBoatI>() != null) { if (componentBoat != null) { componentBoat.TurnOrder = playerInput.Move.X; componentBoat.MoveOrder = playerInput.Move.Z; ComponentLocomotion.LookOrder = new Vector2(playerInput.Look.X, 0f); } else { ComponentLocomotion.LookOrder = playerInput.Look; } ComponentCreatureModel.RowLeftOrder = playerInput.Move.X <-0.2f || playerInput.Move.Z> 0.2f; ComponentCreatureModel.RowRightOrder = playerInput.Move.X > 0.2f || playerInput.Move.Z > 0.2f; } var c = mount.Entity.FindComponent <ComponentLocomotion>(); if (c != null) { c.WalkOrder = playerInput.Move.XZ; c.FlyOrder = new Vector3(0f, playerInput.Move.Y, 0f); c.TurnOrder = playerInput.Look * new Vector2(1f, 0f); c.JumpOrder = playerInput.Jump ? 1 : 0; c.LookOrder = playerInput.Look; if (playerInput.ToggleCreativeFly) { c.IsCreativeFlyEnabled = !c.IsCreativeFlyEnabled; } } } } else { ComponentLocomotion.WalkOrder = (ComponentLocomotion.WalkOrder ?? Vector2.Zero) + (ComponentBody.IsSneaking ? (0.66f * new Vector2(playerInput.SneakMove.X, playerInput.SneakMove.Z)) : new Vector2(playerInput.Move.X, playerInput.Move.Z)); ComponentLocomotion.FlyOrder = new Vector3(0f, playerInput.Move.Y, 0f); ComponentLocomotion.TurnOrder = playerInput.Look * new Vector2(1f, 0f); ComponentLocomotion.JumpOrder = MathUtils.Max(playerInput.Jump ? 1 : 0, ComponentLocomotion.JumpOrder); } ComponentLocomotion.LookOrder += playerInput.Look * (SettingsManager.FlipVerticalAxis ? new Vector2(0f, -1f) : new Vector2(0f, 1f)); int num = Terrain.ExtractContents(ComponentMiner.ActiveBlockValue); Block block = BlocksManager.Blocks[num]; bool flag = false; if (playerInput.Interact.HasValue && !flag && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185) { Vector3 viewPosition = View.ActiveCamera.ViewPosition; var direction = Vector3.Normalize(View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.Interact.Value, 1f), Matrix.Identity) - viewPosition); if (!ComponentMiner.Use(viewPosition, direction)) { var body = ComponentMiner.PickBody(viewPosition, direction); var result = ComponentMiner.PickTerrainForInteraction(viewPosition, direction); if (result.HasValue && (!body.HasValue || result.Value.Distance < body.Value.Distance)) { if (!ComponentMiner.Interact(result.Value)) { if (ComponentMiner.Place(result.Value)) { m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate(); flag = true; m_isAimBlocked = true; } } else { m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate(); flag = true; m_isAimBlocked = true; } } } else { m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate(); flag = true; m_isAimBlocked = true; } } float num2 = (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative || block.BlockIndex == Musket2Block.Index) ? 0.1f : 1.4f; Vector3 viewPosition2 = View.ActiveCamera.ViewPosition; if (playerInput.Aim.HasValue && block.IsAimable && m_subsystemTime.GameTime - m_lastActionTime > num2) { if (!m_isAimBlocked) { Vector2 value = playerInput.Aim.Value; Vector3 v = View.ActiveCamera.ScreenToWorld(new Vector3(value, 1f), Matrix.Identity); Point2 size = Window.Size; if (playerInput.Aim.Value.X >= size.X * 0.1f && playerInput.Aim.Value.X < size.X * 0.9f && playerInput.Aim.Value.Y >= size.Y * 0.1f && playerInput.Aim.Value.Y < size.Y * 0.9f) { m_aimDirection = Vector3.Normalize(v - viewPosition2); if (ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.InProgress)) { ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.Cancelled); m_aimDirection = null; m_isAimBlocked = true; } } else if (m_aimDirection.HasValue) { ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.Cancelled); m_aimDirection = null; m_isAimBlocked = true; } } } else { m_isAimBlocked = false; if (m_aimDirection.HasValue) { ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.Completed); m_aimDirection = null; m_lastActionTime = m_subsystemTime.GameTime; } } flag |= m_aimDirection.HasValue; if (playerInput.Hit.HasValue && !flag && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185) { Vector3 viewPosition3 = View.ActiveCamera.ViewPosition; var vector = Vector3.Normalize(View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.Hit.Value, 1f), Matrix.Identity) - viewPosition3); TerrainRaycastResult?nullable3 = ComponentMiner.PickTerrainForInteraction(viewPosition3, vector); BodyRaycastResult? nullable4 = ComponentMiner.PickBody(viewPosition3, vector); if (nullable4.HasValue && (!nullable3.HasValue || nullable3.Value.Distance > nullable4.Value.Distance)) { if (ComponentMiner.ActiveBlockValue == 0) { Widget widget = ComponentNGui.OpenEntity(ComponentMiner.Inventory, nullable4.Value.ComponentBody.Entity); if (widget != null) { ComponentGui.ModalPanelWidget = widget; AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f); return; } } flag = true; m_isDigBlocked = true; if (Vector3.Distance(viewPosition3 + vector * nullable4.Value.Distance, ComponentCreatureModel.EyePosition) <= 2f) { ComponentMiner.Hit(nullable4.Value.ComponentBody, vector); } } } if (playerInput.Dig.HasValue && !flag && !m_isDigBlocked && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185) { Vector3 viewPosition4 = View.ActiveCamera.ViewPosition; Vector3 v2 = View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.Dig.Value, 1f), Matrix.Identity); TerrainRaycastResult?nullable5 = ComponentMiner.PickTerrainForDigging(viewPosition4, v2 - viewPosition4); if (nullable5.HasValue && ComponentMiner.Dig(nullable5.Value)) { m_lastActionTime = m_subsystemTime.GameTime; m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate(); } } if (!playerInput.Dig.HasValue) { m_isDigBlocked = false; } if (playerInput.Drop && ComponentMiner.Inventory != null) { IInventory inventory = ComponentMiner.Inventory; int slotValue = inventory.GetSlotValue(inventory.ActiveSlotIndex); int num3 = inventory.RemoveSlotItems(count: inventory.GetSlotCount(inventory.ActiveSlotIndex), slotIndex: inventory.ActiveSlotIndex); if (slotValue != 0 && num3 != 0) { Vector3 v3 = ComponentBody.Position + new Vector3(0f, ComponentBody.BoxSize.Y * 0.66f, 0f); Matrix matrix = ComponentBody.Matrix; Vector3 position = v3 + 0.25f * matrix.Forward; matrix = Matrix.CreateFromQuaternion(ComponentCreatureModel.EyeRotation); Vector3 value2 = 8f * matrix.Forward; m_subsystemPickables.AddPickable(slotValue, num3, position, value2, null); } } if (playerInput.PickBlockType.HasValue && !flag) { if (ComponentMiner.Inventory is ComponentCreativeInventory componentCreativeInventory) { Vector3 viewPosition5 = View.ActiveCamera.ViewPosition; Vector3 v4 = View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.PickBlockType.Value, 1f), Matrix.Identity); TerrainRaycastResult?nullable6 = ComponentMiner.PickTerrainForDigging(viewPosition5, v4 - viewPosition5); if (nullable6.HasValue) { int value3 = nullable6.Value.Value; value3 = Terrain.ReplaceLight(value3, 0); int num4 = Terrain.ExtractContents(value3); Block block2 = BlocksManager.Blocks[num4]; int num5 = 0; var creativeValues = block2.GetCreativeValues(); if (block2.GetCreativeValues().Contains(value3)) { num5 = value3; } if (num5 == 0 && !block2.IsNonDuplicable) { var list = new List <BlockDropValue>(); bool _; block2.GetDropValues(m_subsystemTerrain, value3, 0, 2147483647, list, out _); if (list.Count > 0 && list[0].Count > 0) { num5 = list[0].Value; } } if (num5 == 0) { num5 = creativeValues.FirstOrDefault(); } if (num5 != 0) { int num6 = -1; for (int i = 0; i < 6; i++) { if (componentCreativeInventory.GetSlotCount(i) > 0 && componentCreativeInventory.GetSlotValue(i) == num5) { num6 = i; break; } } if (num6 < 0) { for (int j = 0; j < 6; j++) { if (componentCreativeInventory.GetSlotCount(j) == 0 || componentCreativeInventory.GetSlotValue(j) == 0) { num6 = j; break; } } } if (num6 < 0) { num6 = componentCreativeInventory.ActiveSlotIndex; } componentCreativeInventory.RemoveSlotItems(num6, 2147483647); componentCreativeInventory.AddSlotItems(num6, num5, 1); componentCreativeInventory.ActiveSlotIndex = num6; ComponentGui.DisplaySmallMessage(block2.GetDisplayName(m_subsystemTerrain, value3), false, false); m_subsystemAudio.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f, 0f); } } } } HighlightRaycastResult = ComponentMiner.PickTerrainForDigging(View.ActiveCamera.ViewPosition, View.ActiveCamera.ViewDirection); }
public static void AttackBody(ComponentBody target, ComponentCreature attacker, Vector3 hitPoint, Vector3 hitDirection, float attackPower, bool isMeleeAttack) { if (attacker != null && attacker is ComponentPlayer && target.Entity.FindComponent <ComponentPlayer>() != null && !target.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true).WorldSettings.IsFriendlyFireEnabled) { attacker.Entity.FindComponent <ComponentGui>(throwOnError: true).DisplaySmallMessage(LanguageControl.Get(fName, 3), Color.White, blinking: true, playNotificationSound: true); return; } if (attackPower > 0f) { ComponentClothing componentClothing = target.Entity.FindComponent <ComponentClothing>(); if (componentClothing != null) { attackPower = componentClothing.ApplyArmorProtection(attackPower); } ComponentLevel componentLevel = target.Entity.FindComponent <ComponentLevel>(); if (componentLevel != null) { attackPower /= componentLevel.ResilienceFactor; } ComponentHealth componentHealth = target.Entity.FindComponent <ComponentHealth>(); if (componentHealth != null) { float num = attackPower / componentHealth.AttackResilience; string cause; if (attacker != null) { string str = attacker.KillVerbs[s_random.Int(0, attacker.KillVerbs.Count - 1)]; string attackerName = attacker.DisplayName; cause = string.Format(LanguageControl.Get(fName, 4), attackerName, LanguageControl.Get(fName, str)); } else { switch (s_random.Int(0, 5)) { case 0: cause = LanguageControl.Get(fName, 5); break; case 1: cause = LanguageControl.Get(fName, 6); break; case 2: cause = LanguageControl.Get(fName, 7); break; case 3: cause = LanguageControl.Get(fName, 8); break; case 4: cause = LanguageControl.Get(fName, 9); break; default: cause = LanguageControl.Get(fName, 10); break; } } float health = componentHealth.Health; componentHealth.Injure(num, attacker, ignoreInvulnerability: false, cause); if (num > 0f) { target.Project.FindSubsystem <SubsystemAudio>(throwOnError: true).PlayRandomSound("Audio/Impacts/Body", 1f, s_random.Float(-0.3f, 0.3f), target.Position, 4f, autoDelay: false); float num2 = (health - componentHealth.Health) * componentHealth.AttackResilience; if (attacker is ComponentPlayer && num2 > 0f) { string text2 = (0f - num2).ToString("0", CultureInfo.InvariantCulture); HitValueParticleSystem particleSystem = new HitValueParticleSystem(hitPoint + 0.75f * hitDirection, 1f * hitDirection + attacker.ComponentBody.Velocity, Color.White, text2); target.Project.FindSubsystem <SubsystemParticles>(throwOnError: true).AddParticleSystem(particleSystem); } } } ComponentDamage componentDamage = target.Entity.FindComponent <ComponentDamage>(); if (componentDamage != null) { float num3 = attackPower / componentDamage.AttackResilience; componentDamage.Damage(num3); if (num3 > 0f) { target.Project.FindSubsystem <SubsystemAudio>(throwOnError: true).PlayRandomSound(componentDamage.DamageSoundName, 1f, s_random.Float(-0.3f, 0.3f), target.Position, 4f, autoDelay: false); } } } float num4 = 0f; float x = 0f; if (isMeleeAttack && attacker != null) { float num5 = (attackPower >= 2f) ? 1.25f : 1f; float num6 = MathUtils.Pow(attacker.ComponentBody.Mass / target.Mass, 0.5f); float x2 = num5 * num6; num4 = 5.5f * MathUtils.Saturate(x2); x = 0.25f * MathUtils.Saturate(x2); } else if (attackPower > 0f) { num4 = 2f; x = 0.2f; } if (num4 > 0f) { target.ApplyImpulse(num4 * Vector3.Normalize(hitDirection + s_random.Vector3(0.1f) + 0.2f * Vector3.UnitY)); ComponentLocomotion componentLocomotion = target.Entity.FindComponent <ComponentLocomotion>(); if (componentLocomotion != null) { componentLocomotion.StunTime = MathUtils.Max(componentLocomotion.StunTime, x); } } }