-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #610 from fospas/clawling
[PORT] Vent crawling
- Loading branch information
Showing
61 changed files
with
1,280 additions
and
7 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
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,33 @@ | ||
using Content.Client.SubFloor; | ||
using Content.Shared.VentCraw; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.VentCraw; | ||
|
||
public sealed class VentCrawSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] private readonly SubFloorHideSystem _subFloorHideSystem = default!; | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
|
||
if (!_timing.IsFirstTimePredicted) | ||
return; | ||
|
||
var player = _player.LocalPlayer?.ControlledEntity; | ||
|
||
var ventCraslerQuery = GetEntityQuery<VentCrawlerComponent>(); | ||
|
||
if (!ventCraslerQuery.TryGetComponent(player, out var playerVentCrawlerComponent)) | ||
{ | ||
_subFloorHideSystem.ShowVentPipe = false; | ||
return; | ||
} | ||
|
||
_subFloorHideSystem.ShowVentPipe = playerVentCrawlerComponent.InTube; | ||
} | ||
} |
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
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
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,106 @@ | ||
using Content.Server.Ghost; | ||
using Content.Server.Atmos.EntitySystems; | ||
using Content.Server.Body.Systems; | ||
using Content.Server.NodeContainer; | ||
using Content.Server.NodeContainer.EntitySystems; | ||
using Content.Server.NodeContainer.Nodes; | ||
using Content.Shared.Mind; | ||
using Content.Shared.Mobs; | ||
using Content.Shared.VentCraw.Components; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Server.VentCraw; | ||
|
||
public sealed class BeingVentCrawSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!; | ||
[Dependency] private readonly IEntityManager _entities = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<BeingVentCrawComponent, InhaleLocationEvent>(OnInhaleLocation); | ||
SubscribeLocalEvent<BeingVentCrawComponent, ExhaleLocationEvent>(OnExhaleLocation); | ||
SubscribeLocalEvent<BeingVentCrawComponent, AtmosExposedGetAirEvent>(OnGetAir); | ||
SubscribeLocalEvent<BeingVentCrawComponent, MobStateChangedEvent>(OnMobStateChanged); | ||
} | ||
|
||
private void OnMobStateChanged(EntityUid uid, BeingVentCrawComponent component, MobStateChangedEvent args) | ||
{ | ||
if (args.NewMobState != MobState.Dead || args.OldMobState != MobState.Critical) | ||
return; | ||
|
||
if (TryComp<ActorComponent>(uid, out var actor)) | ||
{ | ||
var session = actor.PlayerSession; | ||
|
||
var minds = _entities.System<SharedMindSystem>(); | ||
if (!minds.TryGetMind(session, out var mindId, out var mind)) | ||
{ | ||
mindId = minds.CreateMind(session.UserId); | ||
mind = _entities.GetComponent<MindComponent>(mindId); | ||
} | ||
|
||
_entities.System<GhostSystem>().OnGhostAttempt(mindId, true, true, mind); | ||
} | ||
} | ||
|
||
private void OnGetAir(EntityUid uid, BeingVentCrawComponent component, ref AtmosExposedGetAirEvent args) | ||
{ | ||
if (!TryComp<VentCrawHolderComponent>(component.Holder, out var holder)) | ||
return; | ||
|
||
if (holder.CurrentTube == null) | ||
return; | ||
|
||
if (!TryComp(holder.CurrentTube.Value, out NodeContainerComponent? nodeContainer)) | ||
return; | ||
foreach (var nodeContainerNode in nodeContainer.Nodes) | ||
{ | ||
if (!_nodeContainer.TryGetNode(nodeContainer, nodeContainerNode.Key, out PipeNode? pipe)) | ||
continue; | ||
args.Gas = pipe.Air; | ||
args.Handled = true; | ||
return; | ||
} | ||
} | ||
|
||
private void OnInhaleLocation(EntityUid uid, BeingVentCrawComponent component, InhaleLocationEvent args) | ||
{ | ||
if (!TryComp<VentCrawHolderComponent>(component.Holder, out var holder)) | ||
return; | ||
|
||
if (holder.CurrentTube == null) | ||
return; | ||
|
||
if (!TryComp(holder.CurrentTube.Value, out NodeContainerComponent? nodeContainer)) | ||
return; | ||
foreach (var nodeContainerNode in nodeContainer.Nodes) | ||
{ | ||
if (!_nodeContainer.TryGetNode(nodeContainer, nodeContainerNode.Key, out PipeNode? pipe)) | ||
continue; | ||
args.Gas = pipe.Air; | ||
return; | ||
} | ||
} | ||
|
||
private void OnExhaleLocation(EntityUid uid, BeingVentCrawComponent component, ExhaleLocationEvent args) | ||
{ | ||
if (!TryComp<VentCrawHolderComponent>(component.Holder, out var holder)) | ||
return; | ||
|
||
if (holder.CurrentTube == null) | ||
return; | ||
|
||
if (!TryComp(holder.CurrentTube.Value, out NodeContainerComponent? nodeContainer)) | ||
return; | ||
foreach (var nodeContainerNode in nodeContainer.Nodes) | ||
{ | ||
if (!_nodeContainer.TryGetNode(nodeContainer, nodeContainerNode.Key, out PipeNode? pipe)) | ||
continue; | ||
args.Gas = pipe.Air; | ||
return; | ||
} | ||
} | ||
} |
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,26 @@ | ||
using Content.Shared.Clothing; | ||
using Content.Shared.VentCraw.Components; | ||
using Content.Shared.VentCraw; | ||
|
||
namespace Content.Server.VentCraw; | ||
|
||
public sealed class VentCrawClothingSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<VentCrawClothingComponent, ClothingGotEquippedEvent>(OnClothingEquip); | ||
SubscribeLocalEvent<VentCrawClothingComponent, ClothingGotUnequippedEvent>(OnClothingUnequip); | ||
} | ||
|
||
private void OnClothingEquip(Entity<VentCrawClothingComponent> ent, ref ClothingGotEquippedEvent args) | ||
{ | ||
AddComp<VentCrawlerComponent>(args.Wearer); | ||
} | ||
|
||
private void OnClothingUnequip(Entity<VentCrawClothingComponent> ent, ref ClothingGotUnequippedEvent args) | ||
{ | ||
RemComp<VentCrawlerComponent>(args.Wearer); | ||
} | ||
} |
Oops, something went wrong.