mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +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>
89 lines
3.5 KiB
C#
89 lines
3.5 KiB
C#
using Content.Server.Chemistry.Components;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.NameModifier.EntitySystems;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server.Chemistry.EntitySystems;
|
|
|
|
public sealed class TransformableContainerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionsSystem = default!;
|
|
[Dependency] private readonly MetaDataSystem _metadataSystem = default!;
|
|
[Dependency] private readonly NameModifierSystem _nameMod = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<TransformableContainerComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<TransformableContainerComponent, SolutionChangedEvent>(OnSolutionChange);
|
|
SubscribeLocalEvent<TransformableContainerComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
|
|
}
|
|
|
|
private void OnMapInit(Entity<TransformableContainerComponent> entity, ref MapInitEvent args)
|
|
{
|
|
var meta = MetaData(entity.Owner);
|
|
if (string.IsNullOrEmpty(entity.Comp.InitialDescription))
|
|
{
|
|
entity.Comp.InitialDescription = meta.EntityDescription;
|
|
}
|
|
}
|
|
|
|
private void OnSolutionChange(Entity<TransformableContainerComponent> entity, ref SolutionChangedEvent args)
|
|
{
|
|
if (!_solutionsSystem.TryGetFitsInDispenser(entity.Owner, out _, out var solution))
|
|
return;
|
|
|
|
//Transform container into initial state when emptied
|
|
if (entity.Comp.CurrentReagent != null && solution.Contents.Count == 0)
|
|
{
|
|
CancelTransformation(entity);
|
|
}
|
|
|
|
//the biggest reagent in the solution decides the appearance
|
|
var reagentId = solution.GetPrimaryReagentId();
|
|
|
|
//If biggest reagent didn't change - don't change anything at all
|
|
if (entity.Comp.CurrentReagent != null && entity.Comp.CurrentReagent == reagentId?.Prototype)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//Only reagents with spritePath property can change appearance of transformable containers!
|
|
if (!string.IsNullOrWhiteSpace(reagentId?.Prototype)
|
|
&& _prototypeManager.TryIndex(reagentId.Value.Prototype, out ReagentPrototype? proto))
|
|
{
|
|
var metadata = MetaData(entity.Owner);
|
|
_metadataSystem.SetEntityDescription(entity.Owner, proto.LocalizedDescription, metadata);
|
|
entity.Comp.CurrentReagent = proto;
|
|
entity.Comp.Transformed = true;
|
|
}
|
|
|
|
_nameMod.RefreshNameModifiers(entity.Owner);
|
|
}
|
|
|
|
private void OnRefreshNameModifiers(Entity<TransformableContainerComponent> entity, ref RefreshNameModifiersEvent args)
|
|
{
|
|
if (_prototypeManager.Resolve(entity.Comp.CurrentReagent, out var currentReagent))
|
|
{
|
|
args.AddModifier("transformable-container-component-glass", priority: -1, ("reagent", currentReagent.LocalizedName));
|
|
}
|
|
}
|
|
|
|
private void CancelTransformation(Entity<TransformableContainerComponent> entity)
|
|
{
|
|
entity.Comp.CurrentReagent = null;
|
|
entity.Comp.Transformed = false;
|
|
|
|
var metadata = MetaData(entity);
|
|
|
|
_nameMod.RefreshNameModifiers(entity.Owner);
|
|
|
|
if (!string.IsNullOrEmpty(entity.Comp.InitialDescription))
|
|
{
|
|
_metadataSystem.SetEntityDescription(entity.Owner, entity.Comp.InitialDescription, metadata);
|
|
}
|
|
}
|
|
}
|