Skip to content

Commit

Permalink
Fix new dog tags not getting added due to filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 16, 2024
1 parent 9104573 commit b1d472c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 0 additions & 1 deletion Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@ public override async Task<LocalPlayer> vmethod_2(int playerId, Vector3 position
}

CoopPlayer coopPlayer = (CoopPlayer)myPlayer;
coopPlayer.SetupMainPlayer();
coopHandler.Players.Add(coopPlayer.NetId, coopPlayer);

PlayerSpawnRequest body = new(myPlayer.ProfileId, FikaBackendUtils.GetGroupId());
Expand Down
24 changes: 21 additions & 3 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ await player.Init(rotation, layerName, pointOfView, profile, inventoryController

player.Profile.Info.MainProfileNickname = FikaBackendUtils.PMCName;

player.SetupMainPlayer();

return player;
}

Expand Down Expand Up @@ -879,6 +881,7 @@ public void SetupMainPlayer()
// Setup own dog tag
if (Side != EPlayerSide.Savage)
{
FikaPlugin.Instance.FikaLogger.LogInfo("Setting up DogTag");
if (Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem != null)
{
GStruct414<GClass2801> result = InteractionsHandlerClass.Remove(Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem, _inventoryController, false, true);
Expand All @@ -894,7 +897,16 @@ public void SetupMainPlayer()
{
Item item = Singleton<ItemFactory>.Instance.CreateItem(MongoID.Generate(), templateId, null);

Equipment.GetSlot(EquipmentSlot.Dogtag).Add(item, false);
Slot dogtagSlot = Equipment.GetSlot(EquipmentSlot.Dogtag);
ItemFilter[] filters = dogtagSlot.Filters; // We need to temporarily remove and then re-add these as BSG did not include the new dog tags in their ItemFilter[]
dogtagSlot.Filters = null;
GStruct416<int> addResult = dogtagSlot.Add(item, false);
dogtagSlot.Filters = filters;

if (addResult.Error != null)
{
FikaPlugin.Instance.FikaLogger.LogError("CoopPlayer::SetupMainPlayer: Error adding dog tag to slot: " + addResult.Error);
}

DogtagComponent dogtagComponent = item.GetItemComponent<DogtagComponent>();
if (dogtagComponent != null)
Expand All @@ -907,6 +919,10 @@ public void SetupMainPlayer()
FikaPlugin.Instance.FikaLogger.LogWarning("Unable to find DogTagComponent");
}
}
else
{
FikaPlugin.Instance.FikaLogger.LogError("Could not get templateId for DogTag!");
}
}

// Delete labs card on labs
Expand All @@ -925,7 +941,9 @@ public void SetupMainPlayer()

private string GetDogTagTemplateId()
{
if (Profile.Side is EPlayerSide.Usec)
//return Profile.Side == EPlayerSide.Usec ? "6662ea05f6259762c56f3189" : "59f32bb586f774757e1e8442";

if (Side is EPlayerSide.Usec)
{
switch (Profile.Info.MemberCategory)
{
Expand All @@ -937,7 +955,7 @@ private string GetDogTagTemplateId()
return "6662ea05f6259762c56f3189";
}
}
else if (Profile.Side is EPlayerSide.Bear)
else if (Side is EPlayerSide.Bear)
{
switch (Profile.Info.MemberCategory)
{
Expand Down

0 comments on commit b1d472c

Please sign in to comment.