Skip to content

Commit

Permalink
Little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Sep 1, 2024
1 parent c4e7545 commit 2b87187
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
4 changes: 3 additions & 1 deletion Content.Client/Telescope/TelescopeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public override void FrameUpdate(float frameTime)
{
base.FrameUpdate(frameTime);

if (_timing.ApplyingState || !_timing.IsFirstTimePredicted || !_input.MouseScreenPosition.IsValid)
if (_timing.ApplyingState
|| !_timing.IsFirstTimePredicted
|| !_input.MouseScreenPosition.IsValid)
return;

var player = _player.LocalEntity;
Expand Down
25 changes: 9 additions & 16 deletions Content.Shared/Telescope/SharedTelescopeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public override void Initialize()

private void OnShutdown(Entity<TelescopeComponent> ent, ref ComponentShutdown args)
{
if (!TryComp(ent.Comp.LastEntity, out EyeComponent? eye) || ent.Comp.LastEntity == ent && TerminatingOrDeleted(ent))
if (!TryComp(ent.Comp.LastEntity, out EyeComponent? eye)
|| ent.Comp.LastEntity == ent && TerminatingOrDeleted(ent))
return;

SetOffset((ent.Comp.LastEntity.Value, eye), Vector2.Zero, ent);
Expand All @@ -39,10 +40,8 @@ private void OnHandDeselected(Entity<TelescopeComponent> ent, ref HandDeselected

private void OnUnequip(Entity<TelescopeComponent> ent, ref GotUnequippedHandEvent args)
{
if (!TryComp(args.User, out EyeComponent? eye))
return;

if (!HasComp<ItemComponent>(ent.Owner))
if (!TryComp(args.User, out EyeComponent? eye)
|| !HasComp<ItemComponent>(ent.Owner))
return;

SetOffset((args.User, eye), Vector2.Zero, ent);
Expand All @@ -52,26 +51,20 @@ private void OnUnequip(Entity<TelescopeComponent> ent, ref GotUnequippedHandEven
{
TelescopeComponent? telescope = null;

if (TryComp<HandsComponent>(ent, out var hands) &&
hands.ActiveHandEntity.HasValue &&
TryComp<TelescopeComponent>(hands.ActiveHandEntity, out var handTelescope))
{
if (TryComp<HandsComponent>(ent, out var hands)
&& hands.ActiveHandEntity.HasValue
&& TryComp<TelescopeComponent>(hands.ActiveHandEntity, out var handTelescope))
telescope = handTelescope;
}
else if (TryComp<TelescopeComponent>(ent, out var entityTelescope))
{
telescope = entityTelescope;
}

return telescope;
}

private void OnEyeOffsetChanged(EyeOffsetChangedEvent msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not { } ent)
return;

if (!TryComp(ent, out EyeComponent? eye))
if (args.SenderSession.AttachedEntity is not { } ent
|| !TryComp<EyeComponent>(ent, out var eye))
return;

var telescope = GetRightTelescope(ent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
- CartridgeAntiMateriel
capacity: 5
proto: CartridgeAntiMateriel
- type: Telescope # WD EDIT
- type: Telescope

- type: entity
name: musket
Expand Down
1 change: 0 additions & 1 deletion Resources/keybinds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ binds:
- function: Hotbar9
type: State
key: Num9
#WD EDIT
- function: LookUp
type: State
key: Space

0 comments on commit 2b87187

Please sign in to comment.