public Bleeding(uint _uid, Entity _affected, uint duration = 0, params object[] arguments) : base(_uid, _affected, duration, arguments) { isDebuff = true; isUnique = true; family = StatusEffectFamily.Damage; }
public ExampleEffect(uint _uid, Entity _affected, uint duration = 0, params object[] arguments) //Do not add more parameters to the constructors or bad things happen. : base(_uid, _affected, duration, arguments) { isDebuff = false; isUnique = false; family = StatusEffectFamily.None; }
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); } }
public bool RemoveEntity(Entity user, Entity toRemove) { if (containedEntities.Contains(toRemove)) { containedEntities.Remove(toRemove); return true; } else { return false; } }
public bool AddEntity(Entity user, Entity toAdd) { if (containedEntities.Contains(toAdd)) { return false; } else { containedEntities.Add(toAdd); return true; } }
protected override void RecieveItemInteraction(Entity actor, Entity item, Lookup<ItemCapabilityType, ItemCapabilityVerb> verbs) { base.RecieveItemInteraction(actor, item, verbs); if (verbs[ItemCapabilityType.Tool].Contains(ItemCapabilityVerb.Pry)) { ToggleDoor(true); } else if (verbs[ItemCapabilityType.Tool].Contains(ItemCapabilityVerb.Hit)) { var cm = IoCManager.Resolve<IChatManager>(); cm.SendChatMessage(ChatChannel.Default, actor.Name + " hit the " + Owner.Name + " with a " + item.Name + ".", null, item.Uid); } else if (verbs[ItemCapabilityType.Tool].Contains(ItemCapabilityVerb.Emag)) { OpenDoor(); disabled = true; } }
/// <summary> /// Entry point for interactions between an item and this object /// Basically, the actor uses an item on this object /// </summary> /// <param name="actor">the actor entity</param> protected void HandleItemToLargeObjectInteraction(Entity actor) { //Get the item ComponentReplyMessage reply = actor.SendMessage(this, ComponentFamily.Hands, ComponentMessageType.GetActiveHandItem); if (reply.MessageType != ComponentMessageType.ReturnActiveHandItem) return; // No item in actor's active hand. This shouldn't happen. var item = (Entity) reply.ParamsList[0]; reply = item.SendMessage(this, ComponentFamily.Item, ComponentMessageType.ItemGetCapabilityVerbPairs); if (reply.MessageType == ComponentMessageType.ItemReturnCapabilityVerbPairs) { var verbs = (Lookup<ItemCapabilityType, ItemCapabilityVerb>) reply.ParamsList[0]; if (verbs.Count == 0 || verbs == null) RecieveItemInteraction(actor, item); else RecieveItemInteraction(actor, item, verbs); } }
private void UnEquipEntityToHand(Entity e, Hand h) { var hands = (HumanHandsComponent) Owner.GetComponent(ComponentFamily.Hands); ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Hands, ComponentMessageType.IsHandEmpty, h); if (reply.MessageType == ComponentMessageType.IsHandEmptyReply && (bool) reply.ParamsList[0]) { UnEquipEntity(e); Owner.SendMessage(this, ComponentMessageType.PickUpItemToHand, e, h); } }
// Unequips entity e private void UnEquipEntity(Entity e) { EquipmentSlot key; foreach (var kvp in equippedEntities) { if (kvp.Value == e) { key = kvp.Key; UnEquipEntity(key); break; } } }
/// <summary> /// Entry point for interactions between an empty hand and this object /// Basically, actor "uses" this object /// </summary> /// <param name="actor">The actor entity</param> protected override void HandleEmptyHandToLargeObjectInteraction(Entity actor) { ToggleDoor(); }
private void UnEquipEntityToHand(Entity e) { UnEquipEntity(e); //HumanHandsComponent hh = (HumanHandsComponent)Owner.GetComponent(ComponentFamily.Hands); Owner.SendMessage(this, ComponentMessageType.PickUpItem, e); }
public bool AddEntity(Entity user, Entity toAdd) { if (equippedEntities.Any(x => x.Value == toAdd)) return false; else { EquippableComponent eqCompo = toAdd.GetComponent<EquippableComponent>(ComponentFamily.Equippable); if (eqCompo != null) { if (activeSlots.Contains(eqCompo.wearloc) && !equippedEntities.ContainsKey(eqCompo.wearloc)) { equippedEntities.Add(eqCompo.wearloc, toAdd); eqCompo.currentWearer = this.Owner; return true; } else return false; } else 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; }
public bool AddEntity(Entity actor, Entity toAdd, InventoryLocation location = InventoryLocation.Any) { if (containedEntities.Contains(toAdd)) { return false; } else { containedEntities.Add(toAdd); return true; } }
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 HandleRemoved(Entity entity) { entity.SendMessage(this, ComponentMessageType.Dropped); entity.SendMessage(this, ComponentMessageType.SetVisible, true); }
public bool RemoveEntity(Entity actor, Entity toRemove, InventoryLocation location = InventoryLocation.Any) { if (containedEntities.Contains(toRemove)) { containedEntities.Remove(toRemove); return true; } else { return false; } }
private void HandleAdded(Entity entity) { entity.SendMessage(this, ComponentMessageType.PickedUp, Owner, Hand.None); entity.SendMessage(this, ComponentMessageType.SetVisible, false); }
//Removes item from inventory and dispatches unhide message to sprite compo. public bool RemoveFromInventory(Entity entity) { if (containedEntities.Contains(entity)) { containedEntities.Remove(entity); } HandleRemoved(entity); Owner.SendDirectedComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, null, ComponentMessageType.InventoryUpdateRequired); return true; }
//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); } }
private bool IsItem(Entity e) { if (e.HasComponent(ComponentFamily.Item)) //We can only equip items derp return true; return false; }
/// <summary> /// Recieve an item interaction. woop. NO VERBS D: /// </summary> /// <param name="item"></param> protected virtual void RecieveItemInteraction(Entity actor, Entity item) { }
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); }
/// <summary> /// Entry point for interactions between an empty hand and this object /// Basically, actor "uses" this object /// </summary> /// <param name="actor">The actor entity</param> protected virtual void HandleEmptyHandToLargeObjectInteraction(Entity actor) { //Apply actions }
public bool RemoveEntity(Entity user, Entity toRemove) { if (equippedEntities.Any(x => x.Value == toRemove)) { EquippableComponent eqCompo = toRemove.GetComponent<EquippableComponent>(ComponentFamily.Equippable); if (eqCompo != null) eqCompo.currentWearer = null; equippedEntities[equippedEntities.First(x => x.Value == toRemove).Key] = null; return true; } else { return false; } }
// Equips Entity e to Part part private void EquipEntityToPart(EquipmentSlot part, Entity e) { if (equippedEntities.ContainsValue(e)) //Its already equipped? Unequip first. This shouldnt happen. UnEquipEntity(e); if (CanEquip(e)) //If the part is empty, the part exists on this mob, and the entity specified is not null { RemoveFromOtherComps(e); equippedEntities.Add(part, e); e.SendMessage(this, ComponentMessageType.ItemEquipped, Owner); //Owner.SendDirectedComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, null, // EquipmentComponentNetMessage.ItemEquipped, part, e.Uid); } }
protected override void ApplyDamage(Entity damager, int damageamount, DamageType damType) { base.ApplyDamage(damager, damageamount, damType); SendHealthUpdate(); }
// Equips Entity e and automatically finds the appropriate part private void EquipEntity(Entity e) { if (equippedEntities.ContainsValue(e)) //Its already equipped? Unequip first. This shouldnt happen. UnEquipEntity(e); if (CanEquip(e)) { ComponentReplyMessage reply = e.SendMessage(this, ComponentFamily.Equippable, ComponentMessageType.GetWearLoc); if (reply.MessageType == ComponentMessageType.ReturnWearLoc) { RemoveFromOtherComps(e); EquipEntityToPart((EquipmentSlot) reply.ParamsList[0], e); } } }
public bool containsEntity(Entity entity) { if (containedEntities.Contains(entity)) return true; else return false; }
public override void OnAdd(Entity owner) { base.OnAdd(owner); Owner.GetComponent<TransformComponent>(ComponentFamily.Transform).OnMove += OnMove; }