//+ CLASSIFICATION /// <summary> /// Classifies the gadget into it's respective class /// </summary> /// <param name="gadget">The gadget to classify</param> /// <param name="types">The types to classify as</param> public static void Classify(GadgetDefinition gadget, IEnumerable <GadgetType> types) { foreach (GadgetType type in types) { foreach (GadgetHandler handler in HANDLERS) { handler.Organize(gadget, type); } } }
//+ CLASSIFICATION internal static bool AddToType(GadgetDefinition gadget, GadgetType type) { if (!CLASS_LISTING.ContainsKey(type)) { GuuCore.LOGGER.LogError($"Trying to add gadget {gadget.id} to type {type}, but type listing isn't registered"); return(false); } CLASS_LISTING[type].Add(gadget.id); return(true); }
/// <summary> /// Registers the lock for a blueprint /// </summary> /// <param name="gadget">The gadget to register the lock for</param> /// <param name="unlockCondition">The unlock condition</param> /// <param name="unlockDelayHrs">The amount of game hours to delay</param> public static void RegisterLock(GadgetDefinition gadget, GadgetDirector.UnlockCondition unlockCondition, float unlockDelayHrs) { if (ModLoader.CurrentStep != LoadingState.PRE_LOAD) { throw new Exception("Handlers need to be registered during 'Pre-Load'"); } if (BLUEPRINTS.ContainsKey(gadget.id)) { BLUEPRINTS.Remove(gadget.id); } BLUEPRINT_LOCKS[gadget.id] = new Tuple <GadgetDirector.UnlockCondition, float>(unlockCondition, unlockDelayHrs); }
/// <summary> /// Organizes the gadget by adding it to its list /// </summary> /// <param name="gadget">The gadget to organize</param> /// <param name="type">The type of gadget</param> public virtual void Organize(GadgetDefinition gadget, GadgetType type) { if (!GadgetRegistry.AddToType(gadget, type)) { return; } if (type == GadgetType.FASHION_POD) { Gadget.RegisterFashion(gadget.id); IdentifiableRegistry.RegisterPodForFashion(gadget); } }
/// <summary> /// Register a gadget entry to the <see cref="LookupDirector"/> /// </summary> /// <param name="entry"></param> public static void RegisterGadget(GadgetDefinition entry) { switch (CurrentLoadingStep) { case LoadingStep.PRELOAD: gadgetEntriesToPatch.Add(entry); break; default: GameContext.Instance.LookupDirector.gadgetDefinitions.AddAndRemoveWhere(entry, (x, y) => x.id == y.id); GameContext.Instance.LookupDirector.gadgetDefinitionDict[entry.id] = entry; break; } }
//+ REGISTRATION /// <summary> /// Registers the Gadget /// </summary> /// <param name="gadget">The gadget definition</param> /// <param name="startAvailable">Should it's blueprint start available?</param> /// <param name="startUnlocked">Should it's blueprint start unlocked?</param> /// <param name="buyCount">The amount to get when you buy the gadget on the shop. 1 is the default, and 2 just sets the definition to buy in pairs</param> public static void RegisterGadget(GadgetDefinition gadget, bool startAvailable, bool startUnlocked = false, int buyCount = 1) { if (ModLoader.CurrentStep != LoadingState.PRE_LOAD) { throw new Exception("Handlers need to be registered during 'Pre-Load'"); } if (buyCount == 2) { gadget.buyInPairs = true; } if (buyCount > 2) { GADGET_BUY_COUNT[gadget.id] = buyCount; } GADGETS[gadget.id] = gadget; if ((startAvailable || startUnlocked) && !BLUEPRINT_LOCKS.ContainsKey(gadget.id)) { BLUEPRINTS[gadget.id] = startUnlocked; } }
public static T SetGadgetDefinition <T>(this T entity, GadgetDefinition value) where T : RulesetGadget { entity.SetField("gadgetDefinition", value); return(entity); }
//+ INTERNAL REGISTRATION internal static void RegisterPodForFashion(GadgetDefinition pod) { Dictionary <Identifiable.Id, Gadget.Id> gadgetNameDict = typeof(Identifiable).GetPrivateField <Dictionary <Identifiable.Id, Gadget.Id> >("GADGET_NAME_DICT"); gadgetNameDict.Add(pod.prefab.GetComponent <FashionPod>().fashionId, pod.id); }