forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove wireless surgery (space-wizards#2785)
* Remove wireless surgery * Change surgery window title to Surgery * Remove todo * Check only tools with a window open
- Loading branch information
1 parent
0207a32
commit 127ffe0
Showing
5 changed files
with
136 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Content.Server/GameObjects/Components/Body/Surgery/Messages/SurgeryWindowCloseMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Content.Server.GameObjects.Components.Body.Surgery.Messages | ||
{ | ||
public class SurgeryWindowCloseMessage | ||
{ | ||
public SurgeryWindowCloseMessage(SurgeryToolComponent tool) | ||
{ | ||
Tool = tool; | ||
} | ||
|
||
public SurgeryToolComponent Tool { get; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Content.Server/GameObjects/Components/Body/Surgery/Messages/SurgeryWindowOpenMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Robust.Shared.GameObjects; | ||
|
||
namespace Content.Server.GameObjects.Components.Body.Surgery.Messages | ||
{ | ||
public class SurgeryWindowOpenMessage : ComponentMessage | ||
{ | ||
public SurgeryWindowOpenMessage(SurgeryToolComponent tool) | ||
{ | ||
Tool = tool; | ||
} | ||
|
||
public SurgeryToolComponent Tool { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Content.Server/GameObjects/EntitySystems/Body/Surgery/SurgeryToolSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Collections.Generic; | ||
using Content.Server.GameObjects.Components.Body.Surgery; | ||
using Content.Server.GameObjects.Components.Body.Surgery.Messages; | ||
using Content.Shared.GameObjects.EntitySystems; | ||
using Content.Shared.GameTicking; | ||
using Content.Shared.Utility; | ||
using JetBrains.Annotations; | ||
using Robust.Shared.GameObjects.Systems; | ||
|
||
namespace Content.Server.GameObjects.EntitySystems.Body.Surgery | ||
{ | ||
[UsedImplicitly] | ||
public class SurgeryToolSystem : EntitySystem, IResettingEntitySystem | ||
{ | ||
private readonly HashSet<SurgeryToolComponent> _openSurgeryUIs = new(); | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SurgeryWindowOpenMessage>(OnSurgeryWindowOpen); | ||
SubscribeLocalEvent<SurgeryWindowCloseMessage>(OnSurgeryWindowClose); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
_openSurgeryUIs.Clear(); | ||
} | ||
|
||
private void OnSurgeryWindowOpen(SurgeryWindowOpenMessage ev) | ||
{ | ||
_openSurgeryUIs.Add(ev.Tool); | ||
} | ||
|
||
private void OnSurgeryWindowClose(SurgeryWindowCloseMessage ev) | ||
{ | ||
_openSurgeryUIs.Remove(ev.Tool); | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
foreach (var tool in _openSurgeryUIs) | ||
{ | ||
if (tool.PerformerCache == null) | ||
{ | ||
continue; | ||
} | ||
|
||
if (tool.BodyCache == null) | ||
{ | ||
continue; | ||
} | ||
|
||
if (!ActionBlockerSystem.CanInteract(tool.PerformerCache) || | ||
!tool.PerformerCache.InRangeUnobstructed(tool.BodyCache)) | ||
{ | ||
tool.CloseAllSurgeryUIs(); | ||
} | ||
} | ||
} | ||
} | ||
} |