private void UpdateMostDangerWound(WoundedPedComponent woundedPed, int pedEntity) { if (woundedPed.ThisPed.IsDead) { return; } float maxBleeding = 0; int? mostDangerEntity = null; for (int i = 0; i < _bleedings.EntitiesCount; i++) { BleedingComponent bleeding = _bleedings.Components1[i]; if (!bleeding.CanBeHealed) { continue; } if (bleeding.Entity != pedEntity) { continue; } if (bleeding.BleedSeverity <= maxBleeding) { continue; } maxBleeding = bleeding.BleedSeverity; mostDangerEntity = _bleedings.Entities[i]; } woundedPed.MostDangerBleedingEntity = mostDangerEntity; }
private void ProcessBleedings() { var frameTimeInSeconds = Game.LastFrameTime; for (int i = 0; i < _bleedings.EntitiesCount; i++) { BleedingComponent component = _bleedings.Components1[i]; int pedEntity = _bleedings.Components1[i].Entity; int bleedingEntity = _bleedings.Entities[i]; if (!_ecsWorld.IsEntityExists(pedEntity)) { RemoveBleeding(null, pedEntity, bleedingEntity); continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { RemoveBleeding(null, pedEntity, bleedingEntity); continue; } if (woundedPed.IsDead) { continue; } if (component.BleedSeverity <= 0f) { RemoveBleeding(woundedPed, pedEntity, bleedingEntity); continue; } woundedPed.Health -= component.BleedSeverity * frameTimeInSeconds; component.BleedSeverity -= woundedPed.StopBleedingAmount * frameTimeInSeconds; woundedPed.ThisPed.Health = (int)woundedPed.Health; if (!woundedPed.ThisPed.IsDead) { continue; } RemoveBleeding(woundedPed, pedEntity, bleedingEntity); } }
private void ShowBleedings(WoundedPedComponent woundedPed, int pedEntity) { if (woundedPed.BleedingCount <= 0) { return; } string woundList = ""; for (int woundIndex = 0; woundIndex < _wounds.EntitiesCount; woundIndex++) { BleedingComponent wound = _wounds.Components1[woundIndex]; if (pedEntity != wound.Entity) { continue; } if (woundedPed.MostDangerBleedingEntity != null && woundedPed.MostDangerBleedingEntity == _wounds.Entities[woundIndex]) { woundList += "~g~->~s~"; } if (wound.BleedSeverity > _config.Data.WoundConfig.EmergencyBleedingLevel) { woundList += $"~r~{wound.Name}~s~\n"; } else if (wound.BleedSeverity > _config.Data.WoundConfig.EmergencyBleedingLevel / 2) { woundList += $"~o~{wound.Name}~s~\n"; } else if (wound.BleedSeverity > _config.Data.WoundConfig.EmergencyBleedingLevel / 4) { woundList += $"~y~{wound.Name}\n"; } else { woundList += $"~s~{wound.Name}\n"; } } SendMessage($"~s~{_locale.Data.Wounds}:\n{woundList}"); }