Revert "Solution Entities" (#23160)
Revert "Solution Entities (#21916)"
This reverts commit d75e743dd7.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -17,38 +16,38 @@ public sealed class TransformableContainerSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<TransformableContainerComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<TransformableContainerComponent, SolutionContainerChangedEvent>(OnSolutionChange);
|
||||
SubscribeLocalEvent<TransformableContainerComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<TransformableContainerComponent> entity, ref MapInitEvent args)
|
||||
private void OnMapInit(EntityUid uid, TransformableContainerComponent component, MapInitEvent args)
|
||||
{
|
||||
var meta = MetaData(entity.Owner);
|
||||
if (string.IsNullOrEmpty(entity.Comp.InitialName))
|
||||
var meta = MetaData(uid);
|
||||
if (string.IsNullOrEmpty(component.InitialName))
|
||||
{
|
||||
entity.Comp.InitialName = meta.EntityName;
|
||||
component.InitialName = meta.EntityName;
|
||||
}
|
||||
if (string.IsNullOrEmpty(entity.Comp.InitialDescription))
|
||||
if (string.IsNullOrEmpty(component.InitialDescription))
|
||||
{
|
||||
entity.Comp.InitialDescription = meta.EntityDescription;
|
||||
component.InitialDescription = meta.EntityDescription;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSolutionChange(Entity<TransformableContainerComponent> entity, ref SolutionContainerChangedEvent args)
|
||||
private void OnSolutionChange(EntityUid owner, TransformableContainerComponent component,
|
||||
SolutionChangedEvent args)
|
||||
{
|
||||
if (!_solutionsSystem.TryGetFitsInDispenser(entity.Owner, out _, out var solution))
|
||||
if (!_solutionsSystem.TryGetFitsInDispenser(owner, out var solution))
|
||||
return;
|
||||
|
||||
//Transform container into initial state when emptied
|
||||
if (entity.Comp.CurrentReagent != null && solution.Contents.Count == 0)
|
||||
if (component.CurrentReagent != null && solution.Contents.Count == 0)
|
||||
{
|
||||
CancelTransformation(entity);
|
||||
CancelTransformation(owner, component);
|
||||
}
|
||||
|
||||
//the biggest reagent in the solution decides the appearance
|
||||
var reagentId = solution.GetPrimaryReagentId();
|
||||
|
||||
//If biggest reagent didn't changed - don't change anything at all
|
||||
if (entity.Comp.CurrentReagent != null && entity.Comp.CurrentReagent.ID == reagentId?.Prototype)
|
||||
if (component.CurrentReagent != null && component.CurrentReagent.ID == reagentId?.Prototype)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -57,29 +56,29 @@ public sealed class TransformableContainerSystem : EntitySystem
|
||||
if (!string.IsNullOrWhiteSpace(reagentId?.Prototype)
|
||||
&& _prototypeManager.TryIndex(reagentId.Value.Prototype, out ReagentPrototype? proto))
|
||||
{
|
||||
var metadata = MetaData(entity.Owner);
|
||||
var metadata = MetaData(owner);
|
||||
var val = Loc.GetString("transformable-container-component-glass", ("name", proto.LocalizedName));
|
||||
_metadataSystem.SetEntityName(entity.Owner, val, metadata);
|
||||
_metadataSystem.SetEntityDescription(entity.Owner, proto.LocalizedDescription, metadata);
|
||||
entity.Comp.CurrentReagent = proto;
|
||||
entity.Comp.Transformed = true;
|
||||
_metadataSystem.SetEntityName(owner, val, metadata);
|
||||
_metadataSystem.SetEntityDescription(owner, proto.LocalizedDescription, metadata);
|
||||
component.CurrentReagent = proto;
|
||||
component.Transformed = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelTransformation(Entity<TransformableContainerComponent> entity)
|
||||
private void CancelTransformation(EntityUid owner, TransformableContainerComponent component)
|
||||
{
|
||||
entity.Comp.CurrentReagent = null;
|
||||
entity.Comp.Transformed = false;
|
||||
component.CurrentReagent = null;
|
||||
component.Transformed = false;
|
||||
|
||||
var metadata = MetaData(entity);
|
||||
var metadata = MetaData(owner);
|
||||
|
||||
if (!string.IsNullOrEmpty(entity.Comp.InitialName))
|
||||
if (!string.IsNullOrEmpty(component.InitialName))
|
||||
{
|
||||
_metadataSystem.SetEntityName(entity.Owner, entity.Comp.InitialName, metadata);
|
||||
_metadataSystem.SetEntityName(owner, component.InitialName, metadata);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(entity.Comp.InitialDescription))
|
||||
if (!string.IsNullOrEmpty(component.InitialDescription))
|
||||
{
|
||||
_metadataSystem.SetEntityDescription(entity.Owner, entity.Comp.InitialDescription, metadata);
|
||||
_metadataSystem.SetEntityDescription(owner, component.InitialDescription, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user