public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(WoundSystem); #endif for (int i = 0; i < _components.EntitiesCount; i++) { ProcessWoundEvent component = _components.Components1[i]; int pedEntity = component.Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } float damageDeviation = component.Damage > 0 ? _config.Data.WoundConfig.DamageDeviation * component.Damage : 0; float bleedingDeviation = component.BleedSeverity > 0 ? _config.Data.WoundConfig.BleedingDeviation * component.BleedSeverity : 0; if (!woundedPed.IsDead) { woundedPed.Health -= _config.Data.WoundConfig.DamageMultiplier * component.Damage + Random.NextFloat(-damageDeviation, damageDeviation); woundedPed.ThisPed.Health = (int)woundedPed.Health; } CreateBleeding(woundedPed, pedEntity, component.BleedSeverity + Random.NextFloat(-bleedingDeviation, bleedingDeviation), component.Name); woundedPed.BleedingCount++; CreatePain(pedEntity, component.Pain); CreateCritical(pedEntity, component.Crits); if (component.ArterySevered) { CreateBleeding(woundedPed, pedEntity, 1f, _locale.Data.SeveredArtery); woundedPed.BleedingCount++; } #if DEBUG _ecsWorld.CreateEntityWith <ShowDebugInfoEvent>().Entity = pedEntity; #endif SendWoundInfo(component, woundedPed); } _components.RemoveAllEntities(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(IncreasePainSystem); #endif var woundConfig = _config.Data.WoundConfig; for (var i = 0; i < _events.EntitiesCount; i++) { var component = _events.Components1[i]; var pedEntity = component.Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed != null && component.PainAmount > 0f) { var pain = _ecsWorld.EnsureComponent <PainComponent>(pedEntity, out var firstPain); if (firstPain) { pain.CurrentPain = 0f; } var newPain = component.PainAmount; var painDeviation = GunshotWound2.Random.NextFloat( -woundConfig.PainDeviation * newPain, woundConfig.PainDeviation * newPain); pain.CurrentPain += woundConfig.PainMultiplier * newPain + painDeviation; var painAnimIndex = GunshotWound2.Random.Next(1, 6); PainRecoverySystem.PlayFacialAnim(woundedPed, $"pain_{painAnimIndex.ToString()}"); var painfulWound = woundConfig.PainfulWoundPercent * woundedPed.MaximalPain; if (woundedPed.IsPlayer && newPain > painfulWound / 2f) { _ecsWorld.CreateEntityWith <AddCameraShakeEvent>().Length = CameraShakeLength.ONE_TIME; } if (newPain > painfulWound) { if (woundConfig.RagdollOnPainfulWound) { _ecsWorld.CreateEntityWith(out SetPedToRagdollEvent ragdoll); ragdoll.Entity = pedEntity; ragdoll.RagdollState = RagdollStates.SHORT; } if (woundedPed.IsPlayer) { _ecsWorld.CreateEntityWith <AddFlashEvent>(); } } } _ecsWorld.RemoveEntity(_events.Entities[i]); } }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(BodyHitSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } var bodyPart = GetDamagedBodyPart(woundedPed.ThisPed); var bodyDamage = _ecsWorld.CreateEntityWith <BodyPartWasHitEvent>(); bodyDamage.Entity = pedEntity; bodyDamage.DamagedPart = bodyPart; } }
public void Run() { foreach (int i in _pedsToRemove) { PedBleedingInfoComponent info = _pedsToRemove.Components1[i]; EcsEntity pedEntity = _pedsToRemove.Entities[i]; foreach (EcsEntity entity in info.BleedingEntities) { _ecsWorld.RemoveEntity(entity); } _ecsWorld.RemoveComponent <PedBleedingInfoComponent>(pedEntity); } _ecsWorld.ProcessDelayedUpdates(); foreach (int i in _healedEntities) { PedBleedingInfoComponent info = _healedEntities.Components1[i]; foreach (EcsEntity bleedingEntity in info.BleedingEntities) { if (!_ecsWorld.IsEntityExists(bleedingEntity)) { continue; } _ecsWorld.RemoveEntity(bleedingEntity); } } }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(BasePainStateSystem <TStateEvent>); #endif for (int i = 0; i < Events.EntitiesCount; i++) { var changeEvent = Events.Components1[i]; var pedEntity = changeEvent.Entity; if (!EcsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = EcsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null || woundedPed.IsDead) { continue; } if (woundedPed.PainState == CurrentState && !changeEvent.ForceUpdate) { continue; } ExecuteState(woundedPed, pedEntity); woundedPed.PainState = CurrentState; } Events.RemoveAllEntities(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(CheckSystem); #endif for (int i = 0; i < _events.EntitiesCount; i++) { int pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } ShowHealth(woundedPed); ShowArmor(woundedPed); ShowPain(woundedPed, pedEntity); ShowCrits(woundedPed); ShowBleedings(woundedPed, pedEntity); } _events.RemoveAllEntities(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(AdrenalineSystem); #endif int playerEntity = _config.Data.PlayerConfig.PlayerEntity; if (!_ecsWorld.IsEntityExists(playerEntity)) { return; } var playerPed = _ecsWorld.GetComponent <WoundedPedComponent>(playerEntity); var pain = _ecsWorld.GetComponent <PainComponent>(playerEntity); if (playerPed == null || pain == null || playerPed.InPermanentRagdoll) { Game.TimeScale = 1f; return; } var painPercent = pain.CurrentPain / playerPed.MaximalPain; var adjustable = 1f - _config.Data.PlayerConfig.MaximalSlowMo; Game.TimeScale = painPercent <= 1f ? 1f - adjustable * painPercent : 1f; }
protected override void RunReactive() { _asteroidsId.Clear(); _hashtable.Clear(); var health = (float)_photonServer.CurrentRoom.CustomProperties[RoomDataConstants.Health]; for (int i = 0; i < ReactedEntitiesCount; i++) { var entity = ReactedEntities[i]; if (!_world.IsEntityExists(entity)) { continue; } var asteroidCollision = _world.GetComponent <AsteroidCollision> (entity); health -= _gameConfig.DamageFromAsteroid; var asteroid = _world.GetComponent <Asteroid> (asteroidCollision.AsteroidEntity); _asteroidsId.Add(asteroid.Id); } _photonServer.OpRaiseEvent(GameEventCode.DamageByAsteroids, _asteroidsId.ToArray(), true, ServerSpawnAsteroidSystem.All); _hashtable[RoomDataConstants.Health] = health; _photonServer.CurrentRoom.SetCustomProperties(_hashtable); SoundManager.PlayCollisionSound(); if (health <= 0) { _photonServer.CurrentRoom.IsOpen = false; _photonServer.CurrentRoom.IsVisible = false; } }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(DebugInfoSystem); #endif for (int i = 0; i < _events.EntitiesCount; i++) { #if DEBUG int pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } SendDebug($"{woundedPed}"); _ecsWorld.CreateEntityWith <ShowHealthStateEvent>().Entity = pedEntity; #endif } _events.RemoveAllEntities(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(SwitchAnimationSystem); #endif for (int i = 0; i < _events.EntitiesCount; i++) { int pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null) { continue; } var animationName = _events.Components1[i].AnimationName; if (string.IsNullOrEmpty(animationName) || !woundedPed.ThisPed.IsAlive) { continue; } Function.Call(Hash.REQUEST_ANIM_SET, animationName); if (!Function.Call <bool>(Hash.HAS_ANIM_SET_LOADED, animationName)) { Function.Call(Hash.REQUEST_ANIM_SET, animationName); } Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, woundedPed.ThisPed, animationName, 1.0f); } _events.RemoveAllEntities(); }
protected override void PrepareComponentToNetwork(PrepareComponentToSendEvent <TComponent> prepareComponent) { TComponent componentToSend = EcsWorld.GetComponent <TComponent>(prepareComponent.LocalEntityUid); bool componentWasRemoved = prepareComponent.ComponentFlags.HasFlag(EcsNetComponentFlags.WAS_REMOVED); #if DEBUG if (!componentWasRemoved && componentToSend == null) { throw new Exception(string.Format("{0} doesn't exist on this entity", typeof(TComponent).Name)); } #endif SendNetworkComponentEvent sendEvent; EcsWorld.CreateEntityWith(out sendEvent); sendEvent.ComponentTypeUid = ComponentUid; sendEvent.ComponentFlags = prepareComponent.ComponentFlags; int localEntity = prepareComponent.LocalEntityUid; bool localEntityExist = NetworkConfig.Data.LocalEntitiesToNetwork.ContainsKey(localEntity); long networkEntity; if (componentWasRemoved) { #if DEBUG if (!localEntityExist) { throw new Exception(string.Format("You've tried to send removed {0} for not network entity", typeof(TComponent).Name)); } #endif networkEntity = NetworkConfig .Data .LocalEntitiesToNetwork[localEntity]; sendEvent.NetworkEntityUid = networkEntity; if (EcsWorld.IsEntityExists(localEntity)) { return; } RemoveNetworkToLocalEntity(networkEntity, localEntity); } else { sendEvent.ComponentBytes = NetworkConfig.Data.Serializator.GetBytesFromComponent(componentToSend); if (localEntityExist) { networkEntity = NetworkConfig .Data .LocalEntitiesToNetwork[localEntity]; sendEvent.NetworkEntityUid = networkEntity; } else { networkEntity = NetworkConfig.Data.Random.NextInt64(); AddNetworkToLocalEntity(networkEntity, localEntity); sendEvent.NetworkEntityUid = networkEntity; } } }
public void Run() { foreach (int i in _healedEntities) { BleedingInfoComponent info = _healedEntities.Components1[i]; foreach (int bleedingEntity in info.BleedingEntities) { if (!_ecsWorld.IsEntityExists(bleedingEntity)) { continue; } _ecsWorld.RemoveEntity(bleedingEntity); } } }
protected override void ProcessReceivedComponent(ReceivedNetworkComponentEvent received) { TComponent oldComponent; long networkEntity = received.NetworkEntityUid; bool localEntityExist = NetworkConfig.Data.NetworkEntitiesToLocal.ContainsKey(networkEntity); int localEntity; bool componentWasRemoved = received.ComponentFlags.HasFlag(EcsNetComponentFlags.WAS_REMOVED); if (componentWasRemoved && !localEntityExist) { #if DEBUG throw new Exception(string.Format("Attempt to remove {0} for non exist local entity", typeof(TComponent).Name)); #endif return; } if (localEntityExist) { localEntity = NetworkConfig.Data.NetworkEntitiesToLocal[received.NetworkEntityUid]; bool isNew; oldComponent = EcsWorld.EnsureComponent <TComponent>(localEntity, out isNew); } else { localEntity = EcsWorld.CreateEntityWith(out oldComponent); EcsWorld.CreateEntityWith <NewEntityReceivedEvent>().LocalEntity = localEntity; AddNetworkToLocalEntity(received.NetworkEntityUid, localEntity); } if (componentWasRemoved) { EcsWorld.RemoveComponent <TComponent>(localEntity); if (EcsWorld.IsEntityExists(localEntity)) { return; } RemoveNetworkToLocalEntity(networkEntity, localEntity); } else { var newComponent = NetworkConfig.Data.Serializator.GetComponentFromBytes <TComponent>(received.ComponentBytes); NewToOldConverter(newComponent, oldComponent); } }
private void ProcessBleedings() { var frameTimeInSeconds = Game.LastFrameTime; for (var i = 0; i < _bleedings.EntitiesCount; i++) { var component = _bleedings.Components1[i]; var pedEntity = _bleedings.Components1[i].Entity; var 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.PedHealth = woundedPed.Health; if (!woundedPed.ThisPed.IsDead) { continue; } RemoveBleeding(woundedPed, pedEntity, bleedingEntity); } }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(SwitchAnimationSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null || !woundedPed.ThisPed.IsAlive) { continue; } var animationName = _events.Components1[i].AnimationName; if (string.IsNullOrEmpty(animationName)) { Function.Call(Hash.RESET_PED_MOVEMENT_CLIPSET, woundedPed.ThisPed, 0f); continue; } _animRequestParams[0] = animationName; if (!Function.Call <bool>(Hash.HAS_ANIM_SET_LOADED, _animRequestParams)) { Function.Call(Hash.REQUEST_ANIM_SET, _animRequestParams); } _animSetParams[0] = woundedPed.ThisPed; _animSetParams[1] = animationName; _animSetParams[2] = 1.0f; Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, _animSetParams); } _events.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(IncreasePainSystem); #endif for (int i = 0; i < _events.EntitiesCount; i++) { var component = _events.Components1[i]; int pedEntity = component.Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed != null && component.PainAmount > 0f) { var pain = _ecsWorld.EnsureComponent <PainComponent>(pedEntity, out var firstPain); if (firstPain) { pain.CurrentPain = 0f; } float newPain = component.PainAmount; var painDeviation = Random.NextFloat( -_config.Data.WoundConfig.PainDeviation * newPain, _config.Data.WoundConfig.PainDeviation * newPain); pain.CurrentPain += _config.Data.WoundConfig.PainMultiplier * newPain + painDeviation; int painAnimIndex = Random.Next(1, 6); if (woundedPed.IsMale) { Function.Call(Hash.PLAY_FACIAL_ANIM, woundedPed.ThisPed, "pain_" + painAnimIndex, "facials@gen_male@base"); } else { Function.Call(Hash.PLAY_FACIAL_ANIM, woundedPed.ThisPed, "pain_" + painAnimIndex, "facials@gen_female@base"); } if (newPain > _config.Data.WoundConfig.PainfulWoundValue / 2) { if (woundedPed.IsPlayer) { _ecsWorld.CreateEntityWith <AddCameraShakeEvent>().Length = CameraShakeLength.ONE_TIME; } } if (newPain > _config.Data.WoundConfig.PainfulWoundValue) { if (_config.Data.WoundConfig.RagdollOnPainfulWound) { _ecsWorld.CreateEntityWith(out SetPedToRagdollEvent ragdoll); ragdoll.Entity = pedEntity; ragdoll.RagdollState = RagdollStates.SHORT; } if (woundedPed.IsPlayer) { _ecsWorld.CreateEntityWith <AddFlashEvent>(); } } } _ecsWorld.RemoveEntity(_events.Entities[i]); } }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(RagdollSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { RemoveEvent(); continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null || woundedPed.ThisPed.IsDead) { RemoveEvent(); continue; } var skipRemoving = false; switch (_events.Components1[i].RagdollState) { case RagdollStates.WAKE_UP: WakeUpFromRagdoll(woundedPed, pedEntity); break; case RagdollStates.PERMANENT: skipRemoving = StartPermanentRagdoll(woundedPed); break; case RagdollStates.SHORT: skipRemoving = StartShortRagdoll(woundedPed); break; case RagdollStates.LONG: skipRemoving = StartLongRagdoll(woundedPed); break; case RagdollStates.LEG_DAMAGE: skipRemoving = StartLegDamageRagdoll(woundedPed); break; case RagdollStates.HEART_DAMAGE: skipRemoving = StartHeartDamageRagdoll(woundedPed); break; case RagdollStates.GUTS_DAMAGE: skipRemoving = StartGutsDamageRagdoll(woundedPed); break; default: throw new ArgumentOutOfRangeException(); } if (!skipRemoving) { RemoveEvent(); } void RemoveEvent() { _ecsWorld.RemoveEntity(_events.Entities[i]); } } }
public void Run() { WorldComponent world = _world.Components1[0]; foreach (int i in _moveableEntities) { PositionComponent positionComponent = _moveableEntities.Components1[i]; MoveComponent moveComponent = _moveableEntities.Components2[i]; Transform transform = _moveableEntities.Components3[i].Transform; int movingEntity = _moveableEntities.Entities[i]; float height = transform.position.y; Vector3 desiredPosition = moveComponent.DesiredPosition.ToVector3(height); Vector3 estimatedVector = desiredPosition - transform.position; if (estimatedVector.magnitude > 0.1f) { transform.position = Vector3.Lerp( transform.position, desiredPosition, moveComponent.Speed / estimatedVector.magnitude * Time.deltaTime); continue; } Vector2Int oldPosition = positionComponent.Position; Vector2Int newPosition = moveComponent.DesiredPosition; if (!oldPosition.Equals(newPosition)) { _ecsWorld.AddComponent <NewPositionComponent>(movingEntity).NewPosition = newPosition; } Vector2Int newDesiredPosition; Vector3 newDirection; switch (moveComponent.Heading) { case Directions.UP: newDesiredPosition = new Vector2Int(newPosition.x, newPosition.y + 1); newDirection = new Vector3(0, 0, 0); break; case Directions.RIGHT: newDesiredPosition = new Vector2Int(newPosition.x + 1, newPosition.y); newDirection = new Vector3(0, 90, 0); break; case Directions.DOWN: newDesiredPosition = new Vector2Int(newPosition.x, newPosition.y - 1); newDirection = new Vector3(0, 180, 0); break; case Directions.LEFT: newDesiredPosition = new Vector2Int(newPosition.x - 1, newPosition.y); newDirection = new Vector3(0, -90, 0); break; default: throw new ArgumentOutOfRangeException(); } transform.rotation = Quaternion.Euler(newDirection); bool stuckToWall = false; foreach (int entity in world.WorldField[newDesiredPosition.x][newDesiredPosition.y]) { if (!_ecsWorld.IsEntityExists(entity)) { continue; } if (_ecsWorld.GetComponent <WallComponent>(entity) == null) { continue; } stuckToWall = true; } if (stuckToWall) { bool isNew; _ecsWorld.EnsureComponent <StoppedComponent>(movingEntity, out isNew); } else { moveComponent.DesiredPosition = newDesiredPosition; _ecsWorld.RemoveComponent <StoppedComponent>(movingEntity, true); } } }
public void Run() { foreach (int i in _entities) { Ped ped = _entities.Components1[i].ThisPed; if (!ped.Exists()) { continue; } HealthComponent health = _entities.Components2[i]; if (health.Health <= 0) { continue; } BleedingInfoComponent info = _entities.Components3[i]; int pedEntity = _entities.Entities[i]; float bleedingDamage = 0; for (int bleedingIndex = info.BleedingEntities.Count - 1; bleedingIndex >= 0; bleedingIndex--) { int bleedingEntity = info.BleedingEntities[bleedingIndex]; if (!_ecsWorld.IsEntityExists(bleedingEntity)) { info.BleedingEntities.RemoveAt(bleedingIndex); continue; } var bleeding = _ecsWorld.GetComponent <BleedingComponent>(bleedingEntity); if (bleeding == null) { info.BleedingEntities.RemoveAt(bleedingIndex); continue; } float delta = GswExtensions.GetDeltaTime(); if (delta <= 0) { continue; } bleedingDamage += bleeding.Severity * delta; bleeding.Severity -= info.BleedingHealRate / HEAL_RATE_SLOWER * delta; if (bleeding.Severity > 0) { continue; } #if DEBUG _logger.MakeLog($"Bleeding {bleedingEntity} on Entity ({pedEntity}) was healed"); #endif _ecsWorld.RemoveComponent <BleedingComponent>(bleedingEntity); info.BleedingEntities.RemoveAt(bleedingIndex); } if (bleedingDamage <= 0) { continue; } health.Health -= bleedingDamage; ped.SetHealth(health.Health); } }
public void Run() { for (var i = 0; i < _requestEvents.EntitiesCount; i++) { var pedEntity = _requestEvents.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed?.MostDangerBleedingEntity == null) { continue; } if (woundedPed.InPermanentRagdoll) { continue; } var progress = _ecsWorld.EnsureComponent <BandageInProgressComponent>(pedEntity, out var isNew); if (!isNew) { SendMessage(_localeConfig.Data.AlreadyBandaging, pedEntity); continue; } if (woundedPed.IsPlayer) { if (Game.Player.Money < _config.Data.WoundConfig.BandageCost) { SendMessage(_localeConfig.Data.DontHaveMoneyForBandage, pedEntity); continue; } Game.Player.Money -= _config.Data.WoundConfig.BandageCost; } var timeToBandage = _config.Data.WoundConfig.ApplyBandageTime; progress.EstimateTime = timeToBandage; SendMessage(string.Format(_localeConfig.Data.YouTryToBandage, timeToBandage.ToString("F1")), pedEntity); } _requestEvents.CleanFilter(); var frameTimeInSec = Game.LastFrameTime; for (var i = 0; i < _pedsWithBandageInProgress.EntitiesCount; i++) { var woundedPed = _pedsWithBandageInProgress.Components1[i]; var thisPed = woundedPed.ThisPed; var progress = _pedsWithBandageInProgress.Components2[i]; var pedEntity = _pedsWithBandageInProgress.Entities[i]; if (woundedPed.InPermanentRagdoll || thisPed.IsWalking || thisPed.IsRunning || thisPed.IsSprinting || thisPed.IsShooting || thisPed.IsRagdoll || thisPed.IsJumping || thisPed.IsReloading || thisPed.IsSwimming) { SendMessage($"~r~{_localeConfig.Data.BandageFailed}", pedEntity); _ecsWorld.RemoveComponent <BandageInProgressComponent>(pedEntity); continue; } progress.EstimateTime -= frameTimeInSec; if (progress.EstimateTime > 0) { continue; } _ecsWorld.RemoveComponent <BandageInProgressComponent>(pedEntity); _ecsWorld.CreateEntityWith <SuccessfulBandageEvent>().Entity = pedEntity; } for (var i = 0; i < _successfulEvents.EntitiesCount; i++) { var pedEntity = _successfulEvents.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed?.MostDangerBleedingEntity == null) { continue; } var bleedingEntity = woundedPed.MostDangerBleedingEntity.Value; if (!_ecsWorld.IsEntityExists(bleedingEntity)) { continue; } var bleeding = _ecsWorld.GetComponent <BleedingComponent>(woundedPed.MostDangerBleedingEntity.Value); if (bleeding == null) { continue; } bleeding.BleedSeverity = bleeding.BleedSeverity / 2; UpdateMostDangerWound(woundedPed, pedEntity); SendMessage(string.Format("~g~" + _localeConfig.Data.BandageSuccess, bleeding.Name), pedEntity); } _successfulEvents.CleanFilter(); }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(RagdollSystem); #endif for (int i = 0; i < _events.EntitiesCount; i++) { int pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed == null || woundedPed.ThisPed.IsDead) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } switch (_events.Components1[i].RagdollState) { case RagdollStates.PERMANENT: if (woundedPed.InPermanentRagdoll) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } if (woundedPed.ThisPed.IsRagdoll) { continue; } Function.Call(Hash.SET_PED_TO_RAGDOLL, woundedPed.ThisPed, -1, -1, 0, 0, 0, 0); woundedPed.InPermanentRagdoll = true; _ecsWorld.RemoveEntity(_events.Entities[i]); continue; case RagdollStates.WAKE_UP: if (woundedPed.InPermanentRagdoll && !woundedPed.Crits.HasFlag(CritTypes.NERVES_DAMAGED)) { Function.Call(Hash.SET_PED_TO_RAGDOLL, woundedPed.ThisPed, 1, 1, 1, 0, 0, 0); woundedPed.InPermanentRagdoll = false; } _ecsWorld.RemoveEntity(_events.Entities[i]); RemoveAllPermanentEventsForPed(pedEntity); continue; case RagdollStates.SHORT: if (woundedPed.InPermanentRagdoll) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } if (woundedPed.ThisPed.IsRagdoll) { continue; } Function.Call(Hash.SET_PED_TO_RAGDOLL, woundedPed.ThisPed, 2000, 2000, 0, 0, 0, 0); _ecsWorld.RemoveEntity(_events.Entities[i]); continue; case RagdollStates.LONG: if (woundedPed.InPermanentRagdoll) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } if (woundedPed.ThisPed.IsRagdoll) { continue; } Function.Call(Hash.SET_PED_TO_RAGDOLL, woundedPed.ThisPed, 4000, 4000, 0, 0, 0, 0); _ecsWorld.RemoveEntity(_events.Entities[i]); continue; case RagdollStates.LEG_DAMAGE: if (woundedPed.InPermanentRagdoll) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } if (woundedPed.ThisPed.IsRagdoll) { continue; } Function.Call(Hash.SET_PED_TO_RAGDOLL, woundedPed.ThisPed, 3000, 3000, 4, 0, 0, 0); Function.Call(Hash.CREATE_NM_MESSAGE, true, 0); Function.Call(Hash.GIVE_PED_NM_MESSAGE, woundedPed.ThisPed); Function.Call(Hash.CREATE_NM_MESSAGE, true, 1025); Function.Call(Hash.GIVE_PED_NM_MESSAGE, woundedPed.ThisPed); Function.Call(Hash.CREATE_NM_MESSAGE, true, 169); Function.Call(Hash.GIVE_PED_NM_MESSAGE, woundedPed.ThisPed); _ecsWorld.RemoveEntity(_events.Entities[i]); continue; case RagdollStates.HEART_DAMAGE: if (woundedPed.InPermanentRagdoll) { _ecsWorld.RemoveEntity(_events.Entities[i]); continue; } if (woundedPed.ThisPed.IsRagdoll) { continue; } Function.Call(Hash.SET_PED_TO_RAGDOLL, woundedPed.ThisPed, 6000, 6000, 1, 0, 0, 0); Function.Call(Hash.CREATE_NM_MESSAGE, true, 1083); Function.Call(Hash.GIVE_PED_NM_MESSAGE, woundedPed.ThisPed); _ecsWorld.RemoveEntity(_events.Entities[i]); continue; default: throw new ArgumentOutOfRangeException(); } } }
public void Run() { #if DEBUG GunshotWound2.LastSystem = nameof(InstantHealSystem); #endif for (var i = 0; i < _events.EntitiesCount; i++) { var pedEntity = _events.Components1[i].Entity; if (!_ecsWorld.IsEntityExists(pedEntity)) { continue; } var woundedPed = _ecsWorld.GetComponent <WoundedPedComponent>(pedEntity); if (woundedPed != null) { if (woundedPed.IsPlayer) { _ecsWorld.CreateEntityWith <AddCameraShakeEvent>().Length = CameraShakeLength.CLEAR; Function.Call(Hash.SET_PLAYER_SPRINT, Game.Player, true); Function.Call(Hash._SET_CAM_EFFECT, 0); Function.Call(Hash.ANIMPOSTFX_STOP_ALL); woundedPed.Health = _mainConfig.Data.PlayerConfig.MaximalHealth; Game.Player.IgnoredByEveryone = false; } else { woundedPed.Health = GunshotWound2.Random.Next(50, _mainConfig.Data.NpcConfig.MaxStartHealth); woundedPed.ThisPed.Accuracy = woundedPed.DefaultAccuracy; } woundedPed.IsDead = false; woundedPed.Crits = 0; woundedPed.PedHealth = woundedPed.Health; woundedPed.Armor = woundedPed.ThisPed.Armor; woundedPed.BleedingCount = 0; woundedPed.MostDangerBleedingEntity = null; _ecsWorld.RemoveComponent <PainComponent>(pedEntity, true); Function.Call(Hash.CLEAR_PED_BLOOD_DAMAGE, woundedPed.ThisPed); Function.Call(Hash.SET_PED_MOVE_RATE_OVERRIDE, woundedPed.ThisPed, 1f); _ecsWorld.CreateEntityWith(out NoPainChangeStateEvent noPainEvent); noPainEvent.Entity = pedEntity; noPainEvent.ForceUpdate = true; } for (var bleedIndex = 0; bleedIndex < _bleedingComponents.EntitiesCount; bleedIndex++) { if (_bleedingComponents.Components1[bleedIndex].Entity != pedEntity) { continue; } _ecsWorld.RemoveEntity(_bleedingComponents.Entities[bleedIndex]); } } _events.CleanFilter(); }
public void Run() { if (_gameService.GameIsPaused) { return; } BleedingStatsComponent bleedingStats = _bleedingStats.Components1[0]; foreach (int i in _entities) { Ped ped = _entities.Components1[i].ThisPed; if (!ped.Exists()) { continue; } HealthComponent health = _entities.Components2[i]; if (health.Health <= 0) { continue; } PedBleedingInfoComponent info = _entities.Components3[i]; EcsEntity pedEntity = _entities.Entities[i]; float bleedingDamage = 0; for (int bleedingIndex = info.BleedingEntities.Count - 1; bleedingIndex >= 0; bleedingIndex--) { EcsEntity bleedingEntity = info.BleedingEntities[bleedingIndex]; if (!_ecsWorld.IsEntityExists(bleedingEntity)) { info.BleedingEntities.RemoveAt(bleedingIndex); continue; } var bleeding = _ecsWorld.GetComponent <BleedingComponent>(bleedingEntity); if (bleeding == null) { info.BleedingEntities.RemoveAt(bleedingIndex); continue; } float delta = GswExtensions.GetDeltaTime(); if (delta <= 0) { continue; } bleedingDamage += bleedingStats.BleedingDamageMultiplier * bleeding.Severity * delta; bleeding.Severity -= info.BleedingHealRate * delta; if (bleeding.Severity > 0) { continue; } #if DEBUG _logger.MakeLog($"Bleeding {bleedingEntity} on {pedEntity.GetEntityName()} was healed"); #endif _ecsWorld.RemoveComponent <BleedingComponent>(bleedingEntity); info.BleedingEntities.RemoveAt(bleedingIndex); } if (bleedingDamage <= 0) { continue; } health.Health -= bleedingDamage; ped.SetHealth(health.Health); } }