mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 16:47:26 +00:00
* Reapply "Nubody Merge" (#5807) This reverts commitd62f7cef10. * Revert "Nubody Merge (#5670)" This reverts commitb465cfb3fd. * Revert "IPC fibers (#4968)" This reverts commitc2b42211f0. * Revert "IPC Polymorph fix (#4545)" This reverts commitfa03d8c655. * Revert "fix IPC not having humanoid emotes (#4445)" This reverts commit216fdf999f. * Revert "ipc heat/cold (#4306)" This reverts commitfafd5cf816. * Revert "ipc cables (#4283)" This reverts commit54958039a1. * Revert "feat: ipcs now have dynamic power draw based off movement speed (#3917)" This reverts commit71e8b7e64b. * Revert "fix ipcs not being able to disarm (#3374)" This reverts commit764c4dcf54. * Revert "make steel heal caustic for ipcs (#3206)" This reverts commit450ac82550. * Revert "add missing ipc survival boxes (#3065)" This reverts commit888c9cdb00. * Revert "make borgs use ipc repairing (#3064)" This reverts commitf77a49dd0b. * Revert "Update hud.yml to add ipcs to diagnostic hud (#3019)" This reverts commit7220643531. * Revert "Tweak IPCs (#2979)" This reverts commit98b47476de. * Revert "fix nukies ipc test fail (#2957)" This reverts commit4a1acbf863. * Revert "fix ipc nukies not getting comms (#2884)" This reverts commit8a2254770e. * Revert "fix ipc encryption key mispredict (#2879)" This reverts commitf08726efc1. * Revert "Merge pull request #2800 from Spielern/port-ipc" This reverts commit822fa4312c, reversing changes made tofe4c23c702. * Remove and Fix rest of IPC Hangons causing crashes * Integration test Errors * Expand migration file with removed IPC stuff * IPC Leg was found and migrated to naught * Revert "Merge pull request #2542 from deltanedas/shitmed-ops" This reverts commit83a8002922, reversing changes made tobaa89b0052. * Revert "Set up surgical augments infrastructure & add tool panel augments (#3059)" This reverts commita40f0be6fd. * Revert "Psionic Prosthetics (#4689)" This reverts commit2679bb238a. * Revert "Add surgical cleanliness and sanitation (#2847)" This reverts commit64565ba4f7. * Remove unremoved mentions * Revert "Add autoclave to easily sanitize large amounts of items and faster (#2933)" This reverts commitd0da90fa2e. * Shit Med Removed * Remove _ShitMed Folders and fix Errors in Console * Add OrganAnimalBrain into the mirgraiton file * Heads no Input Mover * Monke * Full migration file I guess * oops * shiv state fix * Restore accidental deleted recipe * Forgot one flt mention * Fix more issues * Comment out Damage Visual for motorkind for now * Motorkind... * Commenting stuff out for now * thought there'd be more of this to gut --------- Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
217 lines
6.7 KiB
C#
217 lines
6.7 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Body.Events;
|
|
using Content.Shared.Body.Organ;
|
|
using Content.Shared.Body.Part;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Shared.Body.Systems;
|
|
|
|
public partial class SharedBodySystem
|
|
{
|
|
private void AddOrgan(
|
|
Entity<OrganComponent> organEnt,
|
|
EntityUid bodyUid,
|
|
EntityUid parentPartUid)
|
|
{
|
|
organEnt.Comp.Body = bodyUid;
|
|
var addedEv = new OrganAddedEvent(parentPartUid);
|
|
RaiseLocalEvent(organEnt, ref addedEv);
|
|
|
|
if (organEnt.Comp.Body is not null)
|
|
{
|
|
var addedInBodyEv = new OrganAddedToBodyEvent(bodyUid, parentPartUid);
|
|
RaiseLocalEvent(organEnt, ref addedInBodyEv);
|
|
}
|
|
|
|
Dirty(organEnt, organEnt.Comp);
|
|
}
|
|
|
|
private void RemoveOrgan(Entity<OrganComponent> organEnt, EntityUid parentPartUid)
|
|
{
|
|
var removedEv = new OrganRemovedEvent(parentPartUid);
|
|
RaiseLocalEvent(organEnt, ref removedEv);
|
|
|
|
if (organEnt.Comp.Body is { Valid: true } bodyUid)
|
|
{
|
|
var removedInBodyEv = new OrganRemovedFromBodyEvent(bodyUid, parentPartUid);
|
|
RaiseLocalEvent(organEnt, ref removedInBodyEv);
|
|
}
|
|
|
|
organEnt.Comp.Body = null;
|
|
Dirty(organEnt, organEnt.Comp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates the specified organ slot on the parent entity.
|
|
/// </summary>
|
|
private OrganSlot? CreateOrganSlot(Entity<BodyPartComponent?> parentEnt, string slotId)
|
|
{
|
|
if (!Resolve(parentEnt, ref parentEnt.Comp, logMissing: false))
|
|
return null;
|
|
|
|
Containers.EnsureContainer<ContainerSlot>(parentEnt, GetOrganContainerId(slotId));
|
|
// Shitmed Change: Don't throw when a slot already exists
|
|
if (parentEnt.Comp.Organs.TryGetValue(slotId, out var existing))
|
|
return existing;
|
|
|
|
var slot = new OrganSlot(slotId);
|
|
parentEnt.Comp.Organs.Add(slotId, slot);
|
|
return slot;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attempts to create the specified organ slot on the specified parent if it exists.
|
|
/// </summary>
|
|
public bool TryCreateOrganSlot(
|
|
EntityUid? parent,
|
|
string slotId,
|
|
[NotNullWhen(true)] out OrganSlot? slot,
|
|
BodyPartComponent? part = null)
|
|
{
|
|
slot = null;
|
|
|
|
if (parent is null || !Resolve(parent.Value, ref part, logMissing: false))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Containers.EnsureContainer<ContainerSlot>(parent.Value, GetOrganContainerId(slotId));
|
|
slot = new OrganSlot(slotId);
|
|
return part.Organs.TryAdd(slotId, slot.Value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns whether the slotId exists on the partId.
|
|
/// </summary>
|
|
public bool CanInsertOrgan(
|
|
EntityUid partId,
|
|
string slotId,
|
|
BodyPartComponent? part = null)
|
|
{
|
|
return Resolve(partId, ref part) && part.Organs.ContainsKey(slotId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns whether the specified organ slot exists on the partId.
|
|
/// </summary>
|
|
public bool CanInsertOrgan(
|
|
EntityUid partId,
|
|
OrganSlot slot,
|
|
BodyPartComponent? part = null)
|
|
{
|
|
return CanInsertOrgan(partId, slot.Id, part);
|
|
}
|
|
|
|
public bool InsertOrgan(
|
|
EntityUid partId,
|
|
EntityUid organId,
|
|
string slotId,
|
|
BodyPartComponent? part = null,
|
|
OrganComponent? organ = null)
|
|
{
|
|
if (!Resolve(organId, ref organ, logMissing: false)
|
|
|| !Resolve(partId, ref part, logMissing: false)
|
|
|| !CanInsertOrgan(partId, slotId, part))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var containerId = GetOrganContainerId(slotId);
|
|
|
|
return Containers.TryGetContainer(partId, containerId, out var container)
|
|
&& Containers.Insert(organId, container);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Removes the organ if it is inside of a body part.
|
|
/// </summary>
|
|
public bool RemoveOrgan(EntityUid organId, OrganComponent? organ = null)
|
|
{
|
|
if (!Containers.TryGetContainingContainer((organId, null, null), out var container))
|
|
return false;
|
|
|
|
var parent = container.Owner;
|
|
|
|
return HasComp<BodyPartComponent>(parent)
|
|
&& Containers.Remove(organId, container);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to add this organ to any matching slot on this body part.
|
|
/// </summary>
|
|
public bool AddOrganToFirstValidSlot(
|
|
EntityUid partId,
|
|
EntityUid organId,
|
|
BodyPartComponent? part = null,
|
|
OrganComponent? organ = null)
|
|
{
|
|
if (!Resolve(partId, ref part, logMissing: false)
|
|
|| !Resolve(organId, ref organ, logMissing: false))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
foreach (var slotId in part.Organs.Keys)
|
|
{
|
|
InsertOrgan(partId, organId, slotId, part, organ);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns a list of Entity<<see cref="T"/>, <see cref="OrganComponent"/>>
|
|
/// for each organ of the body
|
|
/// </summary>
|
|
/// <typeparam name="T">The component that we want to return</typeparam>
|
|
/// <param name="entity">The body to check the organs of</param>
|
|
public List<Entity<T, OrganComponent>> GetBodyOrganEntityComps<T>(
|
|
Entity<BodyComponent?> entity)
|
|
where T : IComponent
|
|
{
|
|
if (!Resolve(entity, ref entity.Comp))
|
|
return new List<Entity<T, OrganComponent>>();
|
|
|
|
var query = GetEntityQuery<T>();
|
|
var list = new List<Entity<T, OrganComponent>>(3);
|
|
foreach (var organ in GetBodyOrgans(entity.Owner, entity.Comp))
|
|
{
|
|
if (query.TryGetComponent(organ.Id, out var comp))
|
|
list.Add((organ.Id, comp, organ.Component));
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to get a list of ValueTuples of <see cref="T"/> and OrganComponent on each organs
|
|
/// in the given body.
|
|
/// </summary>
|
|
/// <param name="uid">The body entity id to check on.</param>
|
|
/// <param name="comps">The list of components.</param>
|
|
/// <param name="body">The body to check for organs on.</param>
|
|
/// <typeparam name="T">The component to check for.</typeparam>
|
|
/// <returns>Whether any were found.</returns>
|
|
public bool TryGetBodyOrganEntityComps<T>(
|
|
Entity<BodyComponent?> entity,
|
|
[NotNullWhen(true)] out List<Entity<T, OrganComponent>>? comps)
|
|
where T : IComponent
|
|
{
|
|
if (!Resolve(entity.Owner, ref entity.Comp))
|
|
{
|
|
comps = null;
|
|
return false;
|
|
}
|
|
|
|
comps = GetBodyOrganEntityComps<T>(entity);
|
|
|
|
if (comps.Count != 0)
|
|
return true;
|
|
|
|
comps = null;
|
|
return false;
|
|
}
|
|
}
|