Exemplo n.º 1
0
        public void Add(string itemGuid, byte[] data)
        {
            var gameObject = ObjectSerializer.GetGameObject(data);

            if (gameObject == null)
            {
                return;
            }

            var pickupable = gameObject.GetComponent <Pickupable>();

            if (pickupable != null)
            {
                pickupable.isPickupable = false;
                pickupable.SetVisible(false);
            }

            foreach (var rigidbody in gameObject.GetComponentsInChildren <Rigidbody>())
            {
                UnityEngine.GameObject.Destroy(rigidbody);
            }

            foreach (var collider in gameObject.GetComponentsInChildren <Collider>())
            {
                UnityEngine.GameObject.Destroy(collider);
            }

            items[itemGuid] = gameObject;
        }
Exemplo n.º 2
0
        private void Process(ClientItemDropped msg)
        {
            var gameObject = ObjectSerializer.GetGameObject(msg.data);

            gameObject.transform.position = msg.position;

            GuidHelper.Set(gameObject, msg.itemGuid);

            var waterParkObject = GuidHelper.Find(msg.waterParkGuid);

            if (waterParkObject != null)
            {
                var waterPark = waterParkObject.GetComponent <WaterPark>();
                if (waterPark != null)
                {
                    var pickupable = gameObject.GetComponent <Pickupable>();
                    if (pickupable != null)
                    {
                        waterPark.AddItem(pickupable);
                    }
                }
            }

            var rigidbody = gameObject.GetComponent <Rigidbody>();

            if (rigidbody != null)
            {
                rigidbody.isKinematic = false;
            }

            SyncedObject.ApplyTo(gameObject);

            var constructor = gameObject.GetComponent <Constructor>();

            if (constructor != null)
            {
                var method = typeof(Constructor).GetMethod("Deploy", BindingFlags.NonPublic | BindingFlags.Instance);
                method.Invoke(constructor, new object[] { true });
                constructor.OnDeployAnimationStart();
                LargeWorldEntity.Register(constructor.gameObject);

                Utils.PlayEnvSound(constructor.releaseSound, constructor.transform.position, 20f);
            }
        }
Exemplo n.º 3
0
        private void Process(ClientContainerAddItem msg)
        {
            var owner     = GuidHelper.Find(msg.ownerGuid);
            var container = Helpers.GetItemsContainer(owner);

            if (container == null)
            {
                FindRemoteInventory(msg.ownerGuid)?.Add(msg.itemGuid, msg.data);
                return;
            }

            using (new MessageBlocker()) {
                var item = ObjectSerializer.GetGameObject(msg.data);
                GuidHelper.Set(item, msg.itemGuid);

                var pickupable = item.GetComponent <Pickupable>();
                if (pickupable == null)
                {
                    return;
                }

                container.AddItem(pickupable);
            }
        }
Exemplo n.º 4
0
        private void Process(ClientEquipmentAddItem msg)
        {
            var owner = GuidHelper.Find(msg.ownerGuid);

            if (owner == null)
            {
                FindRemoteInventory(msg.ownerGuid)?.Add(msg.itemGuid, msg.data);
                return;
            }

            var gameObject = ObjectSerializer.GetGameObject(msg.data);
            var pickupable = gameObject.GetComponent <Pickupable>();

            GuidHelper.Set(gameObject, msg.itemGuid);

            var equipment = Helpers.GetEquipment(owner);

            if (equipment == null)
            {
                Log.Info("Couldn't find equipment: " + msg.ownerGuid);
                return;
            }

            using (new MessageBlocker()) {
                var inventoryItem = new InventoryItem(pickupable);
                inventoryItem.container = equipment;
                inventoryItem.item.Reparent(equipment.tr);

                var itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                itemsBySlot[msg.slot] = inventoryItem;

                equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                Equipment.SendEquipmentEvent(pickupable, 0, owner, msg.slot);                 // equip event is = 0
                equipment.ReflectionCall("NotifyEquip", false, false, new object[] { msg.slot, inventoryItem });
            }
        }