diff --git a/Content.Server/Silicons/StationAi/StationAiSystem.cs b/Content.Server/Silicons/StationAi/StationAiSystem.cs index 6b774381774410..754a99a1421fc8 100644 --- a/Content.Server/Silicons/StationAi/StationAiSystem.cs +++ b/Content.Server/Silicons/StationAi/StationAiSystem.cs @@ -1,6 +1,5 @@ using System.Linq; using Content.Server.Chat.Managers; -using Content.Server.Chat.Systems; using Content.Shared.Chat; using Content.Shared.Mind; using Content.Shared.Roles; @@ -17,8 +16,8 @@ public sealed class StationAiSystem : SharedStationAiSystem { [Dependency] private readonly IChatManager _chats = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; - [Dependency] private readonly SharedMindSystem _mind = default!; - [Dependency] private readonly SharedRoleSystem _roles = default!; + [Dependency] private readonly SharedMindSystem _mind = default!; + [Dependency] private readonly SharedRoleSystem _roles = default!; private readonly HashSet> _ais = new(); @@ -47,10 +46,10 @@ public override bool SetWhitelistEnabled(Entity ent return true; } - - public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) - { - if (!TryComp(uid, out var actor)) + + public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) + { + if (!TryComp(uid, out var actor)) return; var msg = Loc.GetString("ai-intellicard-download-warning"); @@ -59,7 +58,7 @@ public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue if (cue != null && _mind.TryGetMind(uid, out var mindId, out _)) _roles.MindPlaySound(mindId, cue); - } + } private void AnnounceSnip(EntityUid entity) { diff --git a/Content.Shared/Intellicard/IntellicardComponent.cs b/Content.Shared/Intellicard/IntellicardComponent.cs index 1141303cf3e320..e27174977fb1f3 100644 --- a/Content.Shared/Intellicard/IntellicardComponent.cs +++ b/Content.Shared/Intellicard/IntellicardComponent.cs @@ -1,9 +1,7 @@ -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Audio; using Robust.Shared.GameStates; -using Robust.Shared.Prototypes; -namespace Content.Shared.Silicons.StationAi; +namespace Content.Shared.Intellicard; /// /// Allows this entity to download the station AI onto an AiHolderComponent. @@ -15,13 +13,13 @@ public sealed partial class IntellicardComponent : Component /// The duration it takes to download the AI from an AiHolder. /// [DataField, AutoNetworkedField] - public int downloadTime = 15; + public int DownloadTime = 15; /// /// The duration it takes to upload the AI to an AiHolder. /// [DataField, AutoNetworkedField] - public int uploadTime = 3; + public int UploadTime = 3; /// /// The sound that plays for the AI @@ -36,7 +34,6 @@ public sealed partial class IntellicardComponent : Component [DataField, AutoNetworkedField] public TimeSpan WarningDelay = TimeSpan.FromSeconds(8); + [ViewVariables] public TimeSpan NextWarningAllowed = TimeSpan.Zero; - - public const string HolderContainer = "station_ai_mind_slot"; } diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs index b580447fcbb366..c9279b02151381 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs @@ -54,7 +54,7 @@ private void OnCoreJump(Entity ent, ref JumpToCoreEvent } /// - /// Tries to get the entity held in the AI core. + /// Tries to get the entity held in the AI core using StationAiCore. /// private bool TryGetHeld(Entity entity, out EntityUid held) { @@ -71,6 +71,9 @@ private bool TryGetHeld(Entity entity, out EntityUid he return true; } + /// + /// Tries to get the entity held in the AI using StationAiHolder. + /// private bool TryGetHeldFromHolder(Entity entity, out EntityUid held) { held = EntityUid.Invalid; diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index 157574dae38c53..72439c26c9bac0 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Doors.Systems; using Content.Shared.DoAfter; using Content.Shared.Electrocution; +using Content.Shared.Intellicard; using Content.Shared.Interaction; using Content.Shared.Item.ItemToggle; using Content.Shared.Mind; @@ -243,7 +244,7 @@ private void OnIntellicardDoAfter(Entity ent, ref Inte private void OnHolderInteract(Entity ent, ref AfterInteractEvent args) { - if(!args.CanReach) + if (args.Handled || !args.CanReach || args.Target == null) return; if (!TryComp(args.Target, out StationAiHolderComponent? targetHolder)) @@ -252,23 +253,21 @@ private void OnHolderInteract(Entity ent, ref AfterInt if (!TryComp(args.Used, out IntellicardComponent? intelliComp)) return; - bool isUploading = _slots.CanEject(ent.Owner, args.User, ent.Comp.Slot); + var isUploading = _slots.CanEject(ent.Owner, args.User, ent.Comp.Slot); - bool isDownloading = _slots.CanEject(args.Target.Value, args.User, targetHolder.Slot); + var isDownloading = _slots.CanEject(args.Target.Value, args.User, targetHolder.Slot); - if(isUploading == isDownloading) + if (isUploading == isDownloading) return; - if(TryGetHeldFromHolder((targetHolder.Owner, targetHolder), out var held) && _timing.CurTime > intelliComp.NextWarningAllowed) { + if (TryGetHeldFromHolder((args.Target.Value, targetHolder), out var held) && _timing.CurTime > intelliComp.NextWarningAllowed) { intelliComp.NextWarningAllowed = _timing.CurTime + intelliComp.WarningDelay; AnnounceIntellicardUsage(held, intelliComp.WarningSound); } - //TODO: Add a warning so the AI knows when they are being uploaded/downloaded. - - var doAfterArgs = new DoAfterArgs(EntityManager, args.User, isUploading ? intelliComp.uploadTime : intelliComp.downloadTime, new IntellicardDoAfterEvent(), args.Target, ent.Owner) + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, isUploading ? intelliComp.UploadTime : intelliComp.DownloadTime, new IntellicardDoAfterEvent(), args.Target, ent.Owner) { BreakOnDamage = true, BreakOnMove = true,