Ejemplo n.º 1
0
        public bool Event_OnAquire(ComponentEvent e)
        {
            World world = Engine.instance.world;

            // get the item payload of the event and add it to the internal list
            Entity newItem = ((EAquireItem)e).item;

            if (newItem != null && items.Count < size)
            {
                // check if it can be picked up
                ECanPickup carryEvent = (ECanPickup)newItem.FireEvent(new ECanPickup {
                    asker = owner
                });

                if (carryEvent.canPickup)
                {
                    world.DespawnEntity(newItem);
                    items.Add(newItem);

                    var getItemName  = (EGetScreenName)newItem.FireEvent(new EGetScreenName());
                    var getOwnerName = (EGetScreenName)owner.FireEvent(new EGetScreenName());
                    Engine.LogMessage("%2" + getOwnerName.text + "% grabs %2" + getItemName.text + "%", owner);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool Event_CanPickup(ComponentEvent e)
        {
            ECanPickup pickupEvent = (ECanPickup)e;
            Entity     asker       = pickupEvent.asker;

            // check if this is larger than the asker. If it is, then they cant pick it up
            EGetSize getSize   = (EGetSize)asker.FireEvent(new EGetSize());
            int      askerSize = getSize.size;

            // the other object is apperently smaller, so this set the payload to false. Also cant pickup self, like ever
            if (size > askerSize || asker == owner)
            {
                pickupEvent.canPickup = false;
            }
            else
            {
                pickupEvent.canPickup = true;
            }

            return(true);
        }