Adds trash tag to more items. New component "TrashOnEmpty" (#10166)
This commit is contained in:
16
Content.Server/Nutrition/Components/TrashOnEmptyComponent.cs
Normal file
16
Content.Server/Nutrition/Components/TrashOnEmptyComponent.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace Content.Server.Nutrition.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Component that tags solution containers as trash when their contents have been emptied.
|
||||||
|
/// Used for things like used ketchup packets or used syringes.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class TrashOnEmptyComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the solution of which to check emptiness
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables] [DataField("solution")]
|
||||||
|
public string Solution { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
53
Content.Server/Nutrition/EntitySystems/TrashOnEmptySystem.cs
Normal file
53
Content.Server/Nutrition/EntitySystems/TrashOnEmptySystem.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using Content.Server.Chemistry.Components.SolutionManager;
|
||||||
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
|
using Content.Server.Nutrition.Components;
|
||||||
|
using Content.Shared.Chemistry.Components;
|
||||||
|
using Content.Shared.Tag;
|
||||||
|
|
||||||
|
namespace Content.Server.Nutrition.EntitySystems
|
||||||
|
{
|
||||||
|
public sealed class TrashOnEmptySystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||||
|
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<TrashOnEmptyComponent, ComponentStartup>(OnStartup);
|
||||||
|
SubscribeLocalEvent<TrashOnEmptyComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnStartup(EntityUid uid, TrashOnEmptyComponent component, ComponentStartup args)
|
||||||
|
{
|
||||||
|
CheckSolutions(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnSolutionChange(EntityUid uid, TrashOnEmptyComponent component, SolutionChangedEvent args)
|
||||||
|
{
|
||||||
|
CheckSolutions(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CheckSolutions(TrashOnEmptyComponent component)
|
||||||
|
{
|
||||||
|
EntityManager.EnsureComponent<TagComponent>(component.Owner);
|
||||||
|
|
||||||
|
if (!EntityManager.HasComponent<SolutionContainerManagerComponent>((component).Owner))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_solutionContainerSystem.TryGetSolution(component.Owner, component.Solution, out var solution))
|
||||||
|
UpdateTags(component, solution);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateTags(TrashOnEmptyComponent component, Solution solution)
|
||||||
|
{
|
||||||
|
if (solution.DrainAvailable <= 0)
|
||||||
|
{
|
||||||
|
_tagSystem.AddTag(component.Owner, "Trash");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_tagSystem.HasTag(component.Owner, "Trash"))
|
||||||
|
_tagSystem.RemoveTag(component.Owner, "Trash");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,12 +34,11 @@
|
|||||||
- type: DrinkCanVisualizer
|
- type: DrinkCanVisualizer
|
||||||
stateClosed: icon
|
stateClosed: icon
|
||||||
stateOpen: icon_open
|
stateOpen: icon_open
|
||||||
- type: Tag
|
|
||||||
tags:
|
|
||||||
- Trash
|
|
||||||
- type: ItemCooldown
|
- type: ItemCooldown
|
||||||
- type: Recyclable
|
- type: Recyclable
|
||||||
- type: SpaceGarbage
|
- type: SpaceGarbage
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: drink
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: DrinkCanBaseFull
|
parent: DrinkCanBaseFull
|
||||||
|
|||||||
@@ -174,6 +174,8 @@
|
|||||||
maxVol: 20
|
maxVol: 20
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Consumable/Drinks/hot_coffee.rsi
|
sprite: Objects/Consumable/Drinks/hot_coffee.rsi
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: drink
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: DrinkBaseCup
|
parent: DrinkBaseCup
|
||||||
@@ -191,6 +193,8 @@
|
|||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Consumable/Drinks/teacup.rsi
|
sprite: Objects/Consumable/Drinks/teacup.rsi
|
||||||
state: icon-1
|
state: icon-1
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: drink
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: DrinkBaseCup
|
parent: DrinkBaseCup
|
||||||
@@ -210,6 +214,8 @@
|
|||||||
state: icon
|
state: icon
|
||||||
- type: Item
|
- type: Item
|
||||||
sprite: Objects/Consumable/Drinks/lean.rsi
|
sprite: Objects/Consumable/Drinks/lean.rsi
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: drink
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: DrinkBaseCup
|
parent: DrinkBaseCup
|
||||||
@@ -228,3 +234,5 @@
|
|||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Consumable/Drinks/water_cup.rsi
|
sprite: Objects/Consumable/Drinks/water_cup.rsi
|
||||||
state: icon-1
|
state: icon-1
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: drink
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
- type: Icon
|
- type: Icon
|
||||||
sprite: Objects/Consumable/Food/condiments.rsi
|
sprite: Objects/Consumable/Food/condiments.rsi
|
||||||
state: packet-empty
|
state: packet-empty
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: food
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: FoodCondimentPacket
|
parent: FoodCondimentPacket
|
||||||
@@ -357,6 +359,8 @@
|
|||||||
- type: SolutionContainerVisualizer
|
- type: SolutionContainerVisualizer
|
||||||
maxFillLevels: 6
|
maxFillLevels: 6
|
||||||
fillBaseName: bottle-alpha-
|
fillBaseName: bottle-alpha-
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: food
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: FoodCondimentBottle
|
parent: FoodCondimentBottle
|
||||||
@@ -501,6 +505,8 @@
|
|||||||
- type: SolutionContainerVisualizer
|
- type: SolutionContainerVisualizer
|
||||||
maxFillLevels: 3
|
maxFillLevels: 3
|
||||||
fillBaseName: bottle-s-alpha-
|
fillBaseName: bottle-s-alpha-
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: food
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: FoodCondimentBottleSmall
|
parent: FoodCondimentBottleSmall
|
||||||
|
|||||||
@@ -43,7 +43,9 @@
|
|||||||
sprite: Objects/Consumable/Food/snacks.rsi
|
sprite: Objects/Consumable/Food/snacks.rsi
|
||||||
heldPrefix: packet
|
heldPrefix: packet
|
||||||
size: 3
|
size: 3
|
||||||
|
- type: Tag
|
||||||
|
tags:
|
||||||
|
- Trash
|
||||||
# Tins
|
# Tins
|
||||||
|
|
||||||
# Need something that you can open these tins with. I suggest a prying or cutting tool.
|
# Need something that you can open these tins with. I suggest a prying or cutting tool.
|
||||||
|
|||||||
@@ -489,6 +489,9 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
- type: Item
|
- type: Item
|
||||||
size: 1
|
size: 1
|
||||||
|
- type: Tag
|
||||||
|
tags:
|
||||||
|
- Trash
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: onion
|
name: onion
|
||||||
|
|||||||
@@ -40,6 +40,8 @@
|
|||||||
sprite: Objects/Specific/Chemistry/beaker.rsi
|
sprite: Objects/Specific/Chemistry/beaker.rsi
|
||||||
- type: Spillable
|
- type: Spillable
|
||||||
solution: drink
|
solution: drink
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: drink
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: bottle
|
name: bottle
|
||||||
|
|||||||
@@ -235,6 +235,8 @@
|
|||||||
injectOnly: false
|
injectOnly: false
|
||||||
- type: Spillable
|
- type: Spillable
|
||||||
solution: injector
|
solution: injector
|
||||||
|
- type: TrashOnEmpty
|
||||||
|
solution: injector
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
visuals:
|
||||||
# this visualizer used for reagent inside
|
# this visualizer used for reagent inside
|
||||||
|
|||||||
Reference in New Issue
Block a user