private void ClientRpcSwapItem(NetworkConnection conn, int sourceInstanceID, int sourceCollectionIndex, int sourceSlot, int targetInstanceID, int targetCollectionIndex, int targetSlot) { NetworkIdentity sourceIdentity = NetworkIdentityManager.Instance.Get(sourceInstanceID); InventoryItem sourceItem = sourceIdentity.GetComponent <InventoryItem>(); ItemCollection sourceCollection = GetCollectionFromIndex(sourceCollectionIndex); NetworkIdentity targetIdentity = NetworkIdentityManager.Instance.Get(targetInstanceID); InventoryItem targetItem = targetIdentity.GetComponent <InventoryItem>(); ItemCollection targetCollection = GetCollectionFromIndex(targetCollectionIndex); sourceCollection[sourceSlot] = targetItem; targetCollection[targetSlot] = sourceItem; ItemSwapped?.Invoke(targetCollection, sourceItem, targetSlot, sourceCollection, targetItem, sourceSlot); if (sourceCollection == targetCollection) { sourceCollection.RepaintUI(); return; } ItemRemoved?.Invoke(sourceCollection, sourceItem, sourceSlot); ItemRemoved?.Invoke(targetCollection, targetItem, targetSlot); sourceCollection.RepaintUI(); targetCollection.RepaintUI(); }
private void ClientRpcClearCollection(NetworkConnection conn, int collectionIndex) { ItemCollection col = GetCollectionFromIndex(collectionIndex); col.Clear(); col.RepaintUI(); }
private void ClientRpcSetItemStack(int instanceID, int stack, int collection) { NetworkIdentity identity = NetworkIdentityManager.Instance.Get(instanceID); InventoryItem item = identity.GetComponent <InventoryItem>(); item.Stack = stack; ItemCollection col = GetCollectionFromIndex(collection); col.RepaintUI(); }
private void ClientRpcMoveItem(NetworkConnection conn, int instanceID, int fromCollectionIndex, int toCollectionIndex, int fromSlot, int toSlot) { NetworkIdentity identity = NetworkIdentityManager.Instance.Get(instanceID); InventoryItem item = identity.GetComponent <InventoryItem>(); ItemCollection fromCollection = GetCollectionFromIndex(fromCollectionIndex); ItemCollection toCollection = GetCollectionFromIndex(toCollectionIndex); bool contains = toCollection.Contains(item); if (fromCollection == toCollection || !toCollection.IsReferenceCollection) { fromCollection[fromSlot] = null; } toCollection[toSlot] = item; if (!contains) { ItemAdded?.Invoke(toCollection, item, toSlot); } else { ItemMoved?.Invoke(fromCollection, toCollection, fromSlot, toSlot, item); } if (toCollection == fromCollection) { toCollection.RepaintUI(); return; } if (fromCollection[fromSlot] == null) { ItemRemoved?.Invoke(fromCollection, item, fromSlot); } toCollection.RepaintUI(); fromCollection.RepaintUI(); }
private void SharedRpcClientReleaseClaim(int instanceID, int slot, int collectionIndex, Vector3 pos, Quaternion rot) { ItemCollection collection = GetCollectionFromIndex(collectionIndex); if (!collection.IsReferenceCollection) { NetworkIdentity identity = NetworkIdentityManager.Instance.Get(instanceID); identity.transform.position = pos; identity.transform.rotation = rot; identity.gameObject.SetActive(true); } if (IsOwner || IsServer) { if (!collection.IsReferenceCollection) { RemoveItemReferences(collection[slot]); } collection[slot] = null; collection.RepaintUI(); } }