mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 00:27:59 +00:00
* Nubody (#42419) * Nubody * fix test fails * gibbing * lung test returns * doc comment * hand organ test * giblet test * yaml formatting * returning * relocate * trimming * re-smite * oops thusd tweak * arachnids have slower metabolism i guess * never mind the old behaviour is bad actually * rider whyyy * style changes and allat * fix collision --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * C# files done * Visual nubody (humanoid appearance refactor) (#42476) * initial visual nubody * oops overlay * im so pheeming rn * conversion... * tests * comeback of the underwear * oops eyes * blabbl * zeds * yaml linted * search and visible count constraints * reordering * preserve previously selected markings colors * fix test * some ui niceties * ordering * make DB changes backwards-compatible/downgrade-friendly * fix things again * fix migration * vulpkanin markings limit increase * wrapping * code cleanup and more code cleanup and more code cleanup and more code cleanup and * fix slop ports * better sampling API * make filter work + use the method i made for its intended purpose * fix test fails real quick * magic mirror cleanup, remove TODO * don't 0-init the organ profile data * remove deltastates --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Let vox eat trash again (#42503) * C# complete port * Getting closer * Harpy Nubody Port * Port Feroxi, Kitsune. Fix some yml typos and remove ipcs stuff * Port Oni * Port Rest, except Motorkind * Port Motorkind * Remove more surgery, restore too much deleted stuff * Fix Typos and change some organ names. Need to split eyes next * Harpy HAve Wings again * Some fixes, More Surgeyr Removal, Copying of eye organs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use correct Body imports * Markings Refactoring, Harpy Layering * Motorkind doesn't crash anymore. Some layer remappings. * Allow Organs to have Markings Displacements again. (#43604) * first shtep * readd markings support --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix STalk eyes and several layerings * Fix sexed organs (#42554) * Fix markings for several species, fit them for sexed organs and rename some files to fit them for it * Additional IPC-related removals * Vulpkanin eyes are now correct again * Fix Subtle Cultist Marks on species * Fix Asakim Sprites (sexed) and make CD imports work * Migration, error fixes, and Height * Fix humanoid profile voice being broken (#42550) Fix humanoid appearance voice being broken * Change Kitsune SexChanged Event to with ref * Fix asakim issue, Respirator fix * Simplify hands UI code (#42534) * Simplify hands UI code * i remembered about SortedHands in the component * minor cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Set size of Analyzer back to 350, Kitsune can't gib themselves no more. Migration * yml linter errors and an rudimentary onAdd Organ Functionality * Fixing it trying to remove nothing * midpoint migration * Why do you put so many organs everywhere * More missing prototypes * Migration of more organs * Forgot lungs * Move character preview handling into a specialized control (#41252) * Move character preview handling into a specialized control Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> * Restore job name that I accidentally removed from character picker buttons * Just resolve dependencies the standard way --------- Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Janet Blackquill <uhhadd@gmail.com> * Drop ICharacterProfile/ICharacterAppearance interfaces (#42661) * Ensure profile loading only returns valid species (#42842) (Stable merge) (#42865) Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> * Changes to make it work for us. * No more bald Harpy * OperatingTables instead of null * Adding Delta V Comments, commenting out instead of deleting * Fix broken Height Scale. * Remove HumanoidSilicon Mention * Did an error. Readded, uncommented. * Clean up Marking data structure, add tests for Zombie transformation (#42756) * Clean up Marking data structure, add tests for Zombie transformation * empty * AAAAAAAAAAAAAAAA --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> * Fix markings colour setting (#42771) * Fix: Markings Color For Downstream * Comment out A Leg. Remove Todo * Revert to original hidden species code --------- Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Co-authored-by: Absotively <jen@jenpollock.ca> Co-authored-by: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Co-authored-by: Myra <vasilis@pikachu.systems>
251 lines
9.7 KiB
C#
251 lines
9.7 KiB
C#
using Content.Server.Cloning;
|
|
using Content.Server.Medical.Components;
|
|
using Content.Shared.Destructible;
|
|
using Content.Shared.ActionBlocker;
|
|
using Content.Shared.DragDrop;
|
|
using Content.Shared.Movement.Events;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Containers;
|
|
using Content.Server.Cloning.Components;
|
|
using Content.Server.DeviceLinking.Systems;
|
|
using Content.Shared.DeviceLinking.Events;
|
|
using Content.Server.Power.EntitySystems;
|
|
using Content.Shared.Body;
|
|
using Content.Shared.Climbing.Systems;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Robust.Server.Containers;
|
|
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent; // Hmm...
|
|
|
|
namespace Content.Server.Medical
|
|
{
|
|
public sealed class MedicalScannerSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
|
[Dependency] private readonly ClimbSystem _climbSystem = default!;
|
|
[Dependency] private readonly CloningConsoleSystem _cloningConsoleSystem = default!;
|
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
|
[Dependency] private readonly ContainerSystem _containerSystem = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
|
|
private const float UpdateRate = 1f;
|
|
private float _updateDif;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<MedicalScannerComponent, ComponentInit>(OnComponentInit);
|
|
SubscribeLocalEvent<MedicalScannerComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
|
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<InteractionVerb>>(AddInsertOtherVerb);
|
|
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
|
|
SubscribeLocalEvent<MedicalScannerComponent, DestructionEventArgs>(OnDestroyed);
|
|
SubscribeLocalEvent<MedicalScannerComponent, DragDropTargetEvent>(OnDragDropOn);
|
|
SubscribeLocalEvent<MedicalScannerComponent, PortDisconnectedEvent>(OnPortDisconnected);
|
|
SubscribeLocalEvent<MedicalScannerComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
|
SubscribeLocalEvent<MedicalScannerComponent, CanDropTargetEvent>(OnCanDragDropOn);
|
|
}
|
|
|
|
private void OnCanDragDropOn(EntityUid uid, MedicalScannerComponent component, ref CanDropTargetEvent args)
|
|
{
|
|
args.Handled = true;
|
|
args.CanDrop |= CanScannerInsert(uid, args.Dragged, component);
|
|
}
|
|
|
|
public bool CanScannerInsert(EntityUid uid, EntityUid target, MedicalScannerComponent? component = null)
|
|
{
|
|
if (!Resolve(uid, ref component))
|
|
return false;
|
|
|
|
return HasComp<BodyComponent>(target);
|
|
}
|
|
|
|
private void OnComponentInit(EntityUid uid, MedicalScannerComponent scannerComponent, ComponentInit args)
|
|
{
|
|
base.Initialize();
|
|
scannerComponent.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, $"scanner-bodyContainer");
|
|
_signalSystem.EnsureSinkPorts(uid, MedicalScannerComponent.ScannerPort);
|
|
}
|
|
|
|
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent scannerComponent, ref ContainerRelayMovementEntityEvent args)
|
|
{
|
|
if (!_blocker.CanInteract(args.Entity, uid))
|
|
return;
|
|
|
|
EjectBody(uid, scannerComponent);
|
|
}
|
|
|
|
private void AddInsertOtherVerb(EntityUid uid, MedicalScannerComponent component, GetVerbsEvent<InteractionVerb> args)
|
|
{
|
|
if (args.Using == null ||
|
|
!args.CanAccess ||
|
|
!args.CanInteract ||
|
|
IsOccupied(component) ||
|
|
!CanScannerInsert(uid, args.Using.Value, component))
|
|
return;
|
|
|
|
var name = "Unknown";
|
|
if (TryComp(args.Using.Value, out MetaDataComponent? metadata))
|
|
name = metadata.EntityName;
|
|
|
|
InteractionVerb verb = new()
|
|
{
|
|
Act = () => InsertBody(uid, args.Target, component),
|
|
Category = VerbCategory.Insert,
|
|
Text = name
|
|
};
|
|
args.Verbs.Add(verb);
|
|
}
|
|
|
|
private void AddAlternativeVerbs(EntityUid uid, MedicalScannerComponent component, GetVerbsEvent<AlternativeVerb> args)
|
|
{
|
|
if (!args.CanAccess || !args.CanInteract)
|
|
return;
|
|
|
|
// Eject verb
|
|
if (IsOccupied(component))
|
|
{
|
|
AlternativeVerb verb = new()
|
|
{
|
|
Act = () => EjectBody(uid, component),
|
|
Category = VerbCategory.Eject,
|
|
Text = Loc.GetString("medical-scanner-verb-noun-occupant"),
|
|
Priority = 1 // Promote to top to make ejecting the ALT-click action
|
|
};
|
|
args.Verbs.Add(verb);
|
|
}
|
|
|
|
// Self-insert verb
|
|
if (!IsOccupied(component) &&
|
|
CanScannerInsert(uid, args.User, component) &&
|
|
_blocker.CanMove(args.User))
|
|
{
|
|
AlternativeVerb verb = new()
|
|
{
|
|
Act = () => InsertBody(uid, args.User, component),
|
|
Text = Loc.GetString("medical-scanner-verb-enter")
|
|
};
|
|
args.Verbs.Add(verb);
|
|
}
|
|
}
|
|
|
|
private void OnDestroyed(EntityUid uid, MedicalScannerComponent scannerComponent, DestructionEventArgs args)
|
|
{
|
|
EjectBody(uid, scannerComponent);
|
|
}
|
|
|
|
private void OnDragDropOn(EntityUid uid, MedicalScannerComponent scannerComponent, ref DragDropTargetEvent args)
|
|
{
|
|
InsertBody(uid, args.Dragged, scannerComponent);
|
|
}
|
|
|
|
private void OnPortDisconnected(EntityUid uid, MedicalScannerComponent component, PortDisconnectedEvent args)
|
|
{
|
|
component.ConnectedConsole = null;
|
|
}
|
|
|
|
private void OnAnchorChanged(EntityUid uid, MedicalScannerComponent component, ref AnchorStateChangedEvent args)
|
|
{
|
|
if (component.ConnectedConsole == null || !TryComp<CloningConsoleComponent>(component.ConnectedConsole, out var console))
|
|
return;
|
|
|
|
if (args.Anchored)
|
|
{
|
|
_cloningConsoleSystem.RecheckConnections(component.ConnectedConsole.Value, console.CloningPod, uid, console);
|
|
return;
|
|
}
|
|
_cloningConsoleSystem.UpdateUserInterface(component.ConnectedConsole.Value, console);
|
|
}
|
|
private MedicalScannerStatus GetStatus(EntityUid uid, MedicalScannerComponent scannerComponent)
|
|
{
|
|
if (this.IsPowered(uid, EntityManager))
|
|
{
|
|
var body = scannerComponent.BodyContainer.ContainedEntity;
|
|
if (body == null)
|
|
return MedicalScannerStatus.Open;
|
|
|
|
if (!TryComp<MobStateComponent>(body.Value, out var state))
|
|
{ // Is not alive or dead or critical
|
|
return MedicalScannerStatus.Yellow;
|
|
}
|
|
|
|
return GetStatusFromDamageState(body.Value, state);
|
|
}
|
|
return MedicalScannerStatus.Off;
|
|
}
|
|
|
|
public static bool IsOccupied(MedicalScannerComponent scannerComponent)
|
|
{
|
|
return scannerComponent.BodyContainer.ContainedEntity != null;
|
|
}
|
|
|
|
private MedicalScannerStatus GetStatusFromDamageState(EntityUid uid, MobStateComponent state)
|
|
{
|
|
if (_mobStateSystem.IsAlive(uid, state))
|
|
return MedicalScannerStatus.Green;
|
|
|
|
if (_mobStateSystem.IsCritical(uid, state))
|
|
return MedicalScannerStatus.Red;
|
|
|
|
if (_mobStateSystem.IsDead(uid, state))
|
|
return MedicalScannerStatus.Death;
|
|
|
|
return MedicalScannerStatus.Yellow;
|
|
}
|
|
|
|
private void UpdateAppearance(EntityUid uid, MedicalScannerComponent scannerComponent)
|
|
{
|
|
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
|
{
|
|
_appearance.SetData(uid, MedicalScannerVisuals.Status, GetStatus(uid, scannerComponent), appearance);
|
|
}
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
_updateDif += frameTime;
|
|
if (_updateDif < UpdateRate)
|
|
return;
|
|
|
|
_updateDif -= UpdateRate;
|
|
|
|
var query = EntityQueryEnumerator<MedicalScannerComponent>();
|
|
while (query.MoveNext(out var uid, out var scanner))
|
|
{
|
|
UpdateAppearance(uid, scanner);
|
|
}
|
|
}
|
|
|
|
public void InsertBody(EntityUid uid, EntityUid to_insert, MedicalScannerComponent? scannerComponent)
|
|
{
|
|
if (!Resolve(uid, ref scannerComponent))
|
|
return;
|
|
|
|
if (scannerComponent.BodyContainer.ContainedEntity != null)
|
|
return;
|
|
|
|
if (!HasComp<BodyComponent>(to_insert))
|
|
return;
|
|
|
|
_containerSystem.Insert(to_insert, scannerComponent.BodyContainer);
|
|
UpdateAppearance(uid, scannerComponent);
|
|
}
|
|
|
|
public void EjectBody(EntityUid uid, MedicalScannerComponent? scannerComponent)
|
|
{
|
|
if (!Resolve(uid, ref scannerComponent))
|
|
return;
|
|
|
|
if (scannerComponent.BodyContainer.ContainedEntity is not { Valid: true } contained)
|
|
return;
|
|
|
|
_containerSystem.Remove(contained, scannerComponent.BodyContainer);
|
|
_climbSystem.ForciblySetClimbing(contained, uid);
|
|
UpdateAppearance(uid, scannerComponent);
|
|
}
|
|
}
|
|
}
|