Skip to content

Commit

Permalink
addressing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ScarKy0 committed Nov 7, 2024
1 parent b6c44bd commit 6b59dc7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
15 changes: 7 additions & 8 deletions Content.Server/Silicons/StationAi/StationAiSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Entity<StationAiCoreComponent>> _ais = new();

Expand Down Expand Up @@ -47,10 +46,10 @@ public override bool SetWhitelistEnabled(Entity<StationAiWhitelistComponent> ent

return true;
}
public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null)
{
if (!TryComp<ActorComponent>(uid, out var actor))

public override void AnnounceIntellicardUsage(EntityUid uid, SoundSpecifier? cue = null)
{
if (!TryComp<ActorComponent>(uid, out var actor))
return;

var msg = Loc.GetString("ai-intellicard-download-warning");
Expand All @@ -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)
{
Expand Down
11 changes: 4 additions & 7 deletions Content.Shared/Intellicard/IntellicardComponent.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Allows this entity to download the station AI onto an AiHolderComponent.
Expand All @@ -15,13 +13,13 @@ public sealed partial class IntellicardComponent : Component
/// The duration it takes to download the AI from an AiHolder.
/// </summary>
[DataField, AutoNetworkedField]
public int downloadTime = 15;
public int DownloadTime = 15;

/// <summary>
/// The duration it takes to upload the AI to an AiHolder.
/// </summary>
[DataField, AutoNetworkedField]
public int uploadTime = 3;
public int UploadTime = 3;

/// <summary>
/// The sound that plays for the AI
Expand All @@ -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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void OnCoreJump(Entity<StationAiHeldComponent> ent, ref JumpToCoreEvent
}

/// <summary>
/// Tries to get the entity held in the AI core.
/// Tries to get the entity held in the AI core using StationAiCore.
/// </summary>
private bool TryGetHeld(Entity<StationAiCoreComponent?> entity, out EntityUid held)
{
Expand All @@ -71,6 +71,9 @@ private bool TryGetHeld(Entity<StationAiCoreComponent?> entity, out EntityUid he
return true;
}

/// <summary>
/// Tries to get the entity held in the AI using StationAiHolder.
/// </summary>
private bool TryGetHeldFromHolder(Entity<StationAiHolderComponent?> entity, out EntityUid held)
{
held = EntityUid.Invalid;
Expand Down
15 changes: 7 additions & 8 deletions Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -243,7 +244,7 @@ private void OnIntellicardDoAfter(Entity<StationAiHolderComponent> ent, ref Inte

private void OnHolderInteract(Entity<StationAiHolderComponent> ent, ref AfterInteractEvent args)
{
if(!args.CanReach)
if (args.Handled || !args.CanReach || args.Target == null)
return;

if (!TryComp(args.Target, out StationAiHolderComponent? targetHolder))
Expand All @@ -252,23 +253,21 @@ private void OnHolderInteract(Entity<StationAiHolderComponent> 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,
Expand Down

0 comments on commit 6b59dc7

Please sign in to comment.