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); } }
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; }
//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); } }