Skip to content

Commit

Permalink
Upstream Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisfiregamer1 committed Nov 20, 2024
2 parents 6a1a4d3 + 5756a0e commit 4f84f43
Show file tree
Hide file tree
Showing 235 changed files with 13,387 additions and 5,423 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static AlertsUI FindAlertsUI(Control control)
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(2));
var alertControls = clientAlertsUI.AlertContainer.Children.Select(c => (AlertControl) c);
var alertIDs = alertControls.Select(ac => ac.Alert.ID).ToArray();
var expectedIDs = new[] { "HumanHealth", "Debug1", "Debug2" };
var expectedIDs = new[] { "Debug1", "Debug2" };
Assert.That(alertIDs, Is.SupersetOf(expectedIDs));
});

Expand All @@ -106,7 +106,7 @@ await client.WaitAssertion(() =>
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(1));
var alertControls = clientAlertsUI.AlertContainer.Children.Select(c => (AlertControl) c);
var alertIDs = alertControls.Select(ac => ac.Alert.ID).ToArray();
var expectedIDs = new[] { "HumanHealth", "Debug2" };
var expectedIDs = new[] { "Debug2" };
Assert.That(alertIDs, Is.SupersetOf(expectedIDs));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.Backmen.Body;
namespace Content.IntegrationTests.Tests.Shitmed.Body;

[TestFixture]
public sealed class SpeciesBUiTest
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Body/Systems/BodySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ protected override void AddPart(
var layer = partEnt.Comp.ToHumanoidLayers();
if (layer != null)
{
var layers = HumanoidVisualLayersExtension.Sublayers(layer.Value);
_humanoidSystem.SetLayersVisibility(
bodyEnt, layers, visible: true, permanent: true, humanoid);
bodyEnt, new[] { layer.Value }, visible: true, permanent: true, humanoid);
}
}
}
Expand Down Expand Up @@ -163,7 +162,8 @@ public override HashSet<EntityUid> GibPart(
var ev = new BeingGibbedEvent(gibs);
RaiseLocalEvent(partId, ref ev);

QueueDel(partId);
if (gibs.Any())
QueueDel(partId);

return gibs;
}
Expand Down
10 changes: 8 additions & 2 deletions Content.Server/Body/Systems/BrainSystem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Content.Server.Body.Components;
using Content.Server.Ghost.Components;
using Content.Shared.Body.Components;
using Content.Shared.Body.Systems;
using Content.Shared.Body.Events;
using Content.Shared.Body.Organ;
using Content.Server.DelayedDeath;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Pointing;
Expand All @@ -12,8 +14,8 @@ namespace Content.Server.Body.Systems
public sealed class BrainSystem : EntitySystem
{
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly SharedBodySystem _bodySystem = default!;

// Shitmed-Start
public override void Initialize()
{
base.Initialize();
Expand All @@ -30,17 +32,21 @@ private void HandleRemoval(EntityUid uid, BrainComponent _, ref OrganRemovedFrom

// Prevents revival, should kill the user within a given timespan too.
EnsureComp<DebrainedComponent>(args.OldBody);
EnsureComp<DelayedDeathComponent>(args.OldBody);
HandleMind(uid, args.OldBody);
}

private void HandleAddition(EntityUid uid, BrainComponent _, ref OrganAddedToBodyEvent args)
{
if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(args.Body))
return;

RemComp<DebrainedComponent>(args.Body);
if (_bodySystem.TryGetBodyOrganComponents<HeartComponent>(args.Body, out var _))
RemComp<DelayedDeathComponent>(args.Body);
HandleMind(args.Body, uid);
}
// Shitmed-End

private void HandleMind(EntityUid newEntity, EntityUid oldEntity)
{
if (TerminatingOrDeleted(newEntity) || TerminatingOrDeleted(oldEntity))
Expand Down
38 changes: 38 additions & 0 deletions Content.Server/Body/Systems/HeartSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Shared.Body.Components;
using Content.Shared.Body.Systems;
using Content.Shared.Body.Events;
using Content.Shared.Body.Organ;
using Content.Server.DelayedDeath;
using Content.Server.Body.Components;
namespace Content.Server.Body.Systems;

public sealed class HeartSystem : EntitySystem
{
[Dependency] private readonly SharedBodySystem _bodySystem = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<HeartComponent, OrganAddedToBodyEvent>(HandleAddition);
SubscribeLocalEvent<HeartComponent, OrganRemovedFromBodyEvent>(HandleRemoval);
}

private void HandleRemoval(EntityUid uid, HeartComponent _, ref OrganRemovedFromBodyEvent args)
{
if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(args.OldBody))
return;

// TODO: Add some form of very violent bleeding effect.
EnsureComp<DelayedDeathComponent>(args.OldBody);
}

private void HandleAddition(EntityUid uid, HeartComponent _, ref OrganAddedToBodyEvent args)
{
if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(args.Body))
return;

if (_bodySystem.TryGetBodyOrganComponents<BrainComponent>(args.Body, out var _))
RemComp<DelayedDeathComponent>(args.Body);
}
// Shitmed-End
}
4 changes: 2 additions & 2 deletions Content.Server/Body/Systems/RespiratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override void Update(float frameTime)

UpdateSaturation(uid, -(float) respirator.UpdateInterval.TotalSeconds, respirator);

if (!_mobState.IsIncapacitated(uid) || HasComp<DebrainedComponent>(uid)) // Shitmed: cannot breathe in crit or when no brain.
if (!_mobState.IsIncapacitated(uid) && !HasComp<DebrainedComponent>(uid)) // Shitmed: cannot breathe in crit or when no brain.
{
switch (respirator.Status)
{
Expand Down Expand Up @@ -185,7 +185,7 @@ private void TakeSuffocationDamage(Entity<RespiratorComponent> ent)
RaiseLocalEvent(ent, new MoodEffectEvent("Suffocating"));
}

_damageableSys.TryChangeDamage(ent, ent.Comp.Damage, interruptsDoAfters: false);
_damageableSys.TryChangeDamage(ent, HasComp<DebrainedComponent>(ent) ? ent.Comp.Damage * 4.5f : ent.Comp.Damage, interruptsDoAfters: false);
}

private void StopSuffocation(Entity<RespiratorComponent> ent)
Expand Down
16 changes: 16 additions & 0 deletions Content.Server/DelayedDeath/DelayedDeathComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Content.Server.DelayedDeath;

[RegisterComponent]
public sealed partial class DelayedDeathComponent : Component
{
/// <summary>
/// How long it takes to kill the entity.
/// </summary>
[DataField]
public float DeathTime = 60;

/// <summary>
/// How long it has been since the delayed death timer started.
/// </summary>
public float DeathTimer;
}
31 changes: 31 additions & 0 deletions Content.Server/DelayedDeath/DelayedDeathSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Shared.Body.Organ;
using Content.Shared.Body.Events;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.Mobs.Systems;
using Robust.Shared.Timing;
using Robust.Shared.Prototypes;
namespace Content.Server.DelayedDeath;

public partial class DelayedDeathSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;
public override void Update(float frameTime)
{
base.Update(frameTime);

using var query = EntityQueryEnumerator<DelayedDeathComponent>();
while (query.MoveNext(out var ent, out var component))
{
component.DeathTimer += frameTime;

if (component.DeathTimer >= component.DeathTime && !_mobState.IsDead(ent))
{
var damage = new DamageSpecifier(_prototypes.Index<DamageTypePrototype>("Bloodloss"), 150);
_damageable.TryChangeDamage(ent, damage, partMultiplier: 0f);
}
}
}
}
3 changes: 3 additions & 0 deletions Content.Server/LifeDrainer/LifeDrainerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Abilities.Psionics;
using Content.Server.Carrying;
using Content.Server.NPC.Systems;
using Content.Shared.ActionBlocker;
Expand Down Expand Up @@ -27,6 +28,7 @@ public sealed class LifeDrainerSystem : EntitySystem
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly PsionicAbilitiesSystem _psionicAbilitiesSystem = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -88,6 +90,7 @@ private void OnDrain(Entity<LifeDrainerComponent> ent, ref LifeDrainDoAfterEvent
_audio.PlayPvs(comp.FinishSound, uid);

_damageable.TryChangeDamage(target, comp.Damage, true, origin: uid);
_psionicAbilitiesSystem.MindBreak(target);
}

public bool CanDrain(Entity<LifeDrainerComponent> ent, EntityUid target)
Expand Down
38 changes: 14 additions & 24 deletions Content.Server/Medical/Surgery/SurgerySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ public override void Initialize()

SubscribeLocalEvent<SurgeryToolComponent, AfterInteractEvent>(OnToolAfterInteract);
SubscribeLocalEvent<SurgeryTargetComponent, SurgeryStepDamageEvent>(OnSurgeryStepDamage);
SubscribeLocalEvent<SurgeryDamageChangeEffectComponent, SurgeryStepEvent>(OnSurgeryDamageChange);
SubscribeLocalEvent<SurgerySpecialDamageChangeEffectComponent, SurgeryStepEvent>(OnSurgerySpecialDamageChange);
// You might be wondering "why aren't we using StepEvent for these two?" reason being that StepEvent fires off regardless of success on the previous functions
// so this would heal entities even if you had a used or incorrect organ.
SubscribeLocalEvent<SurgerySpecialDamageChangeEffectComponent, SurgeryStepDamageChangeEvent>(OnSurgerySpecialDamageChange);
SubscribeLocalEvent<SurgeryDamageChangeEffectComponent, SurgeryStepDamageChangeEvent>(OnSurgeryDamageChange);
SubscribeLocalEvent<SurgeryStepEmoteEffectComponent, SurgeryStepEvent>(OnStepScreamComplete);
SubscribeLocalEvent<SurgeryStepSpawnEffectComponent, SurgeryStepEvent>(OnStepSpawnComplete);
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReloaded);
Expand Down Expand Up @@ -130,37 +132,25 @@ private void OnToolAfterInteract(Entity<SurgeryToolComponent> ent, ref AfterInte
private void OnSurgeryStepDamage(Entity<SurgeryTargetComponent> ent, ref SurgeryStepDamageEvent args) =>
SetDamage(args.Body, args.Damage, args.PartMultiplier, args.User, args.Part);

private void OnSurgeryDamageChange(Entity<SurgeryDamageChangeEffectComponent> ent, ref SurgeryStepEvent args)
private void OnSurgerySpecialDamageChange(Entity<SurgerySpecialDamageChangeEffectComponent> ent, ref SurgeryStepDamageChangeEvent args)
{
// This unintentionally punishes the user if they have an organ in another hand that is already used.
// Imo surgery shouldn't let you automatically pick tools on both hands anyway, it should only use the one you've got in your selected hand.
if (ent.Comp.IsConsumable
&& args.Tools.Where(tool => TryComp<OrganComponent>(tool, out var organComp)
&& !_body.TrySetOrganUsed(tool, true, organComp)).Any())
return;
if (ent.Comp.DamageType == "Rot")
_rot.ReduceAccumulator(args.Body, TimeSpan.FromSeconds(2147483648)); // BEHOLD, SHITCODE THAT I JUST COPY PASTED. I'll redo it at some point, pinky swear :)
else if (ent.Comp.DamageType == "Eye"
&& TryComp(ent, out BlindableComponent? blindComp)
&& blindComp.EyeDamage > 0)
_blindableSystem.AdjustEyeDamage((args.Body, blindComp), -blindComp!.EyeDamage);
}

private void OnSurgeryDamageChange(Entity<SurgeryDamageChangeEffectComponent> ent, ref SurgeryStepDamageChangeEvent args)
{
var damageChange = ent.Comp.Damage;
if (HasComp<ForcedSleepingComponent>(args.Body))
damageChange = damageChange * ent.Comp.SleepModifier;

SetDamage(args.Body, damageChange, 0.5f, args.User, args.Part);
}

private void OnSurgerySpecialDamageChange(Entity<SurgerySpecialDamageChangeEffectComponent> ent, ref SurgeryStepEvent args)
{
if (ent.Comp.IsConsumable
&& args.Tools.Where(tool => TryComp<OrganComponent>(tool, out var organComp)
&& !_body.TrySetOrganUsed(tool, true, organComp)).Any())
return;

if (ent.Comp.DamageType == "Rot")
_rot.ReduceAccumulator(args.Body, TimeSpan.FromSeconds(2147483648)); // BEHOLD, SHITCODE THAT I JUST COPY PASTED. I'll redo it at some point, pinky swear :)
else if (ent.Comp.DamageType == "Eye"
&& TryComp(args.Body, out BlindableComponent? blindComp)
&& blindComp.EyeDamage > 0)
_blindableSystem.AdjustEyeDamage((args.Body, blindComp), -blindComp!.EyeDamage);
}

private void OnStepScreamComplete(Entity<SurgeryStepEmoteEffectComponent> ent, ref SurgeryStepEvent args)
{
if (HasComp<ForcedSleepingComponent>(args.Body))
Expand Down
94 changes: 94 additions & 0 deletions Content.Server/TimeCycle/TimeCycleSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using Robust.Shared.Timing;
using Robust.Shared.Prototypes;
using Robust.Shared.Map.Components;
using Content.Shared.TimeCycle;

namespace Content.Server.TimeCycle;

public sealed partial class TimeCycleSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

public override void Initialize()
{
base.Initialize();
}

public override void Update(float frameTime)
{
var curTime = _gameTiming.CurTime;
var query = EntityQueryEnumerator<TimeCycleComponent, MapLightComponent>();

while (query.MoveNext(out var mapid, out var timeComp, out var mapLightComp))
{
if (timeComp.Paused
|| curTime < timeComp.DelayTime)
continue;

// Should be used for developing time palletes or for debuging
// O-o-or... You can cosplay pucchi from JoJo 6 with his 'Made In Heaven'
timeComp.DelayTime = curTime + (timeComp.SpeedUp ? timeComp.SpeedUpMinuteDuration : timeComp.MinuteDuration);

// Pass minute of map time
timeComp.CurrentTime += TimeSpan.FromMinutes(1);

// Change ambient color
UpdateAmbientColor(mapid, timeComp, mapLightComp);
}

base.Update(frameTime);
}

private void UpdateAmbientColor(EntityUid mapid, TimeCycleComponent timeComp, MapLightComponent mapLightComp)
{
if (!_prototypeManager.TryIndex(timeComp.PalettePrototype, out TimeCyclePalettePrototype? timeEntries)
|| timeEntries is null)
return;

var timeInCycle = GetTimeInCycle(timeComp.CurrentTime);
mapLightComp.AmbientLightColor = GetInterpolatedColor(timeEntries, timeInCycle);
Dirty(mapid, mapLightComp);
}

// We should convert current 'TimeSpan' (with days) time into one day cycle time (in 24 hours)
private TimeSpan GetTimeInCycle(TimeSpan timeSpan) =>
TimeSpan.FromMilliseconds(timeSpan.TotalMilliseconds % TimeSpan.FromHours(24).TotalMilliseconds);

private Color GetInterpolatedColor(TimeCyclePalettePrototype proto, TimeSpan timeInCycle)
{
// If there is no one any time entries of palette - return black
if (proto.TimeEntries is null)
return Color.Black;

var currentTime = timeInCycle.TotalHours;
var startTime = -1;
var endTime = -1;

foreach (KeyValuePair<int, Color> kvp in proto.TimeEntries)
{
var hour = kvp.Key;
var color = kvp.Value;

if (hour <= currentTime)
startTime = hour;
else if (hour >= currentTime && endTime == -1)
endTime = hour;
}

if (startTime == -1)
startTime = 0;
else if (endTime == -1)
endTime = 23;

var entryStart = proto.TimeEntries[startTime];
var entryEnd = proto.TimeEntries[endTime];
var entryProgress = GetEntryProgress(TimeSpan.FromHours(startTime), TimeSpan.FromHours(endTime), timeInCycle);

return Color.InterpolateBetween(entryStart, entryEnd, entryProgress);
}

private float GetEntryProgress(TimeSpan startTime, TimeSpan endTime, TimeSpan currentTime) =>
((float)(currentTime.TotalMinutes - startTime.TotalMinutes) / (float)(endTime.TotalMinutes - startTime.TotalMinutes));

}
2 changes: 1 addition & 1 deletion Content.Server/Toolshed/Commands/VisualizeCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Content.Server.Administration;
using Content.Server.EUI;
using Content.Shared.Administration;
Expand Down
Loading

0 comments on commit 4f84f43

Please sign in to comment.