Fix throwable solution (#4590)

* Fix throwable solution

* Revert previous commit

* Change Spillable and SpillBehavior

* Fix sloth's suggestion. Add more documents
This commit is contained in:
Ygg01
2021-09-15 12:46:43 +02:00
committed by GitHub
parent 9dae24ad89
commit c3d11fb3e1
15 changed files with 42 additions and 6 deletions

View File

@@ -10,13 +10,32 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataDefinition]
public class SpillBehavior : IThresholdBehavior
{
[DataField("solution")]
public string? Solution;
/// <summary>
/// If there is a SpillableComponent on IEntity owner use it to create a puddle/smear.
/// Or whatever solution is specified in the behavior itself.
/// If none are available do nothing.
/// </summary>
/// <param name="owner">Entity on which behavior is executed</param>
/// <param name="system">system calling the behavior</param>
public void Execute(IEntity owner, DestructibleSystem system)
{
// TODO see if this is correct
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(owner, SpillableComponent.SolutionName, out var solution))
return;
var solutionContainerSystem = EntitySystem.Get<SolutionContainerSystem>();
solution.SpillAt(owner.Transform.Coordinates, "PuddleSmear", false);
if (owner.TryGetComponent(out SpillableComponent? spillableComponent) &&
solutionContainerSystem.TryGetSolution(owner.Uid, spillableComponent.SolutionName,
out var compSolution))
{
compSolution.SpillAt(owner.Transform.Coordinates, "PuddleSmear", false);
}
else if (Solution != null &&
solutionContainerSystem.TryGetSolution(owner.Uid, Solution, out var behaviorSolution))
{
behaviorSolution.SpillAt(owner.Transform.Coordinates, "PuddleSmear", false);
}
}
}
}

View File

@@ -7,6 +7,7 @@ using Content.Shared.Notification.Managers;
using Content.Shared.Verbs;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Fluids.Components
{
@@ -14,7 +15,9 @@ namespace Content.Server.Fluids.Components
public class SpillableComponent : Component, IDropped
{
public override string Name => "Spillable";
public const string SolutionName = "puddle";
[DataField("solution")]
public string SolutionName = "puddle";
/// <summary>
/// Transfers solution from the held container to the floor.

View File

@@ -23,6 +23,7 @@
types:
Blunt: 5
- type: Spillable
solution: food
- type: Damageable
damageContainer: Inorganic
- type: Destructible

View File

@@ -36,6 +36,7 @@
useSound:
path: /Audio/Items/eating_1.ogg
- type: Spillable
solution: food
- type: entity
parent: ReagentContainerBase

View File

@@ -24,6 +24,7 @@
types:
Blunt: 5
- type: Spillable
solution: food
- type: Damageable
damageContainer: Inorganic
- type: Destructible

View File

@@ -16,6 +16,7 @@
- type: Sprite
state: icon
- type: Spillable
solution: drink
- type: UserInterface
interfaces:
- key: enum.TransferAmountUiKey.Key

View File

@@ -27,6 +27,7 @@
types:
Blunt: 10
- type: Spillable
solution: drink
- type: Damageable
damageContainer: Inorganic
- type: Destructible

View File

@@ -23,8 +23,8 @@
type: TransferAmountBoundUserInterface
- type: Sprite
state: icon
- type: Spillable
solution: drink
- type: entity
parent: DrinkCanBaseFull

View File

@@ -21,6 +21,7 @@
- type: Sprite
state: icon
- type: Spillable
solution: drink
- type: entity
parent: DrinkBaseCup

View File

@@ -18,6 +18,7 @@
- type: Drink
isOpen: true
- type: Spillable
solution: drink
- type: UserInterface
interfaces:
- key: enum.TransferAmountUiKey.Key

View File

@@ -44,6 +44,7 @@
- type: DrainableSolution
solution: spray
- type: Spillable
solution: spray
- type: ItemCooldown
- type: Spray
transferAmount: 1

View File

@@ -24,6 +24,7 @@
solution: spray
- type: SolutionTransfer
- type: Spillable
solution: spray
- type: ItemCooldown
- type: Spray
transferAmount: 10

View File

@@ -34,6 +34,7 @@
- type: Item
sprite: Objects/Specific/Chemistry/beaker.rsi
- type: Spillable
solution: drink
- type: entity
name: bottle

View File

@@ -36,6 +36,7 @@
- key: enum.TransferAmountUiKey.Key
type: TransferAmountBoundUserInterface
- type: Spillable
solution: beaker
- type: Drink
isOpen: true
- type: Appearance
@@ -167,6 +168,7 @@
- key: enum.TransferAmountUiKey.Key
type: TransferAmountBoundUserInterface
- type: Spillable
solution: dropper
- type: Item
sprite: Objects/Specific/Chemistry/dropper.rsi
- type: Appearance
@@ -200,6 +202,7 @@
- type: Injector
injectOnly: false
- type: Spillable
solution: injector
- type: Appearance
visuals:
# this visualizer used for reagent inside

View File

@@ -40,3 +40,4 @@
mask:
- Impassable
- type: Spillable
solution: bucket