More borg tweaks (#19143)

* borg tweaks but i'm gonna go code fun stuff first

* werkin' on it

* a ton of tweaks

* fuck everyone and then myself
This commit is contained in:
Nemanja
2023-08-14 19:34:23 -04:00
committed by GitHub
parent 8b0eb7e4de
commit 7ddee71379
40 changed files with 299 additions and 175 deletions

View File

@@ -1,4 +1,3 @@
using Content.Shared.Random.Helpers;
using Robust.Server.Containers;
using Robust.Shared.Containers;
@@ -13,9 +12,6 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
[DataField("containers")]
public List<string> Containers = new();
[DataField("randomOffset")]
public float RandomOffset = 0.25f;
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
if (!system.EntityManager.TryGetComponent<ContainerManagerComponent>(owner, out var containerManager))
@@ -29,11 +25,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
if (!containerSys.TryGetContainer(owner, containerId, out var container, containerManager))
continue;
var entities = containerSys.EmptyContainer(container, true);
foreach (var ent in entities)
{
ent.RandomOffset(RandomOffset);
}
containerSys.EmptyContainer(container, true);
}
}
}

View File

@@ -5,6 +5,7 @@ using Content.Server.Popups;
using Content.Server.Stunnable;
using Content.Shared.Charges.Components;
using Content.Shared.Charges.Systems;
using Content.Shared.Damage;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Flash;
using Content.Shared.IdentityManagement;
@@ -43,7 +44,6 @@ namespace Content.Server.Flash
SubscribeLocalEvent<FlashComponent, MeleeHitEvent>(OnFlashMeleeHit);
// ran before toggling light for extra-bright lantern
SubscribeLocalEvent<FlashComponent, UseInHandEvent>(OnFlashUseInHand, before: new []{ typeof(HandheldLightSystem) });
SubscribeLocalEvent<InventoryComponent, FlashAttemptEvent>(OnInventoryFlashAttempt);
SubscribeLocalEvent<FlashImmunityComponent, FlashAttemptEvent>(OnFlashImmunityFlashAttempt);

View File

@@ -3,7 +3,7 @@
/// <summary>
/// This is used for a ghost role which can be toggled on and off at will, like a PAI.
/// </summary>
[RegisterComponent]
[RegisterComponent, Access(typeof(ToggleableGhostRoleSystem))]
public sealed class ToggleableGhostRoleComponent : Component
{
[DataField("examineTextMindPresent")]

View File

@@ -1,4 +1,5 @@
using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.PAI;
using Content.Shared.Examine;
@@ -16,6 +17,7 @@ public sealed class ToggleableGhostRoleSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly MindSystem _mind = default!;
//todo this really shouldn't be in here but this system was converted from PAIs
[Dependency] private readonly PAISystem _pai = default!;
@@ -79,7 +81,7 @@ public sealed class ToggleableGhostRoleSystem : EntitySystem
private void OnMindAdded(EntityUid uid, ToggleableGhostRoleComponent pai, MindAddedMessage args)
{
// Mind was added, shutdown the ghost role stuff so it won't get in the way
RemComp<GhostTakeoverAvailableComponent>(uid);
RemCompDeferred<GhostTakeoverAvailableComponent>(uid);
UpdateAppearance(uid, ToggleableGhostRoleStatus.On);
}
@@ -105,12 +107,12 @@ public sealed class ToggleableGhostRoleSystem : EntitySystem
Text = Loc.GetString(component.WipeVerbText),
Act = () =>
{
if (component.Deleted || !HasComp<MindContainerComponent>(uid))
if (!TryComp<MindContainerComponent>(uid, out var mindComp) || mindComp.Mind == null)
return;
// Wiping device :(
// The shutdown of the Mind should cause automatic reset of the pAI during OnMindRemoved
// EDIT: But it doesn't!!!! Wtf? Do stuff manually
RemComp<MindContainerComponent>(uid);
_mind.TransferTo(mindComp.Mind, null);
_popup.PopupEntity(Loc.GetString(component.WipeVerbPopup), uid, args.User, PopupType.Large);
UpdateAppearance(uid, ToggleableGhostRoleStatus.Off);
_pai.PAITurningOff(uid);
@@ -127,8 +129,8 @@ public sealed class ToggleableGhostRoleSystem : EntitySystem
{
if (component.Deleted || !HasComp<GhostTakeoverAvailableComponent>(uid))
return;
RemComp<GhostTakeoverAvailableComponent>(uid);
RemComp<GhostRoleComponent>(uid);
RemCompDeferred<GhostTakeoverAvailableComponent>(uid);
RemCompDeferred<GhostRoleComponent>(uid);
_popup.PopupEntity(Loc.GetString(component.StopSearchVerbPopup), uid, args.User);
UpdateAppearance(uid, ToggleableGhostRoleStatus.Off);
_pai.PAITurningOff(uid);

View File

@@ -40,6 +40,12 @@ namespace Content.Server.Mind.Components
public sealed class MindRemovedMessage : EntityEventArgs
{
public Mind OldMind;
public MindRemovedMessage(Mind oldMind)
{
OldMind = oldMind;
}
}
public sealed class MindAddedMessage : EntityEventArgs

View File

@@ -30,6 +30,7 @@ public sealed class MindSystem : EntitySystem
[Dependency] private readonly ActorSystem _actor = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
@@ -125,11 +126,12 @@ public sealed class MindSystem : EntitySystem
/// </summary>
private void InternalEjectMind(EntityUid uid, MindContainerComponent? mind = null)
{
if (!Resolve(uid, ref mind, false))
if (!Resolve(uid, ref mind, false) || mind.Mind == null)
return;
var oldMind = mind.Mind;
mind.Mind = null;
RaiseLocalEvent(uid, new MindRemovedMessage(), true);
RaiseLocalEvent(uid, new MindRemovedMessage(oldMind), true);
}
private void OnVisitingTerminating(EntityUid uid, VisitingMindComponent component, ref EntityTerminatingEvent args)
@@ -159,7 +161,7 @@ public sealed class MindSystem : EntitySystem
return;
}
TransferTo(mind, null);
TransferTo(mind, null, createGhost: false);
if (component.GhostOnShutdown && mind.Session != null)
{
@@ -184,7 +186,7 @@ public sealed class MindSystem : EntitySystem
{
// This should be an error, if it didn't cause tests to start erroring when they delete a player.
Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available.");
TransferTo(mind, null);
TransferTo(mind, null, createGhost: false);
return;
}
@@ -381,7 +383,7 @@ public sealed class MindSystem : EntitySystem
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="entity"/> is already owned by another mind.
/// </exception>
public void TransferTo(Mind mind, EntityUid? entity, bool ghostCheckOverride = false)
public void TransferTo(Mind mind, EntityUid? entity, bool ghostCheckOverride = false, bool createGhost = true)
{
if (entity == mind.OwnedEntity)
return;
@@ -407,6 +409,16 @@ public sealed class MindSystem : EntitySystem
alreadyAttached = true;
}
}
else if (createGhost)
{
var position = Deleted(mind.OwnedEntity)
? _gameTicker.GetObserverSpawnPoint().ToMap(EntityManager, _transform)
: Transform(mind.OwnedEntity.Value).MapPosition;
entity = Spawn("MobObserver", position);
var ghostComponent = Comp<GhostComponent>(entity.Value);
_ghostSystem.SetCanReturnToBody(ghostComponent, false);
}
var oldComp = mind.OwnedComponent;
var oldEntity = mind.OwnedEntity;

View File

@@ -0,0 +1,8 @@
using Content.Shared.Roles;
namespace Content.Server.Roles;
public sealed class SubvertedSiliconRole : AntagonistRole
{
public SubvertedSiliconRole(Mind.Mind mind, AntagPrototype antagPrototype) : base(mind, antagPrototype) { }
}

View File

@@ -38,6 +38,7 @@ public sealed partial class BorgSystem
var ent = args.Entity;
var linked = EnsureComp<MMILinkedComponent>(ent);
linked.LinkedMMI = uid;
Dirty(uid, component);
if (_mind.TryGetMind(ent, out var mind))
_mind.TransferTo(mind, uid, true);

View File

@@ -6,6 +6,7 @@ using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.PowerCell;
using Content.Server.UserInterface;
using Content.Shared.Access.Systems;
using Content.Shared.Alert;
using Content.Shared.Database;
using Content.Shared.IdentityManagement;
@@ -13,6 +14,7 @@ using Content.Shared.Interaction;
using Content.Shared.Movement.Systems;
using Content.Shared.PowerCell;
using Content.Shared.PowerCell.Components;
using Content.Shared.Roles;
using Content.Shared.Silicons.Borgs;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.Throwing;
@@ -30,6 +32,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
[Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly IBanManager _banManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAccessSystem _access = default!;
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
@@ -41,6 +44,9 @@ public sealed partial class BorgSystem : SharedBorgSystem
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[ValidatePrototypeId<JobPrototype>]
public const string BorgJobId = "Borg";
/// <inheritdoc/>
public override void Initialize()
{
@@ -66,18 +72,6 @@ public sealed partial class BorgSystem : SharedBorgSystem
{
UpdateBatteryAlert(uid);
_movementSpeedModifier.RefreshMovementSpeedModifiers(uid);
var coordinates = Transform(uid).Coordinates;
if (component.StartingBrain != null)
{
component.BrainContainer.Insert(Spawn(component.StartingBrain, coordinates), EntityManager);
}
foreach (var startingModule in component.StartingModules)
{
component.ModuleContainer.Insert(Spawn(startingModule, coordinates), EntityManager);
}
}
private void OnChassisInteractUsing(EntityUid uid, BorgChassisComponent component, AfterInteractUsingEvent args)
@@ -104,7 +98,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
{
if (_mind.TryGetMind(used, out var mind) && mind.Session != null)
{
if (!CanPlayerBeBorgged(mind.Session, component))
if (!CanPlayerBeBorgged(mind.Session))
{
Popup.PopupEntity(Loc.GetString("borg-player-not-allowed"), used, args.User);
return;
@@ -218,7 +212,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
if (!_mind.TryGetMind(uid, out var mind) || mind.Session == null)
return;
if (!CanPlayerBeBorgged(mind.Session, chassisComponent))
if (!CanPlayerBeBorgged(mind.Session))
{
Popup.PopupEntity(Loc.GetString("borg-player-not-allowed-eject"), uid);
Container.RemoveEntity(containerEnt, uid);
@@ -284,9 +278,9 @@ public sealed partial class BorgSystem : SharedBorgSystem
/// </summary>
public void BorgActivate(EntityUid uid, BorgChassisComponent component)
{
component.HasPlayer = true;
Popup.PopupEntity(Loc.GetString("borg-mind-added", ("name", Identity.Name(uid, EntityManager))), uid);
_powerCell.SetPowerCellDrawEnabled(uid, true);
_access.SetAccessEnabled(uid, true);
_appearance.SetData(uid, BorgVisuals.HasPlayer, true);
Dirty(uid, component);
}
@@ -296,9 +290,9 @@ public sealed partial class BorgSystem : SharedBorgSystem
/// </summary>
public void BorgDeactivate(EntityUid uid, BorgChassisComponent component)
{
component.HasPlayer = false;
Popup.PopupEntity(Loc.GetString("borg-mind-removed", ("name", Identity.Name(uid, EntityManager))), uid);
_powerCell.SetPowerCellDrawEnabled(uid, false);
_access.SetAccessEnabled(uid, false);
_appearance.SetData(uid, BorgVisuals.HasPlayer, false);
Dirty(uid, component);
}
@@ -307,9 +301,9 @@ public sealed partial class BorgSystem : SharedBorgSystem
/// Checks that a player has fulfilled the requirements for the borg job.
/// If they don't have enough hours, they cannot be placed into a chassis.
/// </summary>
public bool CanPlayerBeBorgged(IPlayerSession session, BorgChassisComponent component)
public bool CanPlayerBeBorgged(IPlayerSession session)
{
if (_banManager.GetJobBans(session.UserId)?.Contains(component.BorgJobId) == true)
if (_banManager.GetJobBans(session.UserId)?.Contains(BorgJobId) == true)
return false;
return true;

View File

@@ -1,7 +1,10 @@
using Content.Server.Administration;
using System.Linq;
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.Roles;
using Content.Server.Station.Systems;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
@@ -10,8 +13,10 @@ using Content.Shared.Chat;
using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems;
using Content.Shared.Examine;
using Content.Shared.Roles;
using Content.Shared.Silicons.Laws;
using Content.Shared.Silicons.Laws.Components;
using Content.Shared.Wires;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Prototypes;
@@ -24,6 +29,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
{
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
@@ -35,6 +41,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
SubscribeLocalEvent<SiliconLawBoundComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<SiliconLawBoundComponent, ComponentShutdown>(OnComponentShutdown);
SubscribeLocalEvent<SiliconLawBoundComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<SiliconLawBoundComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<SiliconLawBoundComponent, ToggleLawsScreenEvent>(OnToggleLawsScreen);
SubscribeLocalEvent<SiliconLawBoundComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
@@ -42,8 +49,11 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
SubscribeLocalEvent<SiliconLawProviderComponent, GetSiliconLawsEvent>(OnDirectedGetLaws);
SubscribeLocalEvent<EmagSiliconLawComponent, GetSiliconLawsEvent>(OnDirectedEmagGetLaws);
SubscribeLocalEvent<EmagSiliconLawComponent, MindAddedMessage>(OnEmagMindAdded);
SubscribeLocalEvent<EmagSiliconLawComponent, MindRemovedMessage>(OnEmagMindRemoved);
SubscribeLocalEvent<EmagSiliconLawComponent, ExaminedEvent>(OnExamined);
}
private void OnComponentStartup(EntityUid uid, SiliconLawBoundComponent component, ComponentStartup args)
{
component.ProvidedAction = new (_prototype.Index<InstantActionPrototype>(component.ViewLawsAction));
@@ -56,6 +66,11 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
_actions.RemoveAction(uid, component.ProvidedAction);
}
private void OnMapInit(EntityUid uid, SiliconLawBoundComponent component, MapInitEvent args)
{
GetLaws(uid, component);
}
private void OnMindAdded(EntityUid uid, SiliconLawBoundComponent component, MindAddedMessage args)
{
if (!TryComp<ActorComponent>(uid, out var actor))
@@ -117,13 +132,47 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
if (!args.IsInDetailsRange || !HasComp<EmaggedComponent>(uid))
return;
if (component.RequireOpenPanel && TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
return;
args.PushMarkup(Loc.GetString("laws-compromised-examine"));
}
protected override void OnGotEmagged(EntityUid uid, EmagSiliconLawComponent component, ref GotEmaggedEvent args)
{
if (component.RequireOpenPanel && TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
return;
base.OnGotEmagged(uid, component, ref args);
NotifyLawsChanged(uid);
EnsureEmaggedRole(uid, component);
}
private void OnEmagMindAdded(EntityUid uid, EmagSiliconLawComponent component, MindAddedMessage args)
{
if (HasComp<EmaggedComponent>(uid))
EnsureEmaggedRole(uid, component);
}
private void OnEmagMindRemoved(EntityUid uid, EmagSiliconLawComponent component, MindRemovedMessage args)
{
if (component.AntagonistRole == null)
return;
if (args.OldMind.Roles.FirstOrDefault(r => r is SubvertedSiliconRole) is not { } role)
return;
_mind.RemoveRole(args.OldMind, role);
}
private void EnsureEmaggedRole(EntityUid uid, EmagSiliconLawComponent component)
{
if (component.AntagonistRole == null || !_mind.TryGetMind(uid, out var mind))
return;
if (_mind.HasRole<SubvertedSiliconRole>(mind))
return;
_mind.AddRole(mind, new SubvertedSiliconRole(mind, _prototype.Index<AntagPrototype>(component.AntagonistRole)));
}
public List<SiliconLaw> GetLaws(EntityUid uid, SiliconLawBoundComponent? component = null)
@@ -131,8 +180,6 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
if (!Resolve(uid, ref component))
return new List<SiliconLaw>();
var xform = Transform(uid);
var ev = new GetSiliconLawsEvent(uid);
RaiseLocalEvent(uid, ref ev);
@@ -142,6 +189,8 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
return ev.Laws;
}
var xform = Transform(uid);
if (_station.GetOwningStation(uid, xform) is { } station)
{
RaiseLocalEvent(station, ref ev);
@@ -188,7 +237,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
var msg = Loc.GetString("laws-update-notify");
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", msg));
_chatManager.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.ConnectedClient, colorOverride: Color.FromHex("#2ed2fd"));
_chatManager.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.ConnectedClient, colorOverride: Color.Red);
}
}

View File

@@ -24,6 +24,7 @@ public sealed class WiresSystem : SharedWiresSystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ActivatableUISystem _activatableUI = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
@@ -511,10 +512,7 @@ public sealed class WiresSystem : SharedWiresSystem
if (args.Open == component.RequireOpen)
return;
if (!TryComp<ActivatableUIComponent>(uid, out var ui) || ui.Key == null)
return;
_uiSystem.TryCloseAll(uid, ui.Key);
_activatableUI.CloseAll(uid);
}
private void OnMapInit(EntityUid uid, WiresComponent component, MapInitEvent args)