IEnumerator ClientArtifactEquip(int itemId, LobbyMessageInfo info) { LobbyPlayer player = LobbyServer.GetLobbyPlayer(info); // Wait for all actions to execute while (player.artifactsEditingFlag) { yield return(null); } try { var arti = new Artifact(itemId); player.artifactsEditingFlag = true; if (player.artifactTree.AddArtifact(itemId)) { player.artifactInventory.RemoveArtifact(arti); Lobby.RPC("ArtifactEquip", player.peer, itemId); // Save changes yield return(ArtifactsDB.SetArtifactTree( player, player.artifactTree )); yield return(ArtifactsDB.SetArtifactInventory( player, player.artifactInventory )); } } finally { player.artifactsEditingFlag = false; } }
IEnumerator ClientArtifactDiscard(byte level, byte slotId, LobbyMessageInfo info) { LobbyPlayer player = LobbyServer.GetLobbyPlayer(info); // Wait for all actions to execute while (player.artifactsEditingFlag) { yield return(null); } try { player.artifactsEditingFlag = true; player.artifactInventory.bags[level].RemoveItemSlot(slotId); Lobby.RPC("ArtifactDiscard", player.peer, level, slotId); // Save changes yield return(ArtifactsDB.SetArtifactTree( player, player.artifactTree )); yield return(ArtifactsDB.SetArtifactInventory( player, player.artifactInventory )); } finally { player.artifactsEditingFlag = false; } }
void ClientArtifactTree(string jsonTree, LobbyMessageInfo info) { LobbyPlayer player = LobbyServer.GetLobbyPlayer(info); //LogManager.General.Log(jsonTree); ArtifactTree tree = Jboy.Json.ReadObject <ArtifactTree>(jsonTree); LogManager.General.Log("Player '" + player.name + "' sent new artifact tree " + tree.ToString()); ArtifactsDB.SetArtifactTree(player, tree); }
IEnumerator ClientArtifactUnequip(byte level, byte slotIndex, LobbyMessageInfo info) { LobbyPlayer player = LobbyServer.GetLobbyPlayer(info); // Wait for all actions to execute while (player.artifactsEditingFlag) { yield return(null); } var slot = player.artifactTree.slots[level][slotIndex]; if (slot.artifact == null) { yield break; } try { player.artifactsEditingFlag = true; player.artifactInventory.AddArtifact(slot.artifact); slot.artifact = null; Lobby.RPC("ArtifactUnequip", player.peer, level, slotIndex); // Save changes yield return(ArtifactsDB.SetArtifactTree( player, player.artifactTree )); yield return(ArtifactsDB.SetArtifactInventory( player, player.artifactInventory )); } finally { player.artifactsEditingFlag = false; } }