private void TransferSolution(BarrelFiredMessage barrelFired) { if (!Owner.TryGetComponent <SolutionContainerComponent>(out var ammoSolutionContainer)) { return; } var projectiles = barrelFired.FiredProjectiles; var projectileSolutionContainers = new List <SolutionContainerComponent>(); foreach (var projectile in projectiles) { if (projectile.TryGetComponent <SolutionContainerComponent>(out var projectileSolutionContainer)) { projectileSolutionContainers.Add(projectileSolutionContainer); } } if (!projectileSolutionContainers.Any()) { return; } var solutionPerProjectile = ammoSolutionContainer.CurrentVolume * (1 / projectileSolutionContainers.Count); foreach (var projectileSolutionContainer in projectileSolutionContainers) { var solutionToTransfer = ammoSolutionContainer.SplitSolution(solutionPerProjectile); projectileSolutionContainer.TryAddSolution(solutionToTransfer); } ammoSolutionContainer.RemoveAllSolution(); }
private void TransferSolution(BarrelFiredMessage barrelFired) { if (!EntitySystem.Get <SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var ammoSolution)) { return; } var projectiles = barrelFired.FiredProjectiles; var solutionContainerSystem = EntitySystem.Get <SolutionContainerSystem>(); var projectileSolutionContainers = new List <(EntityUid, Solution)>(); foreach (var projectile in projectiles) { if (EntitySystem.Get <SolutionContainerSystem>() .TryGetSolution(projectile, SolutionName, out var projectileSolutionContainer)) { projectileSolutionContainers.Add((projectile.Uid, projectileSolutionContainer)); } } if (!projectileSolutionContainers.Any()) { return; } var solutionPerProjectile = ammoSolution.CurrentVolume * (1 / projectileSolutionContainers.Count); foreach (var(projectileUid, projectileSolution) in projectileSolutionContainers) { var solutionToTransfer = solutionContainerSystem.SplitSolution(Owner.Uid, ammoSolution, solutionPerProjectile); solutionContainerSystem.TryAddSolution(projectileUid, projectileSolution, solutionToTransfer); } solutionContainerSystem.RemoveAllSolution(Owner.Uid, ammoSolution); }