private void OnFire(EntityUid uid, ChemicalAmmoComponent component, AmmoShotEvent args) { if (!_solutionSystem.TryGetSolution(uid, component.SolutionName, out var ammoSolution)) { return; } var projectiles = args.FiredProjectiles; var projectileSolutionContainers = new List <(EntityUid, Solution)>(); foreach (var projectile in projectiles) { if (_solutionSystem .TryGetSolution(projectile, component.SolutionName, out var projectileSolutionContainer)) { projectileSolutionContainers.Add((uid, projectileSolutionContainer)); } } if (!projectileSolutionContainers.Any()) { return; } var solutionPerProjectile = ammoSolution.CurrentVolume * (1 / projectileSolutionContainers.Count); foreach (var(projectileUid, projectileSolution) in projectileSolutionContainers) { var solutionToTransfer = _solutionSystem.SplitSolution(uid, ammoSolution, solutionPerProjectile); _solutionSystem.TryAddSolution(projectileUid, projectileSolution, solutionToTransfer); } _solutionSystem.RemoveAllSolution(uid, ammoSolution); }
private void FillSlice(EntityUid sliceUid, Solution solution) { // Replace all reagents on prototype not just copying poisons (example: slices of eaten pizza should have less nutrition) if (EntityManager.TryGetComponent <FoodComponent>(sliceUid, out var sliceFoodComp) && _solutionContainerSystem.TryGetSolution(sliceUid, sliceFoodComp.SolutionName, out var itsSolution)) { _solutionContainerSystem.RemoveAllSolution(sliceUid, itsSolution); var lostSolutionPart = solution.SplitSolution(itsSolution.AvailableVolume); _solutionContainerSystem.TryAddSolution(sliceUid, itsSolution, lostSolutionPart); } }