Skip to content

Commit

Permalink
Improve plant item sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jul 17, 2024
1 parent dc59f3a commit 1221f6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 9 additions & 3 deletions Fika.Core/Coop/ClientClasses/CoopClientSharedQuestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void Profile_OnItemZoneDropped(string itemId, string zoneId)
}

droppedZoneIds.Add(zoneId);
QuestDropItemPacket packet = new(itemId, zoneId);
QuestDropItemPacket packet = new(player.Profile.Info.MainProfileNickname, itemId, zoneId);
#if DEBUG
FikaPlugin.Instance.FikaLogger.LogInfo("Profile_OnItemZoneDropped: Sending quest progress");
#endif
Expand Down Expand Up @@ -216,16 +216,22 @@ internal void ReceiveQuestDropItemPacket(ref QuestDropItemPacket packet)
string itemId = packet.ItemId;
string zoneId = packet.ZoneId;

if (CheckForDroppedItem(itemId, zoneId))
if (DroppedItemAlreadyExists(itemId, zoneId))
{
return;
}

if (FikaPlugin.QuestSharingNotifications.Value)
{
NotificationManagerClass.DisplayMessageNotification($"{packet.Nickname} planted an item.",
iconType: EFT.Communications.ENotificationIconType.Quest);
}

droppedZoneIds.Add(zoneId);
player.Profile.ItemDroppedAtPlace(itemId, zoneId);
}

private bool CheckForDroppedItem(string itemId, string zoneId)
private bool DroppedItemAlreadyExists(string itemId, string zoneId)
{
if (player.Profile.EftStats.DroppedItems.Any(x => x.ItemId == itemId && x.ZoneId == zoneId) || droppedZoneIds.Contains(zoneId))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace Fika.Core.Networking.Packets
{
public struct QuestDropItemPacket(string itemId, string zoneId) : INetSerializable
public struct QuestDropItemPacket(string nickname, string itemId, string zoneId) : INetSerializable
{
public string Nickname = nickname;
public string ItemId = itemId;
public string ZoneId = zoneId;

Expand Down

0 comments on commit 1221f6f

Please sign in to comment.