예제 #1
0
        public async Task <bool> Run()
        {
            if (ErrorLimitReached)
            {
                return(false);
            }

            var area = World.CurrentArea;

            if (!area.IsTown && !area.IsHideoutArea)
            {
                return(false);
            }

            if (!ChaosRecipe.StashData.HasCompleteSet())
            {
                GlobalLog.Info("[SellRecipeTask] No chaos recipe set to sell.");
                return(false);
            }

            GlobalLog.Debug("[SellRecipeTask] Now going to take and sell a set of rare items for chaos recipe.");

            if (!await Inventories.OpenStashTab(Settings.Instance.StashTab))
            {
                ReportError();
                return(true);
            }

            ChaosRecipe.StashData.SyncWithStashTab();

            if (!ChaosRecipe.StashData.HasCompleteSet())
            {
                GlobalLog.Error("[SellRecipeTask] Saved stash data does not match actual stash data.");
                await Coroutines.CloseBlockingWindows();

                return(false);
            }

            var takenItemData = new RecipeData();

            int lowestItemType = RecipeItemType.None;
            var lowestItem     = Inventories.StashTabItems
                                 .OrderBy(i => i.ItemLevel)
                                 .FirstOrDefault(i => RecipeData.IsItemForChaosRecipe(i, out lowestItemType));

            if (lowestItem == null)
            {
                GlobalLog.Error("[SellRecipeTask] Unknown error. Fail to find actual item for chaos recipe.");
                ReportError();
                return(true);
            }

            GlobalLog.Debug($"[SellRecipeTask] Now taking \"{lowestItem.Name}\" (iLvl: {lowestItem.ItemLevel})");

            if (!await Inventories.FastMoveFromStashTab(lowestItem.LocationTopLeft))
            {
                ReportError();
                return(true);
            }

            takenItemData.IncreaseItemCount(lowestItemType);

            while (true)
            {
                int type = RecipeItemType.None;

                for (int i = 0; i < RecipeItemType.TotalTypeCount; i++)
                {
                    var count = takenItemData.GetItemCount(i);
                    if (count == 0 || (count == 1 && i == RecipeItemType.Ring))
                    {
                        type = i;
                        break;
                    }
                }

                if (type == RecipeItemType.None)
                {
                    break;
                }

                var item = Inventories.StashTabItems
                           .Where(i => RecipeData.IsItemForChaosRecipe(i, out var t) && t == type)
                           .OrderByDescending(i => i.ItemLevel)
                           .FirstOrDefault();

                if (item == null)
                {
                    GlobalLog.Error("[SellRecipeTask] Unknown error. Fail to find actual item for chaos recipe.");
                    ReportError();
                    return(true);
                }

                GlobalLog.Debug($"[SellRecipeTask] Now taking \"{item.Name}\" (iLvl: {item.ItemLevel})");

                if (!await Inventories.FastMoveFromStashTab(item.LocationTopLeft))
                {
                    ReportError();
                    return(true);
                }

                takenItemData.IncreaseItemCount(type);
            }

            await Wait.SleepSafe(300);

            ChaosRecipe.StashData.SyncWithStashTab();

            var recipeItems = Inventories.InventoryItems
                              .Where(i => RecipeData.IsItemForChaosRecipe(i, out var t))
                              .Select(i => i.LocationTopLeft)
                              .ToList();

            if (recipeItems.Count == 0)
            {
                GlobalLog.Error("[SellRecipeTask] Unknown error. There are no items in player's inventory after taking them from stash.");
                ReportError();
                return(true);
            }

            if (!await TownNpcs.SellItems(recipeItems))
            {
                ReportError();
            }

            return(true);
        }
예제 #2
0
        public static OptionResult Perform(Sims3.Gameplay.Inventory inventory, Item sort)
        {
            if (inventory == null)
            {
                return(OptionResult.Failure);
            }

            if (sort == null)
            {
                return(OptionResult.Failure);
            }

            Dictionary <Type, int> counts = new Dictionary <Type, int>();

            foreach (InventoryStack stack in inventory.mItems.Values)
            {
                foreach (InventoryItem item in stack.List)
                {
                    if (item.mObject == null)
                    {
                        continue;
                    }

                    counts[item.mObject.GetType()] = stack.List.Count;

                    if (!item.mObject.InUse)
                    {
                        item.mInUse = false;
                    }
                }
            }

            List <SortObject> objs = new List <SortObject>();

            foreach (GameObject obj in Inventories.QuickFind <GameObject>(inventory))
            {
                if (inventory.TryToRemove(obj))
                {
                    objs.Add(new SortObject(obj, counts[obj.GetType()]));
                }
            }

            try
            {
                objs.Sort(sort);
            }
            catch (Exception e)
            {
                Common.Exception(inventory.Owner, e);
            }

            try
            {
                inventory.IgnoreInventoryValidation = true;

                foreach (SortObject obj in objs)
                {
                    if (!Inventories.TryToMove(obj.mObj, inventory))
                    {
                        obj.mObj.Destroy();
                    }
                }
            }
            finally
            {
                inventory.IgnoreInventoryValidation = false;
            }

            return(OptionResult.SuccessClose);
        }
예제 #3
0
        public async Task <bool> Run()
        {
            var area = World.CurrentArea;

            if (!area.IsTown && !area.IsHideoutArea)
            {
                return(false);
            }

            var itemsToId  = new List <Vector2i>();
            var itemFilter = ItemEvaluator.Instance;

            foreach (var item in Inventories.InventoryItems)
            {
                if (item.IsIdentified || item.IsCorrupted || item.IsMirrored)
                {
                    continue;
                }

                if (!itemFilter.Match(item, EvaluationType.Id))
                {
                    continue;
                }

                itemsToId.Add(item.LocationTopLeft);
            }

            if (itemsToId.Count == 0)
            {
                GlobalLog.Info("[IdTask] No items to identify.");
                return(false);
            }

            GlobalLog.Info($"[IdTask] {itemsToId.Count} items to id.");

            int scrollsAmount = LokiPoe.InstanceInfo.GetPlayerInventoryBySlot(InventorySlot.Main).ItemAmount(CurrencyNames.Wisdom);

            if (scrollsAmount == 0 && Inventories.AvailableInventorySquares == 0)
            {
                GlobalLog.Error("[IdTask] No id scrolls and no free space in inventory. Now stopping the bot because it cannot continue.");
                BotManager.Stop();
                return(true);
            }

            GlobalLog.Info($"[IdTask] {scrollsAmount} id scrolls.");

            if (scrollsAmount < itemsToId.Count)
            {
                GlobalLog.Warn("[IdTask] Not enough id scrolls to identify all items. Now going to take them from stash.");

                var result = await Inventories.WithdrawCurrency(CurrencyNames.Wisdom);

                if (result == WithdrawResult.Error)
                {
                    ErrorManager.ReportError();
                    return(true);
                }
                if (result == WithdrawResult.Unavailable)
                {
                    GlobalLog.Error("[IdTask] There are no id scrolls in all tabs assigned to them. Now stopping the bot because it cannot continue.");
                    BotManager.Stop();
                    return(true);
                }
            }

            if (!await Inventories.OpenInventory())
            {
                ErrorManager.ReportError();
                return(true);
            }

            itemsToId.Sort(Position.Comparer.Instance);

            foreach (var pos in itemsToId)
            {
                if (!await Identify(pos))
                {
                    ErrorManager.ReportError();
                    return(true);
                }
            }
            await Coroutines.CloseBlockingWindows();

            return(true);
        }
예제 #4
0
        public async Task <bool> Run()
        {
            if (ErrorLimitReached)
            {
                return(false);
            }

            var area = World.CurrentArea;

            if (!area.IsTown && !area.IsHideoutArea)
            {
                return(false);
            }

            if (_shouldUpdateStashData)
            {
                GlobalLog.Debug("[SellExtraMapsTask] Updating map tab stash data (every Start)");

                if (!await OpenMapTab())
                {
                    return(true);
                }
                else
                {
                    Class1.MapStashData.SyncWithStashTab();
                }
                _shouldUpdateStashData = false;
            }
            else
            {
                if (!await Inventories.OpenStashTab(settings.Instance.MapStashTab))
                {
                    ReportError();
                    return(true);
                }

                Class1.MapStashData.SyncWithStashTab();

                if (Class1.MapStashData.GetMapCount() > settings.Instance.MaxNumMaps)
                {
                    var mapsInStashTab = Inventories.StashTabItems
                                         .Where(m => m.IsMap() && m.Rarity != Rarity.Unique)
                                         .OrderBy(m => m.Priority())
                                         .ThenBy(m => m.MapTier).Take(settings.Instance.SellNumMaps);



                    foreach (var mapItem in mapsInStashTab)
                    {
                        if (!await Inventories.FastMoveFromStashTab(mapItem.LocationTopLeft))
                        {
                            ReportError();
                            return(true);
                        }
                    }

                    await Wait.SleepSafe(300);

                    Class1.MapStashData.SyncWithStashTab();

                    var mapSellItems = Inventories.InventoryItems
                                       .Where(m => m.IsMap())
                                       .Select(i => i.LocationTopLeft)
                                       .ToList();

                    if (mapSellItems.Count == 0)
                    {
                        GlobalLog.Error("[SellExtraMapsTask] Unknown error. There are no map items in player's inventory after taking them from stash.");
                        ReportError();
                        return(true);
                    }

                    if (!await TownNpcs.SellItems(mapSellItems))
                    {
                        ReportError();
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #5
0
        public override bool Run()
        {
            try
            {
                if ((!Target.RouteToBarrelSlot(Actor) || ((Target.CurrentState != NectarMaker.NectarMakerState.FruitAddable) && (Target.CurrentState != NectarMaker.NectarMakerState.SquishingFruit))) || !Target.HasFruit)
                {
                    return(false);
                }
                Target.CurrentState = NectarMaker.NectarMakerState.SquishingFruit;
                Actor.SkillManager.AddElement(SkillNames.Nectar);
                foreach (GameObject obj2 in Inventories.QuickFind <GameObject>(Target.Inventory))
                {
                    Target.Inventory.SetInUse(obj2);
                }
                Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.GoingToSwim);
                StandardEntry();
                BeginCommodityUpdates();
                AcquireStateMachine("NectarMaker");
                SetActorAndEnter("x", Actor, "Enter Squish Grapes");
                SetActor("nectarMaker", Target);
                AnimateSim("Squish Grapes Loop");
                StartStages();
                bool flag = false;

                try
                {
                    flag = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));

                    if (flag)
                    {
                        Target.CurrentState = NectarMaker.NectarMakerState.SquishedFruit;
                        Target.UpdateVisualState();
                        NectarSkill skill = Actor.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                        if ((skill != null) && skill.IsFlavorfulFeet())
                        {
                            Target.mMultiplierFromFeet = NectarSkill.kFlavorfulFeetValueMultiplier;
                        }
                        if (skill != null)
                        {
                            skill.SquishGrapes();
                        }
                        Target.mSquishAmountRemaining = 1f;
                    }
                    else if (ActiveStage != null)
                    {
                        Target.mSquishAmountRemaining *= ActiveStage.TimeRemaining((InteractionInstance)this) / ActiveStage.TotalTime();
                    }
                    AnimateSim("Exit");
                }
                finally
                {
                    EndCommodityUpdates(true);
                    StandardExit();
                }

                Actor.SwitchToPreviousOutfitWithSpin();
                if ((this.mMakeStyleToPush != NectarMaker.MakeNectarStyle.None) && flag)
                {
                    Actor.InteractionQueue.PushAsContinuation(new MakeNectarEx.Definition(mMakeStyleToPush), Target, true);
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
예제 #6
0
        protected static bool Perform(Common.IStatGenerator stats, SimDescription sim, int amount, ref bool push)
        {
            if (sim.CreatedSim == null)
            {
                stats.IncStat("Hibernating");
                return(false);
            }
            else if (!Inventories.VerifyInventory(sim))
            {
                stats.IncStat("No Inventory");
                return(false);
            }

            School school = sim.CareerManager.School;

            if (school != null)
            {
                if (school.OwnersHomework == null)
                {
                    school.OwnersHomework = GlobalFunctions.CreateObjectOutOfWorld("Homework") as Homework;
                    school.OwnersHomework.OwningSimDescription = sim;
                    Inventories.TryToMove(school.OwnersHomework, sim.CreatedSim);

                    stats.IncStat("Homework Created");
                }

                if ((!sim.CreatedSim.Inventory.Contains(school.OwnersHomework)) &&
                    (school.OwnersHomework.LotCurrent != sim.CreatedSim.LotCurrent) &&
                    (school.OwnersHomework.UseCount == 0))
                {
                    Inventories.TryToMove(school.OwnersHomework, sim.CreatedSim);

                    stats.IncStat("Homework Moved");
                }
            }

            if (amount > 100)
            {
                amount = 100;
            }

            bool success = false;

            foreach (Homework obj in Inventories.InventoryFindAll <Homework>(sim))
            {
                if (obj.PercentComplete < 0)
                {
                    continue;
                }

                if ((amount < 0) || (obj.PercentComplete < amount))
                {
                    obj.PercentComplete = amount;
                    stats.AddStat("Homework Value", amount);

                    if (amount > 90)
                    {
                        push = true;
                    }

                    success = true;
                }
            }
            return(success);
        }
예제 #7
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Household house = Sim.Household;

            Sim sim = Sim.CreatedSim;

            Dictionary <SimDescription, float> inheritors = Deaths.GetInheritors(Sim, GetValue <InheritCashScenario.InheritorsOption, ManagerDeath.Inheritors>(), false);

            List <Sim> choices = new List <Sim>();

            foreach (SimDescription other in inheritors.Keys)
            {
                if (other.CreatedSim == null)
                {
                    continue;
                }

                if (!other.ChildOrAbove)
                {
                    continue;
                }

                choices.Add(other.CreatedSim);
            }

            if (choices.Count == 0)
            {
                foreach (Sim other in HouseholdsEx.AllHumans(house))
                {
                    if (other == sim)
                    {
                        continue;
                    }

                    choices.Add(other);
                }

                if (choices.Count == 0)
                {
                    IncStat("No Choices");
                    return(false);
                }
            }

            bool found = false;

            if (HouseholdsEx.NumHumans(house) == 1)
            {
                if (house.RealEstateManager.AllProperties.Count > 0)
                {
                    Dictionary <Household, Sim> houses = new Dictionary <Household, Sim>();

                    foreach (Sim choice in choices)
                    {
                        if (choice.Household == null)
                        {
                            continue;
                        }

                        houses[choice.Household] = choice;
                    }

                    if (houses.Count > 0)
                    {
                        List <KeyValuePair <Household, Sim> > houseChoices = new List <KeyValuePair <Household, Sim> >(houses);

                        foreach (PropertyData data in house.RealEstateManager.AllProperties)
                        {
                            KeyValuePair <Household, Sim> choice = RandomUtil.GetRandomObjectFromList(houseChoices);

                            ManagerMoney.TransferProperty(house, choice.Key, data);

                            mInheritors[choice.Value.SimDescription] = true;

                            IncStat("Property Transferred");
                            found = true;
                        }
                    }
                }
            }

            if (!SimTypes.IsSelectable(Sim))
            {
                Lots.PackupVehicles(sim, (HouseholdsEx.NumHumans(house) > 1));

                foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Inventory))
                {
                    Sim choice = RandomUtil.GetRandomObjectFromList(choices);

                    if ((obj is INotTransferableOnDeath) || (obj is IHiddenInInventory) || (obj is DeathFlower) || (obj is Diploma))
                    {
                        IncStat("NonTrans " + obj.GetLocalizedName());
                        continue;
                    }

                    found = true;

                    if (Inventories.TryToMove(obj, choice))
                    {
                        IncStat("Transferred " + obj.GetLocalizedName());

                        mInheritors[choice.SimDescription] = true;
                    }
                    else
                    {
                        IncStat("Unremovable " + obj.GetLocalizedName());
                    }
                }
            }

            Writing oldSkill = Sim.SkillManager.GetSkill <Writing>(SkillNames.Writing);

            if (oldSkill != null)
            {
                Writing.RoyaltyAlarm alarm = oldSkill.mRoyaltyAlarm;

                if (alarm != null)
                {
                    List <Sim> royaltyChoices = new List <Sim>(choices);

                    while (royaltyChoices.Count > 0)
                    {
                        Sim choice = RandomUtil.GetRandomObjectFromList(royaltyChoices);
                        royaltyChoices.Remove(choice);

                        Writing newSkill = choice.SkillManager.GetSkill <Writing>(SkillNames.Writing);
                        if ((newSkill != null) && (newSkill.mRoyaltyAlarm != null))
                        {
                            continue;
                        }

                        newSkill = choice.SkillManager.AddElement(SkillNames.Writing) as Writing;
                        if (newSkill != null)
                        {
                            alarm.RemoveRoyaltyAlarm();

                            alarm.mAlarmHandle = AlarmManager.Global.AddAlarmDay(Writing.kRoyaltyPayHour, DaysOfTheWeek.Sunday, new AlarmTimerCallback(alarm.AlarmCallBack), "Royalty Alarm", AlarmType.AlwaysPersisted, newSkill.SkillOwner);
                            alarm.mSkill       = newSkill;

                            newSkill.mRoyaltyAlarm = alarm;

                            IncStat("Transferred Royalties");

                            mInheritors[choice.SimDescription] = true;

                            found = true;
                        }

                        break;
                    }
                }
            }

            if (!found)
            {
                return(false);
            }

            return(mInheritors.Count > 0);
        }
예제 #8
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("RepairImaginaryFriends");

            Trait trait;
            if (TraitManager.sDictionary.TryGetValue((ulong)TraitNames.ImaginaryFriendHiddenTrait, out trait))
            {
                trait.mNonPersistableData.mCanBeLearnedRandomly = false;
            }

            foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects<ImaginaryDoll>())
            {
                if (doll.mLiveStateSimDescId == 0) continue;

                if (doll.GetLiveFormSimDescription() != null) continue;

                doll.CreateLiveStateForm();

                Overwatch.Log("Missing Imaginary Doll Repaired");
            }

            foreach (SimDescription sim in Households.All(Household.NpcHousehold))
            {
                if (sim.OccultManager == null) continue;

                OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;
                if (occult == null) continue;

                Overwatch.Log(sim.FullName);

                if (occult.IsReal) continue;

                SimDescription owner = SimDescription.Find(occult.OwnerSimDescriptionId);
                if (owner == null) continue;

                if (owner.LotHome == null) continue;

                IScriptProxy proxy = Simulator.GetProxy(occult.mDollId);
                if (proxy == null)
                {
                    IGameObject obj = GlobalFunctions.CreateObjectOutOfWorld("ImaginaryFriendDoll", ProductVersion.EP4);
                    if (obj != null)
                    {
                        ImaginaryDoll doll = obj as ImaginaryDoll;
                        if (doll == null)
                        {
                            obj.Destroy();
                        }
                        else
                        {
                            occult.UpdateDollGuid(obj.ObjectId);

                            doll.SetOwner(owner);

                            doll.mLiveStateSimDescId = sim.SimDescriptionId;
                            doll.mIsFemale = sim.IsFemale;
                            doll.mGenderSet = true;
                            doll.EstablishState(ImaginaryDoll.OwnershipState.Live);

                            Sim ownerSim = owner.CreatedSim;
                            if (ownerSim != null)
                            {
                                if (Inventories.TryToMove(obj, ownerSim))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Sim Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                            else
                            {
                                if (Inventories.TryToMove(obj, ownerSim.Household.SharedFamilyInventory.Inventory))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Family Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #9
0
 public InventoryRepository(IUserRepository userRepository, Inventories inventories)
 {
     _userRepository = userRepository;
     _inventories    = inventories;
 }
예제 #10
0
        public static void ResetSkillModifiers(SimDescription sim)
        {
            if (sim.SkillManager == null)
            {
                return;
            }

            Corrections.CorrectOverallSkillModifier(sim);

            sim.SkillManager.mSkillModifiers = new Dictionary <SkillNames, float>();

            TraitManager traitManager = sim.TraitManager;

            if (traitManager != null)
            {
                foreach (Trait trait in traitManager.List)
                {
                    traitManager.AddTraitSkillGainModifiers(sim, trait.Guid);
                }
            }

            Dictionary <GameObject, bool> inventory = new Dictionary <GameObject, bool>();

            if ((sim.CreatedSim != null) && (sim.CreatedSim.Inventory != null))
            {
                foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.CreatedSim.Inventory))
                {
                    inventory.Add(obj, true);
                }
            }

            ulong eventId = (ulong)EventTypeId.kSkillLearnedSkill;

            Dictionary <ulong, List <EventListener> > events;

            if (!EventTracker.Instance.mListeners.TryGetValue(eventId, out events))
            {
                events = null;
            }
            else
            {
                EventTracker.Instance.mListeners.Remove(eventId);
            }

            if ((sim.CreatedSim != null) && (!sim.CreatedSim.HasBeenDestroyed))
            {
                foreach (Skill skill in sim.SkillManager.List)
                {
                    bool isChangingWorlds = GameStates.sIsChangingWorlds;

                    // Workaround for issue in IsIdTravelling
                    GameStates.sIsChangingWorlds = false;
                    try
                    {
                        skill.OnSkillAddition(true);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, "Skill: " + skill.Guid.ToString(), e);
                    }
                    finally
                    {
                        GameStates.sIsChangingWorlds = isChangingWorlds;
                    }
                }
            }

            if (events != null)
            {
                EventTracker.Instance.mListeners.Add(eventId, events);
            }

            if ((sim.CreatedSim != null) && (sim.CreatedSim.Inventory != null))
            {
                foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.CreatedSim.Inventory))
                {
                    if (inventory.ContainsKey(obj))
                    {
                        continue;
                    }

                    try
                    {
                        sim.CreatedSim.Inventory.RemoveByForce(obj);
                        obj.Destroy(); // Do not use FadeOut(), it hangs the game
                    }
                    catch
                    { }
                }
            }

            if (sim.OccultManager != null)
            {
                OccultVampire vampire = sim.OccultManager.GetOccultType(OccultTypes.Vampire) as OccultVampire;
                if ((vampire != null) && (vampire.AppliedNightBenefits))
                {
                    try
                    {
                        if ((sim.CreatedSim != null) && (!sim.CreatedSim.HasBeenDestroyed))
                        {
                            vampire.SunsetCallback();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }
            }
        }
예제 #11
0
            public void Dispose(bool postLoad, bool isReset)
            {
                try
                {
                    if (mWasFutureSim)
                    {
                        mSim.TraitManager.AddHiddenElement(TraitNames.FutureSim);
                    }

                    if (mSim.CreatedSim != null)
                    {
                        BuffManager buffManager = mSim.CreatedSim.BuffManager;
                        if ((buffManager != null) && (mBuffs != null))
                        {
                            foreach (BuffInstance buff in mBuffs)
                            {
                                buffManager.AddBuff(buff.Guid, buff.mEffectValue, buff.mTimeoutCount, buff.mTimeoutPaused, buff.mAxisEffected, buff.mBuffOrigin, false);
                            }
                        }

                        if ((mInventory != null) && (mSim.CreatedSim.Inventory != null))
                        {
                            Inventories.RestoreInventoryFromList(mSim.CreatedSim.Inventory, mInventory, true);
                        }

                        if (mDreamStore != null)
                        {
                            mDreamStore.Restore(mSim.CreatedSim);
                        }

                        if (mSafeStore != null)
                        {
                            mSafeStore.Dispose();
                        }

                        if (mSim.DeathStyle != SimDescription.DeathType.None)
                        {
                            Urnstone stone = Urnstones.FindGhostsGrave(mSim);
                            if (stone != null)
                            {
                                stone.GhostSetup(mSim.CreatedSim, true);
                            }
                        }

                        mSim.CreatedSim.ReservedVehicle = mReservedVehicle;
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mSim, null, "Inventory", e);
                }

                // Must be after the opportunities are restored
                if ((mOpportunitiesChanged != null) && (OpportunityTrackerModel.gSingleton != null))
                {
                    OpportunityTrackerModel.gSingleton.OpportunitiesChanged = mOpportunitiesChanged;
                }

                try
                {
                    if (!postLoad)
                    {
                        if ((mSim.CreatedSim != null) &&
                            (mSim.CreatedSim.OpportunityManager != null) &&
                            (mSim.CreatedSim.OpportunityManager.Count > 0))
                        {
                            OpportunityTrackerModel.FireOpportunitiesChanged();
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(mSim, null, "FireOpportunitiesChanged", e);
                }

                EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false;

                mSim.mGenealogy = mGenealogy;

                if (mDoll != null)
                {
                    mDoll.mOwner = mSim;

                    if (SimTypes.IsSelectable(mSim))
                    {
                        try
                        {
                            mDoll.OnOwnerBecameSelectable();
                        }
                        catch (Exception e)
                        {
                            Common.Exception(mSim, e);

                            SimDescription sim = mDoll.GetLiveFormSimDescription();
                            if (sim != null)
                            {
                                new FixInvisibleTask(sim).AddToSimulator();
                            }
                        }
                    }
                }

                if ((mSim.CreatedSim != null) && (mSim.CreatedSim.Motives != null))
                {
                    if (mAcademicPerformance != -101)
                    {
                        mSim.CreatedSim.Motives.CreateMotive(CommodityKind.AcademicPerformance);
                        Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.AcademicPerformance);
                        if (motive != null)
                        {
                            motive.Value = mAcademicPerformance;
                        }
                    }

                    if (mUniversityStudy != -101)
                    {
                        mSim.CreatedSim.Motives.CreateMotive(CommodityKind.UniversityStudy);
                        Motive motive = mSim.CreatedSim.Motives.GetMotive(CommodityKind.UniversityStudy);
                        if (motive != null)
                        {
                            motive.Value = mUniversityStudy;
                        }
                    }
                }

                Relationships.RestoreRelations(mSim, mRelations);

                if ((mSim.TraitChipManager != null) && (mChips != null))
                {
                    for (int i = 0; i < mChips.Length; i++)
                    {
                        if (mChips[i] == null)
                        {
                            continue;
                        }

                        Common.StringBuilder name = new Common.StringBuilder();
                        try
                        {
                            name.Append(mChips[i].GetLocalizedName());

                            mSim.TraitChipManager.AddTraitChip(mChips[i], i);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(mSim, null, name, e);
                        }
                    }
                }

                sChangingWorldsSuppression.Pop();

                if ((mChangedHousehold != null) && (mChangedCallback != null))
                {
                    mChangedHousehold.HouseholdSimsChanged = mChangedCallback;
                }
            }
예제 #12
0
        public static async Task <bool> FullTabCheck()
        {
            if (!await Inventories.OpenStash())
            {
                return(false);
            }

            var actualTabs  = StashUi.TabControl.TabNames;
            var cleanedTabs = new List <Settings.FullTabInfo>();

            foreach (var tab in Settings.Instance.FullTabs)
            {
                var tabName = tab.Name;

                if (!actualTabs.Contains(tabName))
                {
                    GlobalLog.Warn($"[FullTabCheck] \"{tabName}\" tab no longer exists. Removing it from full tab list.");
                    cleanedTabs.Add(tab);
                    continue;
                }

                if (!await Inventories.OpenStashTab(tabName))
                {
                    return(false);
                }

                // Can happen only if user gave map tab a name that was marked as full previously
                if (StashUi.StashTabInfo.IsPremiumMap)
                {
                    GlobalLog.Error("[FullTabCheck] Map tab is unsupported. Removing it from full tab list.");
                    cleanedTabs.Add(tab);
                    continue;
                }

                if (StashUi.StashTabInfo.IsPremiumSpecial)
                {
                    var controlsMetadata = tab.ControlsMetadata;
                    var cleanedControls  = new List <string>();

                    foreach (var metadata in controlsMetadata)
                    {
                        if (PremiumTabCanFit(metadata))
                        {
                            GlobalLog.Warn($"[FullTabCheck] \"{tabName}\" tab is no longer full for \"{metadata}\".");
                            cleanedControls.Add(metadata);
                        }
                        else
                        {
                            GlobalLog.Warn($"[FullTabCheck] \"{tabName}\" tab is still full for \"{metadata}\".");
                        }
                    }
                    foreach (var cleaned in cleanedControls)
                    {
                        controlsMetadata.Remove(cleaned);
                    }
                    if (controlsMetadata.Count == 0)
                    {
                        GlobalLog.Warn($"[FullTabCheck] \"{tabName}\" tab does not contain any controls metadata. Removing it from full tab list.");
                        cleanedTabs.Add(tab);
                    }
                }
                else
                {
                    if (StashUi.InventoryControl.Inventory.AvailableInventorySquares >= 8)
                    {
                        GlobalLog.Warn($"[FullTabCheck] \"{tabName}\" tab is no longer full.");
                        cleanedTabs.Add(tab);
                    }
                    else
                    {
                        GlobalLog.Warn($"[FullTabCheck] \"{tabName}\" tab is still full.");
                    }
                }
            }
            foreach (var tab in cleanedTabs)
            {
                Settings.Instance.FullTabs.Remove(tab);
            }
            return(true);
        }
예제 #13
0
        public async Task <bool> Run()
        {
            var area = World.CurrentArea;

            if (!area.IsTown && !area.IsHideoutArea)
            {
                return(false);
            }

            var itemsToStash      = new List <StashItem>();
            var inventoryCurrency = Settings.Instance.InventoryCurrencies;

            foreach (var item in Inventories.InventoryItems)
            {
                var c = item.Class;

                if (c == ItemClasses.QuestItem || c == ItemClasses.PantheonSoul)
                {
                    continue;
                }

                if (c == ItemClasses.StackableCurrency && inventoryCurrency.Any(i => i.Name == item.Name))
                {
                    continue;
                }

                itemsToStash.Add(new StashItem(item));
            }

            foreach (var currency in inventoryCurrency)
            {
                foreach (var excess in Inventories.GetExcessCurrency(currency.Name))
                {
                    itemsToStash.Add(new StashItem(excess));
                }
            }

            if (itemsToStash.Count == 0)
            {
                GlobalLog.Info("[StashTask] No items to stash.");
                return(false);
            }

            if (_checkInvalidTabs)
            {
                if (!await Inventories.OpenStash())
                {
                    ErrorManager.ReportError();
                    return(true);
                }
                var wrongTabs = GetNonexistentTabs();
                if (wrongTabs.Count > 0)
                {
                    GlobalLog.Error("[StashTask] The following tabs are specified in stashing rules but do not exist in stash:");
                    GlobalLog.Error($"{string.Join(", ", wrongTabs)}");
                    GlobalLog.Error("[StashTask] Please provide correct tab names.");
                    BotManager.Stop();
                    return(true);
                }
                GlobalLog.Debug("[StashTask] All tabs specified in stashing rules exist in stash.");
                _checkInvalidTabs = false;
            }

            if (_checkFullTabs)
            {
                if (Settings.Instance.FullTabs.Count > 0)
                {
                    if (!await FullTabCheck())
                    {
                        ErrorManager.ReportError();
                        return(true);
                    }
                }
                _checkFullTabs = false;
            }

            GlobalLog.Info($"[StashTask] {itemsToStash.Count} items to stash.");

            AssignStashTabs(itemsToStash);

            foreach (var item in itemsToStash.OrderBy(i => i.StashTab).ThenBy(i => i.Position, Position.Comparer.Instance))
            {
                var itemName = item.Name;
                var itemPos  = item.Position;
                var tabName  = item.StashTab;

                GlobalLog.Debug($"[StashTask] Now going to stash \"{itemName}\" to \"{tabName}\" tab.");

                if (!await Inventories.OpenStashTab(tabName))
                {
                    ErrorManager.ReportError();
                    return(true);
                }
                if (StashUi.StashTabInfo.IsPremiumMap)
                {
                    GlobalLog.Error("Map stash tab is unsupported and there are no plans to support it in the future. Please remove it from stashing settings.");
                    BotManager.Stop();
                    return(true);
                }
                if (!Inventories.StashTabCanFitItem(itemPos))
                {
                    if (StashUi.StashTabInfo.IsPremiumSpecial)
                    {
                        var metadata = item.Metadata;
                        GlobalLog.Warn($"[StashTask] Cannot fit \"{itemName}\" to \"{tabName}\" tab.");
                        GlobalLog.Warn($"[StashTask] Now marking inventory control for \"{metadata}\" as full.");
                        Settings.Instance.MarkTabAsFull(tabName, metadata);
                    }
                    else
                    {
                        GlobalLog.Warn($"[StashTask] Cannot fit \"{itemName}\" to \"{tabName}\" tab. Now marking this tab as full.");
                        Settings.Instance.MarkTabAsFull(tabName, null);
                    }
                    return(true);
                }
                if (!await Inventories.FastMoveFromInventory(itemPos))
                {
                    ErrorManager.ReportError();
                    return(true);
                }
                GlobalLog.Info($"[Events] Item stashed ({item.FullName})");
                Utility.BroadcastMessage(this, Events.Messages.ItemStashedEvent, item);
            }
            await Coroutines.CloseBlockingWindows();

            return(true);
        }
예제 #14
0
 private void Awake()
 {
     Inventories.Clear();
     AddInventory(MainInventory);
     AddInventory(ActionBarInventory);
 }
        public async Task <Inventories> AddNewInventory(Inventories inventory)
        {
            var url = URLBuilder.GetURL(Controllers.MAINTENANCE, EndPoint.MAINTENANCE_INVENTORY_INSERT);

            return(await requestProvider.PostAsync(url, inventory));
        }
예제 #16
0
        protected override bool Allow(SimDescription sim)
        {
            if (sim.ChildOrBelow)
            {
                IncStat("Too Young");
                return(false);
            }
            else if (sim.CreatedSim == null)
            {
                IncStat("Hibernating");
                return(false);
            }
            else if (sim.LotHome == null)
            {
                IncStat("Homeless");
                return(false);
            }
            else if (!Inventories.VerifyInventory(sim))
            {
                IncStat("No Inventory");
                return(false);
            }
            else
            {
                LaundryState state;
                if (mPushed.TryGetValue(sim.Household, out state))
                {
                    if ((state.mDryer) && (state.mWasher))
                    {
                        IncStat("Already Pushed");
                        return(false);
                    }
                }

                if (AddScoring("Neat", sim) < 0)
                {
                    int count = 0;
                    foreach (ClothingPileDry pile in sim.LotHome.GetObjects <ClothingPileDry>())
                    {
                        count += pile.Count;
                    }

                    if (count < ClothingPileDry.kCapacity * 2)
                    {
                        IncStat("Scoring Fail");
                        return(false);
                    }
                }

                bool hasNeed = false;
                if (sim.CreatedSim.Inventory.ContainsType(typeof(ClothingPileDry), 1))
                {
                    hasNeed = true;
                }
                else if (sim.LotHome.CountObjects <ClothingPileDry>() > 0)
                {
                    hasNeed = true;
                }
                else
                {
                    foreach (Hamper hamper in sim.LotHome.GetObjects <Hamper>())
                    {
                        if (hamper.HasClothingPiles())
                        {
                            hasNeed = true;
                            break;
                        }
                    }
                }

                if (!hasNeed)
                {
                    IncStat("No Need");
                    return(false);
                }
            }

            return(base.Allow(sim));
        }
예제 #17
0
파일: Kill.cs 프로젝트: pepoluan/NRaas
        protected static bool DelayedKill(Sim actor, Sim target, SimDescription.DeathType deathType)
        {
            if (actor == target)
            {
                target.SimDescription.SetDeathStyle(deathType, true);

                Urnstone urnstone = Urnstone.CreateGrave(target.SimDescription, false, true);
                if (urnstone != null)
                {
                    if (!target.Inventory.TryToAdd(urnstone, false))
                    {
                        urnstone.Destroy();
                        return(false);
                    }

                    urnstone.GhostSetup(target, true);
                }
            }
            else
            {
                List <IRabbitHolePartnershipDeed> list = Inventories.QuickDuoFind <IRabbitHolePartnershipDeed, GameObject>(target.Inventory);
                if ((list != null) && (list.Count > 0x0))
                {
                    Sim   sim      = null;
                    float minValue = float.MinValue;
                    foreach (Sim sim2 in Households.AllHumans(target.Household))
                    {
                        if (sim2 != target)
                        {
                            float        liking       = -100f;
                            Relationship relationship = Relationship.Get(target, sim2, false);
                            if (relationship != null)
                            {
                                liking = relationship.LTR.Liking;
                            }
                            if (liking > minValue)
                            {
                                minValue = liking;
                                sim      = sim2;
                            }
                        }
                    }
                    foreach (IRabbitHolePartnershipDeed deed in list)
                    {
                        target.Inventory.RemoveByForce(deed);
                        if (sim != null)
                        {
                            sim.Inventory.TryToAdd(deed, false);
                        }
                        else
                        {
                            deed.Destroy();
                        }
                    }
                }

                InteractionInstance entry = Urnstone.KillSim.Singleton.CreateInstance(target, target, new InteractionPriority(InteractionPriorityLevel.MaxDeath, 0f), false, false);
                (entry as Urnstone.KillSim).simDeathType = deathType;
                target.InteractionQueue.Add(entry);
            }

            return(true);
        }
예제 #18
0
        protected override List <GameObject> GetInventory(SimDescription sim)
        {
            List <NectarMaker> makers = new List <NectarMaker>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                makers.AddRange(lot.GetObjects <NectarMaker>());
            }

            List <GameObject> list = new List <GameObject>(), nectarItems = new List <GameObject>();

            foreach (Ingredient ingredient in Inventories.InventoryFindAll <Ingredient>(sim))
            {
                if (sim.IsVampire)
                {
                    if (ingredient is VampireFruit)
                    {
                        continue;
                    }
                }

                if (!ingredient.CanBeSold())
                {
                    continue;
                }

                bool found = false;
                foreach (NectarMaker maker in makers)
                {
                    if (maker.CanAddToInventory(ingredient))
                    {
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    nectarItems.Add(ingredient);
                }
                else
                {
                    list.Add(ingredient);
                }
            }

            while (nectarItems.Count > 50)
            {
                GameObject choice = RandomUtil.GetRandomObjectFromList(nectarItems);

                nectarItems.Remove(choice);

                list.Add(choice);
            }

            foreach (HarvestMoneyBag bag in Inventories.InventoryFindAll <HarvestMoneyBag>(sim))
            {
                list.Add(bag);
            }

            return(list);
        }
예제 #19
0
        public override bool Run()
        {
            try
            {
                if (!Actor.RouteToSlotAndCheckInUse(Target, Target.GetRoutingSlot(Actor)))
                {
                    return(false);
                }

                bool paramValue = RandomUtil.RandomChance(ArcadeClawMachine.kPercentChanceOfCheatingTheSystem);
                bool isRare     = false;
                bool flag3      = false;
                mPrize = Target.DecidePrize(Actor, out isRare);
                if (!paramValue)
                {
                    flag3 = true;
                }

                bool flag4 = mPrize is StuffedAnimal;
                EnterStateMachine("arcadeclawmachine", "enter", "x");
                mCurrentStateMachine.AddPersistentScriptEventHandler(0x65, OnHideActor);
                mCurrentStateMachine.AddPersistentScriptEventHandler(0x66, OnShowActorEx);
                mCurrentStateMachine.AddPersistentScriptEventHandler(0x79, ShowPrize);
                mCurrentStateMachine.AddPersistentScriptEventHandler(0x7a, HidePrize);
                mFairy = Actor.SimDescription.OccultManager.GetOccultType(OccultTypes.Fairy) as OccultFairy;
                mFairy.AttachTrueFairyFormToAnimation(mCurrentStateMachine);
                StandardEntry();
                BeginCommodityUpdates();
                SetActor("ClawMachine", Target);
                if (flag4)
                {
                    SetActor("teddybear", mPrize);
                }
                else
                {
                    SetActor("prize", mPrize);
                }

                SetParameter("ArcadeSkill", Actor.SkillManager.GetSkillLevel(SkillNames.ArcadeMachine));
                SetParameter("PickedUpPrize", paramValue);
                SetParameter("RarePrize", isRare);
                SetParameter("IsTeddyBear", flag4);
                SetParameter("PickedUpPrize", flag3);
                mPrize.AddToWorld();
                if (paramValue)
                {
                    AnimateSim("fairy success");
                    if ((mPrize != null) && (Actor.Inventory != null))
                    {
                        if (mPrize is Gem)
                        {
                            Gem    prize = mPrize as Gem;
                            string randomStringFromList = RandomUtil.GetRandomStringFromList(ArcadeClawMachine.kCutTypes);
                            Gem    gem2 = Gem.MakeCutGem(prize.Guid, randomStringFromList, false);
                            if (Actor.Inventory.TryToAdd(gem2))
                            {
                                prize.SetHiddenFlags(HiddenFlags.Nothing);
                                Actor.ShowTNSIfSelectable(TNSNames.ArcadeClawMachinePrizeGem, Actor, Target, new object[] { gem2.GemName });
                                EventTracker.SendEvent(EventTypeId.kUseClawMachine, Actor, gem2);
                                (Actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting).UpdateGemRecords(gem2.Guid, (float)gem2.Value, gem2.LocalizedCutName);
                            }
                            prize.RemoveFromWorld();
                        }
                        else if (Inventories.TryToMove(mPrize, Actor))
                        {
                            mPrize.SetHiddenFlags(HiddenFlags.Nothing);
                            Actor.ShowTNSIfSelectable(TNSNames.ArcadeClawMachinePrize, Actor, Target, new object[] { Actor, mPrize });
                            EventTracker.SendEvent(EventTypeId.kUseClawMachine, Actor, mPrize);
                            mPrize = null;
                        }
                    }
                }
                else
                {
                    AnimateSim("fairy fail");
                    EventTracker.SendEvent(EventTypeId.kUseClawMachine, Actor, null);
                }

                EndCommodityUpdates(true);
                StandardExit();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
예제 #20
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Lot lot = Porter.GetLot(parameters.mTarget);

            if (lot == null)
            {
                return(OptionResult.Failure);
            }

            List <SimDescription> selection = null;

            List <HouseholdItem> allHouses = new List <HouseholdItem>();

            foreach (Household house in Household.sHouseholdList)
            {
                allHouses.Add(new HouseholdItem(house, house == lot.Household));
            }

            string houseName = null;

            while (selection == null)
            {
                List <Household> houses = HouseholdSelection.Perform(lot.Household.Name, allHouses);
                if ((houses == null) || (houses.Count == 0))
                {
                    return(OptionResult.Failure);
                }

                houseName = houses[0].Name;

                selection = GetSimSelection(houses);
            }

            if ((selection == null) || (selection.Count == 0))
            {
                return(OptionResult.Failure);
            }

            Dictionary <Household, int> finalHouses = new Dictionary <Household, int>();

            int nextID = 1;

            foreach (SimDescription sim in selection)
            {
                if (sim.Household == null)
                {
                    continue;
                }

                if (sim.Household.IsServiceNpcHousehold)
                {
                    continue;
                }

                if (!finalHouses.ContainsKey(sim.Household))
                {
                    finalHouses.Add(sim.Household, nextID);
                    nextID++;
                }
            }

            string name = StringInputDialog.Show(Common.Localize("Title"), Common.Localize("Pack:NamePrompt", false, new object[] { finalHouses.Count, selection.Count }), houseName);

            if (string.IsNullOrEmpty(name))
            {
                return(OptionResult.Failure);
            }

            Household export = Household.Create();

            SpeedTrap.Sleep();

            foreach (Household house in finalHouses.Keys)
            {
                if (house.LotHome != null)
                {
                    export.SetFamilyFunds(export.FamilyFunds + house.FamilyFunds + house.LotHome.Cost);
                }
                else
                {
                    export.SetFamilyFunds(export.FamilyFunds + house.NetWorth());
                }
            }

            Dictionary <SimDescription, Household> saveHouses = new Dictionary <SimDescription, Household>();

            Dictionary <Sim, bool> resetDNP = new Dictionary <Sim, bool>();

            Dictionary <Household, bool> inventoried = new Dictionary <Household, bool>();

            foreach (SimDescription sim in selection)
            {
                if (sim.CreatedSim != null)
                {
                    sim.CreatedSim.SetReservedVehicle(null);

                    if (sim.CreatedSim.DreamsAndPromisesManager != null)
                    {
                        sim.CreatedSim.NullDnPManager();

                        if (!resetDNP.ContainsKey(sim.CreatedSim))
                        {
                            resetDNP.Add(sim.CreatedSim, true);
                        }
                    }

                    if ((sim.Household != null) && (!inventoried.ContainsKey(sim.Household)))
                    {
                        inventoried.Add(sim.Household, true);

                        if ((sim.Household.SharedFamilyInventory != null) &&
                            (sim.Household.SharedFamilyInventory.Inventory != null))
                        {
                            foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Household.SharedFamilyInventory.Inventory))
                            {
                                if (Inventories.TryToMove(obj, sim.CreatedSim.Inventory, false))
                                {
                                    continue;
                                }

                                Inventories.TryToMove(obj.Clone(), export.SharedFamilyInventory.Inventory);
                            }
                        }

                        if ((sim.Household.SharedFridgeInventory != null) &&
                            (sim.Household.SharedFridgeInventory.Inventory != null))
                        {
                            foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Household.SharedFridgeInventory.Inventory))
                            {
                                if (Inventories.TryToMove(obj, sim.CreatedSim.Inventory, false))
                                {
                                    continue;
                                }

                                Inventories.TryToMove(obj.Clone(), export.SharedFridgeInventory.Inventory);
                            }
                        }
                    }
                }

                int id = 0;
                if ((sim.Household != null) && (finalHouses.ContainsKey(sim.Household)))
                {
                    id = finalHouses[sim.Household];
                }
                else
                {
                    Urnstone grave = Urnstones.CreateGrave(sim, false);
                    if (grave == null)
                    {
                        continue;
                    }

                    SpeedTrap.Sleep();

                    bool success = false;
                    try
                    {
                        success = Urnstones.GhostToPlayableGhost(grave, Household.NpcHousehold, lot.EntryPoint());
                    }
                    catch (Exception exception)
                    {
                        Common.DebugException(grave.DeadSimsDescription, exception);
                    }

                    if (!success)
                    {
                        Porter.Notify(Common.Localize("Pack:SimFailure", sim.IsFemale, new object[] { sim }));

                        Porter.PlaceGraveTask.Perform(sim);
                        //export.SharedFamilyInventory.Inventory.TryToMove(grave);
                        continue;
                    }
                }

                HouseData data = new HouseData(id, sim);

                sim.mBio = data.ToString();

                saveHouses.Add(sim, sim.Household);

                sim.OnHouseholdChanged(export, false);

                export.mMembers.Add(sim, null);

                Porter.AddExport(sim);
            }

            string packageName = null;

            try
            {
                try
                {
                    ProgressDialog.Show(Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]), false);

                    if (export.mMembers.Count > 0)
                    {
                        export.Name = "NRaas.Porter:" + name;

                        ThumbnailHelper.CacheSimAtlasesForHousehold(export);
                        ThumbnailManager.GenerateHouseholdThumbnail(export.HouseholdId, export.HouseholdId, ThumbnailSizeMask.Large);

                        packageName = BinEx.ExportHousehold(Bin.Singleton, export, false);
                        if (packageName != null)
                        {
                            BinModel.Singleton.AddToExportBin(packageName);
                        }
                    }

                    foreach (Sim sim in resetDNP.Keys)
                    {
                        try
                        {
                            sim.ResetDnP();
                        }
                        catch (Exception e)
                        {
                            Common.DebugException(sim, e);
                        }
                    }

                    List <Urnstone> graves = Inventories.QuickFind <Urnstone>(export.SharedFamilyInventory.Inventory);

                    foreach (Urnstone grave in graves)
                    {
                        Porter.PlaceGraveTask.Perform(grave.DeadSimsDescription);
                    }

                    while (export.mMembers.Count > 0)
                    {
                        SimDescription sim = export.mMembers.SimDescriptionList[0];
                        if (sim != null)
                        {
                            sim.OnHouseholdChanged(saveHouses[sim], false);

                            if ((sim.Household == null) || (sim.Household.IsServiceNpcHousehold))
                            {
                                Porter.PlaceGraveTask.Perform(sim);
                            }
                        }

                        export.mMembers.RemoveAt(0);
                    }

                    export.Destroy();
                    export.Dispose();
                }
                finally
                {
                    ProgressDialog.Close();
                }
            }
            catch (ExecutionEngineException)
            {
                // Ignored
            }
            catch (Exception e)
            {
                Common.Exception(name, e);
                packageName = null;
            }

            if (packageName != null)
            {
                SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Pack:Success", false, new object[] { export.Name }));
            }
            else
            {
                SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Pack:Failure"));
            }

            return(OptionResult.SuccessClose);
        }
예제 #21
0
        protected override void Perform(GameObject obj, object referenceParent, FieldInfo field)
        {
            if (obj is Ocean)
            {
                if (LotManager.sOceanObject == obj)
                {
                    return;
                }
            }
            else if (obj is Terrain)
            {
                if (Terrain.sTerrain == obj)
                {
                    return;
                }
            }

            if (DereferenceManager.HasBeenDestroyed(obj))
            {
                if (obj is Sim)
                {
                    LotManager.sActorList.Remove(obj as Sim);

                    DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), true, false);
                }
                else
                {
                    GameObjectReference refObj = ObjectLookup.GetReference(new ReferenceWrapper(obj));
                    if (DereferenceManager.Perform(obj, refObj, false, false))
                    {
                        DereferenceManager.Perform(obj, refObj, true, false);

                        ErrorTrap.LogCorrection("Destroyed Object Found: " + obj.GetType());
                    }
                }
                return;
            }

            if (kShowFullReferencing)
            {
                DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), false, true);
            }

            if (obj.InWorld)
            {
                return;
            }

            if (obj.InInventory)
            {
                if (Inventories.ParentInventory(obj) == null)
                {
                    if ((obj.Parent != null) || (Consignment.ContainsKey(obj)))
                    {
                        obj.SetFlags(GameObject.FlagField.InInventory, false);

                        ErrorTrap.LogCorrection("Invalid Inventory Object Unflagged: " + obj.GetType());
                    }
                    else
                    {
                        ErrorTrap.LogCorrection("Invalid Inventory Object Found: " + obj.GetType());
                        ErrorTrap.AddToBeDeleted(obj, true);
                    }
                }

                return;
            }
            else
            {
                if (SharedInventories.ContainsKey(obj.ObjectId))
                {
                    obj.SetFlags(GameObject.FlagField.InInventory, true);

                    ErrorTrap.LogCorrection("Inventory Object Flagged: " + obj.GetType());
                    return;
                }
            }

            if (EventItems.ContainsKey(obj.ObjectId))
            {
                return;
            }

            bool hasParent = false;

            IGameObject parent = obj.Parent;

            while (parent != null)
            {
                hasParent = true;

                if (DereferenceManager.HasBeenDestroyed(parent))
                {
                    ErrorTrap.LogCorrection("Destroyed Parent Object Found: " + parent.GetType());
                    ErrorTrap.AddToBeDeleted(obj, true);

                    hasParent = false;
                    break;
                }

                parent = parent.Parent;
            }

            if (!hasParent)
            {
                ReferenceWrapper refObj = new ReferenceWrapper(obj);

                GameObjectReference reference = ObjectLookup.GetReference(refObj);
                if ((reference != null) && (reference.HasReferences))
                {
                    if (DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), false, false))
                    {
                        IScriptProxy proxy = Simulator.GetProxy(obj.ObjectId);
                        if (proxy != null)
                        {
                            IScriptLogic logic = proxy.Target;
                            if (object.ReferenceEquals(logic, obj))
                            {
                                bool log = !sSilentDestroy.ContainsKey(obj.GetType());

                                if (log)
                                {
                                    ErrorTrap.LogCorrection("Out of World Object Found 2: " + obj.GetType());
                                }
                                else
                                {
                                    ErrorTrap.DebugLogCorrection("Out of World Object Found 3: " + obj.GetType());
                                }

                                ErrorTrap.AddToBeDeleted(obj, log);
                            }
                            else
                            {
                                ErrorTrap.DebugLogCorrection("Out of World Object Found 4: " + obj.GetType());
                                ErrorTrap.DebugLogCorrection("Out of World Object Found 5: " + logic.GetType());
                            }
                        }
                        else
                        {
                            DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), true, false);
                        }
                    }
                }
                else
                {
                    ErrorTrap.LogCorrection("Out of World Object Found 1: " + obj.GetType());
                    ErrorTrap.AddToBeDeleted(obj, true);
                }
            }
        }
예제 #22
0
    //AllMaterial material = new AllMaterial(); //Do i need it?

    // Start is called before the first frame update
    void Start()
    {
        inventories = FindObjectOfType <Inventories>();
    }
예제 #23
0
        static void Main(string[] args)
        {
            using (StoreApplicationContext dbContext = CreateDbContext())
                using (IStoreRepository storeRepository = new StoreRepository(dbContext))
                {
                    while (true)
                    {
                        try
                        {
                            _logger.Info($"Saving");
                            storeRepository.Save();
                        }
                        catch (DbUpdateException ex)
                        {
                            _logger.Error($"Failed to Save");
                            Console.WriteLine(ex.Message);
                        }

                        Console.WriteLine();
                        Console.WriteLine("1:\tDisplay All Names");
                        Console.WriteLine("2:\tSearch By Last Name");
                        Console.WriteLine("3:\tDisplay Order History of each location");
                        Console.WriteLine("4:\tQuit");
                        Console.WriteLine();

                        int                              input = IntValidation(1, 4);
                        string                           input2;
                        var                              count = 0;
                        Customer                         customer;
                        Product                          ProductValue;
                        var                              products  = storeRepository.DisplayProducts();
                        var                              products2 = products.ToList();
                        List <OrderDetails>              orderDetails;
                        IEnumerable <Order>              OrderValue;
                        IEnumerable <Customer>           AllNames;
                        IEnumerable <Inventories>        LocationInventory;
                        IEnumerable <ProductCat>         prodCategories;
                        IEnumerable <Product>            getRecoProduct;
                        IEnumerable <ComponentInventory> componentInventories;
                        List <Product>                   Cart;
                        List <Product>                   ComponentCart;
                        decimal                          Total = 0;
                        int                              tempOrderId;
                        Dictionary <string, int>         HashProducts;
                        HashSet <Product>                HashLoop;
                        int                              inventoryId;
                        switch (input)
                        {
                        case 1:
                            AllNames = storeRepository.GetNames();
                            Console.WriteLine();
                            count = 0;
                            _logger.Info($"Choosing Customer to Order for");
                            foreach (var x in AllNames)
                            {
                                Console.WriteLine($"\t{count}: {x.GetFullName()}");
                                count++;
                            }

                            if (count == 0)
                            {
                                Console.WriteLine("There are 0 Customers");
                                break;
                            }
                            var AllNamesList = AllNames.ToList();

                            Console.WriteLine($"Choose Customer to interact with or Press {AllNames.Count()} to go back");

                            input = IntValidation(0, AllNames.Count());
                            if (input != AllNames.Count())
                            {
                                customer   = AllNames.ElementAt(input);
                                OrderValue = storeRepository.GetOrders(customer);

                                _logger.Info($"Displaying orders for {customer.FName} {customer.LName} {customer.CustomerId}");
                                List <OrderDetails> temp2 = new List <OrderDetails>();
                                while (true)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Do you want to view and sort Customer Order History?");
                                    Console.WriteLine("1:\tYes");
                                    Console.WriteLine("2:\tNo");
                                    Console.WriteLine();
                                    input = IntValidation(1, 2);
                                    if (input == 2)
                                    {
                                        break;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine("What do you want to sort by?");
                                    Console.WriteLine("1:\tEarliest");
                                    Console.WriteLine("2:\tLatest");
                                    Console.WriteLine("3:\tCheapest");
                                    Console.WriteLine("4:\tExpensive");
                                    Console.WriteLine();
                                    input = IntValidation(1, 4);
                                    List <Order> orderList = OrderValue.ToList();
                                    if (input == 1)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Early);
                                    }
                                    else if (input == 2)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Late);
                                    }
                                    else if (input == 3)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Cheap);
                                    }
                                    else if (input == 4)
                                    {
                                        orderList = Order.SortList(orderList, Sort.Expensive);
                                    }
                                    count = 0;
                                    foreach (var x in orderList)
                                    {
                                        Console.WriteLine();
                                        Console.WriteLine($"Order {count}:\tTime:{x.TimeStamp}  \nStore: {x.Location.Name}\tCost: ${x.TotalAmount}");
                                        orderDetails = storeRepository.GetOrderDetails(x).ToList();
                                        temp2.AddRange(orderDetails);
                                        var y = orderDetails;
                                        foreach (var z in y)
                                        {
                                            var i = Order.GetProductName(products.ToList(), z.ProductId);
                                            Console.WriteLine($"\t{i}\tAmount:{z.Quantity} ");
                                        }
                                        count++;
                                    }
                                }
                                Cart = new List <Product>();

                                LocationInventory = storeRepository.GetInventories(customer);
                                List <Inventories> LocationInventoryList = LocationInventory.ToList();
                                Total = 0;
                                while (true)
                                {
                                    count    = 4;
                                    products = storeRepository.DisplayProducts();
                                    Console.WriteLine();
                                    foreach (var x in products)
                                    {
                                        if (count % 3 == 0)
                                        {
                                            Console.WriteLine($"\t{count - 4}: {x.ProductCost}  {x.ProductName}\t\t ");
                                        }
                                        else
                                        {
                                            Console.Write($"\t{count - 4}: {x.ProductCost}  {x.ProductName}\t\t ");
                                        }
                                        count++;
                                    }
                                    _logger.Info($"Get Recommended Items");
                                    Product product = new Product();

                                    List <Product> tempP     = new List <Product>();
                                    List <Order>   orderList = OrderValue.ToList();
                                    foreach (var x in orderList)
                                    {
                                        var y = storeRepository.GetOrderDetails(x).ToList();
                                        foreach (var z in y)
                                        {
                                            foreach (var t in products)
                                            {
                                                if (t.ProductId == z.ProductId)
                                                {
                                                    tempP.Add(t);
                                                }
                                            }
                                        }
                                        count++;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine("Recommended Items:\n");
                                    var getStuff = dbContext.Products.Where(x => x.ProductCategoryId == tempP[tempP.Count - 1].CategoryId).ToList();
                                    count = 0;
                                    foreach (var x in getStuff)
                                    {
                                        if (count > 2)
                                        {
                                            break;
                                        }
                                        Console.Write($"   {x.ProductName}");
                                        count++;
                                    }

                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine();
                                    Console.WriteLine($"Add Product to cart or Enter {products.Count()} to purchase it\n");
                                    Console.WriteLine($"Purchasing from Default Location: {customer.DefaultLocation.Name}");
                                    Console.WriteLine($"There are {Cart.Count} Items in cart for a total of ${Total}");
                                    input = IntValidation(0, products.Count());
                                    _logger.Info($"Choose item to add to cart");
                                    if (input != products.Count())
                                    {
                                        ProductValue = products.ElementAt(input);
                                        _logger.Info($"Item chosen = {ProductValue.ProductName}");
                                        if (ProductValue.HasComponents)
                                        {
                                            componentInventories = storeRepository.GetComponents(ProductValue);
                                            ComponentCart        = new List <Product>();
                                            foreach (var x in componentInventories)
                                            {
                                                foreach (var y in products2)
                                                {
                                                    if (x.ComponentProductId == y.ProductId)
                                                    {
                                                        ComponentCart.Add(y);
                                                    }
                                                }
                                            }
                                            List <Inventories> tempInv = new List <Inventories>();
                                            tempInv.AddRange(LocationInventoryList);
                                            Decimal        tempTotal = Total;
                                            List <Product> tempCart  = new List <Product>();
                                            tempCart.AddRange(Cart);

                                            foreach (var x in ComponentCart)
                                            {
                                                if (Order.CheckCart(x, LocationInventoryList))
                                                {
                                                    Console.WriteLine($"\t{x.ProductName} has been added to cart");
                                                    Total += x.ProductCost;
                                                    Cart.Add(x);
                                                }
                                                else
                                                {
                                                    LocationInventoryList.Clear();
                                                    LocationInventoryList.AddRange(tempInv);
                                                    Cart.Clear();
                                                    Cart.AddRange(tempCart);
                                                    Total = tempTotal;

                                                    Console.WriteLine();
                                                    Console.WriteLine("Inventory is out");

                                                    break;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (Order.CheckCart(ProductValue, LocationInventoryList))
                                            {
                                                Console.WriteLine($"\t{ProductValue.ProductName} has been added to cart");
                                                Total += ProductValue.ProductCost;
                                                Cart.Add(ProductValue);
                                            }
                                            else
                                            {
                                                Console.WriteLine();
                                                Console.WriteLine("Inventory is out");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (Cart.Count == 0)
                                        {
                                            Console.WriteLine();
                                            Console.WriteLine("The cart is empty, so nothing was purchased!");
                                            Console.WriteLine();
                                            break;
                                        }
                                        else
                                        {
                                            //SA.Orders(ConsumerId,StoreId,TotalAmount)
                                            Order newOrder = new Order
                                            {
                                                CustomerId  = customer.CustomerId,
                                                StoreId     = customer.DefaultLocation.LocationId,
                                                TotalAmount = Total,
                                                Location    = customer.DefaultLocation,
                                                Customer    = customer,
                                                TimeStamp   = DateTime.Now,
                                            };
                                            storeRepository.AddOrder(newOrder, customer.DefaultLocation, customer);
                                            try
                                            {
                                                _logger.Info($"Saving");
                                                storeRepository.Save();
                                            }
                                            catch (DbUpdateException ex)
                                            {
                                                _logger.Error($"Failed to Save");
                                                Console.WriteLine(ex.Message);
                                            }
                                            Thread.Sleep(50);
                                            tempOrderId  = dbContext.Orders.OrderByDescending(y => y.OrderId).Select(a => a.OrderId).FirstOrDefault();
                                            HashProducts = new Dictionary <string, int>();
                                            HashLoop     = new HashSet <Product>();
                                            foreach (var x in Cart)
                                            {
                                                if (HashProducts.ContainsKey(x.ProductName))
                                                {
                                                    HashProducts[x.ProductName] += 1;
                                                }
                                                else
                                                {
                                                    HashProducts.Add(x.ProductName, 1);
                                                }
                                                HashLoop.Add(x);
                                            }
                                            count = 0;
                                            foreach (var x in HashLoop)
                                            {
                                                count++;
                                                Console.WriteLine(count);
                                                OrderDetails newOrderDetails = new OrderDetails
                                                {
                                                    OrderId   = tempOrderId,
                                                    ProductId = x.ProductId,
                                                    Quantity  = HashProducts[x.ProductName],
                                                };

                                                storeRepository.AddOrderDetails(newOrderDetails, newOrder, x);
                                                try
                                                {
                                                    _logger.Info($"Saving");
                                                    storeRepository.Save();
                                                }
                                                catch (DbUpdateException ex)
                                                {
                                                    _logger.Error($"Failed to Save");
                                                    Console.WriteLine(ex.Message);
                                                }
                                                inventoryId = dbContext.Inventory.Where(y => y.ProductId == x.ProductId && y.StoreId == customer.DefaultLocation.LocationId).Select(a => a.InventoryId).First();
                                                Thread.Sleep(50);
                                                Inventories inventories = new Inventories
                                                {
                                                    Quantity    = Order.getInventory(LocationInventoryList, x.ProductId),
                                                    StoreId     = customer.DefaultLocation.LocationId,
                                                    ProductId   = x.ProductId,
                                                    InventoryId = inventoryId,
                                                };
                                                storeRepository.UpdateInventory(inventories);
                                                try
                                                {
                                                    _logger.Info($"Saving");
                                                    storeRepository.Save();
                                                }
                                                catch (DbUpdateException ex)
                                                {
                                                    _logger.Error($"Failed to Save");
                                                    Console.WriteLine(ex.Message);
                                                }
                                            }
                                        }
                                        break;
                                    }
                                }
                            }
                            break;

                        case 2:
                            _logger.Info($"Search for name name");
                            do
                            {
                                Console.WriteLine("Please enter Full/Parital Last Name to search by");
                                input2 = Console.ReadLine();
                                if (input2.Length < 200 && input2.Length > 0)
                                {
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Please enter word with 1 - 199 characters, ");
                                }
                            } while (true);

                            AllNames = storeRepository.GetNames(input2);
                            Console.WriteLine();
                            count = 0;

                            foreach (var x in AllNames)
                            {
                                Console.WriteLine($"\t{count}: {x.GetFullName()}");
                                count++;
                            }
                            if (count == 0)
                            {
                                Console.WriteLine("Your search had 0 results");
                            }
                            break;

                        case 3:
                            _logger.Info($"Display All orders by each location");
                            var n = storeRepository.GetOrders().ToList();
                            var p = n.OrderByDescending(k => k.Location.LocationId);


                            foreach (var a in p)
                            {
                                var    b    = dbContext.Consumer.ToList();
                                var    z    = dbContext.Store.ToList();
                                string name = "John Albert";
                                foreach (var m in z)
                                {
                                    if (m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.ConsumerId).FirstOrDefault() == a.CustomerId)
                                    {
                                        name = m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.Fname).FirstOrDefault() + " " + m.Consumer.Where(c => c.ConsumerId == a.CustomerId).Select(x => x.Lname).FirstOrDefault();
                                    }
                                }
                                Console.WriteLine($"{ a.Location.Name}");
                                Console.WriteLine($"\t{name}\t{a.TimeStamp}\t{a.TotalAmount}");
                                Console.WriteLine();
                            }
                            break;

                        case 4:
                            _logger.Info($"Exiting Application");
                            return;
                        }
                    }
                }
        }
예제 #24
0
 public virtual IEnumerable <InventoryEntity> GetProductsInventories(IEnumerable <string> productIds)
 {
     return(Inventories.Where(x => productIds.Contains(x.Sku)).Include(x => x.FulfillmentCenter).ToArray());
 }
예제 #25
0
 public void AddInventory(Inventory inventory)
 {
     Inventories.Add(inventory);
 }
예제 #26
0
        public async Task <bool> Run()
        {
            if (MapBot.IsOnRun)
            {
                return(false);
            }

            var area = World.CurrentArea;

            if (!area.IsTown && !area.IsHideoutArea)
            {
                return(false);
            }

            MapExtensions.AtlasData.Update();

            if (!Settings.SellEnabled)
            {
                return(false);
            }

            if (Inventories.AvailableInventorySquares < 3)
            {
                GlobalLog.Error("[SellMapTask] Not enough inventory space.");
                return(false);
            }

            var firstMapTab = ExSettings.Instance.GetTabsForCategory(ExSettings.StashingCategory.Map).First();

            if (!await Inventories.OpenStashTab(firstMapTab))
            {
                GlobalLog.Error($"[SellMapTask] Fail to open stash tab \"{firstMapTab}\".");
                return(false);
            }

            var maps = Inventories.StashTabItems
                       .Where(m => m.IsMap() && m.ShouldSell())
                       .OrderBy(m => m.Priority())
                       .ThenBy(m => m.MapTier)
                       .ToList();

            if (maps.Count == 0)
            {
                return(false);
            }

            var mapGroups = new List <Item[]>();

            foreach (var mapGroup in maps.GroupBy(m => m.Name))
            {
                var groupList = mapGroup.ToList();
                for (int i = 3; i <= groupList.Count; i += 3)
                {
                    var group = new Item[3];
                    group[0] = groupList[i - 3];
                    group[1] = groupList[i - 2];
                    group[2] = groupList[i - 1];
                    mapGroups.Add(group);
                }
            }
            if (mapGroups.Count == 0)
            {
                GlobalLog.Info("[SellMapTask] No map group for sale was found.");
                return(false);
            }

            GlobalLog.Info($"[SellMapTask] Map groups for sale: {mapGroups.Count}");

            foreach (var mapGroup in mapGroups)
            {
                if (Inventories.AvailableInventorySquares < 3)
                {
                    GlobalLog.Error("[SellMapTask] Not enough inventory space.");
                    break;
                }

                //exclude ignored maps from min map amount check, if sell ignored maps is enabled
                if (!Settings.SellIgnoredMaps || !mapGroup[0].Ignored())
                {
                    int mapAmount = Inventories.StashTabItems.Count(i => i.IsMap() && i.Rarity != Rarity.Unique);
                    if ((mapAmount - 3) < Settings.MinMapAmount)
                    {
                        GlobalLog.Warn($"[SellMapTask] Min map amount is reached {mapAmount}(-3) from required {Settings.MinMapAmount}");
                        break;
                    }
                }

                for (int i = 0; i < 3; i++)
                {
                    var map = mapGroup[i];
                    GlobalLog.Info($"[SellMapTask] Now getting {i + 1}/{3} \"{map.Name}\".");
                    if (!await Inventories.FastMoveFromStashTab(map.LocationTopLeft))
                    {
                        ErrorManager.ReportError();
                        return(true);
                    }
                }
            }

            await Wait.SleepSafe(200);

            var forSell = Inventories.InventoryItems.Where(i => i.IsMap()).Select(m => m.LocationTopLeft).ToList();

            if (forSell.Count == 0)
            {
                return(false);
            }

            if (!await TownNpcs.SellItems(forSell))
            {
                ErrorManager.ReportError();
            }

            return(true);
        }
        public async Task <bool> Run()
        {
            if (!settings.Instance.ExaltRecipeEnabled)
            {
                return(false);
            }

            if (_shaperStashTabIsFull || ErrorLimitReached)
            {
                return(false);
            }

            var area = World.CurrentArea;

            if (!area.IsTown && !area.IsHideoutArea)
            {
                return(false);
            }

            if (_shouldUpdateStashData)
            {
                GlobalLog.Debug("[StashRecipeTask] Updating shaper exalt recipe stash data (every Start)");

                if (settings.Instance.ExaltRecipeEnabled)
                {
                    if (!await OpenShaperRecipeTab())
                    {
                        return(true);
                    }
                    else
                    {
                        Class1.ShaperStashData.SyncWithStashTab(RecipeData.ExaltRecipeItemType.Shaper);
                    }
                }

                _shouldUpdateStashData = false;
            }
            else
            {
                if (AnyItemToStash)
                {
                    GlobalLog.Debug("[StashRecipeTask] Updating shaper exalt recipe stash data before actually stashing the items.");

                    if (settings.Instance.ExaltRecipeEnabled)
                    {
                        if (!await OpenShaperRecipeTab())
                        {
                            return(true);
                        }
                        else
                        {
                            Class1.ShaperStashData.SyncWithStashTab(RecipeData.ExaltRecipeItemType.Shaper);
                        }
                    }
                }
                else
                {
                    GlobalLog.Info("[StashRecipeTask] AnyItemsToStash empty, No items to stash for shaper exalt recipe.");
                    await Coroutines.CloseBlockingWindows();

                    return(false);
                }
            }

            var itemsToStash = ItemsToStash;

            if (itemsToStash.Count == 0)
            {
                GlobalLog.Info("[StashRecipeTask] No items to stash for shaper exalt recipe.");
                await Coroutines.CloseBlockingWindows();

                return(false);
            }

            GlobalLog.Info($"[StashRecipeTask] {itemsToStash.Count} items to stash for shaper exalt recipe.");

            await OpenShaperRecipeTab();

            // Shaper Loop
            foreach (var item in itemsToStash.OrderBy(i => i.Position, Position.Comparer.Instance))
            {
                if (item.RecipeType != RecipeData.ExaltRecipeItemType.Shaper)
                {
                    continue;
                }

                GlobalLog.Debug($"[StashRecipeTask] Now stashing \"{item.Name}\" for shaper exalt recipe.");
                var itemPos = item.Position;
                if (!Inventories.StashTabCanFitItem(itemPos))
                {
                    GlobalLog.Error("[StashRecipeTask] Stash tab for shaper exalt recipe is full and must be cleaned.");
                    _shaperStashTabIsFull = true;
                    return(true);
                }
                if (!await Inventories.FastMoveFromInventory(itemPos))
                {
                    ReportError();
                    return(true);
                }
                Class1.ShaperStashData.IncreaseItemCount(item.ItemType);
                GlobalLog.Info($"[Events] Item stashed ({item.FullName})");
                Utility.BroadcastMessage(this, Events.Messages.ItemStashedEvent, item);
            }
            await Wait.SleepSafe(300);

            Class1.ShaperStashData.SyncWithStashTab(RecipeData.ExaltRecipeItemType.Shaper);
            Class1.ShaperStashData.Log();
            return(true);
        }
        public async Task <Inventories> UpdateInventory(Inventories inventory)
        {
            var url = URLBuilder.GetURL(Controllers.MAINTENANCE, EndPoint.MAINTENANCE_INVENTORY_UPDATE);

            return(await requestProvider.PutAsync(url, inventory));
        }
예제 #29
0
        async Task <UnitDetailsModel> GetUnitFromDB(int?unitId, int?inventoryId, bool includeRCI = false)
        {
            var model = await
                            (from u in _context.Units
                            join c in _context.Translators on new { Reference = u.country, Type = "COUNTRY", Language = "EN" } equals new { c.Reference, c.Type, c.Language }
                            join s in _context.Translators on new { Reference = u.state, Type = "_S_" + u.country, Language = "EN" } equals new { s.Reference, s.Type, s.Language } into States
                            from St in States.DefaultIfEmpty()
                            join r in _context.Regions on u.regioncode equals r.regioncode into Regions
                            from Rg in Regions.DefaultIfEmpty()
                            join i in _context.Inventories on u.keyid equals i.unitkeyid into Inventories
                            from Ig in Inventories.DefaultIfEmpty()
                            where u.keyid == (unitId ?? u.keyid) &&
                            Ig.keyid == (inventoryId ?? Ig.keyid)
                            select new UnitDetailsModel()
            {
                Description    = u.info,
                ImageURL       = $"http://accessrsi.com/dannoJR/ProductImageHandler.ashx?imageid={u.thumbID}",
                OwnerId        = u.ownerid,
                OriginalUnitId = u.origionalid,
                UnitId         = u.keyid,
                UnitName       = u.name,
                Address        = new AddressViewModel()
                {
                    City            = u.city,
                    CountryCode     = u.country,
                    CountryFullName = c.Value,
                    PostalCode      = u.zip,
                    RegionCode      = u.regioncode,
                    RegionFullName  = Rg.regiondescription,
                    StateCode       = u.state,
                    StateFullName   = St.Value,
                    StreetAddress   = u.address.Trim()
                }
            }).FirstOrDefaultAsync <UnitDetailsModel>();

            if (model != null)
            {
                model.Amenities = await
                                      (from a in _context.Amenities
                                      where a.unitkeyid == unitId
                                      orderby a.sorder
                                      select new Amenity()
                {
                    Location = a.location,
                    Name     = a.ref1,
                    Distance = a.distance,
                    MK       = a.mk
                }).ToListAsync();

                var urgentInfo = await _context.LoadStoredProc("dbo.vipUrgentInfo")
                                 .WithSqlParam("resortID", unitId)
                                 .ExecuteStoredProcAsync <vipUrgentInfoResult>();

                model.UrgentInfo = urgentInfo.Select(u => u.urgentInfo).ToList();

                if (model.OwnerId == 100)
                {
                    model.AdditionalImageURLs = new List <string>()
                    {
                        $"http://rci.accessrsi.com/api/rci/getImage?resortId={model.OriginalUnitId}"
                    };
                }
                else
                {
                    model.AdditionalImageURLs = await
                                                    (from p in _context.Pics
                                                    where p.ptype == "U_PIC" && p.ref1 == model.UnitId.ToString()
                                                    select $"http://accessrsi.com/dannoJR/ProductImageHandler.ashx?imageid={p.keyid}").ToListAsync();
                }
            }

            if (model != null)
            {
                model.Message = "Success";
            }
            return(model ?? new UnitDetailsModel()
            {
                Message = "Error: Unit Not Found"
            });
        }
예제 #30
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            base.PrivateUpdate(frame);

            List <NectarMaker> choices = new List <NectarMaker>();
            NectarMaker        best = null, broken = null;

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (NectarMaker maker in lot.GetObjects <NectarMaker>())
                {
                    if (!maker.Repairable.Broken)
                    {
                        choices.Add(maker);
                        if (maker.Inventory.IsFull())
                        {
                            best = maker;
                        }
                    }
                    else
                    {
                        broken = maker;
                    }

                    foreach (NectarBottle bottle in maker.mBottles)
                    {
                        Inventories.TryToMove(bottle, Sim.CreatedSim);
                    }

                    AddStat("Collected Bottles", maker.mBottles.Count);

                    maker.mBottles.Clear();
                }
            }

            List <NectarRack> racks = new List <NectarRack>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                foreach (NectarRack rack in lot.GetObjects <NectarRack>())
                {
                    if (rack.HasTreasure())
                    {
                        continue;
                    }

                    if (rack.Buyable)
                    {
                        continue;
                    }

                    if (rack.Tasteable)
                    {
                        continue;
                    }

                    if (rack.Inventory.IsFull())
                    {
                        continue;
                    }

                    racks.Add(rack);
                }
            }

            if (racks.Count > 0)
            {
                List <NectarBottle> bottles = new List <NectarBottle>(Inventories.InventoryFindAll <NectarBottle>(Sim));
                foreach (NectarBottle bottle in bottles)
                {
                    if (!bottle.CanBeSold())
                    {
                        continue;
                    }

                    NectarRack rack = RandomUtil.GetRandomObjectFromList(racks);

                    IncStat("Rack Stored");
                    rack.Inventory.TryToMove(bottle);

                    if (rack.Inventory.IsFull())
                    {
                        racks.Remove(rack);
                        if (racks.Count == 0)
                        {
                            break;
                        }
                    }
                }
            }

            if (best != null)
            {
                choices.Clear();
                choices.Add(best);
            }

            if (choices.Count == 0)
            {
                if (broken != null)
                {
                    IncStat("Attempt Repair");

                    Add(frame, new ScheduledRepairScenario(Sim, broken), ScenarioResult.Start);
                }
                else
                {
                    IncStat("No Choice");
                }
                return(false);
            }

            NectarMaker choice = RandomUtil.GetRandomObjectFromList(choices);

            if (!choice.Inventory.IsFull())
            {
                List <Ingredient> list = new List <Ingredient>(Inventories.InventoryFindAll <Ingredient>(Sim));

                while (list.Count > 0)
                {
                    Ingredient ingredient = RandomUtil.GetRandomObjectFromList(list);
                    list.Remove(ingredient);

                    if (!choice.CanAddToInventory(ingredient))
                    {
                        continue;
                    }

                    if (choice.Inventory.TryToMove(ingredient))
                    {
                        IncStat("Added: " + ingredient.CatalogName);
                    }

                    if (choice.Inventory.IsFull())
                    {
                        break;
                    }
                }
            }

            if (choice.Inventory.IsFull())
            {
                if ((ManagerCareer.HasSkillCareer(Sim, SkillNames.Nectar)) ||
                    (!ManagerCareer.HasSkillCareer(Sim.Household, SkillNames.Nectar)))
                {
                    int skillLevel = Sim.SkillManager.GetSkillLevel(SkillNames.Nectar);

                    List <NectarMaker.MakeNectarStyle> styles = new List <NectarMaker.MakeNectarStyle>();

                    styles.Add(NectarMaker.MakeNectarStyle.Basic);

                    if (skillLevel >= NectarMaker.kConcentratedUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.Concentrated);
                    }
                    if (skillLevel >= NectarMaker.kMassProduceUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.MassProduce);
                    }
                    if (skillLevel >= NectarMaker.kExtendedNectarationUnlockLevel)
                    {
                        styles.Add(NectarMaker.MakeNectarStyle.ExtendedNectaration);
                    }

                    return(Situations.PushInteraction(this, Sim, choice, new MakeNectarEx.Definition(RandomUtil.GetRandomObjectFromList(styles))));
                }
                else
                {
                    IncStat("Not Job");
                    return(false);
                }
            }
            else
            {
                IncStat("Not Full");
                return(false);
            }
        }