private void Session_Update(On.Session.orig_Update orig, Session self) { // Continue attempting to add the ItemHero until it has been added! try { SimulationDescriptor desc; Databases.GetDatabase <SimulationDescriptor>(false).TryGetValue(GetBaseDescriptor().Name, out desc); if (desc != null) { orig(self); return; } ItemHeroConfig itemHeroConfig = GetItemHeroConfig(); Databases.GetDatabase <ItemConfig>(false).Add(itemHeroConfig); Log("Added the item (ItemHeroConfig) to the database!"); Log("Attempting to make sim descriptors"); SimulationDescriptor descriptor = GetBaseDescriptor(); Log("Successfully retrieved the overall descriptor!"); SimulationDescriptor common = GetCommonDescriptor(); Log("Successfully retrieved the common descriptor!"); SimulationDescriptor rarity0 = GetRarity0Descriptor(); Log("Successfully retrieved the rarity0 descriptor!"); SimulationDescriptor rarity1 = GetRarity1Descriptor(); Log("Successfully retrieved the rarity1 descriptor!"); SimulationDescriptor rarity2 = GetRarity2Descriptor(); Log("Successfully retrieved the rarity2 descriptor!"); Log("Attempting to add descriptors to database!"); Databases.GetDatabase <SimulationDescriptor>(false).Add(descriptor); Log("Added Base!"); Databases.GetDatabase <SimulationDescriptor>(false).Add(common); Log("Added Common!"); Databases.GetDatabase <SimulationDescriptor>(false).Add(rarity0); Log("Added Rarity0!"); Databases.GetDatabase <SimulationDescriptor>(false).Add(rarity1); Log("Added Rarity1!"); Databases.GetDatabase <SimulationDescriptor>(false).Add(rarity2); Log("Added Rarity2!"); Log("Added all SimDescriptors to the database!"); } catch (ArgumentException e) { // It already exists! } catch (NullReferenceException e) { // Database doesn't exist yet! } orig(self); }
public ItemHeroConfig GetItemHeroConfig() { ItemHeroConfig config = new ItemHeroConfig(); DynData <ItemHeroConfig> d = new DynData <ItemHeroConfig>(config); d.Set <Amplitude.StaticString>("Name", GetName()); d.Set <int>("MaxCount", GetMaxCount()); d.Set <Amplitude.StaticString>("AttackTypeConfigName", GetAttackType()); d.Set("CannotBeUnequipped", GetCannotBeUnequipped()); d.Set("Skills", GetSkills()); d.Set("FlatSprite", GetFlatSprite()); d.Set("DestroyOnDeath", GetDestroyOnDeath()); d.Set("MaxOccurenceCount", GetMaxOccurenceCount()); d.Set("CategoryParameters", GetCategoryParameters()); d.Set("RarityParameters", GetRarityConfigs()); d.Set("DepthRanges", GetDepthRangeConfigs()); return(config); }