From a889cec36fd2062ab35a1316cfa7c0919d63e052 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 6 Nov 2024 20:34:03 +0100 Subject: [PATCH 01/11] init --- .../Silicons/StationAi/StationAiSystem.cs | 18 +++++ .../Intellicard/IntellicardComponent.cs | 42 +++++++++++ .../StationAi/SharedStationAiSystem.Held.cs | 15 ++++ .../StationAi/SharedStationAiSystem.cs | 75 +++++++++++++++++-- .../Locale/en-US/silicons/station-ai.ftl | 2 + .../Entities/Mobs/Player/silicon.yml | 1 + 6 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 Content.Shared/Intellicard/IntellicardComponent.cs diff --git a/Content.Server/Silicons/StationAi/StationAiSystem.cs b/Content.Server/Silicons/StationAi/StationAiSystem.cs index 846497387d24..6b7743817744 100644 --- a/Content.Server/Silicons/StationAi/StationAiSystem.cs +++ b/Content.Server/Silicons/StationAi/StationAiSystem.cs @@ -2,8 +2,11 @@ using Content.Server.Chat.Managers; using Content.Server.Chat.Systems; using Content.Shared.Chat; +using Content.Shared.Mind; +using Content.Shared.Roles; using Content.Shared.Silicons.StationAi; using Content.Shared.StationAi; +using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Map.Components; using Robust.Shared.Player; @@ -14,6 +17,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!; private readonly HashSet> _ais = new(); @@ -42,6 +47,19 @@ public override bool SetWhitelistEnabled(Entity ent return true; } + + public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) + { + if (!TryComp(uid, out var actor)) + return; + + var msg = Loc.GetString("ai-intellicard-download-warning"); + var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", msg)); + _chats.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.Channel, colorOverride: Color.Red); + + 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 new file mode 100644 index 000000000000..c3d9f0f0c266 --- /dev/null +++ b/Content.Shared/Intellicard/IntellicardComponent.cs @@ -0,0 +1,42 @@ +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; +using Robust.Shared.Audio; +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; + +namespace Content.Shared.Silicons.StationAi; + +/// +/// Allows this entity to download the station AI onto an AiHolderComponent. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class IntellicardComponent : Component +{ + /// + /// The duration it takes to download the AI from an AiHolder. + /// + [DataField, AutoNetworkedField] + public int downloadTime = 15; + + /// + /// The duration it takes to upload the AI to an AiHolder. + /// + [DataField, AutoNetworkedField] + public int uploadTime = 3; + + /// + /// The sound that plays for the Silicon player + /// when the law change is processed for the provider. + /// + [DataField, AutoNetworkedField] + public SoundSpecifier? WarningSound = new SoundPathSpecifier("/Audio/Misc/notice2.ogg"); + + /// + /// The delay before allowing the warning to play again in seconds. + /// + [DataField, AutoNetworkedField] + public TimeSpan WarningDelay = TimeSpan.FromSeconds(5); + + 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 e067cf3efadb..b580447fcbb3 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs @@ -71,6 +71,21 @@ private bool TryGetHeld(Entity entity, out EntityUid he return true; } + private bool TryGetHeldFromHolder(Entity entity, out EntityUid held) + { + held = EntityUid.Invalid; + + if (!Resolve(entity.Owner, ref entity.Comp)) + return false; + + if (!_containers.TryGetContainer(entity.Owner, StationAiHolderComponent.Container, out var container) || + container.ContainedEntities.Count == 0) + return false; + + held = container.ContainedEntities[0]; + return true; + } + private bool TryGetCore(EntityUid ent, out Entity core) { if (!_containers.TryGetContainingContainer(ent, out var container) || diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index f88df9eea6b7..aa6ec0b3252a 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -4,6 +4,7 @@ using Content.Shared.Containers.ItemSlots; using Content.Shared.Database; using Content.Shared.Doors.Systems; +using Content.Shared.DoAfter; using Content.Shared.Electrocution; using Content.Shared.Interaction; using Content.Shared.Item.ItemToggle; @@ -15,6 +16,7 @@ using Content.Shared.Power.EntitySystems; using Content.Shared.StationAi; using Content.Shared.Verbs; +using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; using Robust.Shared.Map.Components; @@ -40,6 +42,7 @@ public abstract partial class SharedStationAiSystem : EntitySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedContainerSystem _containers = default!; [Dependency] private readonly SharedDoorSystem _doors = default!; + [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; [Dependency] private readonly SharedElectrocutionSystem _electrify = default!; [Dependency] private readonly SharedEyeSystem _eye = default!; [Dependency] protected readonly SharedMapSystem Maps = default!; @@ -87,6 +90,7 @@ public override void Initialize() SubscribeLocalEvent(OnHolderMapInit); SubscribeLocalEvent(OnHolderConInsert); SubscribeLocalEvent(OnHolderConRemove); + SubscribeLocalEvent(OnIntellicardDoAfter); SubscribeLocalEvent(OnAiInsert); SubscribeLocalEvent(OnAiRemove); @@ -197,15 +201,26 @@ private void OnAiInRange(Entity ent, ref InRangeOverr args.InRange = _vision.IsAccessible((targetXform.GridUid.Value, broadphase, grid), targetTile); } - private void OnHolderInteract(Entity ent, ref AfterInteractEvent args) + + private void OnIntellicardDoAfter(Entity ent, ref IntellicardDoAfterEvent args) { - if (!TryComp(args.Target, out StationAiHolderComponent? targetHolder)) + + if(args.Args.Target == null) return; - + + if(args.Cancelled) + return; + + if(args.Handled) + return; + + if (!TryComp(args.Args.Target, out StationAiHolderComponent? targetHolder)) + return; + // Try to insert our thing into them if (_slots.CanEject(ent.Owner, args.User, ent.Comp.Slot)) { - if (!_slots.TryInsert(args.Target.Value, targetHolder.Slot, ent.Comp.Slot.Item!.Value, args.User, excludeUserAudio: true)) + if (!_slots.TryInsert(args.Args.Target.Value, targetHolder.Slot, ent.Comp.Slot.Item!.Value, args.User, excludeUserAudio: true)) { return; } @@ -215,7 +230,7 @@ private void OnHolderInteract(Entity ent, ref AfterInt } // Otherwise try to take from them - if (_slots.CanEject(args.Target.Value, args.User, targetHolder.Slot)) + if (_slots.CanEject(args.Args.Target.Value, args.User, targetHolder.Slot)) { if (!_slots.TryInsert(ent.Owner, ent.Comp.Slot, targetHolder.Slot.Item!.Value, args.User, excludeUserAudio: true)) { @@ -226,6 +241,44 @@ private void OnHolderInteract(Entity ent, ref AfterInt } } + private void OnHolderInteract(Entity ent, ref AfterInteractEvent args) + { + if(!args.CanReach) + return; + + if (!TryComp(args.Target, out StationAiHolderComponent? targetHolder)) + return; + + if (!TryComp(args.Used, out IntellicardComponent? intellicard)) + return; + + bool isUploading = _slots.CanEject(ent.Owner, args.User, ent.Comp.Slot); + + bool isDownloading = _slots.CanEject(args.Target.Value, args.User, targetHolder.Slot); + + if(isUploading == isDownloading) + return; + + if(TryGetHeldFromHolder((targetHolder.Owner, targetHolder), out var held) && _timing.CurTime > intellicard.NextWarningAllowed) { + + intellicard.NextWarningAllowed = _timing.CurTime + intellicard.WarningDelay; + + AnnounceIntellicardUsage(held, intellicard.WarningSound); + } + + //TODO: Add a warning so the AI knows when they are being uploaded/downloaded. + + var doAfterArgs = new DoAfterArgs(EntityManager, args.User, isUploading ? intellicard.uploadTime : intellicard.downloadTime, new IntellicardDoAfterEvent(), args.Target, ent.Owner) + { + BreakOnDamage = true, + BreakOnMove = true, + NeedHand = true, + BreakOnDropItem = true + }; + + _doAfter.TryStartDoAfter(doAfterArgs); + } + private void OnHolderInit(Entity ent, ref ComponentInit args) { _slots.AddItemSlot(ent.Owner, StationAiHolderComponent.Container, ent.Comp.Slot); @@ -377,6 +430,11 @@ private void UpdateAppearance(Entity entity) _appearance.SetData(entity.Owner, StationAiVisualState.Key, StationAiState.Occupied); } + + public virtual void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) + { + + } public virtual bool SetVisionEnabled(Entity entity, bool enabled, bool announce = false) { @@ -419,6 +477,13 @@ public sealed partial class JumpToCoreEvent : InstantActionEvent } +[Serializable, NetSerializable] +public sealed partial class IntellicardDoAfterEvent : SimpleDoAfterEvent +{ + +} + + [Serializable, NetSerializable] public enum StationAiVisualState : byte { diff --git a/Resources/Locale/en-US/silicons/station-ai.ftl b/Resources/Locale/en-US/silicons/station-ai.ftl index 7d9db3f6dc5a..edd2e933be52 100644 --- a/Resources/Locale/en-US/silicons/station-ai.ftl +++ b/Resources/Locale/en-US/silicons/station-ai.ftl @@ -20,3 +20,5 @@ electrify-door-off = Disable overcharge toggle-light = Toggle light ai-device-not-responding = Device is not responding + +ai-intellicard-download-warning = Your consciousness is being downloaded. diff --git a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml index be2b5a44f953..cbe307f466a3 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml @@ -303,6 +303,7 @@ unshaded: Empty: { state: empty } Occupied: { state: full } + - type: Intellicard - type: entity id: PlayerStationAiEmpty From e86fb41e3b380268bdda47d38ca760abcb187273 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Wed, 6 Nov 2024 21:17:23 +0100 Subject: [PATCH 02/11] cleanup --- .../Intellicard/IntellicardComponent.cs | 2 +- .../StationAi/SharedStationAiSystem.cs | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Content.Shared/Intellicard/IntellicardComponent.cs b/Content.Shared/Intellicard/IntellicardComponent.cs index c3d9f0f0c266..0027fcbdf49f 100644 --- a/Content.Shared/Intellicard/IntellicardComponent.cs +++ b/Content.Shared/Intellicard/IntellicardComponent.cs @@ -34,7 +34,7 @@ public sealed partial class IntellicardComponent : Component /// The delay before allowing the warning to play again in seconds. /// [DataField, AutoNetworkedField] - public TimeSpan WarningDelay = TimeSpan.FromSeconds(5); + public TimeSpan WarningDelay = TimeSpan.FromSeconds(8); public TimeSpan NextWarningAllowed = TimeSpan.Zero; diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index aa6ec0b3252a..157574dae38c 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -243,13 +243,13 @@ private void OnIntellicardDoAfter(Entity ent, ref Inte private void OnHolderInteract(Entity ent, ref AfterInteractEvent args) { - if(!args.CanReach) - return; - + if(!args.CanReach) + return; + if (!TryComp(args.Target, out StationAiHolderComponent? targetHolder)) return; - if (!TryComp(args.Used, out IntellicardComponent? intellicard)) + if (!TryComp(args.Used, out IntellicardComponent? intelliComp)) return; bool isUploading = _slots.CanEject(ent.Owner, args.User, ent.Comp.Slot); @@ -258,17 +258,17 @@ private void OnHolderInteract(Entity ent, ref AfterInt if(isUploading == isDownloading) return; - - if(TryGetHeldFromHolder((targetHolder.Owner, targetHolder), out var held) && _timing.CurTime > intellicard.NextWarningAllowed) { - - intellicard.NextWarningAllowed = _timing.CurTime + intellicard.WarningDelay; - - AnnounceIntellicardUsage(held, intellicard.WarningSound); - } + + if(TryGetHeldFromHolder((targetHolder.Owner, 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 ? intellicard.uploadTime : intellicard.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, @@ -430,11 +430,11 @@ private void UpdateAppearance(Entity entity) _appearance.SetData(entity.Owner, StationAiVisualState.Key, StationAiState.Occupied); } - - public virtual void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) - { - - } + + public virtual void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) + { + + } public virtual bool SetVisionEnabled(Entity entity, bool enabled, bool announce = false) { From b6c44bd431af233cc8004d406a253b20d62d1158 Mon Sep 17 00:00:00 2001 From: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Date: Thu, 7 Nov 2024 09:37:20 +0100 Subject: [PATCH 03/11] Oops! Forgot something --- Content.Shared/Intellicard/IntellicardComponent.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Intellicard/IntellicardComponent.cs b/Content.Shared/Intellicard/IntellicardComponent.cs index 0027fcbdf49f..1141303cf3e3 100644 --- a/Content.Shared/Intellicard/IntellicardComponent.cs +++ b/Content.Shared/Intellicard/IntellicardComponent.cs @@ -24,8 +24,8 @@ public sealed partial class IntellicardComponent : Component public int uploadTime = 3; /// - /// The sound that plays for the Silicon player - /// when the law change is processed for the provider. + /// The sound that plays for the AI + /// when they are being downloaded /// [DataField, AutoNetworkedField] public SoundSpecifier? WarningSound = new SoundPathSpecifier("/Audio/Misc/notice2.ogg"); From 6b59dc760700c600c9f7a60ff3319154a971175c Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Thu, 7 Nov 2024 17:21:06 +0100 Subject: [PATCH 04/11] addressing changes --- .../Silicons/StationAi/StationAiSystem.cs | 15 +++++++-------- .../Intellicard/IntellicardComponent.cs | 11 ++++------- .../StationAi/SharedStationAiSystem.Held.cs | 5 ++++- .../Silicons/StationAi/SharedStationAiSystem.cs | 15 +++++++-------- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Content.Server/Silicons/StationAi/StationAiSystem.cs b/Content.Server/Silicons/StationAi/StationAiSystem.cs index 6b7743817744..754a99a1421f 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 1141303cf3e3..e27174977fb1 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 b580447fcbb3..c9279b021513 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 157574dae38c..72439c26c9ba 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, From 8c4de25e56d1900827ee4e4c97018cb934af3f79 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Thu, 7 Nov 2024 17:30:29 +0100 Subject: [PATCH 05/11] guh --- Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index 72439c26c9ba..904e690e516c 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -205,10 +205,6 @@ private void OnAiInRange(Entity ent, ref InRangeOverr private void OnIntellicardDoAfter(Entity ent, ref IntellicardDoAfterEvent args) { - - if(args.Args.Target == null) - return; - if(args.Cancelled) return; From 4f9a56a8a842d5758e39610f1a4740e1473b107b Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Thu, 7 Nov 2024 17:31:31 +0100 Subject: [PATCH 06/11] guh 2.0 --- Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index 904e690e516c..1f807390e36b 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -207,13 +207,13 @@ private void OnIntellicardDoAfter(Entity ent, ref Inte { if(args.Cancelled) return; - + if(args.Handled) return; - + if (!TryComp(args.Args.Target, out StationAiHolderComponent? targetHolder)) return; - + // Try to insert our thing into them if (_slots.CanEject(ent.Owner, args.User, ent.Comp.Slot)) { From 5a93d06898becb2f69b755e8e98ef00ba655ab0b Mon Sep 17 00:00:00 2001 From: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Date: Fri, 8 Nov 2024 00:36:13 +0100 Subject: [PATCH 07/11] some cleanup --- .../Silicons/StationAi/StationAiSystem.cs | 3 +- .../StationAi/SharedStationAiSystem.cs | 32 ++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Content.Server/Silicons/StationAi/StationAiSystem.cs b/Content.Server/Silicons/StationAi/StationAiSystem.cs index 754a99a1421f..25871713b5b0 100644 --- a/Content.Server/Silicons/StationAi/StationAiSystem.cs +++ b/Content.Server/Silicons/StationAi/StationAiSystem.cs @@ -6,7 +6,6 @@ using Content.Shared.Silicons.StationAi; using Content.Shared.StationAi; using Robust.Shared.Audio; -using Robust.Shared.Audio.Systems; using Robust.Shared.Map.Components; using Robust.Shared.Player; @@ -47,7 +46,7 @@ public override bool SetWhitelistEnabled(Entity ent return true; } - public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) + public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) { if (!TryComp(uid, out var actor)) return; diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index 1f807390e36b..b5f4026e53b8 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -203,12 +203,12 @@ private void OnAiInRange(Entity ent, ref InRangeOverr } - private void OnIntellicardDoAfter(Entity ent, ref IntellicardDoAfterEvent args) + private void OnIntellicardDoAfter(Entity ent, ref IntellicardDoAfterEvent args) { - if(args.Cancelled) + if (args.Cancelled) return; - if(args.Handled) + if (args.Handled) return; if (!TryComp(args.Args.Target, out StationAiHolderComponent? targetHolder)) @@ -242,24 +242,22 @@ private void OnHolderInteract(Entity ent, ref AfterInt { if (args.Handled || !args.CanReach || args.Target == null) return; - + if (!TryComp(args.Target, out StationAiHolderComponent? targetHolder)) return; - + if (!TryComp(args.Used, out IntellicardComponent? intelliComp)) return; - + var isUploading = _slots.CanEject(ent.Owner, args.User, ent.Comp.Slot); - var isDownloading = _slots.CanEject(args.Target.Value, args.User, targetHolder.Slot); - + if (isUploading == isDownloading) return; - - if (TryGetHeldFromHolder((args.Target.Value, 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); } @@ -270,8 +268,9 @@ private void OnHolderInteract(Entity ent, ref AfterInt NeedHand = true, BreakOnDropItem = true }; - + _doAfter.TryStartDoAfter(doAfterArgs); + args.Handled = true; } private void OnHolderInit(Entity ent, ref ComponentInit args) @@ -425,11 +424,8 @@ private void UpdateAppearance(Entity entity) _appearance.SetData(entity.Owner, StationAiVisualState.Key, StationAiState.Occupied); } - - public virtual void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) - { - - } + + public virtual void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null) { } public virtual bool SetVisionEnabled(Entity entity, bool enabled, bool announce = false) { From 9c650a686b4b72f2f422fc04a6bf3bae3b052ad4 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Fri, 8 Nov 2024 17:37:01 +0100 Subject: [PATCH 08/11] all bless the intellicard --- .../{ => Components}/IntellicardComponent.cs | 0 .../StationAi/SharedStationAiSystem.cs | 22 ++++++++++++------- .../Locale/en-US/intellicard/intellicard.ftl | 3 +++ 3 files changed, 17 insertions(+), 8 deletions(-) rename Content.Shared/Intellicard/{ => Components}/IntellicardComponent.cs (100%) create mode 100644 Resources/Locale/en-US/intellicard/intellicard.ftl diff --git a/Content.Shared/Intellicard/IntellicardComponent.cs b/Content.Shared/Intellicard/Components/IntellicardComponent.cs similarity index 100% rename from Content.Shared/Intellicard/IntellicardComponent.cs rename to Content.Shared/Intellicard/Components/IntellicardComponent.cs diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index b5f4026e53b8..5a5f33b10c78 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -25,6 +25,7 @@ using Robust.Shared.Physics; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; +using Robust.Shared.Serialization.Manager.Exceptions; using Robust.Shared.Timing; namespace Content.Shared.Silicons.StationAi; @@ -249,11 +250,19 @@ private void OnHolderInteract(Entity ent, ref AfterInt if (!TryComp(args.Used, out IntellicardComponent? intelliComp)) return; - var isUploading = _slots.CanEject(ent.Owner, args.User, ent.Comp.Slot); - var isDownloading = _slots.CanEject(args.Target.Value, args.User, targetHolder.Slot); + var cardHasAi = _slots.CanEject(ent.Owner, args.User, ent.Comp.Slot); + var coreHasAi = _slots.CanEject(args.Target.Value, args.User, targetHolder.Slot); - if (isUploading == isDownloading) + if (cardHasAi && coreHasAi) + { + _popup.PopupClient(Loc.GetString("intellicard-core-occupied"), args.User, args.User, PopupType.Medium); + return; + } + if (!cardHasAi && !coreHasAi) + { + _popup.PopupClient(Loc.GetString("intellicard-core-empty"), args.User, args.User, PopupType.Medium); return; + } if (TryGetHeldFromHolder((args.Target.Value, targetHolder), out var held) && _timing.CurTime > intelliComp.NextWarningAllowed) { @@ -261,7 +270,7 @@ private void OnHolderInteract(Entity ent, ref AfterInt AnnounceIntellicardUsage(held, intelliComp.WarningSound); } - 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, cardHasAi ? intelliComp.UploadTime : intelliComp.DownloadTime, new IntellicardDoAfterEvent(), args.Target, ent.Owner) { BreakOnDamage = true, BreakOnMove = true, @@ -469,10 +478,7 @@ public sealed partial class JumpToCoreEvent : InstantActionEvent } [Serializable, NetSerializable] -public sealed partial class IntellicardDoAfterEvent : SimpleDoAfterEvent -{ - -} +public sealed partial class IntellicardDoAfterEvent : SimpleDoAfterEvent; [Serializable, NetSerializable] diff --git a/Resources/Locale/en-US/intellicard/intellicard.ftl b/Resources/Locale/en-US/intellicard/intellicard.ftl new file mode 100644 index 000000000000..8f6eb646bcbc --- /dev/null +++ b/Resources/Locale/en-US/intellicard/intellicard.ftl @@ -0,0 +1,3 @@ +# General +intellicard-core-occupied = The core is already occupied. +intellicard-core-empty = The core is empty. \ No newline at end of file From e3d174470b12a7ee984c8d655c9bf8c9ca797ad3 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Fri, 8 Nov 2024 17:46:22 +0100 Subject: [PATCH 09/11] Yippee --- Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index 5a5f33b10c78..b586732fb4db 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -25,7 +25,6 @@ using Robust.Shared.Physics; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.Manager.Exceptions; using Robust.Shared.Timing; namespace Content.Shared.Silicons.StationAi; @@ -256,11 +255,13 @@ private void OnHolderInteract(Entity ent, ref AfterInt if (cardHasAi && coreHasAi) { _popup.PopupClient(Loc.GetString("intellicard-core-occupied"), args.User, args.User, PopupType.Medium); + args.Handled = true; return; } if (!cardHasAi && !coreHasAi) { _popup.PopupClient(Loc.GetString("intellicard-core-empty"), args.User, args.User, PopupType.Medium); + args.Handled = true; return; } From 0956c4e29336cbc4794177d491cd0a2b9b1b3277 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Fri, 8 Nov 2024 17:51:00 +0100 Subject: [PATCH 10/11] small locale thing --- Content.Server/Silicons/StationAi/StationAiSystem.cs | 2 +- Resources/Locale/en-US/silicons/station-ai.ftl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Silicons/StationAi/StationAiSystem.cs b/Content.Server/Silicons/StationAi/StationAiSystem.cs index 25871713b5b0..a10833dc63b0 100644 --- a/Content.Server/Silicons/StationAi/StationAiSystem.cs +++ b/Content.Server/Silicons/StationAi/StationAiSystem.cs @@ -51,7 +51,7 @@ public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue if (!TryComp(uid, out var actor)) return; - var msg = Loc.GetString("ai-intellicard-download-warning"); + var msg = Loc.GetString("ai-consciousness-download-warning"); var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", msg)); _chats.ChatMessageToOne(ChatChannel.Server, msg, wrappedMessage, default, false, actor.PlayerSession.Channel, colorOverride: Color.Red); diff --git a/Resources/Locale/en-US/silicons/station-ai.ftl b/Resources/Locale/en-US/silicons/station-ai.ftl index edd2e933be52..76c30eb10187 100644 --- a/Resources/Locale/en-US/silicons/station-ai.ftl +++ b/Resources/Locale/en-US/silicons/station-ai.ftl @@ -21,4 +21,4 @@ toggle-light = Toggle light ai-device-not-responding = Device is not responding -ai-intellicard-download-warning = Your consciousness is being downloaded. +ai-consciousness-download-warning = Your consciousness is being downloaded. From c20076250a11eede6017ebb848255e1c14f09e84 Mon Sep 17 00:00:00 2001 From: ScarKy0 Date: Sat, 9 Nov 2024 16:57:43 +0100 Subject: [PATCH 11/11] changes + small bugfix --- Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs | 4 ++++ Resources/Locale/en-US/intellicard/intellicard.ftl | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs index b586732fb4db..189515635a82 100644 --- a/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs +++ b/Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs @@ -246,6 +246,10 @@ private void OnHolderInteract(Entity ent, ref AfterInt if (!TryComp(args.Target, out StationAiHolderComponent? targetHolder)) return; + //Don't want to download/upload between several intellicards. You can just pick it up at that point. + if (HasComp(args.Target)) + return; + if (!TryComp(args.Used, out IntellicardComponent? intelliComp)) return; diff --git a/Resources/Locale/en-US/intellicard/intellicard.ftl b/Resources/Locale/en-US/intellicard/intellicard.ftl index 8f6eb646bcbc..aed155a12029 100644 --- a/Resources/Locale/en-US/intellicard/intellicard.ftl +++ b/Resources/Locale/en-US/intellicard/intellicard.ftl @@ -1,3 +1,3 @@ # General -intellicard-core-occupied = The core is already occupied. -intellicard-core-empty = The core is empty. \ No newline at end of file +intellicard-core-occupied = The AI core is already occupied by another digital consciousness. +intellicard-core-empty = The AI core has no digital consciousness to download. \ No newline at end of file