Skip to content

Commit

Permalink
glasses healing myopia
Browse files Browse the repository at this point in the history
  • Loading branch information
nixsilvam404 authored and themanyfaceddemon committed Jul 1, 2024
1 parent 637f429 commit ae37801
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Content.Shared/ADT/Glasses/GlassesComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Traits.Assorted;

/// <summary>
/// This is used for making something blind forever.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class GlassesComponent : Component
{

}

49 changes: 49 additions & 0 deletions Content.Shared/ADT/Glasses/GlassesSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Content.Shared.Damage.Components;
using Content.Shared.Examine;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Eye.Blinding.Systems;
using Content.Shared.IdentityManagement;
using Robust.Shared.Network;
using Content.Shared.Inventory.Events;
using Content.Shared.Inventory;
using Content.Shared.Traits.Assorted;

namespace Content.Shared.Traits.Assorted;

/// <summary>
/// This handles permanent blindness, both the examine and the actual effect.
/// </summary>
public sealed class GlassesSystem : EntitySystem
{
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly BlindableSystem _blinding = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<GlassesComponent, GotEquippedEvent>(Equipped);
SubscribeLocalEvent<GlassesComponent, GotUnequippedEvent>(Unequipped);

}

private void Equipped(EntityUid uid, GlassesComponent component, ref GotEquippedEvent args)
{
if (!TryComp<MyopiaComponent>(args.Equipee, out var myopia))
return;
myopia.Active = false;
if (!TryComp<BlindableComponent>(args.Equipee, out var blindable))
return;
_blinding.AdjustEyeDamage((args.Equipee, blindable), -myopia.EyeDamage);
}

private void Unequipped(EntityUid uid, GlassesComponent component, ref GotUnequippedEvent args)
{
if (!TryComp<MyopiaComponent>(args.Equipee, out var myopia))
return;
myopia.Active = true;
if (!TryComp<BlindableComponent>(args.Equipee, out var blindable))
return;
_blinding.AdjustEyeDamage((args.Equipee, blindable), myopia.EyeDamage);
}
}
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
name: glasses
description: A pair of spectacular spectacles with prescription lenses.
components:
- type: Glasses
- type: Sprite
sprite: Clothing/Eyes/Glasses/glasses.rsi
- type: Clothing
Expand Down

0 comments on commit ae37801

Please sign in to comment.