public override bool Run() { try { Definition definition = InteractionDefinition as Definition; TraitChip chip = TraitChipManager.CreateTraitChip(definition.mChip); if (chip == null) { return(false); } Inventories.TryToMove(chip, Target); return(true); } catch (Exception exception) { Common.Exception(Actor, Target, exception); return(false); } }
protected override bool Run(SimDescription me, bool singleSelection) { List <BotChip.Item> allOptions = new List <BotChip.Item>(); List <TraitChip> list = new List <TraitChip>(); list = me.TraitChipManager.GetInstalledTraitChips(); List <TraitChipName> installed = new List <TraitChipName>(); foreach (TraitChip chip in list) { installed.Add(chip.TraitChipName); } foreach (TraitChipName name in Enum.GetValues(typeof(TraitChipName))) { TraitChipStaticData data = TraitChipManager.GetStaticElement(name); if (data == null) { continue; } int count = 0; if (installed.Contains(data.Guid)) { count++; } allOptions.Add(new BotChip.Item(data.Guid, count)); } CommonSelection <BotChip.Item> .Results selection = new CommonSelection <BotChip.Item>(Name, me.FullName, allOptions, new BotChip.AuxillaryColumn()).SelectMultiple(); if (selection.Count == 0) { return(false); } List <TraitChipStaticData> chipsToInstall = new List <TraitChipStaticData>(); foreach (BotChip.Item item in selection) { if (item == null) { continue; } TraitChipName chipName = item.Value; TraitChipStaticData chip = TraitChipManager.GetStaticElement(chipName); if (chip != null) { if (installed.Contains(chipName)) { foreach (TraitChip chipInBot in list) { if (chipInBot.TraitChipName == chipName) { me.TraitChipManager.RemoveTraitChip(chipInBot.mTraitChipSlot); chipInBot.RemoveTraitChipFromSim(); } } } else { chipsToInstall.Add(chip); } } } bool exceeded = false; foreach (TraitChipStaticData chip in chipsToInstall) { TraitChipName chipName = chip.Guid; TraitChip chipToUse = null; foreach (TraitChip inChip in me.CreatedSim.Inventory.FindAll <TraitChip>(false)) { if (inChip.TraitChipName == chipName) { chipToUse = inChip; break; } } if (chipToUse == null && me.TraitChipManager.Owner != null) { SimDescription owner = me.TraitChipManager.Owner; if (owner.CreatedSim != null && owner.CreatedSim.Inventory != null) { foreach (TraitChip inChip in owner.CreatedSim.Inventory.FindAll <TraitChip>(false)) { if (inChip.TraitChipName == chipName) { chipToUse = inChip; break; } } } } bool created = false; if (chipToUse == null) { chipToUse = TraitChipManager.CreateTraitChip(chipName); if (chipToUse != null) { me.CreatedSim.Inventory.TryToAdd(chipToUse); chipToUse.CreatorSim = me.SimDescriptionId; chipToUse.SetOwner(me); created = true; } } if (chipToUse != null) { int count = me.TraitChipManager.GetInstalledTraitChips().Count; count++; if (count > me.TraitChipManager.NumTraitSlots && me.TraitChipManager.NumTraitSlots < me.TraitChipManager.MaxNumTraitSlots) { me.TraitChipManager.UpgradeNumTraitChips(count); } int newSlot = me.TraitChipManager.GetOpenTraitChipSlot(); if (newSlot != -1) { me.TraitChipManager.AddTraitChip(chipToUse, newSlot); } else { exceeded = true; if (created) { chipToUse.Destroy(); } break; } } } if (exceeded) { // tried to expand this beyond 7 but the change trait chip UI has a cow, chicken, pig and a plumbot when it encounters > 7 Common.Notify(Common.Localize("ChangeTraitChips:MaxExceeded", me.IsFemale, new object[] { me, 7, 7 })); } return(true); }
public static IGameObject FetchRandomOccultTreat(OccultTypes type, bool isAlien) { if (isAlien) { InteractionDefinition instance = RabbitHole.StealSpaceRocks.Singleton; RabbitHole.StealSpaceRocks instance2 = instance as RabbitHole.StealSpaceRocks; if (instance2 != null) { RabbitHole.StealSpaceRocks.SpaceRockSize weightedIndex = (RabbitHole.StealSpaceRocks.SpaceRockSize)RandomUtil.GetWeightedIndex(instance2.SSRTuning.SpaceRockWeights); RockGemMetal spaceRockSize = RockGemMetal.SpaceRockSmall; switch (weightedIndex) { case RabbitHole.StealSpaceRocks.SpaceRockSize.Small: spaceRockSize = RockGemMetal.SpaceRockSmall; break; case RabbitHole.StealSpaceRocks.SpaceRockSize.Medium: spaceRockSize = RockGemMetal.SpaceRockMedium; break; case RabbitHole.StealSpaceRocks.SpaceRockSize.Large: spaceRockSize = RockGemMetal.SpaceRockLarge; break; } return(RockGemMetalBase.Make(spaceRockSize, false)); } } switch (type) { case OccultTypes.Fairy: PlantRarity rarity = (PlantRarity)RandomUtil.GetInt(0, 3); Quality quality = (Quality)RandomUtil.GetInt(4, 9); PlayerDisclosure playerKnowledgeOfPlantableType = (rarity == PlantRarity.Common) ? PlayerDisclosure.Exposed : PlayerDisclosure.Concealed; IGameObject seed = PlantHelper.CreateRandomPlantable(rarity, quality, true, playerKnowledgeOfPlantableType); return(seed); case OccultTypes.Frankenstein: ScrapInitParameters initData = new ScrapInitParameters(1); IGameObject scrap = GlobalFunctions.CreateObjectOutOfWorld("scrapPile", ProductVersion.EP2, null, initData); return(scrap); case OccultTypes.Genie: IGameObject lamp = GlobalFunctions.CreateObjectOutOfWorld("GenieLamp", ProductVersion.EP6); return(lamp); case OccultTypes.Mermaid: IGameObject kelp = MermadicKelp.MakeMermadicKelp(RandomUtil.CoinFlip()); return(kelp); case OccultTypes.PlantSim: string randomHerb = RandomUtil.GetRandomObjectFromList <string>(new List <string>(Herb.sIngredientToHerbDataMap.Keys)); Ingredient herb = Ingredient.Create(IngredientData.NameToDataMap[randomHerb]); return(herb as IGameObject); case OccultTypes.Robot: TraitChipStaticData data = RandomUtil.GetRandomObjectFromDictionary <ulong, TraitChipStaticData>(GenericManager <TraitChipName, TraitChipStaticData, TraitChip> .sDictionary); if (data != null) { TraitChip chip = TraitChipManager.CreateTraitChip(data.Guid); return(chip); } return(null); case OccultTypes.Vampire: IGameObject vampireTreat = null; if (!GameUtils.IsInstalled(ProductVersion.EP3)) { vampireTreat = Recipe.NameToRecipeHash["VampireJuiceEP7"].CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Perfect); } else { bool coinToss = RandomUtil.CoinFlip(); if (coinToss) { vampireTreat = Recipe.NameToRecipeHash["VampireJuice"].CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Perfect); } else { vampireTreat = Ingredient.Create(IngredientData.NameToDataMap["VampireFruit"]); } } return(vampireTreat); case OccultTypes.Werewolf: List <FishType> fish = new List <FishType>(); List <float> weights = new List <float>(fish.Count); foreach (FishType fishType in Fish.sFishData.Keys) { FishData data2 = Fish.sFishData[fishType]; if (((data2.IngredientData != null) && data2.IngredientData.CanBuyFromStore) && (data2.Level >= 0)) { fish.Add(fishType); weights.Add(1f); } } int weightedIndexFish = RandomUtil.GetWeightedIndex(weights.ToArray()); Fish obj2 = Fish.CreateFishOfRandomWeight(fish[weightedIndexFish]); return(obj2 as IGameObject); case OccultTypes.Witch: if (RandomUtil.CoinFlip()) { ISoloInteractionDefinition cdef = TraitFunctions.ConjureApple.Singleton; TraitFunctions.ConjureApple appleDef = cdef as TraitFunctions.ConjureApple; if (appleDef != null) { return(appleDef.CreateAppleForInventory(RandomUtil.CoinFlip(), Quality.Perfect)); } } else { AlchemyPotion potion = AlchemyPotion.CreateARandomPotion(RandomUtil.CoinFlip(), 0); return(potion as IGameObject); } return(null); case OccultTypes.None: default: return(null); } }