Skip to content

Commit

Permalink
Merge branch 'master' into akupara-fan-compliance-and-wire-fix-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
tonotom1 authored Sep 20, 2024
2 parents e260836 + bbd4841 commit 895ecc2
Show file tree
Hide file tree
Showing 255 changed files with 4,692 additions and 2,182 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared.Nyanotrasen.Item.PseudoItem;

namespace Content.Client.Nyanotrasen.Item.PseudoItem;

public sealed class PseudoItemSystem : SharedPseudoItemSystem
{
}
199 changes: 109 additions & 90 deletions Content.Server/Nyanotrasen/Carrying/CarryingSystem.cs

Large diffs are not rendered by default.

This file was deleted.

170 changes: 20 additions & 150 deletions Content.Server/Nyanotrasen/Item/PseudoItem/PseudoItemSystem.cs
Original file line number Diff line number Diff line change
@@ -1,88 +1,50 @@
using Content.Server.Actions;
using Content.Server.Carrying;
using Content.Server.Carrying;
using Content.Server.DoAfter;
using Content.Server.Item;
using Content.Server.Popups;
using Content.Server.Storage.EntitySystems;
using Content.Shared.Bed.Sleep;
using Content.Shared.DoAfter;
using Content.Shared.Hands;
using Content.Shared.IdentityManagement;
using Content.Shared.Item;
using Content.Shared.Item.PseudoItem;
using Content.Shared.Nyanotrasen.Item.PseudoItem;
using Content.Shared.Storage;
using Content.Shared.Tag;
using Content.Shared.Verbs;
using Robust.Shared.Containers;

namespace Content.Server.Item.PseudoItem;
namespace Content.Server.Nyanotrasen.Item.PseudoItem;

public sealed class PseudoItemSystem : EntitySystem
public sealed class PseudoItemSystem : SharedPseudoItemSystem
{
[Dependency] private readonly StorageSystem _storageSystem = default!;
[Dependency] private readonly ItemSystem _itemSystem = default!;
[Dependency] private readonly StorageSystem _storage = default!;
[Dependency] private readonly ItemSystem _item = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly CarryingSystem _carrying = default!; // Frontier
[Dependency] private readonly ActionsSystem _actions = default!; // Frontier
[Dependency] private readonly PopupSystem _popup = default!; // Frontier

[ValidatePrototypeId<TagPrototype>]
private const string PreventTag = "PreventLabel";
[Dependency] private readonly CarryingSystem _carrying = default!;
[Dependency] private readonly PopupSystem _popup = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PseudoItemComponent, GetVerbsEvent<InnateVerb>>(AddInsertVerb);
SubscribeLocalEvent<PseudoItemComponent, GetVerbsEvent<AlternativeVerb>>(AddInsertAltVerb);
SubscribeLocalEvent<PseudoItemComponent, EntGotRemovedFromContainerMessage>(OnEntRemoved);
SubscribeLocalEvent<PseudoItemComponent, GettingPickedUpAttemptEvent>(OnGettingPickedUpAttempt);
SubscribeLocalEvent<PseudoItemComponent, DropAttemptEvent>(OnDropAttempt);
SubscribeLocalEvent<PseudoItemComponent, PseudoItemInsertDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<PseudoItemComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt);
SubscribeLocalEvent<PseudoItemComponent, TryingToSleepEvent>(OnTrySleeping); // Frontier
}

private void AddInsertVerb(EntityUid uid, PseudoItemComponent component, GetVerbsEvent<InnateVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
return;

if (component.Active)
return;

if (!TryComp<StorageComponent>(args.Target, out var targetStorage))
return;

if (Transform(args.Target).ParentUid == uid)
return;

InnateVerb verb = new()
{
Act = () =>
{
TryInsert(args.Target, uid, args.User, component, targetStorage);
},
Text = Loc.GetString("action-name-insert-self"),
Priority = 2
};
args.Verbs.Add(verb);
SubscribeLocalEvent<PseudoItemComponent, TryingToSleepEvent>(OnTrySleeping);
}

private void AddInsertAltVerb(EntityUid uid, PseudoItemComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess)
return;

if (args.User == args.Target)
if (component.Active)
return;

if (component.Active)
if (!TryComp<StorageComponent>(args.Using, out var targetStorage))
return;

if (args.Hands == null)
if (!CheckItemFits((uid, component), (args.Using.Value, targetStorage)))
return;

if (!TryComp<StorageComponent>(args.Hands.ActiveHandEntity, out var targetStorage))
if (args.Hands?.ActiveHandEntity == null)
return;

AlternativeVerb verb = new()
Expand All @@ -97,112 +59,20 @@ private void AddInsertAltVerb(EntityUid uid, PseudoItemComponent component, GetV
args.Verbs.Add(verb);
}

private void OnEntRemoved(EntityUid uid, PseudoItemComponent component, EntGotRemovedFromContainerMessage args)
protected override void OnGettingPickedUpAttempt(EntityUid uid, PseudoItemComponent component, GettingPickedUpAttemptEvent args)
{
if (!component.Active)
return;

RemComp<ItemComponent>(uid);
component.Active = false;

// Frontier
if (component.SleepAction is { Valid: true })
_actions.RemoveAction(uid, component.SleepAction);
}

private void OnGettingPickedUpAttempt(EntityUid uid, PseudoItemComponent component,
GettingPickedUpAttemptEvent args)
{
if (args.User == args.Item)
return;

// Frontier: prevent people from pushing each other from a bag
if (HasComp<ItemComponent>(args.User))
// Try to pick the entity up instead first
if (args.User != args.Item && _carrying.TryCarry(args.User, uid))
{
args.Cancel();
return;
}

// Frontier: try to carry the person when taking them out of a bag.
if (_carrying.TryCarry(args.User, uid))
{
args.Cancel();
return;
}

Transform(uid).AttachToGridOrMap();
args.Cancel();
}

private void OnDropAttempt(EntityUid uid, PseudoItemComponent component, DropAttemptEvent args)
{
if (component.Active)
args.Cancel();
}

private void OnDoAfter(EntityUid uid, PseudoItemComponent component, DoAfterEvent args)
{
if (args.Handled || args.Cancelled || args.Args.Used == null)
return;

args.Handled = TryInsert(args.Args.Used.Value, uid, args.User, component);
}

public bool TryInsert(EntityUid storageUid, EntityUid toInsert, EntityUid userUid, PseudoItemComponent component,
StorageComponent? storage = null)
{
if (!Resolve(storageUid, ref storage))
return false;

var item = EnsureComp<ItemComponent>(toInsert);
_tagSystem.TryAddTag(toInsert, PreventTag);
_itemSystem.SetSize(toInsert, component.Size, item);
_itemSystem.VisualsChanged(toInsert);

if (!_storageSystem.CanInsert(storageUid, toInsert, out _) ||
!_storageSystem.PlayerInsertEntityInWorld(storageUid, userUid, toInsert))
{
component.Active = false;
RemComp<ItemComponent>(toInsert);
return false;
}
_storageSystem.UpdateUI(storageUid);
_storageSystem.UpdateAppearance(storageUid);

// Frontier
if (HasComp<AllowsSleepInsideComponent>(storageUid))
_actions.AddAction(toInsert, ref component.SleepAction, SleepingSystem.SleepActionId, toInsert);

component.Active = true;
return true;
}

private void StartInsertDoAfter(EntityUid inserter, EntityUid toInsert, EntityUid storageEntity,
PseudoItemComponent? pseudoItem = null)
{
if (!Resolve(toInsert, ref pseudoItem))
return;

var ev = new PseudoItemInsertDoAfterEvent();
var args = new DoAfterArgs(EntityManager, inserter, 5f, ev, toInsert, toInsert, storageEntity)
{
BreakOnMove = true,
NeedHand = true
};

_doAfter.TryStartDoAfter(args);
}

private void OnInsertAttempt(EntityUid uid, PseudoItemComponent component,
ContainerGettingInsertedAttemptEvent args)
{
if (!component.Active)
return;
// This hopefully shouldn't trigger, but this is a failsafe just in case so we dont bluespace them cats
args.Cancel();
// If could not pick up, just take it out onto the ground as per default
base.OnGettingPickedUpAttempt(uid, component, args);
}

// Frontier - show a popup when a pseudo-item falls asleep inside a bag.
// Show a popup when a pseudo-item falls asleep inside a bag.
private void OnTrySleeping(EntityUid uid, PseudoItemComponent component, TryingToSleepEvent args)
{
var parent = Transform(uid).ParentUid;
Expand Down
8 changes: 8 additions & 0 deletions Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Content.Shared._NC.Radio; // Nuclear-14
using Robust.Server.GameObjects; // Nuclear-14
using Robust.Shared.Prototypes;
using Content.Shared.Access.Systems; // Frontier

namespace Content.Server.Radio.EntitySystems;

Expand All @@ -30,6 +31,7 @@ public sealed class RadioDeviceSystem : EntitySystem
[Dependency] private readonly InteractionSystem _interaction = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly AccessReaderSystem _access = default!; // Frontier: access

// Used to prevent a shitter from using a bunch of radios to spam chat.
private HashSet<(string, EntityUid)> _recentlySent = new();
Expand Down Expand Up @@ -250,6 +252,8 @@ private void OnToggleIntercomMic(Entity<IntercomComponent> ent, ref ToggleInterc
{
if (ent.Comp.RequiresPower && !this.IsPowered(ent, EntityManager))
return;
if (!_access.IsAllowed(args.Actor, ent.Owner)) // Frontier
return; // Frontier

SetMicrophoneEnabled(ent, args.Actor, args.Enabled, true);
ent.Comp.MicrophoneEnabled = args.Enabled;
Expand All @@ -260,6 +264,8 @@ private void OnToggleIntercomSpeaker(Entity<IntercomComponent> ent, ref ToggleIn
{
if (ent.Comp.RequiresPower && !this.IsPowered(ent, EntityManager))
return;
if (!_access.IsAllowed(args.Actor, ent.Owner)) // Frontier
return; // Frontier

SetSpeakerEnabled(ent, args.Actor, args.Enabled, true);
ent.Comp.SpeakerEnabled = args.Enabled;
Expand All @@ -270,6 +276,8 @@ private void OnSelectIntercomChannel(Entity<IntercomComponent> ent, ref SelectIn
{
if (ent.Comp.RequiresPower && !this.IsPowered(ent, EntityManager))
return;
if (!_access.IsAllowed(args.Actor, ent.Owner)) // Frontier
return; // Frontier

if (!_protoMan.TryIndex<RadioChannelPrototype>(args.Channel, out var channel) || !ent.Comp.SupportedChannels.Contains(args.Channel)) // Nuclear-14: add channel
return;
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Robust.Shared.Map;
using Robust.Shared.Utility;
using Content.Shared.UserInterface;
using Content.Shared.Access.Systems; // Frontier

namespace Content.Server.Shuttles.Systems;

Expand All @@ -37,6 +38,7 @@ public sealed partial class ShuttleConsoleSystem : SharedShuttleConsoleSystem
[Dependency] private readonly TagSystem _tags = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly SharedContentEyeSystem _eyeSystem = default!;
[Dependency] private readonly AccessReaderSystem _access = default!;

private EntityQuery<MetaDataComponent> _metaQuery;
private EntityQuery<TransformComponent> _xformQuery;
Expand Down Expand Up @@ -78,6 +80,8 @@ public override void Initialize()
SubscribeLocalEvent<FTLDestinationComponent, ComponentShutdown>(OnFtlDestShutdown);

InitializeFTL();

InitializeNFDrone(); // Frontier: add our drone subscriptions
}

private void OnFtlDestStartup(EntityUid uid, FTLDestinationComponent component, ComponentStartup args)
Expand Down Expand Up @@ -178,6 +182,9 @@ private bool TryPilot(EntityUid user, EntityUid uid)
return false;
}

if (!_access.IsAllowed(user, uid)) // Frontier: check access
return false; // Frontier

var pilotComponent = EnsureComp<PilotComponent>(user);
var console = pilotComponent.Console;

Expand Down
17 changes: 17 additions & 0 deletions Content.Server/_NF/Shuttles/NFDroneConsoleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Content.Server.Shuttles.Components;

/// <summary>
/// Lets you remotely control a shuttle.
/// </summary>
[RegisterComponent]
public sealed partial class NFDroneConsoleComponent : Component
{
[DataField(required: true)]
public string Id = default!;

/// <summary>
/// <see cref="ShuttleConsoleComponent"/> that we're proxied into.
/// </summary>
[DataField]
public EntityUid? Entity;
}
11 changes: 11 additions & 0 deletions Content.Server/_NF/Shuttles/NFDroneConsoleTargetComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Server.Shuttles;

/// <summary>
/// Lets you remotely control a shuttle.
/// </summary>
[RegisterComponent]
public sealed partial class NFDroneConsoleTargetComponent : Component
{
[DataField(required: true)]
public string Id = default!;
}
Loading

0 comments on commit 895ecc2

Please sign in to comment.