mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 22:18:52 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description the adding AI is now up to y'all because i'm not touching loadout code for name datasets, but it shouldn't be too bad from here --------- Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Signed-off-by: SolStar <44028047+ewokswagger@users.noreply.github.com> Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: themias <89101928+themias@users.noreply.github.com> Co-authored-by: Verm <32827189+Vermidia@users.noreply.github.com> Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Co-authored-by: Sphiral <145869023+SphiraI@users.noreply.github.com> Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: Alzore <140123969+Blackern5000@users.noreply.github.com> Co-authored-by: ravage <142820619+ravage123321@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Co-authored-by: Intoxicating-Innocence <188202277+Intoxicating-Innocence@users.noreply.github.com> Co-authored-by: Saphire <lattice@saphi.re> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Errant <35878406+Errant-4@users.noreply.github.com> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: CaasGit <87243814+CaasGit@users.noreply.github.com> Co-authored-by: BramvanZijp <56019239+BramvanZijp@users.noreply.github.com> Co-authored-by: Boaz1111 <149967078+Boaz1111@users.noreply.github.com> Co-authored-by: NakataRin <45946146+NakataRin@users.noreply.github.com> Co-authored-by: Kara <lunarautomaton6@gmail.com> Co-authored-by: Plykiya <58439124+Plykiya@users.noreply.github.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com> Co-authored-by: Doomsdrayk <robotdoughnut@comcast.net> Co-authored-by: Brandon Hu <103440971+Brandon-Huu@users.noreply.github.com> Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: Julian Giebel <juliangiebel@live.de> Co-authored-by: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Co-authored-by: Repo <47093363+Titian3@users.noreply.github.com> Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Co-authored-by: icekot8 <93311212+icekot8@users.noreply.github.com> Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: no <165581243+pissdemon@users.noreply.github.com> Co-authored-by: Tornado Tech <54727692+Tornado-Technology@users.noreply.github.com> Co-authored-by: osjarw <62134478+osjarw@users.noreply.github.com> Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com> Co-authored-by: TGRCDev <tgrc@tgrc.dev> Co-authored-by: Milon <milonpl.git@proton.me> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: Fildrance <fildrance@gmail.com> Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> Co-authored-by: chavonadelal <156101927+chavonadelal@users.noreply.github.com> Co-authored-by: SolStar <44028047+ewokswagger@users.noreply.github.com> Co-authored-by: K-Dynamic <20566341+K-Dynamic@users.noreply.github.com> Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> Co-authored-by: ArchRBX <5040911+ArchRBX@users.noreply.github.com> Co-authored-by: archrbx <punk.gear5260@fastmail.com> Co-authored-by: Radezolid <snappednexus@gmail.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com> Co-authored-by: MilenVolf <63782763+MilenVolf@users.noreply.github.com> Co-authored-by: Velcroboy <107660393+IamVelcroboy@users.noreply.github.com> Co-authored-by: Velcroboy <velcroboy333@hotmail.com> Co-authored-by: neuPanda <chriseparton@gmail.com> Co-authored-by: neuPanda <spainman0@yahoo.com> Co-authored-by: Dvir <39403717+dvir001@users.noreply.github.com> Co-authored-by: Whatstone <whatston3@gmail.com> Co-authored-by: VideoKompany <135313844+VlaDOS1408@users.noreply.github.com> (cherry picked from commit 93ed70acfeda357133a701f637d3faeec02749bb)
276 lines
8.0 KiB
C#
276 lines
8.0 KiB
C#
using Content.Shared.DeltaV.CartridgeLoader.Cartridges;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.PDA;
|
|
using Robust.Shared.Timing;
|
|
|
|
|
|
namespace Content.Shared.DeltaV.NanoChat;
|
|
|
|
/// <summary>
|
|
/// Base system for NanoChat functionality shared between client and server.
|
|
/// </summary>
|
|
public abstract class SharedNanoChatSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<NanoChatCardComponent, ExaminedEvent>(OnExamined);
|
|
}
|
|
|
|
private void OnExamined(Entity<NanoChatCardComponent> ent, ref ExaminedEvent args)
|
|
{
|
|
if (!args.IsInDetailsRange)
|
|
return;
|
|
|
|
if (ent.Comp.Number == null)
|
|
{
|
|
args.PushMarkup(Loc.GetString("nanochat-card-examine-no-number"));
|
|
return;
|
|
}
|
|
|
|
args.PushMarkup(Loc.GetString("nanochat-card-examine-number", ("number", $"{ent.Comp.Number:D4}")));
|
|
}
|
|
|
|
#region Public API Methods
|
|
|
|
/// <summary>
|
|
/// Gets the NanoChat number for a card.
|
|
/// </summary>
|
|
public uint? GetNumber(Entity<NanoChatCardComponent?> card)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return null;
|
|
|
|
return card.Comp.Number;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the NanoChat number for a card.
|
|
/// </summary>
|
|
public void SetNumber(Entity<NanoChatCardComponent?> card, uint number)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return;
|
|
|
|
card.Comp.Number = number;
|
|
Dirty(card);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the recipients dictionary from a card.
|
|
/// </summary>
|
|
public IReadOnlyDictionary<uint, NanoChatRecipient> GetRecipients(Entity<NanoChatCardComponent?> card)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return new Dictionary<uint, NanoChatRecipient>();
|
|
|
|
return card.Comp.Recipients;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the messages dictionary from a card.
|
|
/// </summary>
|
|
public IReadOnlyDictionary<uint, List<NanoChatMessage>> GetMessages(Entity<NanoChatCardComponent?> card)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return new Dictionary<uint, List<NanoChatMessage>>();
|
|
|
|
return card.Comp.Messages;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets a specific recipient in the card.
|
|
/// </summary>
|
|
public void SetRecipient(Entity<NanoChatCardComponent?> card, uint number, NanoChatRecipient recipient)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return;
|
|
|
|
card.Comp.Recipients[number] = recipient;
|
|
Dirty(card);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a specific recipient from the card.
|
|
/// </summary>
|
|
public NanoChatRecipient? GetRecipient(Entity<NanoChatCardComponent?> card, uint number)
|
|
{
|
|
if (!Resolve(card, ref card.Comp) || !card.Comp.Recipients.TryGetValue(number, out var recipient))
|
|
return null;
|
|
|
|
return recipient;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all messages for a specific recipient.
|
|
/// </summary>
|
|
public List<NanoChatMessage>? GetMessagesForRecipient(Entity<NanoChatCardComponent?> card, uint recipientNumber)
|
|
{
|
|
if (!Resolve(card, ref card.Comp) || !card.Comp.Messages.TryGetValue(recipientNumber, out var messages))
|
|
return null;
|
|
|
|
return new List<NanoChatMessage>(messages);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds a message to a recipient's conversation.
|
|
/// </summary>
|
|
public void AddMessage(Entity<NanoChatCardComponent?> card, uint recipientNumber, NanoChatMessage message)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return;
|
|
|
|
if (!card.Comp.Messages.TryGetValue(recipientNumber, out var messages))
|
|
{
|
|
messages = new List<NanoChatMessage>();
|
|
card.Comp.Messages[recipientNumber] = messages;
|
|
}
|
|
|
|
messages.Add(message);
|
|
card.Comp.LastMessageTime = _timing.CurTime;
|
|
Dirty(card);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the currently selected chat recipient.
|
|
/// </summary>
|
|
public uint? GetCurrentChat(Entity<NanoChatCardComponent?> card)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return null;
|
|
|
|
return card.Comp.CurrentChat;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the currently selected chat recipient.
|
|
/// </summary>
|
|
public void SetCurrentChat(Entity<NanoChatCardComponent?> card, uint? recipient)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return;
|
|
|
|
card.Comp.CurrentChat = recipient;
|
|
Dirty(card);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets whether notifications are muted.
|
|
/// </summary>
|
|
public bool GetNotificationsMuted(Entity<NanoChatCardComponent?> card)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return false;
|
|
|
|
return card.Comp.NotificationsMuted;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets whether notifications are muted.
|
|
/// </summary>
|
|
public void SetNotificationsMuted(Entity<NanoChatCardComponent?> card, bool muted)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return;
|
|
|
|
card.Comp.NotificationsMuted = muted;
|
|
Dirty(card);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the time of the last message.
|
|
/// </summary>
|
|
public TimeSpan? GetLastMessageTime(Entity<NanoChatCardComponent?> card)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return null;
|
|
|
|
return card.Comp.LastMessageTime;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets if there are unread messages from a recipient.
|
|
/// </summary>
|
|
public bool HasUnreadMessages(Entity<NanoChatCardComponent?> card, uint recipientNumber)
|
|
{
|
|
if (!Resolve(card, ref card.Comp) || !card.Comp.Recipients.TryGetValue(recipientNumber, out var recipient))
|
|
return false;
|
|
|
|
return recipient.HasUnread;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clears all messages and recipients from the card.
|
|
/// </summary>
|
|
public void Clear(Entity<NanoChatCardComponent?> card)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return;
|
|
|
|
card.Comp.Messages.Clear();
|
|
card.Comp.Recipients.Clear();
|
|
card.Comp.CurrentChat = null;
|
|
Dirty(card);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes a chat conversation with a recipient from the card.
|
|
/// Optionally keeps message history while removing from active chats.
|
|
/// </summary>
|
|
/// <returns>True if the chat was deleted successfully</returns>
|
|
public bool TryDeleteChat(Entity<NanoChatCardComponent?> card, uint recipientNumber, bool keepMessages = false)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return false;
|
|
|
|
// Remove from recipients list
|
|
var removed = card.Comp.Recipients.Remove(recipientNumber);
|
|
|
|
// Clear messages if requested
|
|
if (!keepMessages)
|
|
card.Comp.Messages.Remove(recipientNumber);
|
|
|
|
// Clear current chat if we just deleted it
|
|
if (card.Comp.CurrentChat == recipientNumber)
|
|
card.Comp.CurrentChat = null;
|
|
|
|
if (removed)
|
|
Dirty(card);
|
|
|
|
return removed;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ensures a recipient exists in the card's contacts and message lists.
|
|
/// If the recipient doesn't exist, they will be added with the provided info.
|
|
/// </summary>
|
|
/// <returns>True if the recipient was added or already existed</returns>
|
|
public bool EnsureRecipientExists(Entity<NanoChatCardComponent?> card,
|
|
uint recipientNumber,
|
|
NanoChatRecipient? recipientInfo = null)
|
|
{
|
|
if (!Resolve(card, ref card.Comp))
|
|
return false;
|
|
|
|
if (!card.Comp.Recipients.ContainsKey(recipientNumber))
|
|
{
|
|
// Only add if we have recipient info
|
|
if (recipientInfo == null)
|
|
return false;
|
|
|
|
card.Comp.Recipients[recipientNumber] = recipientInfo.Value;
|
|
}
|
|
|
|
// Ensure message list exists for this recipient
|
|
if (!card.Comp.Messages.ContainsKey(recipientNumber))
|
|
card.Comp.Messages[recipientNumber] = new List<NanoChatMessage>();
|
|
|
|
Dirty(card);
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
}
|