QOL мед отдела (#3176)

This commit is contained in:
A-Mironov 2025-09-27 00:48:54 +03:00 committed by GitHub
parent cba2f71064
commit 1107d4350c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 69 additions and 4 deletions

View file

@ -40,6 +40,10 @@
<Label Name="TemperatureLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-blood-level-text'}" />
<Label Name="BloodLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-hunger-level-text'}" />
<Label Name="HungerLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-thirst-level-text'}" />
<Label Name="ThirstLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-damage-total-text'}" />
<Label Name="DamageLabel" />
</GridContainer>

View file

@ -99,6 +99,14 @@ namespace Content.Client.HealthAnalyzer.UI
? $"{msg.BloodLevel * 100:F1} %"
: Loc.GetString("health-analyzer-window-entity-unknown-value-text");
HungerLabel.Text = msg.HungerLevel.HasValue && !float.IsNaN(msg.HungerLevel.Value)
? $"{msg.HungerLevel.Value:F1} %"
: Loc.GetString("health-analyzer-window-entity-unknown-value-text");
ThirstLabel.Text = msg.ThirstLevel.HasValue && !float.IsNaN(msg.ThirstLevel.Value)
? $"{msg.ThirstLevel.Value:F1} %"
: Loc.GetString("health-analyzer-window-entity-unknown-value-text");
StatusLabel.Text =
_entityManager.TryGetComponent<MobStateComponent>(target.Value, out var mobStateComponent)
? GetStatus(mobStateComponent.CurrentState)

View file

@ -16,6 +16,7 @@ public sealed class BrainSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<BrainComponent, ComponentInit>(OnBrainInit);
SubscribeLocalEvent<BrainComponent, OrganAddedToBodyEvent>((uid, _, args) => HandleMind(args.Body, uid));
SubscribeLocalEvent<BrainComponent, OrganRemovedFromBodyEvent>((uid, _, args) => HandleMind(uid, args.OldBody));
SubscribeLocalEvent<BrainComponent, PointAttemptEvent>(OnPointAttempt);
@ -26,8 +27,12 @@ public sealed class BrainSystem : EntitySystem
if (TerminatingOrDeleted(newEntity) || TerminatingOrDeleted(oldEntity))
return;
EnsureComp<MindContainerComponent>(newEntity);
EnsureComp<MindContainerComponent>(oldEntity);
var newMindContainer = EnsureComp<MindContainerComponent>(newEntity);
var oldMindContainer = EnsureComp<MindContainerComponent>(oldEntity);
// Enable mind examination for brains
_mindSystem.SetExamineInfo(newEntity, true);
_mindSystem.SetExamineInfo(oldEntity, true);
var ghostOnMove = EnsureComp<GhostOnMoveComponent>(newEntity);
ghostOnMove.MustBeDead = HasComp<MobStateComponent>(newEntity); // Don't ghost living players out of their bodies.
@ -38,6 +43,14 @@ public sealed class BrainSystem : EntitySystem
_mindSystem.TransferTo(mindId, newEntity, mind: mind);
}
private void OnBrainInit(Entity<BrainComponent> ent, ref ComponentInit args)
{
// Ensure brain has mind container with examination enabled
var mindContainer = EnsureComp<MindContainerComponent>(ent);
// Use the mind system to set the examine info
_mindSystem.SetExamineInfo(ent, true);
}
private void OnPointAttempt(Entity<BrainComponent> ent, ref PointAttemptEvent args)
{
args.Cancel();

View file

@ -14,6 +14,8 @@ using Content.Shared.MedicalScanner;
using Content.Shared.Mobs.Components;
using Content.Shared.Popups;
using Content.Shared.Traits.Assorted;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Robust.Server.GameObjects;
namespace Content.Server.Medical;
@ -62,6 +64,22 @@ public sealed class HealthAnalyzerSystem : AbstractAnalyzerSystem<HealthAnalyzer
if (TryComp<UnrevivableComponent>(target, out var unrevivableComp) && unrevivableComp.Analyzable)
unrevivable = true;
// Collect hunger and thirst data as percentages
float hungerLevel = -1;
float thirstLevel = -1;
if (TryComp<HungerComponent>(target, out var hunger))
{
// Calculate hunger as percentage (max hunger is 200.0f from Overfed threshold)
hungerLevel = (hunger.LastAuthoritativeHungerValue / 200.0f) * 100.0f;
}
if (TryComp<ThirstComponent>(target, out var thirst))
{
// Calculate thirst as percentage (max thirst is 600.0f from OverHydrated threshold)
thirstLevel = (thirst.CurrentThirst / 600.0f) * 100.0f;
}
// Sunrise edit start - новый триггер
RaiseLocalEvent(target, new EntityAnalyzedEvent ());
// Sunrise edit end
@ -72,7 +90,9 @@ public sealed class HealthAnalyzerSystem : AbstractAnalyzerSystem<HealthAnalyzer
bloodAmount,
scanMode,
bleeding,
unrevivable
unrevivable,
hungerLevel,
thirstLevel
));
}

View file

@ -14,8 +14,10 @@ public sealed class HealthAnalyzerScannedUserMessage : BoundUserInterfaceMessage
public bool? ScanMode;
public bool? Bleeding;
public bool? Unrevivable;
public float? HungerLevel;
public float? ThirstLevel;
public HealthAnalyzerScannedUserMessage(NetEntity? targetEntity, float temperature, float bloodLevel, bool? scanMode, bool? bleeding, bool? unrevivable)
public HealthAnalyzerScannedUserMessage(NetEntity? targetEntity, float temperature, float bloodLevel, bool? scanMode, bool? bleeding, bool? unrevivable, float? hungerLevel = null, float? thirstLevel = null)
{
TargetEntity = targetEntity;
Temperature = temperature;
@ -23,6 +25,8 @@ public sealed class HealthAnalyzerScannedUserMessage : BoundUserInterfaceMessage
ScanMode = scanMode;
Bleeding = bleeding;
Unrevivable = unrevivable;
HungerLevel = hungerLevel;
ThirstLevel = thirstLevel;
}
}

View file

@ -155,6 +155,18 @@ public abstract partial class SharedMindSystem : EntitySystem
return mind.Value;
}
/// <summary>
/// Sets whether mind examination info should be shown for an entity.
/// </summary>
public void SetExamineInfo(EntityUid uid, bool showInfo)
{
if (TryComp<MindContainerComponent>(uid, out var mindContainer))
{
mindContainer.ShowExamineInfo = showInfo;
Dirty(uid, mindContainer);
}
}
private void OnVisitingTerminating(EntityUid uid, VisitingMindComponent component, ref EntityTerminatingEvent args)
{
if (component.MindId != null)

View file

@ -9,6 +9,8 @@ health-analyzer-window-entity-critical-text = Critical
health-analyzer-window-entity-temperature-text = Temperature:
health-analyzer-window-entity-blood-level-text = Blood Level:
health-analyzer-window-entity-hunger-level-text = Hunger:
health-analyzer-window-entity-thirst-level-text = Thirst:
health-analyzer-window-entity-status-text = Status:
health-analyzer-window-entity-damage-total-text = Total Damage:

View file

@ -7,6 +7,8 @@ health-analyzer-window-entity-dead-text = Мёртв
health-analyzer-window-entity-critical-text = Критическое состояние
health-analyzer-window-entity-temperature-text = Температура:
health-analyzer-window-entity-blood-level-text = Уровень крови:
health-analyzer-window-entity-hunger-level-text = Голод:
health-analyzer-window-entity-thirst-level-text = Жажда:
health-analyzer-window-entity-status-text = Статус:
health-analyzer-window-entity-damage-total-text = Общие повреждения:
health-analyzer-window-damage-group-text = { $damageGroup }: { $amount }