mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 21:48:58 +03:00
# Description Removes the ability to circumvent the effects of Blindness and Wheelchair User through surgery. Additionally tweaks glasses to better counteract nearsightedness and minor eye damage. Most glasses now mitigate 3 points of eye damage, fully countering the nearsighted penalty, while jamjars mitigate 3.5 points of eye damage. Also tweaks the starting amounts of eye damage given by Blindness and Nearsighted. Blindness gives 8 points of eye damage, up from 6 (this doesn't have any visual effect but makes glasses worse since visual effects cap at 6 points), and Nearsighted gives 3 points of eye damage, down from 4. --- <details><summary><h1>Media</h1></summary> <p>     (i'm trying to walk around after the surgery in the second video, prommy)   </p> </details> --- # Changelog 🆑 - tweak: Made Wheelchair User and Blindness permanent - tweak: Made Shortsighted less visually intense - tweak: Made glasses counteract eye damage better --------- Signed-off-by: Timfa <timfalken@hotmail.com> Co-authored-by: Timfa <timfalken@hotmail.com> (cherry picked from commit 0187c38b3a96220f133281adf311cf259b3f4e50)
91 lines
3.6 KiB
C#
91 lines
3.6 KiB
C#
using Content.Server.Body.Components;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Body.Events;
|
|
using Content.Shared._Shitmed.Body.Organ;
|
|
using Content.Shared.Eye.Blinding.Components;
|
|
using Content.Shared.Eye.Blinding.Systems;
|
|
|
|
namespace Content.Server.Body.Systems
|
|
{
|
|
public sealed class EyesSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
[Dependency] private readonly BlindableSystem _blindableSystem = default!;
|
|
[Dependency] private readonly BodySystem _bodySystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<EyesComponent, OrganEnabledEvent>(OnOrganEnabled);
|
|
SubscribeLocalEvent<EyesComponent, OrganDisabledEvent>(OnOrganDisabled);
|
|
}
|
|
|
|
private void HandleSight(EntityUid newEntity, EntityUid oldEntity)
|
|
{
|
|
if (TerminatingOrDeleted(newEntity) || TerminatingOrDeleted(oldEntity))
|
|
return;
|
|
|
|
BlindableComponent? newSight;
|
|
BlindableComponent? oldSight;
|
|
//transfer existing component to organ
|
|
if (!TryComp(newEntity, out newSight))
|
|
newSight = EnsureComp<BlindableComponent>(newEntity);
|
|
|
|
if (!TryComp(oldEntity, out oldSight))
|
|
oldSight = EnsureComp<BlindableComponent>(oldEntity);
|
|
|
|
//give new sight all values of old sight
|
|
_blindableSystem.TransferBlindness(newSight, oldSight, newEntity);
|
|
|
|
var hasOtherEyes = false;
|
|
//check for other eye components on owning body and owning body organs (if old entity has a body)
|
|
if (TryComp<BodyComponent>(oldEntity, out var body))
|
|
{
|
|
if (TryComp<EyesComponent>(oldEntity, out var bodyEyes)) //some bodies see through their skin!!! (slimes)
|
|
hasOtherEyes = true;
|
|
else
|
|
{
|
|
foreach (var (organ, _) in _bodySystem.GetBodyOrgans(oldEntity, body))
|
|
{
|
|
if (TryComp<EyesComponent>(organ, out var eyes))
|
|
{
|
|
hasOtherEyes = true;
|
|
break;
|
|
}
|
|
}
|
|
//TODO (MS14): Should we do this for body parts too? might be a little overpowered but could be funny/interesting
|
|
}
|
|
}
|
|
|
|
//if there are no existing eye components for the old entity - set old sight to be blind otherwise leave it as is
|
|
if (!hasOtherEyes && !TryComp<EyesComponent>(oldEntity, out var self))
|
|
_blindableSystem.AdjustEyeDamage((oldEntity, oldSight), oldSight.MaxDamage);
|
|
|
|
}
|
|
|
|
private void OnOrganEnabled(EntityUid uid, EyesComponent component, OrganEnabledEvent args)
|
|
{
|
|
if (TerminatingOrDeleted(uid)
|
|
|| args.Organ.Comp.Body is not { Valid: true } body)
|
|
return;
|
|
|
|
RemComp<TemporaryBlindnessComponent>(body);
|
|
HandleSight(uid, body);
|
|
if (TryComp<BlindableComponent>(body, out var incurable) && incurable.Incurable)
|
|
_blindableSystem.SetMinDamage(body, 8);
|
|
// hack fix, please remove if you fix eye damage transferring to eyes
|
|
}
|
|
|
|
private void OnOrganDisabled(EntityUid uid, EyesComponent component, OrganDisabledEvent args)
|
|
{
|
|
if (TerminatingOrDeleted(uid)
|
|
|| args.Organ.Comp.Body is not { Valid: true } body)
|
|
return;
|
|
|
|
EnsureComp<TemporaryBlindnessComponent>(body);
|
|
HandleSight(body, uid);
|
|
}
|
|
}
|
|
}
|