private void DoEquip(Creature wearer, UseItemCallbackSafe <ArmorBase> postItemCallback, bool enabled) { active = enabled; this.userPrompted = true; ArmorBase retVal = ChangeEquipment(wearer, out string resultsOfUse); postItemCallback(true, resultsOfUse, Author(), retVal); }
private StandardDisplay BuildMenu(Creature wearer, UseItemCallbackSafe <ArmorBase> postItemCallback) { var display = new StandardDisplay(); display.OutputText(WearBimboSkirt(wearer)); display.AddButtonWithToolTip(0, GlobalStrings.ENABLE(), () => DoEquip(wearer, postItemCallback, true), BimboText(true), BimboTitle(true)); display.AddButtonWithToolTip(1, GlobalStrings.DISABLE(), () => DoEquip(wearer, postItemCallback, false), BimboText(false), BimboTitle(false)); return(display); }
//you can now give this a menu if you really want. for a valid example, see bimbo skirt. protected virtual DisplayBase AttemptToUse(Creature creature, UseItemCallbackSafe <LowerGarmentBase> useItemCallback) { if (!CanUse(creature, false, out string whyNot)) { useItemCallback(false, whyNot, Author(), this); return(null); } else { LowerGarmentBase retVal = ChangeEquipment(creature, out string resultsOfUse); useItemCallback(true, resultsOfUse, Author(), retVal); return(null); } }
//safe variant that ensures T->T when item is used. this allows us to enforce inventories that require a certain Base Item Type. //for example: the weapon rack will always have weapons; you can't pull a fast one and swap in a non-weapon when equipping a weapon off the rack. private protected virtual DisplayBase AttemptToUseSafe(Creature target, UseItemCallbackSafe <T> postItemUseCallbackSafe) { if (!CanUse(target, false, out string whyNot)) { postItemUseCallbackSafe(false, whyNot, Author(), (T)this); return(null); } else { T retVal = UseItemSafe(target, out string resultsOfUse); postItemUseCallbackSafe(true, resultsOfUse, Author(), retVal); return(null); } }
//we're going way tf buck to give this a menu when you equip it. protected override DisplayBase AttemptToUse(Creature target, UseItemCallbackSafe <ArmorBase> postItemUseCallbackSafe) { if (!CanUse(target, false, out string whyNot)) { postItemUseCallbackSafe(false, whyNot, Author(), this); return(null); } else { if (target.intelligence > 20) { return(BuildMenu(target, postItemUseCallbackSafe)); } else { active = true; ArmorBase retVal = ChangeEquipment(target, out string resultsOfUse); postItemUseCallbackSafe(true, resultsOfUse, Author(), retVal); return(null); } } }
private protected override DisplayBase AttemptToUseSafe(Creature target, UseItemCallbackSafe <LowerGarmentBase> postItemUseCallbackSafe) { return(AttemptToUse(target, postItemUseCallbackSafe)); }
public DisplayBase UseItemSafe(Creature target, UseItemCallbackSafe <T> postItemUseCallback) { return(AttemptToUseSafe(target, postItemUseCallback)); }