Re-organize all projects (#4166)
This commit is contained in:
30
Content.Client/Nutrition/Components/HungerComponent.cs
Normal file
30
Content.Client/Nutrition/Components/HungerComponent.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Nutrition.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class HungerComponent : SharedHungerComponent
|
||||
{
|
||||
private HungerThreshold _currentHungerThreshold;
|
||||
public override HungerThreshold CurrentHungerThreshold => _currentHungerThreshold;
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
|
||||
if (curState is not HungerComponentState hunger)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_currentHungerThreshold = hunger.CurrentThreshold;
|
||||
|
||||
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? movement))
|
||||
{
|
||||
movement.RefreshMovementSpeedModifiers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Content.Client/Nutrition/Components/ThirstComponent.cs
Normal file
30
Content.Client/Nutrition/Components/ThirstComponent.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Nutrition.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class ThirstComponent : SharedThirstComponent
|
||||
{
|
||||
private ThirstThreshold _currentThirstThreshold;
|
||||
public override ThirstThreshold CurrentThirstThreshold => _currentThirstThreshold;
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
|
||||
if (curState is not ThirstComponentState thirst)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_currentThirstThreshold = thirst.CurrentThreshold;
|
||||
|
||||
if (Owner.TryGetComponent(out MovementSpeedModifierComponent? movement))
|
||||
{
|
||||
movement.RefreshMovementSpeedModifiers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Content.Client/Nutrition/Visualizers/CreamPiedVisualizer.cs
Normal file
49
Content.Client/Nutrition/Visualizers/CreamPiedVisualizer.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Nutrition.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class CreamPiedVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("state")]
|
||||
private string? _state;
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
base.InitializeEntity(entity);
|
||||
|
||||
var sprite = entity.GetComponent<ISpriteComponent>();
|
||||
|
||||
sprite.LayerMapReserveBlank(CreamPiedVisualLayers.Pie);
|
||||
sprite.LayerSetRSI(CreamPiedVisualLayers.Pie, "Effects/creampie.rsi");
|
||||
sprite.LayerSetVisible(CreamPiedVisualLayers.Pie, false);
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
if (component.TryGetData<bool>(CreamPiedVisuals.Creamed, out var pied))
|
||||
{
|
||||
SetPied(component, pied);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPied(AppearanceComponent component, bool pied)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
|
||||
sprite.LayerSetVisible(CreamPiedVisualLayers.Pie, pied);
|
||||
sprite.LayerSetState(CreamPiedVisualLayers.Pie, _state);
|
||||
}
|
||||
}
|
||||
|
||||
public enum CreamPiedVisualLayers : byte
|
||||
{
|
||||
Pie,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Rounding;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Nutrition.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class FoodContainerVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("base_state", required: true)]
|
||||
private string? _baseState;
|
||||
|
||||
[DataField("steps", required: true)]
|
||||
private int _steps;
|
||||
|
||||
[DataField("mode")]
|
||||
private FoodContainerVisualMode _mode = FoodContainerVisualMode.Rounded;
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
|
||||
if (!component.TryGetData<int>(FoodContainerVisuals.Current, out var current))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!component.TryGetData<int>(FoodContainerVisuals.Capacity, out var capacity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int step;
|
||||
|
||||
switch (_mode)
|
||||
{
|
||||
case FoodContainerVisualMode.Discrete:
|
||||
step = Math.Min(_steps - 1, current);
|
||||
break;
|
||||
case FoodContainerVisualMode.Rounded:
|
||||
step = ContentHelpers.RoundToLevels(current, capacity, _steps);
|
||||
break;
|
||||
default:
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
|
||||
sprite.LayerSetState(0, $"{_baseState}-{step}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user