Пример #1
0
        /// <summary>Registers the item into it's registry</summary>
        public override IdentifiableItem Register()
        {
            Build();

            foreach (Identifiable.Id id in Prefabs.Keys)
            {
                IdentifiableRegistry.CategorizeId(id);

                if (GameContext.Instance.MessageDirector.Get("actor", "l." + id.ToString().ToLower()) == null)
                {
                    LanguageController.AddActorTranslation("l." + id.ToString().ToLower(), DefTranslation[id]);
                }

                LookupRegistry.RegisterIdentifiablePrefab(Prefabs[id]);

                VacEntry = VacItemDefinition.CreateVacItemDefinition(id, Color, Icon ? Icon : SRObjects.MissingIcon);
                LookupRegistry.RegisterVacEntry(VacEntry);
                VacEntries.Add(id, VacEntry);

                if (IsVacuumableOverride || Size == Vacuumable.Size.NORMAL)
                {
                    AmmoRegistry.RegisterPlayerAmmo(PlayerState.AmmoMode.DEFAULT, id);
                }

                if (IsRefineryResource)
                {
                    AmmoRegistry.RegisterRefineryResource(id);
                }

                AmmoRegistry.RegisterSiloAmmo(ValidSiloAmmo, id);
            }

            VacEntry = null;
            return(this);
        }
Пример #2
0
        /// <summary>
        /// Register a vacuumable item into the <see cref=""/>
        /// </summary>
        /// <param name="id">Id of the vacuumable item</param>
        /// <param name="color">Color of the background of the inventory slot</param>
        /// <param name="icon">Icon that will be used for the item in inventory</param>
        public static void RegisterVacEntry(Identifiable.Id id, Color color, Sprite icon)
        {
            VacItemDefinition definition = ScriptableObject.CreateInstance <VacItemDefinition>();

            definition.id    = id;
            definition.color = color;
            definition.icon  = icon;
            RegisterVacEntry(definition);
        }
Пример #3
0
        /// <summary>
        /// Register <paramref name="entry"/> into the <see cref="LookupDirector"/>
        /// </summary>
        /// <param name="entry"></param>
        public static void RegisterVacEntry(VacItemDefinition entry)
        {
            switch (CurrentLoadingStep)
            {
            case LoadingStep.PRELOAD:
                vacEntriesToPatch.Add(entry);
                break;

            default:
                GameContext.Instance.LookupDirector.vacItemDefinitions.AddAndRemoveWhere(entry, (x, y) => x.id == y.id);
                GameContext.Instance.LookupDirector.vacItemDict[entry.id] = entry;
                break;
            }
        }
        /// <summary>
        /// Registers a Vac Entry for an Identifiable
        /// </summary>
        /// <param name="vacEntry">The vac entry to register</param>
        public static void RegisterVacEntry(VacItemDefinition vacEntry)
        {
            if (ModLoader.CurrentStep != LoadingState.REGISTER)
            {
                throw new Exception("You can only register things during the 'Register' step");
            }

            if (VAC_ITEM_DEFS.ContainsKey(vacEntry.Id))
            {
                VAC_ITEM_DEFS[vacEntry.Id] = vacEntry;
            }
            else
            {
                VAC_ITEM_DEFS.Add(vacEntry.Id, vacEntry);
            }
        }
Пример #5
0
        /// <summary>Registers the item into it's registry</summary>
        public override IdentifiableItem Register()
        {
            Build();

            LookupRegistry.RegisterIdentifiablePrefab(Prefab);

            VacEntry = VacItemDefinition.CreateVacItemDefinition(ID, Color, Icon ? Icon : SRObjects.MissingIcon);
            LookupRegistry.RegisterVacEntry(VacEntry);

            if (IsVacuumableOverride || Size == Vacuumable.Size.NORMAL)
            {
                AmmoRegistry.RegisterPlayerAmmo(PlayerState.AmmoMode.DEFAULT, ID);
            }

            if (IsRefineryResource)
            {
                AmmoRegistry.RegisterRefineryResource(ID);
            }

            AmmoRegistry.RegisterSiloAmmo(ValidSiloAmmo, ID);

            return(this);
        }