Пример #1
0
        // Only use if we need to Discover patterns through the sewing table
        //public static Pattern DiscoverPatternWithOnlySewingTable(GameObject target, Sim actor)
        //{
        //    PatternInfo mPatternInfoInit = new PatternInfo();
        //    ResourceKey getPattern = GetUnregisteredpattern(actor, false);
        //    SimDescription actorDesc = actor.SimDescription;


        //    ResourceKey emptyRes = new ResourceKey(0uL, 0u, 0u);
        //    if (getPattern != emptyRes)
        //    {

        //        for (int i = 0; i < ObjectLoader.sewableSettings.Count; i++)
        //        {

        //            if (ObjectLoader.sewableSettings[i].key == getPattern)
        //            {
        //                try
        //                {
        //                    mPatternInfoInit.resKeyPattern = getPattern;
        //                    mPatternInfoInit.fabricsNeeded = ObjectLoader.sewableSettings[i].typeFabric;
        //                    mPatternInfoInit.IsMagic = ObjectLoader.sewableSettings[i].isMagicProject;
        //                    mPatternInfoInit.amountOfFabricToRemove = ObjectLoader.sewableSettings[i].amountRemoveFabric;
        //                    mPatternInfoInit.isClothing = ObjectLoader.sewableSettings[i].isClothing;
        //                    mPatternInfoInit.mClothingName = ObjectLoader.sewableSettings[i].clothingName;
        //                    mPatternInfoInit.mWasPatternGifted = false;

        //                    if (mPatternInfoInit.isClothing)
        //                    {
        //                        mPatternInfoInit.mSimOutfit = new CASPart(mPatternInfoInit.resKeyPattern);
        //                    }

        //                    // Move on if the reskey is invalid.
        //                    if (mPatternInfoInit.resKeyPattern == ResourceKey.kInvalidResourceKey)
        //                    {
        //                        continue;
        //                    }

        //                    // Pattern OBJD key.
        //                    ResourceKey reskey1 = new ResourceKey(0x19D4F5930F26B2D8, 0x319E4F1D, 0x00000000);
        //                    Pattern.PatternObjectInitParams initData = new Pattern.PatternObjectInitParams(mPatternInfoInit.fabricsNeeded, mPatternInfoInit.IsMagic, mPatternInfoInit.amountOfFabricToRemove, mPatternInfoInit.mSkilllevel, mPatternInfoInit.resKeyPattern, mPatternInfoInit.isClothing, mPatternInfoInit.mSimOutfit, mPatternInfoInit.mClothingName, mPatternInfoInit.mWasPatternGifted);
        //                    Pattern pattern = GlobalFunctions.CreateObject(reskey1, target.GetSlotPosition(Slot.ContainmentSlot_1), 0, target.GetForwardOfSlot(Slot.ContainmentSlot_1), null, initData) as Pattern;

        //                    SetPatternMaterial(pattern, mPatternInfoInit.mSkilllevel, actor);

        //                    if (pattern.GetType() == typeof(FailureObject))
        //                    {
        //                        continue;
        //                    }
        //                    if (pattern != null)
        //                    {
        //                        SimDescription desc = actor.SimDescription;
        //                        SewingSkill.AddItemsToDiscoveredList(desc, mPatternInfoInit.resKeyPattern);
        //                        IGameObject getname = (GameObject)GlobalFunctions.CreateObjectOutOfWorld(mPatternInfoInit.resKeyPattern, null, initData);
        //                        // Currently uses the pattern object's name. We need to concatinate the sewable's name here as well. Since EA never made a function to get the name direction from the resource key, we need to do this.
        //                        mPatternInfoInit.Name = pattern.GetLocalizedName() + ": " + getname.GetLocalizedName();
        //                        pattern.NameComponent.SetName(pattern.GetLocalizedName() + ": " + getname.GetLocalizedName());
        //                        // Now we finally got the name and can destroy the object.
        //                        getname.Destroy();
        //                        //Set global

        //                        //actor.ShowTNSIfSelectable("Ah yes! I just came up with a great project to sew and just drew the pattern for it! For the time being, I put it in the sewing table's inventory.", StyledNotification.NotificationStyle.kSimTalking);
        //                        return pattern;
        //                    }
        //                    else if (pattern != null && mPatternInfoInit.isClothing)
        //                    {
        //                        mPatternInfoInit.Name = mPatternInfoInit.mClothingName;
        //                        pattern.NameComponent.SetName(mPatternInfoInit.mClothingName);

        //                        pattern.mPatternInfo = mPatternInfoInit;
        //                        actor.Inventory.TryToAdd(pattern);
        //                        return pattern;
        //                    }
        //                    else
        //                    {
        //                        GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n The pattern doesn't exist! Did you delete things from the sewing table .package? Else, contact Lyralei.");
        //                        return null;
        //                    }
        //                }
        //                catch (Exception ex2)
        //                {
        //                    GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n REPORT THIS TO LYRALEI: " + ex2.ToString());
        //                    return null;
        //                }
        //            }
        //        }
        //    }
        //    return null;
        //}

        public static ResourceKey GetRandomKeyWithSKills(Sim actor)
        {
            ResourceKey emptyRes         = new ResourceKey(0uL, 0u, 0u);
            ResourceKey randomPatternKey = new ResourceKey();

            Pattern.PatternInfo mPatternInfoInit = new Pattern.PatternInfo();
            int skillLevel = actor.SkillManager.GetSkillLevel(SewingSkill.kSewingSkillGUID);

            if (skillLevel >= 0)
            {
                randomPatternKey             = RandomUtil.GetRandomObjectFromList(ObjectLoader.EasySewablesList);
                mPatternInfoInit.mSkilllevel = 0;
                return(randomPatternKey);
            }
            if (skillLevel >= 3)
            {
                randomPatternKey             = RandomUtil.GetRandomObjectFromList(ObjectLoader.MediumSewablesList);
                mPatternInfoInit.mSkilllevel = 3;
                return(randomPatternKey);
            }
            if (skillLevel >= 6)
            {
                randomPatternKey             = RandomUtil.GetRandomObjectFromList(ObjectLoader.HardSewablesList);
                mPatternInfoInit.mSkilllevel = 6;
                return(randomPatternKey);
            }
            if (skillLevel >= 9)
            {
                randomPatternKey             = RandomUtil.GetRandomObjectFromList(ObjectLoader.HarderSewablesList);
                mPatternInfoInit.mSkilllevel = 9;
                if (actor.mSimDescription.IsWitch || (actor.mSimDescription.IsFairy) || (actor.mSimDescription.IsGenie) || (actor.mSimDescription.IsImaginaryFriend))
                {
                    randomPatternKey             = RandomUtil.GetRandomObjectFromList(ObjectLoader.MagicHarderSewablesList);
                    mPatternInfoInit.mSkilllevel = 9;
                    return(randomPatternKey);
                }
                return(randomPatternKey);
            }
            return(emptyRes);
        }
Пример #2
0
        public static void DiscoverAllPatterns(Sim actor)
        {
            List <ResourceKey> allPatternsList = new List <ResourceKey>();

            allPatternsList.AddRange(ObjectLoader.EasySewablesList);
            allPatternsList.AddRange(ObjectLoader.MediumSewablesList);
            allPatternsList.AddRange(ObjectLoader.HardSewablesList);
            allPatternsList.AddRange(ObjectLoader.HarderSewablesList);
            allPatternsList.AddRange(ObjectLoader.MagicHarderSewablesList);

            Pattern.PatternInfo mPatternInfoInit = new Pattern.PatternInfo();
            int skillLevel = actor.SkillManager.GetSkillLevel(SewingSkill.kSewingSkillGUID);

            for (int i = 0; i < ObjectLoader.sewableSettings.Count; i++)
            {
                //					if(ObjectLoader.sewableSettings[i].key == getPattern)
                //                  {
                try
                {
                    mPatternInfoInit.resKeyPattern          = ObjectLoader.sewableSettings[i].key;
                    mPatternInfoInit.fabricsNeeded          = ObjectLoader.sewableSettings[i].typeFabric;
                    mPatternInfoInit.IsMagic                = ObjectLoader.sewableSettings[i].isMagicProject;
                    mPatternInfoInit.amountOfFabricToRemove = ObjectLoader.sewableSettings[i].amountRemoveFabric;
                    mPatternInfoInit.mSkilllevel            = 0;
                    mPatternInfoInit.isClothing             = ObjectLoader.sewableSettings[i].isClothing;
                    mPatternInfoInit.mClothingName          = ObjectLoader.sewableSettings[i].clothingName;
                    mPatternInfoInit.mWasPatternGifted      = false;

                    if (mPatternInfoInit.isClothing)
                    {
                        mPatternInfoInit.mSimOutfit = new CASPart(mPatternInfoInit.resKeyPattern);
                    }

                    // Move on if the reskey is invalid.
                    if (mPatternInfoInit.resKeyPattern == ResourceKey.kInvalidResourceKey)
                    {
                        continue;
                    }

                    // Pattern OBJD key.
                    ResourceKey reskey1 = new ResourceKey(0x19D4F5930F26B2D8, 0x319E4F1D, 0x00000000);
                    Pattern.PatternObjectInitParams initData = new Pattern.PatternObjectInitParams(mPatternInfoInit.fabricsNeeded, mPatternInfoInit.IsMagic, mPatternInfoInit.amountOfFabricToRemove, mPatternInfoInit.mSkilllevel, mPatternInfoInit.resKeyPattern, mPatternInfoInit.isClothing, mPatternInfoInit.mSimOutfit, mPatternInfoInit.mClothingName, mPatternInfoInit.mWasPatternGifted);
                    Pattern pattern = (Pattern)GlobalFunctions.CreateObjectOutOfWorld(reskey1, null, initData);

                    //Move on if the pattern resulted into a failure Object
                    if (pattern.GetType() == typeof(FailureObject))
                    {
                        continue;
                    }

                    if (pattern != null && !mPatternInfoInit.isClothing)
                    {
                        IGameObject getname = (GameObject)GlobalFunctions.CreateObjectOutOfWorld(mPatternInfoInit.resKeyPattern, null, initData);
                        if (getname != null)
                        {
                            // Currently uses the pattern object's name. We need to concatinate the sewable's name here as well. Since EA never made a function to get the name direction from the resource key, we need to do this.
                            mPatternInfoInit.Name = pattern.GetLocalizedName() + ":" + getname.GetLocalizedName();
                            pattern.NameComponent.SetName(pattern.GetLocalizedName() + ": " + getname.GetLocalizedName());
                            // Now we finally got the name and can destroy the object.
                            getname.Destroy();
                        }
                        pattern.mPatternInfo = mPatternInfoInit;
                        actor.Inventory.TryToAdd(pattern);
                    }
                    else if (pattern != null && mPatternInfoInit.isClothing)
                    {
                        mPatternInfoInit.Name = mPatternInfoInit.mClothingName;
                        pattern.NameComponent.SetName(mPatternInfoInit.mClothingName);

                        pattern.mPatternInfo = mPatternInfoInit;
                        actor.Inventory.TryToAdd(pattern);
                    }
                    else
                    {
                        GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n The pattern doesn't exist! Did you delete things from the sewing table .package? Else, contact Lyralei.");
                    }
                    SewingSkill.AddItemsToDiscoveredList(actor.mSimDescription.mSimDescriptionId, mPatternInfoInit.resKeyPattern);
                }
                catch (Exception ex2)
                {
                    GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n REPORT THIS TO LYRALEI: " + ex2.ToString());
                }
                //}
            }
        }