Exemple #1
0
 public override void OnUse(Entity targetEnt)
 {
     if (targetEnt.HasComponent(ComponentFamily.StatusEffects)) //Use component messages instead.
     {
         var statComp = (StatusEffectComp) targetEnt.GetComponent(ComponentFamily.StatusEffects);
         statComp.AddEffect("Bleeding", 10);
         parent.StartCooldown(this);
     }
 }
        private void RemoveFromOtherComps(Entity entity)
        {
            Entity holder = null;

            if (entity.HasComponent(ComponentFamily.Item))
            {
                holder = ((BasicItemComponent)entity.GetComponent(ComponentFamily.Item)).CurrentHolder;
            }
            if (holder == null && entity.HasComponent(ComponentFamily.Equippable))
            {
                holder = ((EquippableComponent)entity.GetComponent(ComponentFamily.Equippable)).currentWearer;
            }
            if (holder != null)
            {
                holder.SendMessage(this, ComponentMessageType.DisassociateEntity, entity);
            }
            else
            {
                Owner.SendMessage(this, ComponentMessageType.DisassociateEntity, entity);
            }
        }
Exemple #3
0
        public void SetMaster(Entity m)
        {
            if (!m.HasComponent(ComponentFamily.Renderable))
            {
                return;
            }
            var mastercompo = m.GetComponent <IRenderableComponent>(ComponentFamily.Renderable);

            //If there's no sprite component, then F**K IT
            if (mastercompo == null)
            {
                return;
            }

            mastercompo.AddSlave(this);
            master = mastercompo;
        }
        private bool CanEquip(Entity e)
        {
            if (!e.HasComponent(ComponentFamily.Equippable))
            {
                return(false);
            }

            ComponentReplyMessage reply = e.SendMessage(this, ComponentFamily.Equippable,
                                                        ComponentMessageType.GetWearLoc);

            if (reply.MessageType == ComponentMessageType.ReturnWearLoc)
            {
                if (IsItem(e) && IsEmpty((EquipmentSlot)reply.ParamsList[0]) && e != null &&
                    activeSlots.Contains((EquipmentSlot)reply.ParamsList[0]))
                {
                    return(true);
                }
            }

            return(false);
        }
        public void SetMaster(Entity m)
        {
            if (!m.HasComponent(ComponentFamily.Renderable))
                return;
            var mastercompo = m.GetComponent<IRenderableComponent>(ComponentFamily.Renderable);
            //If there's no sprite component, then F**K IT
            if (mastercompo == null)
                return;

            mastercompo.AddSlave(this);
            master = mastercompo;
        }
        private bool CanEquip(Entity e)
        {
            if (!e.HasComponent(ComponentFamily.Equippable))
                return false;

            ComponentReplyMessage reply = e.SendMessage(this, ComponentFamily.Equippable,
                                                        ComponentMessageType.GetWearLoc);
            if (reply.MessageType == ComponentMessageType.ReturnWearLoc)
            {
                if (IsItem(e) && IsEmpty((EquipmentSlot) reply.ParamsList[0]) && e != null &&
                    activeSlots.Contains((EquipmentSlot) reply.ParamsList[0]))
                {
                    return true;
                }
            }

            return false;
        }
 private void RemoveFromOtherComps(Entity entity)
 {
     Entity holder = null;
     if (entity.HasComponent(ComponentFamily.Item))
         holder = ((BasicItemComponent) entity.GetComponent(ComponentFamily.Item)).CurrentHolder;
     if (holder == null && entity.HasComponent(ComponentFamily.Equippable))
         holder = ((EquippableComponent) entity.GetComponent(ComponentFamily.Equippable)).currentWearer;
     if (holder != null) holder.SendMessage(this, ComponentMessageType.DisassociateEntity, entity);
     else Owner.SendMessage(this, ComponentMessageType.DisassociateEntity, entity);
 }
 private bool IsItem(Entity e)
 {
     if (e.HasComponent(ComponentFamily.Item)) //We can only equip items derp
         return true;
     return false;
 }
Exemple #9
0
        //Adds item to inventory and dispatches hide message to sprite compo.
        private void AddToInventory(Entity entity)
        {
            if (!containedEntities.Contains(entity) && containedEntities.Count < maxSlots)
            {
                Entity holder = null;
                if (entity.HasComponent(ComponentFamily.Item))
                    holder = ((BasicItemComponent) entity.GetComponent(ComponentFamily.Item)).CurrentHolder;
                if (holder == null && entity.HasComponent(ComponentFamily.Equippable))
                    holder = ((EquippableComponent) entity.GetComponent(ComponentFamily.Equippable)).currentWearer;
                if (holder != null) holder.SendMessage(this, ComponentMessageType.DisassociateEntity, entity);
                else Owner.SendMessage(this, ComponentMessageType.DisassociateEntity, entity);

                containedEntities.Add(entity);

                HandleAdded(entity);
                Owner.SendDirectedComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, null,
                                                          ComponentMessageType.InventoryUpdateRequired);
            }
        }