Skip to content

Commit

Permalink
Yet another shitmed update (DeltaV-Station#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
gluesniffler authored and deltanedas committed Dec 27, 2024
1 parent 468dc14 commit 6104945
Show file tree
Hide file tree
Showing 95 changed files with 1,660 additions and 205 deletions.
5 changes: 3 additions & 2 deletions Content.Shared/Body/Organ/OrganComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes; // Shitmed Change
using Content.Shared._Shitmed.Medical.Surgery; // Shitmed Change
using Content.Shared._Shitmed.Medical.Surgery.Tools; // Shitmed Change

namespace Content.Shared.Body.Organ;

[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedBodySystem))]
[Access(typeof(SharedBodySystem), typeof(SharedSurgerySystem))] // Shitmed Change
public sealed partial class OrganComponent : Component, ISurgeryToolComponent // Shitmed Change
{
/// <summary>
Expand Down Expand Up @@ -52,7 +53,7 @@ public sealed partial class OrganComponent : Component, ISurgeryToolComponent //
public ComponentRegistry? OnAdd;

/// <summary>
/// When removed, the organ will ensure these components on the entity, and add them on removal.
/// When removed, the organ will ensure these components on the entity, and delete them on insertion.
/// </summary>
[DataField]
public ComponentRegistry? OnRemove;
Expand Down
1 change: 0 additions & 1 deletion Content.Shared/Body/Systems/SharedBodySystem.Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ private void OnProfileLoadFinished(EntityUid uid, BodyComponent component, Profi
|| !Initialized(uid)) // We do this last one for urists on test envs.
return;

Logger.Debug($"{ToPrettyString(uid)}: ProfileLoadFinished with {HasComp<HumanoidAppearanceComponent>(uid)} and {component}");
foreach (var part in GetBodyChildren(uid, component))
EnsureComp<BodyPartAppearanceComponent>(part.Id);
}
Expand Down
4 changes: 3 additions & 1 deletion Content.Shared/Stealth/Components/StealthComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ public sealed class StealthComponentState : ComponentState
{
public readonly float Visibility;
public readonly TimeSpan? LastUpdated;
public readonly float MaxVisibility; // Shitmed Change
public readonly bool Enabled;

public StealthComponentState(float stealthLevel, TimeSpan? lastUpdated, bool enabled)
public StealthComponentState(float stealthLevel, TimeSpan? lastUpdated, float maxVisibility, bool enabled)
{
Visibility = stealthLevel;
LastUpdated = lastUpdated;
MaxVisibility = maxVisibility; // Shitmed Change
Enabled = enabled;
}
}
3 changes: 2 additions & 1 deletion Content.Shared/Stealth/SharedStealthSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected virtual void OnInit(EntityUid uid, StealthComponent component, Compone

private void OnStealthGetState(EntityUid uid, StealthComponent component, ref ComponentGetState args)
{
args.State = new StealthComponentState(component.LastVisibility, component.LastUpdated, component.Enabled);
args.State = new StealthComponentState(component.LastVisibility, component.LastUpdated, component.MaxVisibility, component.Enabled); // Shitmed Change
}

private void OnStealthHandleState(EntityUid uid, StealthComponent component, ref ComponentHandleState args)
Expand All @@ -109,6 +109,7 @@ private void OnStealthHandleState(EntityUid uid, StealthComponent component, ref
SetEnabled(uid, cast.Enabled, component);
component.LastVisibility = cast.Visibility;
component.LastUpdated = cast.LastUpdated;
component.MaxVisibility = cast.MaxVisibility; // Shitmed Change
}

private void OnMove(EntityUid uid, StealthOnMoveComponent component, ref MoveEvent args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public abstract partial class BatteryAmmoProviderComponent : AmmoProviderCompone
/// <summary>
/// How much battery it costs to fire once.
/// </summary>
[DataField("fireCost"), ViewVariables(VVAccess.ReadWrite)]
[DataField("fireCost")] // Shitmed Change
public float FireCost = 100;

// Batteries aren't predicted which means we need to track the battery and manually count it ourselves woo!
Expand All @@ -15,4 +15,4 @@ public abstract partial class BatteryAmmoProviderComponent : AmmoProviderCompone

[ViewVariables(VVAccess.ReadWrite)]
public int Capacity;
}
}
11 changes: 10 additions & 1 deletion Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,24 @@ private void OnBatteryHandleState(EntityUid uid, BatteryAmmoProviderComponent co
component.Capacity = state.MaxShots;
component.FireCost = state.FireCost;
UpdateAmmoCount(uid, prediction: false);

if (component is HitscanBatteryAmmoProviderComponent hitscan && state.Prototype != null) // Shitmed Change
hitscan.Prototype = state.Prototype;
}

private void OnBatteryGetState(EntityUid uid, BatteryAmmoProviderComponent component, ref ComponentGetState args)
{
args.State = new BatteryAmmoProviderComponentState()
var state = new BatteryAmmoProviderComponentState() // Shitmed Change
{
Shots = component.Shots,
MaxShots = component.Capacity,
FireCost = component.FireCost,
};

if (TryComp<HitscanBatteryAmmoProviderComponent>(uid, out var hitscan)) // Shitmed Change
state.Prototype = hitscan.Prototype;

args.State = state; // Shitmed Change
}

private void OnBatteryExamine(EntityUid uid, BatteryAmmoProviderComponent component, ExaminedEvent args)
Expand Down Expand Up @@ -116,5 +124,6 @@ private sealed class BatteryAmmoProviderComponentState : ComponentState
public int Shots;
public int MaxShots;
public float FireCost;
public string? Prototype; // Shitmed Change
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Shared._Shitmed.GoliathTentacle;

/// <summary>
/// Component that grants the entity the ability to use goliath tentacles.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class GoliathTentacleComponent : Component
{
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? Action = "ActionGoliathTentacleCrew";

[DataField, AutoNetworkedField]
public EntityUid? ActionEntity;
}
23 changes: 23 additions & 0 deletions Content.Shared/_Shitmed/Abilities/Goliath/GoliathTentacleSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Content.Shared.Actions;

namespace Content.Shared._Shitmed.GoliathTentacle;

internal sealed class GoliathTentacleSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<GoliathTentacleComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<GoliathTentacleComponent, ComponentShutdown>(OnShutdown);
}

private void OnStartup(EntityUid uid, GoliathTentacleComponent component, ComponentStartup args)
{
_actionsSystem.AddAction(uid, ref component.ActionEntity, component.Action);
}

private void OnShutdown(EntityUid uid, GoliathTentacleComponent component, ComponentShutdown args)
{
_actionsSystem.RemoveAction(uid, component.ActionEntity);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Shared.Body.Part;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared._Shitmed.Medical.Surgery.Conditions;

// <summary>
// What components are necessary in the body for the surgery to be valid.
// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class SurgeryBodyComponentConditionComponent : Component
{
// <summary>
// The components to check for.
// </summary>
[DataField(required: true)]
public ComponentRegistry Components;

// <summary>
// If true, the lack of these components will instead make the surgery valid.
// </summary>
[DataField]
public bool Inverse = false;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Shared.Body.Part;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared._Shitmed.Medical.Surgery.Conditions;

// <summary>
// What components are necessary in the part's organs' OnAdd fields for the surgery to be valid.
//
// Not all components need to be present (or missing for Inverse = true). At least one component matching (or missing) can make the surgery valid.
// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class SurgeryOrganOnAddConditionComponent : Component
{
// <summary>
// The components to check for on each organ, with the key being the organ's SlotId.
// </summary>
[DataField(required: true)]
public Dictionary<string, ComponentRegistry> Components;

// <summary>
// If true, the lack of these components will instead make the surgery valid.
// </summary>
[DataField]
public bool Inverse = false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Shared.Body.Part;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared._Shitmed.Medical.Surgery.Conditions;

// <summary>
// What components are necessary in the targeted body part for the surgery to be valid.
// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class SurgeryPartComponentConditionComponent : Component
{
// <summary>
// The components to check for.
// </summary>
[DataField(required: true)]
public ComponentRegistry Components;

// <summary>
// If true, the lack of these components will instead make the surgery valid.
// </summary>
[DataField]
public bool Inverse = false;
}
74 changes: 74 additions & 0 deletions Content.Shared/_Shitmed/Surgery/SharedSurgerySystem.Steps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.Body.Part;
using Content.Shared.Body.Organ;
using Content.Shared.Body.Events;
using Content.Shared._Shitmed.BodyEffects;
using Content.Shared._Shitmed.Body.Events;
using Content.Shared.Buckle.Components;
using Content.Shared.Containers.ItemSlots;
Expand Down Expand Up @@ -123,6 +124,47 @@ private void OnToolStep(Entity<SurgeryStepComponent> ent, ref SurgeryStepEvent a
}
}

// Dude this fucking function is so bloated now what the fuck.
if (ent.Comp.AddOrganOnAdd != null)
{
var organSlotIdToOrgan = _body.GetPartOrgans(args.Part).ToDictionary(o => o.Item2.SlotId, o => o);

foreach (var (organSlotId, compsToAdd) in ent.Comp.AddOrganOnAdd)
{
if (!organSlotIdToOrgan.TryGetValue(organSlotId, out var organValue))
continue;
var (organId, organ) = organValue;

organ.OnAdd ??= new();

foreach (var (key, compToAdd) in compsToAdd)
organ.OnAdd[key] = compToAdd;

EnsureComp<OrganEffectComponent>(organId);
RaiseLocalEvent(organId, new OrganComponentsModifyEvent(args.Body, true));
}
}

if (ent.Comp.RemoveOrganOnAdd != null)
{
var organSlotIdToOrgan = _body.GetPartOrgans(args.Part).ToDictionary(o => o.Item2.SlotId, o => o);

foreach (var (organSlotId, compsToRemove) in ent.Comp.RemoveOrganOnAdd)
{
if (!organSlotIdToOrgan.TryGetValue(organSlotId, out var organValue) ||
organValue.Item2.OnAdd == null)
continue;
var (organId, organ) = organValue;

// Need to raise this event first before removing the component entries so
// OrganEffectSystem still knows which components on the body to remove
RaiseLocalEvent(organId, new OrganComponentsModifyEvent(args.Body, false));
foreach (var key in compsToRemove.Keys)
organ.OnAdd.Remove(key);
}
}


//if (!HasComp<ForcedSleepingComponent>(args.Body))
// //RaiseLocalEvent(args.Body, new MoodEffectEvent("SurgeryPain"));
// No mood on Goob :(
Expand Down Expand Up @@ -188,6 +230,38 @@ private void OnToolCheck(Entity<SurgeryStepComponent> ent, ref SurgeryStepComple
}
}
}

if (ent.Comp.AddOrganOnAdd != null)
{
var organSlotIdToOrgan = _body.GetPartOrgans(args.Part).ToDictionary(o => o.Item2.SlotId, o => o.Item2);
foreach (var (organSlotId, compsToAdd) in ent.Comp.AddOrganOnAdd)
{
if (!organSlotIdToOrgan.TryGetValue(organSlotId, out var organ))
continue;

if (organ.OnAdd == null || compsToAdd.Keys.Any(key => !organ.OnAdd.ContainsKey(key)))
{
args.Cancelled = true;
return;
}
}
}

if (ent.Comp.RemoveOrganOnAdd != null)
{
var organSlotIdToOrgan = _body.GetPartOrgans(args.Part).ToDictionary(o => o.Item2.SlotId, o => o.Item2);
foreach (var (organSlotId, compsToRemove) in ent.Comp.RemoveOrganOnAdd)
{
if (!organSlotIdToOrgan.TryGetValue(organSlotId, out var organ) || organ.OnAdd == null)
continue;

if (compsToRemove.Keys.Any(key => organ.OnAdd.ContainsKey(key)))
{
args.Cancelled = true;
return;
}
}
}
}

private void OnToolCanPerform(Entity<SurgeryStepComponent> ent, ref SurgeryCanPerformStepEvent args)
Expand Down
Loading

0 comments on commit 6104945

Please sign in to comment.