* temp * #3898 some progress on DrinkCanVisualizer * Fixed implementation * Moved drink can sprite layer definition to abstract parent * Added open drink can sprites * #3898 - fixes for drink cans' sprite field after merge + moved UpdateAppeareance from DrinkComponent to DrinkSystem * Update Content.Server/Nutrition/EntitySystems/DrinkSystem.cs * #3898 removed obsolete comment Co-authored-by: Javier Guardia Fernández <DrSmugleaf@users.noreply.github.com>
40
Content.Client/Nutrition/Visualizers/DrinkCanVisualizer.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Nutrition.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class DrinkCanVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("stateClosed")]
|
||||
private string? _stateClosed;
|
||||
|
||||
[DataField("stateOpen")]
|
||||
private string? _stateOpen;
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.TryGetData<bool>(DrinkCanStateVisual.Opened, out var opened) && opened)
|
||||
{
|
||||
sprite.LayerSetState(DrinkCanVisualLayers.Icon, $"{_stateOpen}");
|
||||
return;
|
||||
}
|
||||
|
||||
sprite.LayerSetState(DrinkCanVisualLayers.Icon, $"{_stateClosed}");
|
||||
}
|
||||
}
|
||||
|
||||
public enum DrinkCanVisualLayers : byte
|
||||
{
|
||||
Icon = 0
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Body.Behavior;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
@@ -21,6 +19,8 @@ using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Content.Server.Nutrition.Components
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace Content.Server.Nutrition.Components
|
||||
}
|
||||
|
||||
_opened = value;
|
||||
OpenedChanged();
|
||||
OnOpenedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Content.Server.Nutrition.Components
|
||||
|
||||
[DataField("burstSound")] public SoundSpecifier BurstSound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg");
|
||||
|
||||
private void OpenedChanged()
|
||||
private void OnOpenedChanged()
|
||||
{
|
||||
var solutionSys = EntitySystem.Get<SolutionContainerSystem>();
|
||||
if (!solutionSys.TryGetSolution(Owner, SolutionName, out _))
|
||||
@@ -89,6 +89,11 @@ namespace Content.Server.Nutrition.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (Owner.TryGetComponent(out AppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(DrinkCanStateVisual.Opened, Opened);
|
||||
}
|
||||
|
||||
if (Opened)
|
||||
{
|
||||
var refillable = Owner.EnsureComponent<RefillableSolutionComponent>();
|
||||
@@ -103,19 +108,6 @@ namespace Content.Server.Nutrition.Components
|
||||
}
|
||||
}
|
||||
|
||||
// TODO move to DrinkSystem
|
||||
public void UpdateAppearance()
|
||||
{
|
||||
if (!Owner.TryGetComponent(out AppearanceComponent? appearance) ||
|
||||
!Owner.HasComponent<SolutionContainerManagerComponent>())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var drainAvailable = EntitySystem.Get<SolutionContainerSystem>().DrainAvailable(Owner);
|
||||
appearance.SetData(SharedFoodComponent.FoodVisuals.Visual, drainAvailable.Float());
|
||||
}
|
||||
|
||||
bool IUse.UseEntity(UseEntityEventArgs args)
|
||||
{
|
||||
if (!Opened)
|
||||
@@ -218,7 +210,6 @@ namespace Content.Server.Nutrition.Components
|
||||
SoundSystem.Play(Filter.Pvs(target), _useSound.GetSound(), target, AudioParams.Default.WithVolume(-2f));
|
||||
|
||||
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-success-slurp"));
|
||||
UpdateAppearance();
|
||||
|
||||
// TODO: Account for partial transfer.
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -35,6 +37,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
_solutionContainerSystem.TryGetDrainableSolution(uid, out var interactions))
|
||||
{
|
||||
component.Opened = true;
|
||||
UpdateAppearance(component);
|
||||
|
||||
var entity = EntityManager.GetEntity(uid);
|
||||
|
||||
@@ -60,13 +63,25 @@ namespace Content.Server.Nutrition.EntitySystems
|
||||
_solutionContainerSystem.EnsureSolution(owner, component.SolutionName);
|
||||
}
|
||||
|
||||
component.UpdateAppearance();
|
||||
UpdateAppearance(component);
|
||||
}
|
||||
|
||||
|
||||
private void OnSolutionChange(EntityUid uid, DrinkComponent component, SolutionChangedEvent args)
|
||||
{
|
||||
component.UpdateAppearance();
|
||||
UpdateAppearance(component);
|
||||
}
|
||||
|
||||
public void UpdateAppearance(DrinkComponent component)
|
||||
{
|
||||
if (!component.Owner.TryGetComponent(out AppearanceComponent? appearance) ||
|
||||
!component.Owner.HasComponent<SolutionContainerManagerComponent>())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var drainAvailable = Get<SolutionContainerSystem>().DrainAvailable(component.Owner);
|
||||
appearance.SetData(FoodVisuals.Visual, drainAvailable.Float());
|
||||
appearance.SetData(DrinkCanStateVisual.Opened, component.Opened);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,18 @@ using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Nutrition.Components
|
||||
{
|
||||
public class SharedFoodComponent
|
||||
// TODO: Remove maybe? Add visualizer for food
|
||||
[Serializable, NetSerializable]
|
||||
public enum FoodVisuals : byte
|
||||
{
|
||||
// TODO: Remove maybe? Add visualizer for food
|
||||
[Serializable, NetSerializable]
|
||||
public enum FoodVisuals
|
||||
{
|
||||
Visual,
|
||||
MaxUses,
|
||||
}
|
||||
Visual,
|
||||
MaxUses,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum DrinkCanStateVisual : byte
|
||||
{
|
||||
Closed,
|
||||
Opened
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,17 @@
|
||||
type: TransferAmountBoundUserInterface
|
||||
- type: Sprite
|
||||
state: icon
|
||||
- type: Spillable
|
||||
layers:
|
||||
- state: icon
|
||||
map: ["enum.DrinkCanVisualLayers.Icon"]
|
||||
netsync: false
|
||||
- type: DrainableSolution
|
||||
solution: drink
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: DrinkCanVisualizer
|
||||
stateClosed: icon
|
||||
stateOpen: icon_open
|
||||
|
||||
- type: entity
|
||||
parent: DrinkCanBaseFull
|
||||
@@ -37,7 +46,6 @@
|
||||
- Cola
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/cola.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/cola.rsi
|
||||
|
||||
@@ -49,7 +57,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/ice_tea_can.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/ice_tea_can.rsi
|
||||
|
||||
@@ -61,7 +68,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/lemon-lime.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/lemon-lime.rsi
|
||||
|
||||
@@ -73,7 +79,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/purple_can.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/purple_can.rsi
|
||||
|
||||
@@ -85,7 +90,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/space_mountain_wind.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/space_mountain_wind.rsi
|
||||
|
||||
@@ -97,7 +101,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/space-up.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/space-up.rsi
|
||||
|
||||
@@ -109,7 +112,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/starkist.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/starkist.rsi
|
||||
|
||||
@@ -128,7 +130,6 @@
|
||||
Quantity: 20
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/thirteen_loko.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/thirteen_loko.rsi
|
||||
|
||||
@@ -141,7 +142,6 @@
|
||||
- type: Drink
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/changelingsting.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/changelingsting.rsi
|
||||
|
||||
@@ -154,7 +154,6 @@
|
||||
- type: Drink
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/dr_gibb.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/dr_gibb.rsi
|
||||
|
||||
@@ -167,7 +166,6 @@
|
||||
- type: Drink
|
||||
- type: Sprite
|
||||
sprite: Objects/Consumable/Drinks/energy_drink.rsi
|
||||
|
||||
- type: Item
|
||||
sprite: Objects/Consumable/Drinks/energy_drink.rsi
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -1 +1,35 @@
|
||||
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "https://github.com/discordia-space/CEV-Eris/raw/f7aa28fd4b4d0386c3393d829681ebca526f1d2d/icons/obj/drinks.dmi", "states": [{"name": "icon", "delays": [[10.0, 10.0, 10.0, 10.0, 10.0]]}]}
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "https://github.com/discordia-space/CEV-Eris/raw/f7aa28fd4b4d0386c3393d829681ebca526f1d2d/icons/obj/drinks.dmi",
|
||||
"states": [
|
||||
{
|
||||
"name": "icon",
|
||||
"delays": [
|
||||
[
|
||||
10.0,
|
||||
10.0,
|
||||
10.0,
|
||||
10.0,
|
||||
10.0
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "icon_open",
|
||||
"delays": [
|
||||
[
|
||||
10.0,
|
||||
10.0,
|
||||
10.0,
|
||||
10.0,
|
||||
10.0
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 504 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 535 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 517 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 549 B |
@@ -1 +1,17 @@
|
||||
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "https://github.com/discordia-space/CEV-Eris/raw/f7aa28fd4b4d0386c3393d829681ebca526f1d2d/icons/obj/drinks.dmi", "states": [{"name": "icon"}]}
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "https://github.com/discordia-space/CEV-Eris/raw/f7aa28fd4b4d0386c3393d829681ebca526f1d2d/icons/obj/drinks.dmi",
|
||||
"states": [
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
After Width: | Height: | Size: 477 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 475 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 480 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 504 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 520 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||
|
After Width: | Height: | Size: 493 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "icon"
|
||||
},
|
||||
{
|
||||
"name": "icon_open"
|
||||
},
|
||||
{
|
||||
"name": "inhand-right",
|
||||
"directions": 4,
|
||||
|
||||