using Content.Shared.Containers.ItemSlots; using Content.Shared.IdentityManagement; using Content.Shared.Item.ItemToggle; using Content.Shared.Movement.Components; using Content.Shared.Movement.Systems; using Content.Shared.Popups; using Content.Shared.PowerCell.Components; using Content.Shared.Silicons.Borgs.Components; using Content.Shared.UserInterface; using Content.Shared.Wires; using Robust.Shared.Containers; namespace Content.Shared.Silicons.Borgs; /// /// This handles logic, interactions, and UI related to and other related components. /// public abstract partial class SharedBorgSystem : EntitySystem { [Dependency] protected readonly SharedContainerSystem Container = default!; [Dependency] protected readonly ItemSlotsSystem ItemSlots = default!; [Dependency] protected readonly ItemToggleSystem Toggle = default!; [Dependency] protected readonly SharedPopupSystem Popup = default!; /// public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnItemSlotInsertAttempt); SubscribeLocalEvent(OnItemSlotEjectAttempt); SubscribeLocalEvent(OnInserted); SubscribeLocalEvent(OnRemoved); SubscribeLocalEvent(OnRefreshMovementSpeedModifiers); SubscribeLocalEvent(OnUIOpenAttempt); SubscribeLocalEvent(OnTryGetIdentityShortInfo); InitializeRelay(); } private void OnTryGetIdentityShortInfo(TryGetIdentityShortInfoEvent args) { if (args.Handled) { return; } if (!HasComp(args.ForActor)) { return; } args.Title = Name(args.ForActor).Trim(); args.Handled = true; } private void OnItemSlotInsertAttempt(EntityUid uid, BorgChassisComponent component, ref ItemSlotInsertAttemptEvent args) { if (args.Cancelled) return; if (!TryComp(uid, out var cellSlotComp) || !TryComp(uid, out var panel)) return; if (!ItemSlots.TryGetSlot(uid, cellSlotComp.CellSlotId, out var cellSlot) || cellSlot != args.Slot) return; if (!panel.Open || args.User == uid) args.Cancelled = true; } private void OnItemSlotEjectAttempt(EntityUid uid, BorgChassisComponent component, ref ItemSlotEjectAttemptEvent args) { if (args.Cancelled) return; if (!TryComp(uid, out var cellSlotComp) || !TryComp(uid, out var panel)) return; if (!ItemSlots.TryGetSlot(uid, cellSlotComp.CellSlotId, out var cellSlot) || cellSlot != args.Slot) return; if (!panel.Open || args.User == uid) args.Cancelled = true; } private void OnStartup(EntityUid uid, BorgChassisComponent component, ComponentStartup args) { if (!TryComp(uid, out var containerManager)) return; component.BrainContainer = Container.EnsureContainer(uid, component.BrainContainerId, containerManager); component.ModuleContainer = Container.EnsureContainer(uid, component.ModuleContainerId, containerManager); } private void OnUIOpenAttempt(EntityUid uid, BorgChassisComponent component, ActivatableUIOpenAttemptEvent args) { // borgs can't view their own ui if (args.User == uid) args.Cancel(); } protected virtual void OnInserted(EntityUid uid, BorgChassisComponent component, EntInsertedIntoContainerMessage args) { } protected virtual void OnRemoved(EntityUid uid, BorgChassisComponent component, EntRemovedFromContainerMessage args) { } private void OnRefreshMovementSpeedModifiers(EntityUid uid, BorgChassisComponent component, RefreshMovementSpeedModifiersEvent args) { if (Toggle.IsActivated(uid)) return; if (!TryComp(uid, out var movement)) return; var sprintDif = movement.BaseWalkSpeed / movement.BaseSprintSpeed; args.ModifySpeed(1f, sprintDif); } /// /// Sets . /// public void SetBorgModuleDefault(Entity ent, bool newDefault) { ent.Comp.DefaultModule = newDefault; Dirty(ent); } }