public static Models.Schematic Load(Models.Schematic schem, GomObject obj) { if (obj == null) { return(schem); } if (schem == null) { return(null); } schem.NodeId = obj.Id; schem.Fqn = obj.Name; schem.Deprecated = obj.Data.ValueOrDefault <bool>("prfSchematicDeprecated", false); schem.DisableCritical = obj.Data.ValueOrDefault <bool>("prfDisableCritical", false); schem.DisableDisassemble = obj.Data.ValueOrDefault <bool>("prfDisableDisassemble", false); ulong itemId = (ulong)obj.Data.ValueOrDefault <ulong>("prfSchematicItemSpec", 0); if (itemId > 0) { schem.Item = ItemLoader.Load(itemId); if (schem.Item != null) { schem.Id = schem.Item.Id; } else { Console.WriteLine("Schematic references non-existant item: " + schem.Fqn); } } schem.MissionCost = (int)obj.Data.ValueOrDefault <long>("prfMissionCost", 0); schem.MissionFaction = FactionExtensions.ToFaction((long)obj.Data.ValueOrDefault <long>("prfMissionFaction", 0)); schem.MissionUnlockable = obj.Data.ValueOrDefault <bool>("prfMissionUnlockable", false); schem.MissionLight = (int)obj.Data.ValueOrDefault <long>("prfMissionRewardLight", 0); schem.MissionLightCrit = (int)obj.Data.ValueOrDefault <long>("prfMissionRewardLightCritical", 0); schem.MissionDark = (int)obj.Data.ValueOrDefault <long>("prfMissionRewardDark", 0); schem.MissionDarkCrit = (int)obj.Data.ValueOrDefault <long>("prfMissionRewardDarkCritical", 0); schem.NameId = (ulong)obj.Data.ValueOrDefault <long>("prfSchematicNameId", 0); if (schem.NameId > 0) { schem.Name = missionStrTable.GetText((int)schem.NameId + strOffset, schem.Fqn); schem.Id = schem.NameId; } if ((schem.Name == null) && (schem.Item != null)) { schem.Name = schem.Item.Name; } schem.MissionYieldDescriptionId = (int)obj.Data.ValueOrDefault <long>("prfMissionYieldDescriptionId", 0); if (schem.MissionYieldDescriptionId > 0) { schem.MissionYieldDescription = missionStrTable.GetText(schem.MissionYieldDescriptionId + strOffset, schem.Fqn); } schem.MissionDescriptionId = (int)obj.Data.ValueOrDefault <long>("prfMissionDescriptionId", 0); if (schem.MissionDescriptionId > 0) { schem.MissionDescription = missionStrTable.GetText(schem.MissionDescriptionId + strOffset, schem.Fqn); } schem.CrewSkillId = ProfessionExtensions.ToProfession((ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("prfProfessionRequired", null)); schem.Subtype = ProfessionSubtypeExtensions.ToProfessionSubtype((ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("prfProfessionSubtype", null)); schem.SkillGrey = (int)obj.Data.ValueOrDefault <long>("prfSchematicGrey", 0); schem.SkillGreen = (int)obj.Data.ValueOrDefault <long>("prfSchematicGreen", 0); schem.SkillYellow = (int)obj.Data.ValueOrDefault <long>("prfSchematicYellow", 0); schem.SkillOrange = (int)obj.Data.ValueOrDefault <long>("prfProfessionLevelRequired", 0); schem.TrainingCost = (int)obj.Data.ValueOrDefault <long>("prfTrainingCost", 0); schem.Workstation = WorkstationExtensions.ToWorkstation((ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("prfWorkstationRequired", null)); var materials = (Dictionary <object, object>)obj.Data.ValueOrDefault <Dictionary <object, object> >("prfSchematicMaterials", null); if (materials != null) { int matIdx = 1; foreach (var mat_quantity in materials) { switch (matIdx) { case 1: schem.Mat1 = ItemLoader.Load((ulong)mat_quantity.Key); schem.Mat1Quantity = (int)(long)mat_quantity.Value; break; case 2: schem.Mat2 = ItemLoader.Load((ulong)mat_quantity.Key); schem.Mat2Quantity = (int)(long)mat_quantity.Value; break; case 3: schem.Mat3 = ItemLoader.Load((ulong)mat_quantity.Key); schem.Mat3Quantity = (int)(long)mat_quantity.Value; break; case 4: schem.Mat4 = ItemLoader.Load((ulong)mat_quantity.Key); schem.Mat4Quantity = (int)(long)mat_quantity.Value; break; case 5: schem.Mat5 = ItemLoader.Load((ulong)mat_quantity.Key); schem.Mat5Quantity = (int)(long)mat_quantity.Value; break; default: throw new InvalidOperationException("Schematic has too many materials!"); } matIdx++; } } var researchChance = (Dictionary <object, object>)obj.Data.ValueOrDefault <Dictionary <object, object> >("prfSchematicResearchChances", null); if (researchChance != null) { int rLvl = 1; foreach (var r_chance in researchChance) { switch (rLvl) { case 1: schem.ResearchChance1 = SchematicResearchChanceExtensions.ToSchematicResearchChance((ScriptEnum)r_chance.Value); break; case 2: schem.ResearchChance2 = SchematicResearchChanceExtensions.ToSchematicResearchChance((ScriptEnum)r_chance.Value); break; case 3: schem.ResearchChance3 = SchematicResearchChanceExtensions.ToSchematicResearchChance((ScriptEnum)r_chance.Value); break; default: throw new InvalidOperationException("This schematic has 4 tiers of research!?!"); } rLvl++; } } var craftTime = (List <object>)obj.Data.ValueOrDefault <List <object> >("prfSchematicCraftingTime", null); if (craftTime != null) { int timeIdx = 0; foreach (var time in craftTime) { switch (timeIdx) { case 0: schem.CraftingTime = (int)(ulong)time / 1000; break; case 1: schem.CraftingTimeT1 = (int)(ulong)time / 1000; break; case 2: schem.CraftingTimeT2 = (int)(ulong)time / 1000; break; case 3: schem.CraftingTimeT3 = (int)(ulong)time / 1000; break; default: throw new InvalidOperationException("This schematic has 4 tiers of research!?!"); } timeIdx++; } } var researchMaterials = (Dictionary <object, object>)obj.Data.ValueOrDefault <Dictionary <object, object> >("prfSchematicResearchMaterials", null); if (researchMaterials != null) { int idx = 1; foreach (var r_mats in researchMaterials) { Dictionary <object, object> matLookup = (Dictionary <object, object>)r_mats.Value; if (matLookup.Count > 1) { throw new InvalidOperationException("Research Tier adds more than one material"); } ulong matId = (ulong)matLookup.First().Key; int matQuantity = (int)(long)matLookup.First().Value; if (matId > 0) { switch (idx) { case 1: schem.Research1 = ItemLoader.Load(matId); schem.ResearchQuantity1 = matQuantity; break; case 2: schem.Research2 = ItemLoader.Load(matId); schem.ResearchQuantity2 = matQuantity; break; case 3: schem.Research3 = ItemLoader.Load(matId); schem.ResearchQuantity3 = matQuantity; break; default: throw new InvalidOperationException("This schematic has 4 tiers of research!?!"); } } idx++; } } if (idMap.Values.Where(s => s.Id == schem.Id).Count() > 0) { throw new InvalidOperationException("Attempting to set Id of a schematic to one that's already taken"); } return(schem); }
public static Models.Npc Load(Models.Npc npc, GomObject obj) { if (obj == null) { return(npc); } if (npc == null) { return(null); } ulong baseNpcId = obj.Data.ValueOrDefault <ulong>("npcParentSpecId", 0); Npc baseNpc; if (baseNpcId > 0) { baseNpc = Load(baseNpcId); } else { baseNpc = new Npc(); } npc.Fqn = obj.Name; npc.NodeId = obj.Id; var textLookup = obj.Data.ValueOrDefault <Dictionary <object, object> >("locTextRetrieverMap", null); GomObjectData nameLookupData = (GomObjectData)textLookup[NameLookupKey]; var nameId = nameLookupData.ValueOrDefault <long>("strLocalizedTextRetrieverStringID", 0); npc.Name = StringTable.TryGetString(npc.Fqn, nameLookupData); if (textLookup.ContainsKey(TitleLookupKey)) { var titleLookupData = (GomObjectData)textLookup[TitleLookupKey]; npc.Title = StringTable.TryGetString(npc.Fqn, titleLookupData); } npc.Id = (ulong)(nameId >> 32); //if (objIdMap.ContainsKey(npc.Id)) //{ // Npc otherNpc = objIdMap[npc.Id]; // if (!String.Equals(otherNpc.Fqn, npc.Fqn)) // { // throw new InvalidOperationException(String.Format("Duplicate NPC Ids: {0} and {1}", otherNpc.Fqn, npc.Fqn)); // } //} //else //{ // objIdMap[npc.Id] = npc; //} npc.MinLevel = (int)obj.Data.ValueOrDefault <long>("field_4000000027BDA14B", (long)baseNpc.MinLevel); npc.MaxLevel = (int)obj.Data.ValueOrDefault <long>("field_4000000027BDA14C", (long)baseNpc.MaxLevel); // Load Toughness var toughnessEnum = (ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("field_40000005618EC27C", null); if (toughnessEnum == null) { npc.Toughness = baseNpc.Toughness; } else { npc.Toughness = ToughnessExtensions.ToToughness(toughnessEnum); } // Load Faction long factionId = obj.Data.ValueOrDefault <long>("npcFaction", 0); if (factionId == 0) { npc.Faction = baseNpc.Faction; } else { npc.Faction = FactionExtensions.ToFaction(factionId); } npc.DifficultyFlags = (int)obj.Data.ValueOrDefault <long>("spnDifficultyLevelFlags", baseNpc.DifficultyFlags); npc.LootTableId = obj.Data.ValueOrDefault <long>("field_40000009AF9F1222", baseNpc.LootTableId); ulong npcClass = obj.Data.ValueOrDefault <ulong>("npcClassPackage", 0); if (npcClass == 0) { npc.ClassSpec = baseNpc.ClassSpec; } else { npc.ClassSpec = ClassSpecLoader.Load(npcClass); } ulong cdxNodeId = obj.Data.ValueOrDefault <ulong>("npcCodexSpec", 0); if (cdxNodeId > 0) { npc.Codex = CodexLoader.Load(cdxNodeId); } else { npc.Codex = baseNpc.Codex; } var profTrained = (ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("prfTrainerProfession", null); if (profTrained == null) { npc.ProfessionTrained = baseNpc.ProfessionTrained; } else { npc.ProfessionTrained = ProfessionExtensions.ToProfession(profTrained); } List <object> trainedPackages = obj.Data.ValueOrDefault <List <object> >("field_4000000A1D72EA38", null); if (trainedPackages == null) { npc.IsClassTrainer = baseNpc.IsClassTrainer; } else { npc.IsClassTrainer = trainedPackages.Count > 0; } npc.ConversationFqn = obj.Data.ValueOrDefault <string>("cnvConversationName", baseNpc.ConversationFqn); List <object> vendorPackages = obj.Data.ValueOrDefault <List <object> >("field_400000037C4DE713", null); if (vendorPackages != null) { foreach (string pkg in vendorPackages) { npc.VendorPackages.Add(pkg.ToLower()); } } else { npc.VendorPackages = baseNpc.VendorPackages; } return(npc); }
public static Models.Placeable Load(Models.Placeable plc, GomObject obj) { if (obj == null) { return(null); } if (plc == null) { return(null); } plc.Fqn = obj.Name; plc.NodeId = obj.Id; var textLookup = obj.Data.Get <Dictionary <object, object> >("locTextRetrieverMap"); var nameLookupData = (GomObjectData)textLookup[NameLookupKey]; long nameId = nameLookupData.Get <long>("strLocalizedTextRetrieverStringID"); plc.Id = (ulong)(nameId >> 32); plc.Name = StringTable.TryGetString(plc.Fqn, nameLookupData); //public Conversation Conversation { get; set; } string cnvFqn = obj.Data.ValueOrDefault <string>("plcConvo", null); // if (cnvFqn != null) { plc.Conversation = ConversationLoader.Load(cnvFqn); } //public Codex Codex { get; set; } ulong cdxNodeId = obj.Data.ValueOrDefault <ulong>("plcCodexSpec", 0); if (cdxNodeId > 0) { plc.Codex = CodexLoader.Load(cdxNodeId); } //public Profession RequiredProfession { get; set; } plc.RequiredProfession = ProfessionExtensions.ToProfession((ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("prfProfessionRequired", null)); //public int RequiredProfessionLevel { get; set; } plc.RequiredProfessionLevel = (int)obj.Data.ValueOrDefault <long>("prfProfessionLevelRequired", 0); //public bool IsBank { get; set; } plc.IsBank = obj.Data.ValueOrDefault <bool>("field_400000070210234D", false); //public bool IsMailbox { get; set; } plc.IsMailbox = obj.Data.ValueOrDefault <bool>("plcIsMailbox", false); //public AuctionHouseNetwork AuctionNetwork { get; set; } plc.AuctionNetwork = AuctionHouseNetworkExtensions.ToAuctionHouseNetwork((ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("field_40000008D92E8668", null)); //public bool IsAuctionHouse { get; set; } plc.IsAuctionHouse = plc.AuctionNetwork != AuctionHouseNetwork.None; //public bool IsEnhancementStation { get; set; } plc.IsEnhancementStation = EnhancementStationType.None != EnhancementStationTypeExtensions.ToEnhancementStationType((ScriptEnum)obj.Data.ValueOrDefault <ScriptEnum>("itmEnhancementStationType", null)); //public Faction Faction { get; set; } plc.Faction = FactionExtensions.ToFaction(obj.Data.ValueOrDefault <long>("plcFaction", 0)); //public int LootLevel { get; set; } plc.LootLevel = (int)obj.Data.ValueOrDefault <long>("plcdynLootLevel", 0); //public long LootPackageId { get; set; } plc.LootPackageId = obj.Data.ValueOrDefault <long>("plcdynLootPackage", 0); //public long WonkaPackageId { get; set; } plc.WonkaPackageId = obj.Data.ValueOrDefault <long>("wnkPackageID", 0); //public DifficultyLevel Difficulty { get; set; } plc.DifficultyFlags = (int)obj.Data.ValueOrDefault <long>("spnDifficultyLevelFlags", 0); //public HydraScript HydraScript { get; set; } ulong hydNodeId = obj.Data.ValueOrDefault <ulong>("field_4000000A4FA14A25", 0); if (hydNodeId > 0) { //plc.HydraScript = HydraScriptLoader.Load(hydNodeId); } Categorize(plc, obj); return(plc); }
public static Models.Codex Load(Models.Codex cdx, GomObject obj) { if (obj == null) { return(null); } if (cdx == null) { return(null); } cdx.Fqn = obj.Name; cdx.NodeId = obj.Id; cdx.Image = obj.Data.ValueOrDefault <string>("cdxImage", null); TorLib.Icons.AddCodex(cdx.Image); var textLookup = obj.Data.ValueOrDefault <Dictionary <object, object> >("locTextRetrieverMap", null); var descLookup = (GomObjectData)textLookup[DescriptionLookupKey]; var titleLookup = (GomObjectData)textLookup[NameLookupKey]; object categoryLookup; if (textLookup.TryGetValue(CategoryLookupKey, out categoryLookup)) { cdx.CategoryId = ((GomObjectData)categoryLookup).ValueOrDefault <long>("strLocalizedTextRetrieverStringID", 0); } var titleId = titleLookup.ValueOrDefault <long>("strLocalizedTextRetrieverStringID", 0); cdx.Id = (ulong)(titleId >> 32); cdx.Title = TryGetString(cdx.Fqn, titleLookup); cdx.Text = TryGetString(cdx.Fqn, descLookup); cdx.Level = (int)obj.Data.ValueOrDefault <long>("cdxLevel", 0); if (String.IsNullOrEmpty(cdx.Title)) { cdx.IsHidden = true; } cdx.Faction = FactionExtensions.ToFaction((long)obj.Data.ValueOrDefault <long>("cdxFaction", 0)); cdx.IsPlanet = obj.Data.ValueOrDefault <bool>("cdxIsPlanetCodex", false); Dictionary <object, object> classLookup = obj.Data.ValueOrDefault <Dictionary <object, object> >("cdxClassesLookupList", null); if (classLookup == null) { cdx.ClassRestricted = false; } else { cdx.ClassRestricted = true; cdx.Classes = new List <ClassSpec>(); foreach (var kvp in classLookup) { if ((bool)kvp.Value) { cdx.Classes.Add(ClassSpecLoader.Load((ulong)kvp.Key)); } } } List <object> cdxPlanets = obj.Data.ValueOrDefault <List <object> >("cdxPlanets", null); if (cdxPlanets != null) { cdx.HasPlanets = true; cdx.Planets = new List <Codex>(); foreach (var planetId in cdxPlanets) { cdx.Planets.Add(CodexLoader.Load((ulong)planetId)); } } return(cdx); }