public byte GetSubsort(ObjectCatalogItem item) { switch (Mode) { case UICatalogMode.Downtown: return(item.DowntownSort); case UICatalogMode.Community: return(item.CommunitySort); case UICatalogMode.Vacation: return(item.VacationSort); case UICatalogMode.Studiotown: return(item.StudiotownSort); case UICatalogMode.Magictown: return(item.MagictownSort); default: if (item.RoomSort == 0) { return(0); //items without a room sort should not appear. } return(item.Subsort); } }
public ObjectCatalogItem GetItemByGUID(uint guid) { ObjectCatalogItem item = null; ItemsByGUID.TryGetValue(guid, out item); return(item); }
public void Init(Content content) { //load and build catalog ItemsByGUID = new Dictionary<uint, ObjectCatalogItem>(); ItemsByCategory = new List<ObjectCatalogItem>[30]; for (int i = 0; i < 30; i++) ItemsByCategory[i] = new List<ObjectCatalogItem>(); var packingslip = new XmlDocument(); packingslip.Load(content.GetPath("packingslips/catalog.xml")); var objectInfos = packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) continue; var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } //load and build Content Objects into catalog if (File.Exists(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml"))) { var dpackingslip = new XmlDocument(); dpackingslip.Load(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml")); var downloadInfos = dpackingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in downloadInfos) { sbyte dCategory = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint dguid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (dCategory < 0) continue; var ditem = new ObjectCatalogItem() { GUID = dguid, Category = dCategory, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[dCategory].Add(ditem); ItemsByGUID[dguid] = ditem; } } }
private void BuildOffer(VMEODSecureTradeObject[] offer, UICatalog target) { var inventory = LotController.vm.MyInventory; var offercat = new List <UICatalogElement>(); foreach (var item in offer) { ObjectCatalogItem?catItem; uint tag = 0; if (item == null || item.PID == DragUID || (item.LotID > 0 && DragUID > 0 && DragUID < 3)) { catItem = new ObjectCatalogItem() { GUID = uint.MaxValue }; } else if (item.LotID > 0) { var c = GenCatItem((uint)((item.GUID == 1) ? 0x3495FC60 : 0x34B4B46A)); if (item.GUID == 2) { c.Name = item.LotName + " w/ " + item.ObjectCount + " objects ($" + item.ObjectValue + ")"; } else { c.Name += " - " + item.LotName; } catItem = c; tag = item.GUID; } else { catItem = Content.Content.Get().WorldCatalog.GetItemByGUID(item.GUID); if (catItem == null) { catItem = GenCatItem(item.GUID); } tag = item.PID; } var obj = catItem.Value; obj.Price = 0; offercat.Add(new UICatalogElement { Item = obj, Tag = tag }); } target.SetCategory(offercat); }
public static int GetDiscountFor(ObjectCatalogItem item, VM vm) { if (vm?.TSOState.PropertyCategory != 5) { return(0); } var guid = item.GUID; var catalog = Content.Content.Get().WorldCatalog; var sameItem = vm.Entities.Count(x => x == x.MultitileGroup.BaseObject && (x.Object.OBJ.GUID == guid || x.MasterDefinition?.GUID == guid)); var catItems = vm.Entities.Count(x => x == x.MultitileGroup.BaseObject && item.Category == catalog.GetItemByGUID((x.MasterDefinition == null) ? x.Object.OBJ.GUID : x.MasterDefinition.GUID)?.Category); sameItem = Math.Min(3, sameItem); catItems = Math.Min(10, catItems); return(sameItem * 10 + catItems * 3); }
public byte GetSubsort(ObjectCatalogItem item) { switch (Mode) { case UICatalogMode.Downtown: return(item.DowntownSort); case UICatalogMode.Community: return(item.CommunitySort); case UICatalogMode.Vacation: return(item.VacationSort); case UICatalogMode.Studiotown: return(item.StudiotownSort); case UICatalogMode.Magictown: return(item.MagictownSort); default: return(item.Subsort); } }
public void Init(Content content) { //load and build catalog ItemsByGUID = new Dictionary <uint, ObjectCatalogItem>(); ItemsByCategory = new List <ObjectCatalogItem> [30]; for (int i = 0; i < 30; i++) { ItemsByCategory[i] = new List <ObjectCatalogItem>(); } var packingslip = new XmlDocument(); packingslip.Load(content.GetPath("packingslips/catalog.xml")); var objectInfos = packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } //load and build Content Objects into catalog if (File.Exists(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml"))) { var dpackingslip = new XmlDocument(); dpackingslip.Load(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml")); var downloadInfos = dpackingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in downloadInfos) { sbyte dCategory = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint dguid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (dCategory < 0) { continue; } var ditem = new ObjectCatalogItem() { GUID = dguid, Category = dCategory, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[dCategory].Add(ditem); ItemsByGUID[dguid] = ditem; } } }
public void Init() { GameObjects.Init(); Entries = new Dictionary <ulong, GameObjectReference>(); Cache = new TimedReferenceCache <ulong, GameObject>(); ItemsByGUID = new Dictionary <uint, ObjectCatalogItem>(); ItemsByCategory = new List <ObjectCatalogItem> [30]; for (int i = 0; i < 30; i++) { ItemsByCategory[i] = new List <ObjectCatalogItem>(); } var allIffs = GameObjects.ListGeneric(); foreach (var iff in allIffs) { var file = (IffFile)iff.GetThrowawayGeneric(); file.MarkThrowaway(); var objects = file.List <OBJD>(); var slots = file.List <SLOT>(); if (objects != null) { foreach (var obj in objects) { Entries[obj.GUID] = new GameObjectReference(this) { FileName = Path.GetFileName(iff.ToString().Replace('\\','/')), ID = obj.GUID, Name = obj.ChunkLabel, Source = GameObjectSource.Far, Group = (short)obj.MasterID, SubIndex = obj.SubIndex, GlobalSimObject = obj.ObjectType == OBJDType.SimType && obj.Global == 1 }; if (obj.ObjectType == OBJDType.Person) { PersonGUIDs.Add(obj.GUID); } //does this object appear in the catalog? if ((obj.FunctionFlags > 0 || obj.BuildModeType > 0) && obj.Disabled == 0 && (obj.MasterID == 0 || obj.SubIndex == -1)) { //todo: more than one of these set? no normal game objects do this //todo: room sort var cat = (sbyte)Math.Log(obj.FunctionFlags,2); if (obj.FunctionFlags == 0) { cat = (sbyte)(obj.BuildModeType + 7); } var item = new ObjectCatalogItem() { Category = (sbyte)(cat), //0-7 buy categories. 8-15 build mode categories GUID = obj.GUID, DisableLevel = 0, Price = obj.Price, Name = obj.ChunkLabel, Subsort = (byte)obj.FunctionSubsort, CommunitySort = (byte)obj.CommunitySubsort, DowntownSort = (byte)obj.DTSubsort, MagictownSort = (byte)obj.MTSubsort, StudiotownSort = (byte)obj.STSubsort, VacationSort = (byte)obj.VacationSubsort }; ItemsByCategory[item.Category].Add(item); ItemsByGUID[item.GUID] = item; } } } } var globalSims = Entries.Values.Where(x => x.GlobalSimObject); ControllerObjects.Clear(); ControllerObjects.AddRange(globalSims); ContentManager.Neighborhood.LoadCharacters(false); }
public void Init(GameContent content) { //load and build catalog ItemsByGUID = new Dictionary <uint, ObjectCatalogItem>(); ItemsByCategory = new List <ObjectCatalogItem> [30]; for (int i = 0; i < 30; i++) { ItemsByCategory[i] = new List <ObjectCatalogItem>(); } var packingslip = new XmlDocument(); //very simple overide incase you don't want to use the TSO catalog or want to change it. if (File.Exists(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog.xml"))) { packingslip.Load(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog.xml")); } else { packingslip.Load(content.GetPath("packingslips/catalog.xml")); } //If the community lot file exists, load it for uilotbutton. if (File.Exists(Path.Combine(FSOEnvironment.ContentDir, "patch/mtune/clots.txt"))) { CLots = File.ReadAllText(Path.Combine(FSOEnvironment.ContentDir, "patch/mtune/clots.txt"), Encoding.UTF8); } var objectInfos = packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value, DisableLevel = Convert.ToByte(objectInfo.Attributes["r"]?.Value ?? "0") }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } //load and build Content Objects into catalog if (File.Exists(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml"))) { var dpackingslip = new XmlDocument(); dpackingslip.Load(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml")); var downloadInfos = dpackingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in downloadInfos) { sbyte dCategory = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint dguid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (dCategory < 0) { continue; } var ditem = new ObjectCatalogItem() { GUID = dguid, Category = dCategory, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value, DisableLevel = Convert.ToByte(objectInfo.Attributes["r"]?.Value ?? "0") }; ItemsByCategory[dCategory].Add(ditem); ItemsByGUID[dguid] = ditem; } } }
public void Init(Content content) { //load and build catalog ItemsByGUID = new Dictionary <uint, ObjectCatalogItem>(); ItemsByCategory = new List <ObjectCatalogItem> [30]; for (int i = 0; i < 30; i++) { ItemsByCategory[i] = new List <ObjectCatalogItem>(); } var packingslip = new XmlDocument(); packingslip.Load("Content/catalog.xml"); var objectInfos = packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } if (Directory.Exists(FSOEnvironment.SimsCompleteDir + "/ExpansionPack")) { var ep1packingslip = new XmlDocument(); ep1packingslip.Load("Content/ep1.xml"); var ep1objectInfos = ep1packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in ep1objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } } if (Directory.Exists(FSOEnvironment.SimsCompleteDir + "/ExpansionPack2")) { var ep2packingslip = new XmlDocument(); ep2packingslip.Load("Content/ep2.xml"); var ep2objectInfos = ep2packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in ep2objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } } if (Directory.Exists(FSOEnvironment.SimsCompleteDir + "/ExpansionPack3")) { var ep3packingslip = new XmlDocument(); ep3packingslip.Load("Content/ep3.xml"); var ep3objectInfos = ep3packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in ep3objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } } if (Directory.Exists(FSOEnvironment.SimsCompleteDir + "/ExpansionPack4")) { var ep4packingslip = new XmlDocument(); ep4packingslip.Load("Content/ep4.xml"); var ep4objectInfos = ep4packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in ep4objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } } if (Directory.Exists(FSOEnvironment.SimsCompleteDir + "/ExpansionPack5")) { var ep5packingslip = new XmlDocument(); ep5packingslip.Load("Content/ep5.xml"); var ep5objectInfos = ep5packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in ep5objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } } if (Directory.Exists(FSOEnvironment.SimsCompleteDir + "/ExpansionPack6")) { var ep6packingslip = new XmlDocument(); ep6packingslip.Load("Content/ep6.xml"); var ep6objectInfos = ep6packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in ep6objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } } if (Directory.Exists(FSOEnvironment.SimsCompleteDir + "/ExpansionPack7")) { var ep7packingslip = new XmlDocument(); ep7packingslip.Load("Content/ep7.xml"); var ep7objectInfos = ep7packingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in ep7objectInfos) { sbyte Category = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint guid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (Category < 0) { continue; } var item = new ObjectCatalogItem() { GUID = guid, Category = Category, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[Category].Add(item); ItemsByGUID[guid] = item; } } //load and build Content Objects into catalog if (File.Exists(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml"))) { var dpackingslip = new XmlDocument(); dpackingslip.Load(Path.Combine(FSOEnvironment.ContentDir, "Objects/catalog_downloads.xml")); var downloadInfos = dpackingslip.GetElementsByTagName("P"); foreach (XmlNode objectInfo in downloadInfos) { sbyte dCategory = Convert.ToSByte(objectInfo.Attributes["s"].Value); uint dguid = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16); if (dCategory < 0) { continue; } var ditem = new ObjectCatalogItem() { GUID = dguid, Category = dCategory, Price = Convert.ToUInt32(objectInfo.Attributes["p"].Value), Name = objectInfo.Attributes["n"].Value }; ItemsByCategory[dCategory].Add(ditem); ItemsByGUID[dguid] = ditem; } } }
public void Init() { GameObjects.Init(); Entries = new Dictionary<ulong, GameObjectReference>(); Cache = new TimedReferenceCache<ulong, GameObject>(); ItemsByGUID = new Dictionary<uint, ObjectCatalogItem>(); ItemsByCategory = new List<ObjectCatalogItem>[30]; for (int i = 0; i < 30; i++) ItemsByCategory[i] = new List<ObjectCatalogItem>(); var allIffs = GameObjects.ListGeneric(); foreach (var iff in allIffs) { var file = (IffFile)iff.GetThrowawayGeneric(); file.MarkThrowaway(); var objects = file.List<OBJD>(); if (objects != null) { foreach (var obj in objects) { Entries.Add(obj.GUID, new GameObjectReference(this) { FileName = iff.ToString(), ID = obj.GUID, Name = obj.ChunkLabel, Source = GameObjectSource.Far, Group = (short)obj.MasterID, SubIndex = obj.SubIndex }); //does this object appear in the catalog? if (obj.FunctionFlags > 0 && (obj.MasterID == 0 || obj.SubIndex == -1)) { var cat = (sbyte)Math.Log(obj.FunctionFlags, 2); var item = new ObjectCatalogItem() { Category = (sbyte)(cat + 11), //debug for now GUID = obj.GUID, DisableLevel = 0, Price = obj.Price, Name = obj.ChunkLabel }; ItemsByCategory[item.Category].Add(item); ItemsByGUID[item.GUID] = item; } } } } var path = Path.Combine(ContentManager.TS1BasePath, "UserData/Characters/"); var files = Directory.EnumerateFiles(path); foreach (var filename in files) { if (Path.GetExtension(filename) != ".iff") return; var file = new IffFile(filename); file.MarkThrowaway(); var objects = file.List<OBJD>(); if (objects != null) { foreach (var obj in objects) { Entries.Add(obj.GUID, new GameObjectReference(this) { FileName = filename, ID = obj.GUID, Name = obj.ChunkLabel, Source = GameObjectSource.Standalone, Group = (short)obj.MasterID, SubIndex = obj.SubIndex }); } } } }