public override WIListOption GetListOption(IItemOfInterest targetObject) { WIListOption option = base.GetListOption(targetObject); option.Flavors.Clear(); option.OptionText = "Barter"; option.DefaultFlavorIndex = -1; option.Disabled = false; //barter targets the owner of objects, not the object itself, so check if the owner is a shop owner if (targetObject.IOIType == ItemOfInterestType.WorldItem && targetObject.worlditem.Is <ShopOwner> ()) { //only do this if it's an actual worlditem //get the thing we're focusing on if (Player.Local.Surroundings.IsWorldItemInRange && !Player.Local.Surroundings.WorldItemFocus.worlditem.Is <OwnedByPlayer> () && Player.Local.Surroundings.WorldItemFocus.worlditem != targetObject.worlditem) { option.DefaultFlavorIndex = BuyFlavor; option.OptionText = "Buy for $" + Player.Local.Surroundings.WorldItemFocus.worlditem.BaseCurrencyValue.ToString(); } } else { //don't make it possible to barter for books BookAvatar bookAvatar = null; try { if (Player.Local.Surroundings.WorldItemFocus.worlditem.Is <BookAvatar> (out bookAvatar) && !bookAvatar.worlditem.Is <OwnedByPlayer> ()) { option.DefaultFlavorIndex = BuyFlavor; Book b = null; if (Books.Get.BookByName(bookAvatar.State.BookName, out b)) { if (b.TypeOfBook == BookType.Diary) { //can't buy diaries option.Disabled = true; option.OptionText = "Won't sell"; } else { option.OptionText = "Buy for $" + Player.Local.Surroundings.WorldItemFocus.worlditem.BaseCurrencyValue.ToString(); } } else { option.Disabled = true; } } } catch (Exception e) { Debug.Log("Couldn't get option because: " + e.ToString()); option.Disabled = true; } } return(option); }
public void Awake( ) { bookAvatar = (BookAvatar)target; }