From 796b8cbf3bfe3db922773fb5e60ac2fc3a2aa0b3 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Sat, 20 Jul 2024 01:31:28 +0200 Subject: [PATCH] Show item name when pinging an item --- Fika.Core/Coop/Players/CoopPlayer.cs | 19 +++++++++++++++---- Fika.Core/Networking/FikaClient.cs | 2 +- Fika.Core/Networking/FikaServer.cs | 2 +- .../Packets/GameWorld/GenericPacket.cs | 3 +++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Fika.Core/Coop/Players/CoopPlayer.cs b/Fika.Core/Coop/Players/CoopPlayer.cs index 6a64a80d..780ac59d 100644 --- a/Fika.Core/Coop/Players/CoopPlayer.cs +++ b/Fika.Core/Coop/Players/CoopPlayer.cs @@ -855,6 +855,7 @@ public void Ping() PingFactory.EPingType pingType = PingFactory.EPingType.Point; object userData = null; + string localeId = null; //ConsoleScreen.Log(statement: $"{hit.collider.GetFullPath()}: {LayerMask.LayerToName(hitLayer)}/{hitGameObject.name}"); @@ -880,6 +881,7 @@ public void Ping() { pingType = PingFactory.EPingType.LootItem; userData = lootItem; + localeId = lootItem.Item.ShortName; } else if (hitGameObject.TryGetComponent(out Door door)) { @@ -908,7 +910,8 @@ public void Ping() PingLocation = hitPoint, PingType = pingType, PingColor = pingColor, - Nickname = Profile.Nickname + Nickname = Profile.Nickname, + LocaleId = string.IsNullOrEmpty(localeId) ? string.Empty : localeId }; PacketSender.Writer.Reset(); @@ -929,7 +932,7 @@ public void Ping() } } - public void ReceivePing(Vector3 location, PingFactory.EPingType pingType, Color pingColor, string nickname) + public void ReceivePing(Vector3 location, PingFactory.EPingType pingType, Color pingColor, string nickname, string localeId) { GameObject prefab = PingFactory.AbstractPing.pingBundle.LoadAsset("BasePingPrefab"); GameObject pingGameObject = Instantiate(prefab); @@ -938,8 +941,16 @@ public void ReceivePing(Vector3 location, PingFactory.EPingType pingType, Color { abstractPing.Initialize(ref location, null, pingColor); Singleton.Instance.PlayUISound(EUISoundType.QuestSubTrackComplete); - NotificationManagerClass.DisplayMessageNotification($"Received a ping from '{nickname}'", - ENotificationDurationType.Default, ENotificationIconType.Friend); + if (string.IsNullOrEmpty(localeId)) + { + NotificationManagerClass.DisplayMessageNotification($"Received a ping from '{nickname}'", + ENotificationDurationType.Default, ENotificationIconType.Friend); + } + else + { + NotificationManagerClass.DisplayMessageNotification($"'{nickname}' has pinged item '{localeId.Localized()}'", + ENotificationDurationType.Default, ENotificationIconType.Friend); + } } else { diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index f39f3a63..b90bf1ad 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -485,7 +485,7 @@ private void OnGenericPacketReceived(GenericPacket packet) { if (Players.TryGetValue(packet.NetId, out CoopPlayer pingPlayerToApply)) { - pingPlayerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname); + pingPlayerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname, packet.LocaleId); } } break; diff --git a/Fika.Core/Networking/FikaServer.cs b/Fika.Core/Networking/FikaServer.cs index b68dba6f..c93844b0 100644 --- a/Fika.Core/Networking/FikaServer.cs +++ b/Fika.Core/Networking/FikaServer.cs @@ -522,7 +522,7 @@ private void OnGenericPacketReceived(GenericPacket packet, NetPeer peer) { if (Players.TryGetValue(packet.NetId, out CoopPlayer playerToApply)) { - playerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname); + playerToApply.ReceivePing(packet.PingLocation, packet.PingType, packet.PingColor, packet.Nickname, packet.LocaleId); } } else if (packet.PacketType == EPackageType.LoadBot) diff --git a/Fika.Core/Networking/Packets/GameWorld/GenericPacket.cs b/Fika.Core/Networking/Packets/GameWorld/GenericPacket.cs index b69d6a0f..c108764f 100644 --- a/Fika.Core/Networking/Packets/GameWorld/GenericPacket.cs +++ b/Fika.Core/Networking/Packets/GameWorld/GenericPacket.cs @@ -19,6 +19,7 @@ public struct GenericPacket(EPackageType packageType) : INetSerializable public PingFactory.EPingType PingType; public Color PingColor = Color.white; public string Nickname; + public string LocaleId; public int BotNetId; public long DepartureTime; public string ExfilName; @@ -36,6 +37,7 @@ public void Deserialize(NetDataReader reader) PingType = (PingFactory.EPingType)reader.GetByte(); PingColor = reader.GetColor(); Nickname = reader.GetString(); + LocaleId = reader.GetString(); break; case EPackageType.TrainSync: DepartureTime = reader.GetLong(); @@ -67,6 +69,7 @@ public void Serialize(NetDataWriter writer) writer.Put((byte)PingType); writer.Put(PingColor); writer.Put(Nickname); + writer.Put(LocaleId); break; case EPackageType.TrainSync: writer.Put(DepartureTime);