Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
CrimeMoot authored Nov 23, 2024
1 parent 72a8731 commit 0c81588
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 17 deletions.
9 changes: 4 additions & 5 deletions Content.Server/VentCraw/VentCrawTubeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ namespace Content.Server.VentCraw
{
public sealed class VentCrawTubeSystem : EntitySystem
{
[Dependency] private readonly SharedVentCrawableSystem _ventCrawableSystemSystem = default!;
[Dependency] private readonly SharedVentCrawableSystem _ventCrawableSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly VentCrawTubeSystem _ventCrawTubeSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedMoverController _mover = default!;
Expand Down Expand Up @@ -68,7 +67,7 @@ private void OnDoAfterEnterTube(EntityUid uid, VentCrawlerComponent component, E
if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null)
return;

_ventCrawTubeSystem.TryInsert(args.Args.Target.Value, args.Args.Used.Value);
TryInsert(args.Args.Target.Value, args.Args.Used.Value);

args.Handled = true;
}
Expand Down Expand Up @@ -212,13 +211,13 @@ private bool TryInsert(EntityUid uid, EntityUid entity, VentCrawEntryComponent?
var holder = Spawn(VentCrawEntryComponent.HolderPrototypeId, _transform.GetMapCoordinates(uid));
var holderComponent = Comp<VentCrawHolderComponent>(holder);

_ventCrawableSystemSystem.TryInsert(holder, entity, holderComponent);
_ventCrawableSystem.TryInsert(holder, entity, holderComponent);

_mover.SetRelay(entity, holder);
ventCrawlerComponent.InTube = true;
Dirty(entity, ventCrawlerComponent);

return _ventCrawableSystemSystem.EnterTube(holder, uid, holderComponent);
return _ventCrawableSystem.EnterTube(holder, uid, holderComponent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ protected void SetMoveInput(Entity<InputMoverComponent> entity, MoveButtons butt

// Relay the fact we had any movement event.
// TODO: Ideally we'd do these in a tick instead of out of sim.
Vector2 vector2 = DirVecForButtons(entity.Comp.HeldMoveButtons);
Vector2 vector2 = DirVecForButtons(buttons);
Vector2i vector2i = new Vector2i((int)vector2.X, (int)vector2.Y);
Direction dir = (vector2i == Vector2i.Zero) ? Direction.Invalid : vector2i.AsDirection();

var moveEvent = new MoveInputEvent(entity, entity.Comp.HeldMoveButtons, dir, entity.Comp.HeldMoveButtons != 0);
var moveEvent = new MoveInputEvent(entity, buttons, dir, buttons != 0);
entity.Comp.HeldMoveButtons = buttons;
RaiseLocalEvent(entity, ref moveEvent);
Dirty(entity, entity.Comp);
Expand Down
27 changes: 25 additions & 2 deletions Content.Shared/VentCraw/Components/BeingVentCrawComponent.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
namespace Content.Shared.VentCraw.Components;

/// <summary>
/// A component indicating that the entity is in the process of moving through the venting process
/// </summary>
[RegisterComponent]
public sealed partial class BeingVentCrawComponent : Component
{
[ViewVariables]
public EntityUid Holder;
/// <summary>
/// The entity that contains this object in the vent
/// </summary>
[DataField("holder")]
private EntityUid _holder;
/// <summary>
/// Gets or sets up a holder entity
/// </summary>
public EntityUid Holder
{
get => _holder;
set
{
if (_holder == value)
return;

if (value == default)
throw new ArgumentException("Holder cannot be default EntityUid");

_holder = value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ namespace Content.Shared.VentCraw.Components;
[RegisterComponent]
public sealed partial class VentCrawHolderComponent : Component
{
public Container Container = null!;
private Container? _container;
public Container Container
{
get => _container ?? throw new InvalidOperationException("Container not initialized");
set => _container = value;
}

[ViewVariables]
public float StartingTime { get; set; }
Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/VentCraw/Components/VentCrawTubeComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

namespace Content.Shared.VentCraw.Tube.Components;

/// <summary>
/// A component representing a vent that you can crawl through
/// </summary>
[RegisterComponent]
public sealed partial class VentCrawTubeComponent : Component
{
[DataField("containerId")]
public string ContainerId { get; set; } = "VentCrawTube";

[DataField("connected")]
public bool Connected;

[ViewVariables]
public Container Contents { get; set; } = default!;
public Container Contents { get; set; } = null!;
}

[ByRefEvent]
Expand Down
11 changes: 5 additions & 6 deletions Content.Shared/VentCraw/SharedVentCrawableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ public override void Initialize()
/// <param name="uid">The EntityUid of the VentCrawHolderComponent.</param>
/// <param name="component">The VentCrawHolderComponent instance.</param>
/// <param name="args">The MoveInputEvent arguments.</param>
private void OnMoveInput(EntityUid uid, VentCrawHolderComponent component, ref MoveInputEvent args)
private void OnMoveInput(EntityUid uid, VentCrawHolderComponent holder, ref MoveInputEvent args)
{
if (!TryComp<VentCrawHolderComponent>(uid, out var holder))
return;

if (!EntityManager.EntityExists(holder.CurrentTube))
{
var ev = new VentCrawExitEvent();
RaiseLocalEvent(uid, ref ev);
}

component.IsMoving = args.State;
component.CurrentDirection = args.Dir;
holder.IsMoving = args.State;
holder.CurrentDirection = args.Dir;
}

/// <summary>
Expand Down Expand Up @@ -146,6 +143,8 @@ public bool EnterTube(EntityUid holderUid, EntityUid toUid, VentCrawHolderCompon
RaiseLocalEvent(holderUid, ref ev);
return false;
}
if (TryComp<PhysicsComponent>(holderUid, out var physBody))
_physicsSystem.SetCanCollide(holderUid, false, body: physBody);

if (holder.CurrentTube != null)
{
Expand Down

0 comments on commit 0c81588

Please sign in to comment.