2022-09-29 15:51:59 +10:00
using Content.Server.Body.Components ;
using Content.Server.Body.Systems ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
using Content.Server.Chat.Systems ;
2022-09-29 15:51:59 +10:00
using Content.Server.Chemistry.Components ;
2023-12-29 04:47:43 -08:00
using Content.Server.Chemistry.Containers.EntitySystems ;
2022-09-29 15:51:59 +10:00
using Content.Server.CombatMode.Disarm ;
2022-10-17 15:54:31 +11:00
using Content.Server.Movement.Systems ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
using Content.Shared.Actions.Events ;
2023-09-28 16:20:29 -07:00
using Content.Shared.Administration.Components ;
2022-09-29 15:51:59 +10:00
using Content.Shared.CombatMode ;
2023-08-07 12:09:35 +03:00
using Content.Shared.Damage.Events ;
2023-09-28 16:20:29 -07:00
using Content.Shared.Damage.Systems ;
2022-09-29 15:51:59 +10:00
using Content.Shared.Database ;
2023-09-28 16:20:29 -07:00
using Content.Shared.Effects ;
2023-04-07 11:21:12 -07:00
using Content.Shared.Hands.Components ;
2022-09-29 15:51:59 +10:00
using Content.Shared.IdentityManagement ;
2023-04-11 02:19:43 +00:00
using Content.Shared.Inventory ;
2023-12-10 19:54:41 +01:00
using Content.Shared.Mobs.Systems ;
2023-04-11 02:19:43 +00:00
using Content.Shared.Popups ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
using Content.Shared.Speech.Components ;
2023-04-07 11:21:12 -07:00
using Content.Shared.StatusEffect ;
2023-04-11 02:19:43 +00:00
using Content.Shared.Tag ;
2022-09-29 15:51:59 +10:00
using Content.Shared.Weapons.Melee ;
using Content.Shared.Weapons.Melee.Events ;
using Robust.Shared.Audio ;
using Robust.Shared.Map ;
using Robust.Shared.Player ;
using Robust.Shared.Random ;
2023-12-29 04:47:43 -08:00
using System.Linq ;
using System.Numerics ;
2022-09-29 15:51:59 +10:00
namespace Content.Server.Weapons.Melee ;
public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem
{
[Dependency] private readonly IRobustRandom _random = default ! ;
[Dependency] private readonly BloodstreamSystem _bloodstream = default ! ;
2023-08-11 03:44:52 +10:00
[Dependency] private readonly ChatSystem _chat = default ! ;
[Dependency] private readonly DamageExamineSystem _damageExamine = default ! ;
2023-04-11 02:19:43 +00:00
[Dependency] private readonly InventorySystem _inventory = default ! ;
2022-10-17 15:54:31 +11:00
[Dependency] private readonly LagCompensationSystem _lag = default ! ;
2023-12-10 19:54:41 +01:00
[Dependency] private readonly MobStateSystem _mobState = default ! ;
2023-08-11 03:44:52 +10:00
[Dependency] private readonly SharedColorFlashEffectSystem _color = default ! ;
2022-09-29 15:51:59 +10:00
[Dependency] private readonly SolutionContainerSystem _solutions = default ! ;
2023-04-11 02:19:43 +00:00
[Dependency] private readonly TagSystem _tag = default ! ;
2022-09-29 15:51:59 +10:00
public override void Initialize ( )
{
base . Initialize ( ) ;
SubscribeLocalEvent < MeleeChemicalInjectorComponent , MeleeHitEvent > ( OnChemicalInjectorHit ) ;
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
SubscribeLocalEvent < MeleeSpeechComponent , MeleeHitEvent > ( OnSpeechHit ) ;
2023-08-07 12:09:35 +03:00
SubscribeLocalEvent < MeleeWeaponComponent , DamageExamineEvent > ( OnMeleeExamineDamage ) ;
2022-09-29 15:51:59 +10:00
}
2023-08-07 12:09:35 +03:00
private void OnMeleeExamineDamage ( EntityUid uid , MeleeWeaponComponent component , ref DamageExamineEvent args )
2022-09-29 15:51:59 +10:00
{
2023-09-28 16:20:29 -07:00
if ( component . Hidden )
2022-09-29 15:51:59 +10:00
return ;
2023-06-07 16:26:45 -04:00
var damageSpec = GetDamage ( uid , args . User , component ) ;
2022-09-29 15:51:59 +10:00
2023-10-09 03:27:41 +11:00
if ( damageSpec . Empty )
2022-09-29 15:51:59 +10:00
return ;
2023-08-07 12:09:35 +03:00
_damageExamine . AddDamageExamine ( args . Message , damageSpec , Loc . GetString ( "damage-melee" ) ) ;
2022-09-29 15:51:59 +10:00
}
2023-05-02 05:07:17 +10:00
protected override bool ArcRaySuccessful ( EntityUid targetUid , Vector2 position , Angle angle , Angle arcWidth , float range , MapId mapId ,
EntityUid ignore , ICommonSession ? session )
{
// Originally the client didn't predict damage effects so you'd intuit some level of how far
// in the future you'd need to predict, but then there was a lot of complaining like "why would you add artifical delay" as if ping is a choice.
// Now damage effects are predicted but for wide attacks it differs significantly from client and server so your game could be lying to you on hits.
// This isn't fair in the slightest because it makes ping a huge advantage and this would be a hidden system.
// Now the client tells us what they hit and we validate if it's plausible.
// Even if the client is sending entities they shouldn't be able to hit:
// A) Wide-damage is split anyway
// B) We run the same validation we do for click attacks.
// Could also check the arc though future effort + if they're aimbotting it's not really going to make a difference.
// (This runs lagcomp internally and is what clickattacks use)
if ( ! Interaction . InRangeUnobstructed ( ignore , targetUid , range + 0.1f ) )
return false ;
// TODO: Check arc though due to the aforementioned aimbot + damage split comments it's less important.
return true ;
}
2023-02-13 07:55:39 -05:00
protected override bool DoDisarm ( EntityUid user , DisarmAttackEvent ev , EntityUid meleeUid , MeleeWeaponComponent component , ICommonSession ? session )
2022-09-29 15:51:59 +10:00
{
2023-02-13 07:55:39 -05:00
if ( ! base . DoDisarm ( user , ev , meleeUid , component , session ) )
2022-09-29 15:51:59 +10:00
return false ;
2022-10-15 15:14:07 +11:00
if ( ! TryComp < CombatModeComponent > ( user , out var combatMode ) | |
combatMode . CanDisarm ! = true )
{
2022-09-29 15:51:59 +10:00
return false ;
2022-10-15 15:14:07 +11:00
}
2022-09-29 15:51:59 +10:00
2023-09-11 09:42:41 +10:00
var target = GetEntity ( ev . Target ! . Value ) ;
2022-09-29 15:51:59 +10:00
2023-12-10 19:54:41 +01:00
if ( _mobState . IsIncapacitated ( target ) )
{
return false ;
}
2023-09-11 09:42:41 +10:00
if ( ! TryComp < HandsComponent > ( target , out var targetHandsComponent ) )
2022-09-29 15:51:59 +10:00
{
2023-09-11 09:42:41 +10:00
if ( ! TryComp < StatusEffectsComponent > ( target , out var status ) | | ! status . AllowedEffects . Contains ( "KnockedDown" ) )
2022-11-08 16:10:59 -05:00
return false ;
2022-09-29 15:51:59 +10:00
}
2023-09-11 09:42:41 +10:00
if ( ! InRange ( user , target , component . Range , session ) )
2022-09-29 15:51:59 +10:00
{
return false ;
}
EntityUid ? inTargetHand = null ;
2022-11-08 16:10:59 -05:00
if ( targetHandsComponent ? . ActiveHand is { IsEmpty : false } )
2022-09-29 15:51:59 +10:00
{
inTargetHand = targetHandsComponent . ActiveHand . HeldEntity ! . Value ;
}
2023-09-11 09:42:41 +10:00
Interaction . DoContactInteraction ( user , target ) ;
2022-10-26 14:15:48 +13:00
2022-09-29 15:51:59 +10:00
var attemptEvent = new DisarmAttemptEvent ( target , user , inTargetHand ) ;
if ( inTargetHand ! = null )
{
RaiseLocalEvent ( inTargetHand . Value , attemptEvent ) ;
}
RaiseLocalEvent ( target , attemptEvent ) ;
if ( attemptEvent . Cancelled )
return false ;
var chance = CalculateDisarmChance ( user , target , inTargetHand , combatMode ) ;
if ( _random . Prob ( chance ) )
{
2024-02-21 04:01:45 +00:00
// Yknow something tells me this comment is hilariously out of date...
2022-09-29 15:51:59 +10:00
// Don't play a sound as the swing is already predicted.
// Also don't play popups because most disarms will miss.
return false ;
}
2024-02-21 04:01:45 +00:00
AdminLogger . Add ( LogType . DisarmedAction , $"{ToPrettyString(user):user} used disarm on {ToPrettyString(target):target}" ) ;
var eventArgs = new DisarmedEvent { Target = target , Source = user , PushProbability = 1 - chance } ;
RaiseLocalEvent ( target , eventArgs ) ;
if ( ! eventArgs . Handled )
{
return false ;
}
Audio . PlayPvs ( combatMode . DisarmSuccessSound , user , AudioParams . Default . WithVariation ( 0.025f ) . WithVolume ( 5f ) ) ;
2022-11-08 16:10:59 -05:00
2024-02-21 04:01:45 +00:00
var targetEnt = Identity . Entity ( target , EntityManager ) ;
var userEnt = Identity . Entity ( user , EntityManager ) ;
2022-09-29 15:51:59 +10:00
var msgOther = Loc . GetString (
2024-02-21 04:01:45 +00:00
eventArgs . PopupPrefix + "popup-message-other-clients" ,
( "performerName" , userEnt ) ,
( "targetName" , targetEnt ) ) ;
2022-09-29 15:51:59 +10:00
2024-02-21 04:01:45 +00:00
var msgUser = Loc . GetString ( eventArgs . PopupPrefix + "popup-message-cursor" , ( "targetName" , targetEnt ) ) ;
var filterOther = Filter . PvsExcept ( user , entityManager : EntityManager ) ;
2022-09-29 15:51:59 +10:00
2022-12-19 10:41:47 +13:00
PopupSystem . PopupEntity ( msgOther , user , filterOther , true ) ;
PopupSystem . PopupEntity ( msgUser , target , user ) ;
2022-09-29 15:51:59 +10:00
2024-02-21 04:01:45 +00:00
if ( eventArgs . IsStunned )
{
PopupSystem . PopupEntity ( Loc . GetString ( "stunned-component-disarm-success-others" , ( "source" , userEnt ) , ( "target" , targetEnt ) ) , targetEnt , Filter . PvsExcept ( user ) , true , PopupType . LargeCaution ) ;
PopupSystem . PopupCursor ( Loc . GetString ( "stunned-component-disarm-success" , ( "target" , targetEnt ) ) , user , PopupType . Large ) ;
AdminLogger . Add ( LogType . DisarmedKnockdown , LogImpact . Medium , $"{ToPrettyString(user):user} knocked down {ToPrettyString(target):target}" ) ;
}
2022-09-29 15:51:59 +10:00
return true ;
}
2022-11-14 08:33:54 +11:00
protected override bool InRange ( EntityUid user , EntityUid target , float range , ICommonSession ? session )
2022-10-17 15:54:31 +11:00
{
EntityCoordinates targetCoordinates ;
Angle targetLocalAngle ;
2023-10-28 09:59:53 +11:00
if ( session is { } pSession )
2022-10-17 15:54:31 +11:00
{
( targetCoordinates , targetLocalAngle ) = _lag . GetCoordinatesAngle ( target , pSession ) ;
}
else
{
var xform = Transform ( target ) ;
targetCoordinates = xform . Coordinates ;
targetLocalAngle = xform . LocalRotation ;
}
2022-11-14 08:33:54 +11:00
return Interaction . InRangeUnobstructed ( user , target , targetCoordinates , targetLocalAngle , range ) ;
}
protected override void DoDamageEffect ( List < EntityUid > targets , EntityUid ? user , TransformComponent targetXform )
{
var filter = Filter . Pvs ( targetXform . Coordinates , entityMan : EntityManager ) . RemoveWhereAttachedEntity ( o = > o = = user ) ;
2023-08-11 03:44:52 +10:00
_color . RaiseEffect ( Color . Red , targets , filter ) ;
2022-10-17 15:54:31 +11:00
}
2023-04-08 13:16:48 -07:00
private float CalculateDisarmChance ( EntityUid disarmer , EntityUid disarmed , EntityUid ? inTargetHand , CombatModeComponent disarmerComp )
2022-09-29 15:51:59 +10:00
{
if ( HasComp < DisarmProneComponent > ( disarmer ) )
return 1.0f ;
if ( HasComp < DisarmProneComponent > ( disarmed ) )
return 0.0f ;
2024-02-21 17:39:52 +11:00
var chance = disarmerComp . BaseDisarmFailChance ;
2022-09-29 15:51:59 +10:00
if ( inTargetHand ! = null & & TryComp < DisarmMalusComponent > ( inTargetHand , out var malus ) )
{
chance + = malus . Malus ;
}
return Math . Clamp ( chance , 0f , 1f ) ;
}
2023-10-17 20:12:00 -05:00
public override void DoLunge ( EntityUid user , EntityUid weapon , Angle angle , Vector2 localPos , string? animation , bool predicted = true )
2022-09-29 15:51:59 +10:00
{
2023-04-10 15:37:03 +10:00
Filter filter ;
if ( predicted )
{
filter = Filter . PvsExcept ( user , entityManager : EntityManager ) ;
}
else
{
filter = Filter . Pvs ( user , entityManager : EntityManager ) ;
}
2023-10-17 20:12:00 -05:00
RaiseNetworkEvent ( new MeleeLungeEvent ( GetNetEntity ( user ) , GetNetEntity ( weapon ) , angle , localPos , animation ) , filter ) ;
2022-09-29 15:51:59 +10:00
}
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
private void OnSpeechHit ( EntityUid owner , MeleeSpeechComponent comp , MeleeHitEvent args )
{
if ( ! args . IsHit | |
! args . HitEntities . Any ( ) )
{
return ;
}
if ( comp . Battlecry ! = null ) //If the battlecry is set to empty, doesn't speak
{
2023-05-30 18:11:35 -07:00
_chat . TrySendInGameICMessage ( args . User , comp . Battlecry , InGameICChatType . Speak , true , true , checkRadioPrefix : false ) ; //Speech that isn't sent to chat or adminlogs
Northstar Gloves (#16021)
* Added Gloves of North Star, no sprite or talking yet...
* Added sprites for the gloves of the north star...
* Replaced more placeholder sprites for northstar gloves...
* Added gloves of the north star to uplink...
* Added speech on hit, not yet configureable
* Not functional yet, but a step in the right direction I hope...
* IT WORKS!!
* Licensing and cleanup
* Reduced attack speed, changed from chat to popup, added some admin logging. It was causing too much adminlog spam otherwise
* Reorganized some files, final build??
* Changed the adminlog type from Verb to new type ItemConfigure
* More cleanup, fix sprite reference maybe
* Keronshb's suggestions, fixed some stuff, made hit sound use the meaty punch sfx
* Adds support for hiding speak/whisper/emote from adminlogs, makes northstar speak again!
* Some file shuffling, some of Keronshb's requests. Might appear a bit funky in github because vscode kept duplicating files for some reason and I had to delete them
* Made it work with the latest changes on Master
* Final? cleanup, upped dmg to 8, made ui not activate on activateinhand, instead you need to right click
* Set value to 0 credits, that's all
* Well that was much easier than I made it out to be. Now you can only activate the gloves with right click, no more mispredicts.
* Update MeleeWeaponSystem.cs
Iunno why this got changed in the first place, but I'm changin it back
* emptycommit
* emptycommit
* The tiny fixening
2023-05-23 11:12:30 -07:00
}
}
2023-12-29 04:47:43 -08:00
private void OnChemicalInjectorHit ( Entity < MeleeChemicalInjectorComponent > entity , ref MeleeHitEvent args )
2022-09-29 15:51:59 +10:00
{
2023-02-13 07:55:39 -05:00
if ( ! args . IsHit | |
! args . HitEntities . Any ( ) | |
2023-12-29 04:47:43 -08:00
! _solutions . TryGetSolution ( entity . Owner , entity . Comp . Solution , out var solutionContainer ) )
2023-02-13 07:55:39 -05:00
{
2022-09-29 15:51:59 +10:00
return ;
2023-02-13 07:55:39 -05:00
}
2022-09-29 15:51:59 +10:00
2023-03-12 15:56:05 +11:00
var hitBloodstreams = new List < ( EntityUid Entity , BloodstreamComponent Component ) > ( ) ;
2022-09-29 15:51:59 +10:00
var bloodQuery = GetEntityQuery < BloodstreamComponent > ( ) ;
2023-12-29 04:47:43 -08:00
foreach ( var hit in args . HitEntities )
2022-09-29 15:51:59 +10:00
{
2023-12-29 04:47:43 -08:00
if ( Deleted ( hit ) )
2022-09-29 15:51:59 +10:00
continue ;
2023-04-11 02:19:43 +00:00
// prevent deathnettles injecting through hardsuits
2023-12-29 04:47:43 -08:00
if ( ! entity . Comp . PierceArmor & & _inventory . TryGetSlotEntity ( hit , "outerClothing" , out var suit ) & & _tag . HasTag ( suit . Value , "Hardsuit" ) )
2023-04-11 02:19:43 +00:00
{
2023-12-29 04:47:43 -08:00
PopupSystem . PopupEntity ( Loc . GetString ( "melee-inject-failed-hardsuit" , ( "weapon" , entity . Owner ) ) , args . User , args . User , PopupType . SmallCaution ) ;
2023-04-11 02:19:43 +00:00
continue ;
}
2023-12-29 04:47:43 -08:00
if ( bloodQuery . TryGetComponent ( hit , out var bloodstream ) )
hitBloodstreams . Add ( ( hit , bloodstream ) ) ;
2022-09-29 15:51:59 +10:00
}
if ( ! hitBloodstreams . Any ( ) )
return ;
2023-12-29 04:47:43 -08:00
var removedSolution = _solutions . SplitSolution ( solutionContainer . Value , entity . Comp . TransferAmount * hitBloodstreams . Count ) ;
2023-01-12 16:41:40 +13:00
var removedVol = removedSolution . Volume ;
2023-12-29 04:47:43 -08:00
var solutionToInject = removedSolution . SplitSolution ( removedVol * entity . Comp . TransferEfficiency ) ;
2023-01-12 16:41:40 +13:00
var volPerBloodstream = solutionToInject . Volume * ( 1 / hitBloodstreams . Count ) ;
2022-09-29 15:51:59 +10:00
2023-03-12 15:56:05 +11:00
foreach ( var ( ent , bloodstream ) in hitBloodstreams )
2022-09-29 15:51:59 +10:00
{
var individualInjection = solutionToInject . SplitSolution ( volPerBloodstream ) ;
2023-03-12 15:56:05 +11:00
_bloodstream . TryAddToChemicals ( ent , individualInjection , bloodstream ) ;
2022-09-29 15:51:59 +10:00
}
}
}