public override bool Apply(IActionLog log, EffectContext context) { // TODO: Test for immunity HitPoints hP = context?.Target?.GetData <HitPoints>(); if (hP != null) { // Calculate damage (taking account of target resistances/vulnerabilities) double damage = Damage * DamageType.MultiplierFor(context.Target); // Apply damage hP.Value -= damage; // Kill the target (if applicable) if (hP.Value <= 0) { Vector position = context.Target.GetData <MapData>()?.Position ?? Vector.Unset; context.SFX.Trigger(SFXKeywords.Bang, position); // Destroy! Equipped equipped = context.Target.GetData <Equipped>(); if (equipped != null) { // Drop held items! equipped.DropAll(context.Target, context); } context.Target.Delete(); } return(true); } else { return(false); } }
public override bool Apply(IActionLog log, EffectContext context) { PickUp pickUp = context.Target?.GetData <PickUp>(); if (pickUp != null) // Can pick up { // Does it still exist on the map? MapData mD = context.Target.GetData <MapData>(); if (mD?.MapCell != null) { // TEMP? // Add to equipped: Equipped equipped = context.Actor?.GetData <Equipped>(); if (equipped != null && equipped.Equip(context.Target)) { mD.MapCell.RemoveFromCell(context.Target); context.State.Elements.Remove(context.Target); } // TODO: Add to inventory as well as/instead? } } return(false); }
protected override void GenerateActions(TurnContext context, AvailableActions addTo) { Element actor = context.Element; Equipped equipped = actor?.GetData <Equipped>(); if (equipped != null) { foreach (EquipmentSlot slot in equipped.Slots) { if (slot.Item != null) { var iA = slot.Item.GetData <ItemActions>(); if (iA?.Prototype != null) { var action = iA.Prototype.Duplicate(); action.Trigger = new ActionInputTrigger(slot.HotKey); addTo.Actions.Add(action); } } } } //TODO: Base on items //addTo.Actions.Add(new WindUpAction(InputFunction.Ability_1)); }