Ejemplo n.º 1
0
        public override bool Run()
        {
            base.StandardEntry();
            if (!base.Target.StartComputing(this, SurfaceHeight.Table, true))
            {
                base.StandardExit();
                return(false);
            }

            SewingSkill sewingSkill = base.Actor.SkillManager.AddElement(SewingSkill.kSewingSkillGUID) as SewingSkill;

            if (sewingSkill == null)
            {
                GlobalOptionsSewingTable.print("Lyralei's Sewing Table: Failed to load sewing skill");
                return(false);
            }

            sewingSkill.StartSkillGain(3.5f);

            base.Target.StartVideo(Computer.VideoType.Browse);
            base.BeginCommodityUpdates();
            base.AnimateSim("GenericTyping");
            bool flag = base.DoLoop(ExitReason.Default, LoopDel, null);

            base.EndCommodityUpdates(flag);
            base.Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
            if (RandomUtil.RandomChance(kChanceDiscoverPatternComputer))
            {
                Pattern.DiscoverPattern(base.Actor);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Lyralei/Localized/BrowseWebForPatternsSuccess:InteractionName", new object[0]), StyledNotification.NotificationStyle.kSimTalking);
            }
            sewingSkill.StopSkillGain();
            base.StandardExit();
            return(flag);
        }
Ejemplo n.º 2
0
        public static void AddItemsToDiscoveredList(ulong sim, ResourceKey reskey)
        {
            foreach (KeyValuePair <ulong, List <ResourceKey> > keyvalues in GlobalOptionsSewingTable.retrieveData.mDiscoveredObjectsNEWEST)
            {
                ulong simmie = keyvalues.Key;
                List <ResourceKey> storedKeys = keyvalues.Value;

                if (sim == simmie)
                {
                    try
                    {
                        storedKeys.Add(reskey);
                        return;
                    }
                    catch (Exception exc)
                    {
                        GlobalOptionsSewingTable.print("Woops! Something went wrong when adding the pattern to the sim's list of 'known patterns'. if this happens frequently, please show this to Lyralei: /n /n" + exc.ToString());
                        return;
                    }
                }
                else
                {
                    storedKeys.Add(reskey);
                    GlobalOptionsSewingTable.retrieveData.mDiscoveredObjectsNEWEST.Add(sim, storedKeys);
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        public static void ReadSettingData(ResourceKey xmlKey)
        {
            ResourceKey empty = new ResourceKey(0, 0, 0);

            try
            {
                string data = Sims3.SimIFace.Simulator.LoadXMLString(xmlKey);
                if (data == null)
                {
                    GlobalOptionsSewingTable.print("Creator Debugger: XML Sewables settings are empty/Don't exist! Try the following: \n 1. Use the Instance of your OBJD/CASP and apply that to your XML's instance. \n 2. Make sure that the XML actually exists. \n 3. That the XML file has the group 0x7354C1FC.");
                }
                string[] SettingElements = data.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
                int      currentEntry    = sewableSettings.Count - 1;
                int      currentLine     = 0;

                foreach (string element in SettingElements)
                {
                    if (element == "----")
                    {
                        currentEntry++;
                        currentLine = 0;
                        sewableSettings.Add(new sewableSetting());
                    }
                    if (currentLine == 1)
                    {
                        sewableSettings[currentEntry].key = ResourceKey.FromString(element);
                        if (sewableSettings[currentEntry].key == empty || sewableSettings[currentEntry].key == ResourceKey.kInvalidResourceKey)
                        {
                            GlobalOptionsSewingTable.print("Creator Debugger: \n Oops, seems like the OBJD key is incorrect or doesn't exist inside your package/game. Therefore, the mod can't find it! :/ What you entered was: " + sewableSettings[currentEntry].key.ToString() + "\n Make sure of the following: \n 1. Your OBJD Key is correct. \n 2. That, inside S3PE, you highlighted the OBJD and right+clicked and then used the 'Copy resourceKey' Function. And then pasted this inside 'XML_Lyralei_Settings_Sewables'. \n \n \n If all that fails, make sure to contact me (Lyralei at MTS or Greenplumbboblover at tumblr)");
                        }
                    }
                    if (currentLine == 2)
                    {
                        string[] fabrics = element.Split(',');
                        for (int i = 0; i < fabrics.Length; i++)
                        {
                            string type1 = fabrics[i].ToUpper().Trim();

                            // Knitted, Cotton, Satin, Leather, Denim, Synthetic
                            switch (type1)
                            {
                            case "KNITTED":
                                sewableSettings[currentEntry].typeFabric.Add(SewingSkill.FabricType.Knitted);
                                break;

                            case "COTTON":
                                sewableSettings[currentEntry].typeFabric.Add(SewingSkill.FabricType.Cotton);
                                break;

                            case "SATIN":
                                sewableSettings[currentEntry].typeFabric.Add(SewingSkill.FabricType.Satin);
                                break;

                            case "LEATHER":
                                sewableSettings[currentEntry].typeFabric.Add(SewingSkill.FabricType.Leather);
                                break;

                            case "DENIM":
                                sewableSettings[currentEntry].typeFabric.Add(SewingSkill.FabricType.Denim);
                                break;

                            case "SYNTHETIC":
                                sewableSettings[currentEntry].typeFabric.Add(SewingSkill.FabricType.Synthetic);
                                break;

                            // FOR CC CREATORS - An error
                            default:
                                GlobalOptionsSewingTable.print("Creator Debugger: \n The fabric you used in " + data.ToString() + " isn't correct. What you entered was: " + type1.ToString() + "\n Make sure of the following: \n 1. You've formatted them Uppercase-like (i.e 'Knitted' or 'Cotton', etc) \n 2. It being an existing fabric type inside the mod. Either: (Knitted, Cotton, Satin, Leather, Denim, Synthetic). \n 3. Check for any typos! :) \n 4. If you have multiple, that you differentiate them with comma's ',' without any spaces!. \n \n If all that fails, make sure to contact me (Lyralei at MTS or Greenplumbboblover at tumblr)");
                                break;
                            }
                        }
                    }
                    if (currentLine == 3)
                    {
                        if (element.Contains("isMagicProject="))
                        {
                            string strBool   = element.Replace("isMagicProject=", "");
                            bool   ToBoolean = Convert.ToBoolean(strBool);
                            sewableSettings[currentEntry].isMagicProject = ToBoolean;
                        }
                    }
                    if (currentLine == 4)
                    {
                        if (element.Contains("isDiscoverableOnly="))
                        {
                            string strBool   = element.Replace("isDiscoverableOnly=", "");
                            bool   ToBoolean = Convert.ToBoolean(strBool);
                            sewableSettings[currentEntry].isDiscoverableOnly = ToBoolean;
                        }
                    }
                    if (currentLine == 5)
                    {
                        if (element.Contains("amountOfFabricToRemove="))
                        {
                            string strInt = element.Replace("amountOfFabricToRemove=", "");
                            int    ToInt  = Convert.ToInt16(strInt);
                            sewableSettings[currentEntry].amountRemoveFabric = ToInt;
                        }
                    }
                    if (currentLine == 6)
                    {
                        if (element.Contains("isClothing="))
                        {
                            string strBool   = element.Replace("isClothing=", "");
                            bool   ToBoolean = Convert.ToBoolean(strBool);
                            sewableSettings[currentEntry].isClothing = ToBoolean;
                            if (ToBoolean)
                            {
                                mStoredClothingPattern.Add(sewableSettings[currentEntry].key);
                            }
                        }
                        else
                        {
                            sewableSettings[currentEntry].isClothing = false;
                        }
                    }
                    if (currentLine == 7)
                    {
                        if (element.Contains("ClothingName="))
                        {
                            string name = element.Replace("ClothingName=", "");

                            sewableSettings[currentEntry].clothingName = name;
                        }
                        else
                        {
                            sewableSettings[currentEntry].clothingName = "";
                        }
                    }
                    // Check for dupes
                    if (!dictSettings.ContainsKey(sewableSettings[currentEntry].key))
                    {
                        dictSettings.Add(sewableSettings[currentEntry].key, sewableSettings[currentEntry]);
                    }
                    currentLine++;
                }
            }
            catch (Exception ex)
            {
                GlobalOptionsSewingTable.print("A problem was found when reading the XML file for your settings:  " + ex.ToString());
            }
        }
Ejemplo n.º 4
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());
                }
                //}
            }
        }
Ejemplo n.º 5
0
        public static Pattern DiscoverPattern(Sim actor)
        {
            //int skillLevel = actor.SkillManager.GetSkillLevel(SewingSkill.kSewingSkillGUID);
            ResourceKey getPattern       = GetUnregisteredpattern(actor, false);
            ResourceKey emptyRes         = new ResourceKey(0uL, 0u, 0u);
            PatternInfo mPatternInfoInit = new PatternInfo();
            SewingSkill sewingSkill      = actor.SkillManager.AddElement(SewingSkill.kSewingSkillGUID) as SewingSkill;

            try
            {
                ObjectLoader.sewableSetting sSetting = ObjectLoader.dictSettings[getPattern];

                mPatternInfoInit.resKeyPattern          = getPattern;
                mPatternInfoInit.fabricsNeeded          = sSetting.typeFabric;
                mPatternInfoInit.IsMagic                = sSetting.isMagicProject;
                mPatternInfoInit.amountOfFabricToRemove = sSetting.amountRemoveFabric;
                mPatternInfoInit.isClothing             = sSetting.isClothing;
                mPatternInfoInit.mClothingName          = sSetting.clothingName;
                mPatternInfoInit.mWasPatternGifted      = false;

                //mPatternInfoInit.mSkilllevel              = 0;

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

                // 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);

                if (pattern.GetType() == typeof(FailureObject))
                {
                    return(null);
                }

                if (pattern != null)
                {
                    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();
                    }
                    SimDescription desc = actor.SimDescription;
                    pattern.mPatternInfo = mPatternInfoInit;
                    SewingSkill.AddItemsToDiscoveredList(desc.mSimDescriptionId, mPatternInfoInit.resKeyPattern);

                    actor.Inventory.TryToAdd(pattern);
                    sewingSkill.AddPatternCount(1);
                    return(pattern);
                }
                else if (pattern != null && mPatternInfoInit.isClothing)
                {
                    mPatternInfoInit.Name = mPatternInfoInit.mClothingName;
                    pattern.NameComponent.SetName(mPatternInfoInit.mClothingName);

                    pattern.mPatternInfo = mPatternInfoInit;
                    actor.Inventory.TryToAdd(pattern);
                    sewingSkill.AddPatternCount(1);

                    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);
            }
        }