Files
crystall-punk-14/Content.Server/Silicons/StationAi/StationAiSystem.cs
metalgearsloth afd0618a60 Station AI (#30944)
* Station AI overlay

* implement

* Bunch of ports

* Fix a heap of bugs and basic scouting

* helldivers

* Shuffle interactions a bit

* navmap stuff

* Revert "navmap stuff"

This reverts commit d1f89dd4be83233e22cf5dd062b2581f3c6da062.

* AI wires implemented

* Fix examines

* Optimise the overlay significantly

* Back to old static

* BUI radial working

* lots of work

* Saving work

* thanks fork

* alright

* pc

* AI upload console

* AI upload

* stuff

* Fix copy-paste shitcode

* AI actions

* navmap work

* Fixes

* first impressions

* a

* reh

* Revert "navmap work"

This reverts commit 6f63fea6e9245e189f368f97be3e32e9b210580e.

# Conflicts:
#	Content.Client/Silicons/StationAi/StationAiOverlay.cs

* OD

* radar

* weh

* Fix examines

* scoop mine eyes

* fixes

* reh

* Optimise

* Final round of optimisations

* Fixes

* fixes
2024-08-28 10:57:12 +10:00

77 lines
2.2 KiB
C#

using System.Linq;
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Shared.Chat;
using Content.Shared.Silicons.StationAi;
using Content.Shared.StationAi;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Map.Components;
using Robust.Shared.Player;
namespace Content.Server.Silicons.StationAi;
public sealed class StationAiSystem : SharedStationAiSystem
{
[Dependency] private readonly IChatManager _chats = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
private readonly HashSet<Entity<StationAiCoreComponent>> _ais = new();
public override bool SetVisionEnabled(Entity<StationAiVisionComponent> entity, bool enabled, bool announce = false)
{
if (!base.SetVisionEnabled(entity, enabled, announce))
return false;
if (announce)
{
AnnounceSnip(entity.Owner);
}
return true;
}
public override bool SetWhitelistEnabled(Entity<StationAiWhitelistComponent> entity, bool enabled, bool announce = false)
{
if (!base.SetWhitelistEnabled(entity, enabled, announce))
return false;
if (announce)
{
AnnounceSnip(entity.Owner);
}
return true;
}
private void AnnounceSnip(EntityUid entity)
{
var xform = Transform(entity);
if (!TryComp(xform.GridUid, out MapGridComponent? grid))
return;
_ais.Clear();
_lookup.GetChildEntities(xform.GridUid.Value, _ais);
var filter = Filter.Empty();
foreach (var ai in _ais)
{
// TODO: Filter API?
if (TryComp(ai.Owner, out ActorComponent? actorComp))
{
filter.AddPlayer(actorComp.PlayerSession);
}
}
// TEST
// filter = Filter.Broadcast();
// No easy way to do chat notif embeds atm.
var tile = Maps.LocalToTile(xform.GridUid.Value, grid, xform.Coordinates);
var msg = Loc.GetString("ai-wire-snipped", ("coords", tile));
_chats.ChatMessageToMany(ChatChannel.Notifications, msg, msg, entity, false, true, filter.Recipients.Select(o => o.Channel));
// Apparently there's no sound for this.
}
}