Skip to content

Commit

Permalink
Refactor methods for player init
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Jun 14, 2024
1 parent 263ca7f commit 1d4c8e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ 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
14 changes: 9 additions & 5 deletions Fika.Core/Coop/Players/CoopPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -871,18 +871,20 @@ public override void TryInteractionCallback(LootableContainer container)
_openAction = null;
}

protected virtual void Start()
public void SetupMainPlayer()
{
// Set own group id
Profile.Info.GroupId = "Fika";

// Setup own dog tag
if (Side != EPlayerSide.Savage)
{
if (Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem != null)
{
GStruct414<GClass2801> result = InteractionsHandlerClass.Remove(Equipment.GetSlot(EquipmentSlot.Dogtag).ContainedItem, _inventoryController, false, true);
if (result.Error != null)
{
FikaPlugin.Instance.FikaLogger.LogWarning("CoopPlayer::Start: Error removing dog tag!");
FikaPlugin.Instance.FikaLogger.LogWarning("CoopPlayer::SetupMainPlayer: Error removing dog tag!");
}
}

Expand Down Expand Up @@ -911,10 +913,12 @@ protected virtual void Start()
CoopGame coopGame = (CoopGame)Singleton<IFikaGame>.Instance;
if (coopGame.Location_0.Name.ToLower() == "laboratory")
{
Item accessCardItem = Profile.Inventory.AllRealPlayerItems.FirstOrDefault(x => x.TemplateId == "5c94bbff86f7747ee735c08f");
if (accessCardItem != null)
foreach (Item item in Profile.Inventory.AllRealPlayerItems)
{
InteractionsHandlerClass.Remove(accessCardItem, _inventoryController, false, true);
if (item.TemplateId == "5c94bbff86f7747ee735c08f")
{
InteractionsHandlerClass.Remove(item, _inventoryController, false, true);
}
}
}
}
Expand Down

0 comments on commit 1d4c8e4

Please sign in to comment.