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); }
public static void SendPatterns() { if (!Sims3.SimIFace.Environment.HasEditInGameModeSwitch && !GameUtils.IsOnVacation()) { Household activeHousehold = Household.ActiveHousehold; if (activeHousehold != null) { Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(activeHousehold.LotHome); if (mailboxOnLot != null) { foreach (Sim sim in activeHousehold.Sims) { SimDescription desc = sim.SimDescription; if (SewingSkill.isInPatternClub(desc)) { Pattern randomPattern = Pattern.DiscoverPattern(sim); if (randomPattern != null) { mailboxOnLot.AddMail(randomPattern, false); } else { randomPattern.Destroy(); } } } } } } }
public override bool Test(Sim a, Computer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (target.IsComputerUsable(a, true, false, isAutonomous)) { return(SewingSkill.isInPatternClub(a.SimDescription)); } return(false); }
public override bool Test(Sim a, Computer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { SewingSkill sewingSkill = a.SkillManager.GetElement(SewingSkill.kSewingSkillGUID) as SewingSkill; if (a.SkillManager.HasElement(SewingSkill.kSewingSkillGUID) && target.IsComputerUsable(a, true, false, isAutonomous) && sewingSkill.SkillLevel > 6) { return(a.FamilyFunds >= kCost); } return(false); }
//public static Pattern DiscoverPatternStartUp() //{ // ResourceKey getPattern = new ResourceKey(); // PatternInfo mPatternInfoInit = new PatternInfo(); // List<ResourceKey> checkIfAdded = new List<ResourceKey>(); // do // { // getPattern = RandomUtil.GetRandomObjectFromList(ObjectLoader.EasySewablesList); // if (!checkIfAdded.Contains(getPattern)) // { // checkIfAdded.Add(getPattern); // break; // } // } // while (true); // if (mStoredPatternsKeySettingsList.Contains(getPattern)) // { // try // { // for (int i = 0; i < ObjectLoader.sewableSettings.Count; i++) // { // mPatternInfoInit.resKeyPattern = getPattern; // // Move on if the reskey is invalid. // if (mPatternInfoInit.resKeyPattern == ResourceKey.kInvalidResourceKey) // { // continue; // } // 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); // } // // 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; // } // // We always pick a random EASY EA resource (and creator stuff) but clothing will always have a hardness level of medium. So we don't need the clothing check!! // 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(); // } // // 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()); // return pattern; // } // else if (pattern != null && mPatternInfoInit.isClothing) // { // mPatternInfoInit.Name = mPatternInfoInit.mClothingName; // pattern.NameComponent.SetName(mPatternInfoInit.Name); // pattern.mPatternInfo = mPatternInfoInit; // 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 GetUnregisteredpattern(Sim actor, bool NeedsToCache) { ResourceKey getPattern = new ResourceKey(); SimDescription actorDesc = actor.SimDescription; // Checks whether the current actor already knows the pattern chosen. do { getPattern = GetRandomKeyWithSKills(actor); if (!SewingSkill.HasAlreadyDiscoveredThis(actorDesc.mSimDescriptionId, getPattern)) { return(getPattern); } }while (true); }
public static Pattern GetRandomClothingPattern(Sim sim) { ResourceKey reskeyPattern; SewingSkill sewingSkill = sim.SkillManager.AddElement(SewingSkill.kSewingSkillGUID) as SewingSkill; do { reskeyPattern = RandomUtil.GetRandomObjectFromList(ObjectLoader.mStoredClothingPattern); if (!SewingSkill.HasAlreadyDiscoveredThis(sim.mSimDescription.mSimDescriptionId, reskeyPattern)) { break; } }while (true); if (reskeyPattern != ResourceKey.kInvalidResourceKey) { PatternInfo mPatternInfoInit = new PatternInfo(); mPatternInfoInit.resKeyPattern = reskeyPattern; ObjectLoader.sewableSetting sSetting = ObjectLoader.dictSettings[reskeyPattern]; mPatternInfoInit.fabricsNeeded = sSetting.typeFabric; mPatternInfoInit.IsMagic = sSetting.isMagicProject; mPatternInfoInit.amountOfFabricToRemove = sSetting.amountRemoveFabric; mPatternInfoInit.isClothing = sSetting.isClothing; mPatternInfoInit.mClothingName = sSetting.clothingName; mPatternInfoInit.mWasPatternGifted = false; if (mPatternInfoInit.isClothing) { mPatternInfoInit.mSimOutfit = new CASPart(mPatternInfoInit.resKeyPattern); } 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); mPatternInfoInit.Name = mPatternInfoInit.mClothingName; pattern.NameComponent.SetName(mPatternInfoInit.mClothingName); pattern.mPatternInfo = mPatternInfoInit; sim.Inventory.TryToAdd(pattern); sewingSkill.AddPatternCount(1); return(pattern); } return(null); }
public override bool Test(Sim a, Computer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (a.SkillManager.HasElement(SewingSkill.kSewingSkillGUID) && target.IsComputerUsable(a, true, false, isAutonomous) && !SewingSkill.isInPatternClub(a.SimDescription)) { return(a.FamilyFunds >= kCost); } return(false); }
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()); } //} } }
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); } }