mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 14:07:53 +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)
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using Content.Shared.Eye.Blinding.Components;
|
|
using Content.Shared.Inventory.Events;
|
|
using Content.Shared.Inventory;
|
|
|
|
namespace Content.Shared.Eye.Blinding.Systems;
|
|
|
|
public sealed class BlurryVisionSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<VisionCorrectionComponent, GotEquippedEvent>(OnGlassesEquipped);
|
|
SubscribeLocalEvent<VisionCorrectionComponent, GotUnequippedEvent>(OnGlassesUnequipped);
|
|
SubscribeLocalEvent<VisionCorrectionComponent, InventoryRelayedEvent<GetBlurEvent>>(OnGetBlur);
|
|
}
|
|
|
|
private void OnGetBlur(Entity<VisionCorrectionComponent> glasses, ref InventoryRelayedEvent<GetBlurEvent> args)
|
|
{
|
|
args.Args.Blur += glasses.Comp.VisionBonus;
|
|
args.Args.CorrectionPower *= glasses.Comp.CorrectionPower;
|
|
}
|
|
|
|
public void UpdateBlurMagnitude(Entity<BlindableComponent?> ent)
|
|
{
|
|
if (!Resolve(ent.Owner, ref ent.Comp, false))
|
|
return;
|
|
|
|
var ev = new GetBlurEvent(ent.Comp.EyeDamage);
|
|
RaiseLocalEvent(ent, ev);
|
|
|
|
var blur = Math.Clamp(ev.Blur, 0, BlurryVisionComponent.MaxMagnitude);
|
|
///if (blur <= 0)
|
|
///{
|
|
/// RemCompDeferred<BlurryVisionComponent>(ent);
|
|
/// return;
|
|
///}
|
|
/// this makes prediction freak out when you put on glasses
|
|
|
|
var blurry = EnsureComp<BlurryVisionComponent>(ent);
|
|
blurry.Magnitude = blur;
|
|
blurry.CorrectionPower = ev.CorrectionPower;
|
|
Dirty(ent, blurry);
|
|
}
|
|
|
|
private void OnGlassesEquipped(Entity<VisionCorrectionComponent> glasses, ref GotEquippedEvent args)
|
|
{
|
|
UpdateBlurMagnitude(args.Equipee);
|
|
}
|
|
|
|
private void OnGlassesUnequipped(Entity<VisionCorrectionComponent> glasses, ref GotUnequippedEvent args)
|
|
{
|
|
UpdateBlurMagnitude(args.Equipee);
|
|
}
|
|
}
|
|
|
|
public sealed class GetBlurEvent : EntityEventArgs, IInventoryRelayEvent
|
|
{
|
|
public readonly float BaseBlur;
|
|
public float Blur;
|
|
public float CorrectionPower = BlurryVisionComponent.DefaultCorrectionPower;
|
|
|
|
public GetBlurEvent(float blur)
|
|
{
|
|
Blur = blur;
|
|
BaseBlur = blur;
|
|
}
|
|
|
|
public SlotFlags TargetSlots => SlotFlags.HEAD | SlotFlags.MASK | SlotFlags.EYES;
|
|
}
|