mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-12 11:51:11 +03:00
* Everything except the YAML slop... * She solution on my manager till I sajfslkahfsjakfhaskjfshajksafhfsakhfasjfas * another 1000 lines * fix chem dispenser size * go my shnelf * Implicit ass * rider is being mean for some reason * dasdas * borger * better formatting go! * clothes/bloodstream * Cartons * cups and bottles * mmm soder * bar drinks * Spray bottles and some size tweaks with hindsight * 99 bottles of beer on the wall I hate YAML * push that shit * mmm burger * Sneed * sheets * condiments * mmm yummy * fridge yummyfood * meat... * sub 300 * burger... * bready * let them eat cake * does she know how to make a grilled cheese? * pizza pie! * misc shit * soup or salad * Food and drinks, vanquished * the cubes!!! * Almost free from YAML... * fix test fails and some yaml issues * fix prediction, almost done * fix all test fails * remove master merge artifacts and undo autonetworking * review and compatibility * graaah * unfuck master merge I hate github * merg conflicts * sfsa * ehoop * sadas * afsafsaasf * merge conflicts * fucked up the merge conflicts * merge conflict is fucked I might need to completely redo this branch * test fail * no calcium???? --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
85 lines
3.3 KiB
C#
85 lines
3.3 KiB
C#
using Content.Server.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Vapor;
|
|
using Content.Shared.Weapons.Ranged;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Content.Server.Weapons.Ranged.Systems;
|
|
|
|
public sealed partial class GunSystem
|
|
{
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
|
|
|
protected override void InitializeSolution()
|
|
{
|
|
base.InitializeSolution();
|
|
|
|
SubscribeLocalEvent<SolutionAmmoProviderComponent, MapInitEvent>(OnSolutionMapInit);
|
|
SubscribeLocalEvent<SolutionAmmoProviderComponent, SolutionChangedEvent>(OnSolutionChanged);
|
|
}
|
|
|
|
private void OnSolutionMapInit(Entity<SolutionAmmoProviderComponent> entity, ref MapInitEvent args)
|
|
{
|
|
UpdateSolutionShots(entity);
|
|
}
|
|
|
|
private void OnSolutionChanged(Entity<SolutionAmmoProviderComponent> entity, ref SolutionChangedEvent args)
|
|
{
|
|
if (args.Solution.Comp.Id == entity.Comp.SolutionId)
|
|
UpdateSolutionShots(entity, args.Solution.Comp.Solution);
|
|
}
|
|
|
|
protected override void UpdateSolutionShots(Entity<SolutionAmmoProviderComponent> ent, Solution? solution = null)
|
|
{
|
|
var shots = 0;
|
|
var maxShots = 0;
|
|
if (solution == null && !_solutionContainer.TryGetSolution(ent.Owner, ent.Comp.SolutionId, out _, out solution))
|
|
{
|
|
ent.Comp.Shots = shots;
|
|
DirtyField(ent.AsNullable(), nameof(SolutionAmmoProviderComponent.Shots));
|
|
ent.Comp.MaxShots = maxShots;
|
|
DirtyField(ent.AsNullable(), nameof(SolutionAmmoProviderComponent.MaxShots));
|
|
return;
|
|
}
|
|
|
|
shots = (int)(solution.Volume / ent.Comp.FireCost);
|
|
maxShots = (int)(solution.MaxVolume / ent.Comp.FireCost);
|
|
|
|
ent.Comp.Shots = shots;
|
|
DirtyField(ent.AsNullable(), nameof(SolutionAmmoProviderComponent.Shots));
|
|
|
|
ent.Comp.MaxShots = maxShots;
|
|
DirtyField(ent.AsNullable(), nameof(SolutionAmmoProviderComponent.MaxShots));
|
|
|
|
UpdateSolutionAppearance(ent);
|
|
}
|
|
|
|
protected override (EntityUid Entity, IShootable) GetSolutionShot(Entity<SolutionAmmoProviderComponent> ent, EntityCoordinates position)
|
|
{
|
|
var (shot, shootable) = base.GetSolutionShot(ent, position);
|
|
|
|
if (!_solutionContainer.TryGetSolution(ent.Owner, ent.Comp.SolutionId, out var solution, out _))
|
|
return (shot, shootable);
|
|
|
|
var newSolution = _solutionContainer.SplitSolution(solution.Value, ent.Comp.FireCost);
|
|
|
|
if (newSolution.Volume <= FixedPoint2.Zero)
|
|
return (shot, shootable);
|
|
|
|
if (TryComp<AppearanceComponent>(shot, out var appearance))
|
|
{
|
|
Appearance.SetData(shot, VaporVisuals.Color, newSolution.GetColor(ProtoManager).WithAlpha(1f), appearance);
|
|
Appearance.SetData(shot, VaporVisuals.State, true, appearance);
|
|
}
|
|
|
|
// Add the solution to the vapor and actually send the thing
|
|
if (_solutionContainer.TryGetSolution(shot, VaporComponent.SolutionName, out var vaporSolution, out _))
|
|
{
|
|
_solutionContainer.TryAddSolution(vaporSolution.Value, newSolution);
|
|
}
|
|
return (shot, shootable);
|
|
}
|
|
}
|