mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
# Description I am trying to port over the AI turrets being implemented into wizden made by chromiumboy. It looks fantastic and would like to port this now and work on any issues that might show. --- # Original PRs https://github.com/space-wizards/space-station-14/issues/35223 https://github.com/space-wizards/space-station-14/pull/35025 https://github.com/space-wizards/space-station-14/pull/35031 https://github.com/space-wizards/space-station-14/pull/35058 https://github.com/space-wizards/space-station-14/pull/35123 https://github.com/space-wizards/space-station-14/pull/35149 https://github.com/space-wizards/space-station-14/pull/35235 https://github.com/space-wizards/space-station-14/pull/35236 --- # TODO - [x] Port all related PRs to EE. - [x] Patch any bugs with turrets or potential issues. - [x] Cleanup my shitcode or changes. --- # Changelog 🆑 - add: Added recharging sentry turrets, one is AI-based or the other is Sec can make. - add: The sentry turrets can be made after researching in T3 arsenal. The boards are made in the sec fab. - add: New ID permissions for borgs and minibots for higher turret options. - tweak: Turrets stop shooting after someone goes crit. --------- Co-authored-by: Nathaniel Adams <60526456+Nathaniel-Adams@users.noreply.github.com> (cherry picked from commit 209d0537401cbda448a03e910cca9a898c9d566f)
97 lines
3.6 KiB
C#
97 lines
3.6 KiB
C#
using System.Linq;
|
|
using Content.Server.Administration.Logs;
|
|
using Content.Server.Kitchen.Components;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.Access;
|
|
using Content.Shared.Access.Components;
|
|
using Content.Shared.Access.Systems;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
using Content.Server.Kitchen.EntitySystems;
|
|
|
|
namespace Content.Server.Access.Systems;
|
|
|
|
public sealed class IdCardSystem : SharedIdCardSystem
|
|
{
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly MicrowaveSystem _microwave = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<IdCardComponent, BeingMicrowavedEvent>(OnMicrowaved);
|
|
}
|
|
|
|
private void OnMicrowaved(EntityUid uid, IdCardComponent component, BeingMicrowavedEvent args)
|
|
{
|
|
if (!component.CanMicrowave || !TryComp<MicrowaveComponent>(args.Microwave, out var micro) || micro.Broken)
|
|
return;
|
|
|
|
if (TryComp<AccessComponent>(uid, out var access))
|
|
{
|
|
float randomPick = _random.NextFloat();
|
|
|
|
// if really unlucky, burn card
|
|
if (randomPick <= 0.15f)
|
|
{
|
|
TryComp(uid, out TransformComponent? transformComponent);
|
|
if (transformComponent != null)
|
|
{
|
|
_popupSystem.PopupCoordinates(Loc.GetString("id-card-component-microwave-burnt", ("id", uid)),
|
|
transformComponent.Coordinates, PopupType.Medium);
|
|
EntityManager.SpawnEntity("FoodBadRecipe",
|
|
transformComponent.Coordinates);
|
|
}
|
|
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
|
$"{ToPrettyString(args.Microwave)} burnt {ToPrettyString(uid):entity}");
|
|
EntityManager.QueueDeleteEntity(uid);
|
|
return;
|
|
}
|
|
|
|
//Explode if the microwave can't handle it
|
|
if (!micro.CanMicrowaveIdsSafely)
|
|
{
|
|
_microwave.Explode((args.Microwave, micro));
|
|
return;
|
|
}
|
|
|
|
// If they're unlucky, brick their ID
|
|
if (randomPick <= 0.25f)
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-bricked", ("id", uid)), uid);
|
|
|
|
access.Tags.Clear();
|
|
Dirty(uid, access);
|
|
|
|
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
|
$"{ToPrettyString(args.Microwave)} cleared access on {ToPrettyString(uid):entity}");
|
|
}
|
|
else
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("id-card-component-microwave-safe", ("id", uid)), uid, PopupType.Medium);
|
|
}
|
|
|
|
// Give them a wonderful new access to compensate for everything
|
|
var ids = _prototypeManager.EnumeratePrototypes<AccessLevelPrototype>().Where(x => x.CanAddToIdCard).ToArray();
|
|
|
|
if (ids.Length == 0)
|
|
return;
|
|
|
|
var random = _random.Pick(ids);
|
|
|
|
access.Tags.Add(random.ID);
|
|
Dirty(uid, access);
|
|
|
|
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
|
$"{ToPrettyString(args.Microwave)} added {random.ID} access to {ToPrettyString(uid):entity}");
|
|
|
|
}
|
|
}
|
|
}
|