/// <summary> /// This will be called at server to order character to pickup items /// </summary> /// <param name="objectId"></param> protected virtual void NetFuncPickupItem(PackedUInt objectId) { if (!CanMoveOrDoActions()) { return; } ItemDropEntity itemDropEntity = null; if (!TryGetEntityByObjectId(objectId, out itemDropEntity)) { return; } if (Vector3.Distance(CacheTransform.position, itemDropEntity.CacheTransform.position) > GameInstance.pickUpItemDistance + 5f) { return; } if (!itemDropEntity.IsAbleToLoot(this)) { GameManager.SendServerGameMessage(ConnectionId, GameMessage.Type.NotAbleToLoot); return; } var itemDropData = itemDropEntity.dropData; if (!itemDropData.IsValid()) { // Destroy item drop entity without item add because this is not valid itemDropEntity.NetworkDestroy(); return; } var itemDataId = itemDropData.dataId; var level = itemDropData.level; var amount = itemDropData.amount; if (!IncreasingItemsWillOverwhelming(itemDataId, amount) && this.IncreaseItems(itemDataId, level, amount)) { itemDropEntity.NetworkDestroy(); } }
/// <summary> /// This will be called at server to order character to pickup items /// </summary> /// <param name="objectId"></param> protected virtual void NetFuncPickupItem(PackedUInt objectId) { if (!CanDoActions()) { return; } ItemDropEntity itemDropEntity = null; if (!TryGetEntityByObjectId(objectId, out itemDropEntity)) { return; } if (Vector3.Distance(CacheTransform.position, itemDropEntity.CacheTransform.position) > gameInstance.pickUpItemDistance + 5f) { return; } if (!itemDropEntity.IsAbleToLoot(this)) { gameManager.SendServerGameMessage(ConnectionId, GameMessage.Type.NotAbleToLoot); return; } CharacterItem itemDropData = itemDropEntity.dropData; if (!itemDropData.NotEmptySlot()) { // Destroy item drop entity without item add because this is not valid itemDropEntity.MarkAsPickedUp(); itemDropEntity.NetworkDestroy(); return; } if (!this.IncreasingItemsWillOverwhelming(itemDropData.dataId, itemDropData.amount) && this.IncreaseItems(itemDropData)) { itemDropEntity.MarkAsPickedUp(); itemDropEntity.NetworkDestroy(); } }