Example #1
0
        public static void Patch()
        {
            darktest = AssetBundle.LoadFromFile(Environment.CurrentDirectory + "/QMods/techpistol/Assets");
            Atlas.Sprite Icon = new Atlas.Sprite(darktest.LoadAsset <Sprite>("Icon"));
            var          gun  = TechTypeHandler.AddTechType("techpistol", "tech pistol", "tech pistol", true);

            SpriteHandler.RegisterSprite(gun, Icon);
            GunPrefab gunper = new GunPrefab("techpistol", "WorldEntities/Tools/techpistol", gun);

            PrefabHandler.RegisterPrefab(gunper);
            CraftDataHandler.SetEquipmentType(gun, EquipmentType.Hand);
            var techData = new TechData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>()
                {
                    new Ingredient(TechType.SeaTreaderPoop, 1),
                    new Ingredient(TechType.TitaniumIngot, 2),
                    new Ingredient(TechType.Lubricant, 1),
                    new Ingredient(TechType.EnameledGlass, 3),
                }
            };

            CraftDataHandler.SetTechData(gun, techData);
            CraftDataHandler.SetCraftingTime(gun, 5f);
            CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, gun, "Personal", "Tools", "techpistol");
            CraftDataHandler.SetItemSize(gun, 2, 2);
        }
Example #2
0
        /// <summary>
        /// Creates a new tab node for the custom crafting tree and links it to the calling node.
        /// </summary>
        /// <param name="nameID">The name/ID of this node.</param>
        /// <param name="displayText">The hover text to display in-game.</param>
        /// <param name="sprite">The custom sprite to display on this tab node.</param>
        public CustomCraftTreeTab AddTabNode(string nameID, string displayText, Atlas.Sprite sprite)
        {
            var tabNode = new CustomCraftTreeTab(nameID, displayText, sprite);

            tabNode.LinkToParent(this);
            return(tabNode);
        }
        public static void PostPatch()
        {
#if BELOWZERO
            Sprite hoverbike = SpriteManager.Get(SpriteManager.Group.Pings, "Hoverbike");
            CraftTreeHandler.AddTabNode(CraftTree.Type.Fabricator, "HoverbikeUpgrades", "Snowfox Upgrades", hoverbike, new string[] { "Upgrades" });
            foreach (Spawnable s in new List <Spawnable>()
            {
                new HoverbikeWaterTravelModule(),
                new HoverbikeSolarChargerModule(),
                new HoverbikeStructuralIntegrityModule(),
                new HoverbikeEngineEfficiencyModule(),
                new HoverbikeSelfRepairModule(),
                new HoverbikeDurabilitySystem(),
                new HoverbikeSpeedModule(),
            })
            {
                s.Patch();
            }


            //Batteries.PostPatch();
            LanguageHandler.SetLanguageLine("SeamothWelcomeAboard", "Welcome aboard captain.");
#endif
            CoroutineHost.StartCoroutine(PostPatchCoroutine());
        }
Example #4
0
        protected FcCraftable(string classId, string friendlyName, string description, FcCraftingTab parentTab)
            : base(classId, friendlyName, description)
        {
            this.ParentTab = parentTab;

            OnStartedPatching += () =>
            {
                this.ParentTab.LoadAssets(this.AssetBundlesService);
                this.AssetBundle = this.AssetBundlesService.GetAssetBundleByName(this.AssetBundleName);
            };

            OnFinishedPatching += () =>
            {
                if (!this.FabricatorService.HasCraftingTab(this.ParentTab.Id))
                {
                    string       tabId       = this.ParentTab.Id;
                    string       displayText = this.ParentTab.DisplayName;
                    Atlas.Sprite icon        = this.ParentTab.Icon;

                    this.FabricatorService.AddTabNode(tabId, displayText, icon);
                }

                this.FabricatorService.AddCraftNode(this, this.ParentTab.Id);
            };
        }
Example #5
0
        public virtual void Patch()
        {
#if SUBNAUTICA
            Atlas.Sprite sprite = NameUsingForFiles != null
                ? ImageUtils.LoadSpriteFromFile($"./QMods/{NameUsingForFiles}/Assets/{NameUsingForFiles}.png")
                : GetResourceIcon(PrefabTemplate);
#elif BELOWZERO
            Sprite sprite = NameUsingForFiles != null
                ? ImageUtils.LoadSpriteFromFile($"./QMods/{NameUsingForFiles}/Assets/{NameUsingForFiles}.png")
                : GetResourceIcon(PrefabTemplate);
#endif

            this.TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, sprite, false);
            SpriteHandler.RegisterSprite(this.TechType, sprite);
            CraftTreeHandler.AddCraftingNode(FabricatorType, this.TechType, FabricatorTab);
            CraftDataHandler.SetTechData(this.TechType, GetRecipe());
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, this.TechType);
            CraftDataHandler.SetEquipmentType(this.TechType, TypeForEquipment);
            CraftDataHandler.SetQuickSlotType(this.TechType, TypeForQuickslot);
            CraftDataHandler.SetItemSize(this.TechType, ItemSize);

            KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                this.TechType
            }, $"{FriendlyName} blueprint discovered!");

            PrefabHandler.RegisterPrefab(this);
        }
        public static void DebugAtlasSprite(this Atlas.Sprite sprite, string prefixString = null)
        {
            if (prefixString == null)
            {
                DLog.Log($"\n[Sprite]");
                prefixString = "this";
            }

            DLog.Log($"{prefixString}.border: {sprite.border}");
            DLog.Log($"{prefixString}.inner: {sprite.inner}");
            DLog.Log($"{prefixString}.outer: {sprite.outer}");
            DLog.Log($"{prefixString}.padding: {sprite.padding}");
            DLog.Log($"{prefixString}.pixelsPerUnit: {sprite.pixelsPerUnit}");
            DLog.Log($"{prefixString}.size: {sprite.size}");
            DLog.Log($"{prefixString}.slice9Grid: {sprite.slice9Grid}");

            sprite.texture.DebugTexture2D($"{prefixString}.texture");

            for (int i = 0; i < sprite.triangles.Length; i++)
            {
                DLog.Log($"{prefixString}.triangles[{i}]: {sprite.triangles[i]}");
            }

            for (int i = 0; i < sprite.uv0.Length; i++)
            {
                DLog.Log($"{prefixString}.uv0[{i}]: {sprite.uv0[i]}");
            }

            for (int i = 0; i < sprite.vertices.Length; i++)
            {
                DLog.Log($"{prefixString}.vertices[{i}]: {sprite.vertices[i]}");
            }
        }
Example #7
0
        private void SetModuleVisibility(string slot, GameObject module)
        {
            if (module is null)
            {
                QuickLogger.Debug($"SetModuleVisibility in slot {slot} module was null", true);
                return;
            }

            TechType techType = this.Modules.GetTechTypeInSlot(slot);

            bool hasItem = techType != TechType.None;

            uGUI_Icon icon = module.GetComponent <uGUI_Icon>();

            if (hasItem)
            {
                Atlas.Sprite atlasSprite = SpriteManager.Get(techType);

                if (atlasSprite is null)
                {
                    QuickLogger.Debug($"sprite for {module.name} was null when it should not have been", true);
                }

                icon.sprite = atlasSprite;
            }
            else
            {
                icon.sprite = null; // Clear the sprite when empty
            }

            module.SetActive(hasItem);
            icon.enabled = hasItem;
        }
            public bool AddTank(TechType tank, float baseCapacity, Sprite sprite = null, bool bUpdate = false, bool bUnlockAtStart = false)
            {
                if (TankTypes == null)
                {
                    TankTypes = new Dictionary <TechType, TankType>();
                }

                //if (TankTypes[i].tankTechType == tank)
                if (TankTypes.TryGetValue(tank, out TankType tt))
                {
                    if (bUpdate)
                    {
#if !RELEASE
                        Logger.Log(Logger.Level.Debug, $"Updating tank type for TechType '{tank.AsString()}' with value {baseCapacity}");
#endif
                        TankTypes[tank].UpdateCapacity(baseCapacity);
                    }
                    return(false);
                }
#if !RELEASE
                Logger.Log(Logger.Level.Debug, $"Adding Tank '{tank.AsString()}' with capacity of {baseCapacity}");
#endif
                TankTypes[tank] = new TankType(tank, baseCapacity, bUnlockAtStart: bUnlockAtStart);
                return(true);
            }
 /// <summary>
 /// Creates a new ModSprite to be used with a specific group and internal ID.
 /// Created with an Atlas Sprite.
 /// </summary>
 /// <param name="group">The sprite group.</param>
 /// <param name="id">The sprite internal identifier.</param>
 /// <param name="sprite">The sprite to be added.</param>
 public ModSprite(SpriteManager.Group group, string id, Atlas.Sprite sprite)
 {
     Group    = group;
     Id       = id;
     Sprite   = sprite;
     TechType = TechType.None;
 }
Example #10
0
 internal CustomCraftTreeTab(string nameID, string displayText, Sprite sprite)
     : base(nameID, TreeAction.Expand, TechType.None)
 {
     DisplayText = displayText;
     Asprite     = null;
     Usprite     = sprite;
 }
 /// <summary>
 /// Creates a new ModSprite to be used with a specific group and internal ID.
 /// Created with an Atlas Sprite.
 /// </summary>
 /// <param name="group">The sprite group.</param>
 /// <param name="type">The techtype paired to this sprite.</param>
 /// <param name="sprite">The sprite to be added.</param>
 public ModSprite(SpriteManager.Group group, TechType type, Atlas.Sprite sprite)
 {
     Group    = group;
     Id       = type.AsString();
     Sprite   = sprite;
     TechType = type;
 }
Example #12
0
 public CustomSprite(TechType type, Atlas.Sprite sprite)
 {
     Group    = SpriteManager.Group.None;
     TechType = type;
     Id       = type.AsString();
     Sprite   = sprite;
 }
Example #13
0
 protected AmbientEnergyCharger(TechType tier1TechType, TechType tier2TechType, SubRoot cyclops) : base(cyclops)
 {
     tier1Id     = tier1TechType;
     tier2Id2    = tier2TechType;
     tier1Sprite = SpriteManager.Get(tier1TechType);
     tier2Sprite = SpriteManager.Get(tier2TechType);
 }
        public void Patch()
        {
            UnlockSprite = GetItemSprite();

            TechType = TechTypeHandler.Main.AddTechType(TechTypeName, FriendlyName, string.Empty, UnlockSprite, false);

            PrefabHandler.Main.RegisterPrefab(this);

            LootDistributionData.SrcData srcData = new LootDistributionData.SrcData()
            {
                prefabPath   = $"{ClassID}_Prefab",
                distribution = GetBiomeDatas()
            };

            LootDistributionHandler.Main.AddLootDistributionData(ClassID, srcData);

            WorldEntityInfo EntityInfo = new WorldEntityInfo()
            {
                classId    = ClassID,
                techType   = TechType,
                slotType   = SlotType,
                prefabZUp  = PrefabZUp,
                cellLevel  = CellLevel,
                localScale = LocalScale
            };

            WorldEntityDatabaseHandler.Main.AddCustomInfo(ClassID, EntityInfo);
        }
Example #15
0
        protected FCSVehicleUpgradeModule(string classId, string friendlyName, string description, FcCraftingTab parentTab)
            : base(classId, friendlyName, description)
        {
            this.ParentTab = parentTab;

            OnStartedPatching += () =>
            {
                this.ParentTab.LoadAssets(this.AssetBundlesService);
                this.AssetBundle = this.AssetBundlesService.GetAssetBundleByName(this.AssetBundleName);
            };

            OnFinishedPatching += () =>
            {
                if (!this.FabricatorService.HasCraftingTab(this.ParentTab.Id))
                {
                    string       tabId       = this.ParentTab.Id;
                    string       displayText = this.ParentTab.DisplayName;
                    Atlas.Sprite icon        = this.ParentTab.Icon;

                    this.FabricatorService.AddTabNode(tabId, displayText, icon);
                }
                CraftDataHandler.SetQuickSlotType(this.TechType, QuickSlotType.Passive);
                this.FabricatorService.AddCraftNode(this, this.ParentTab.Id);
            };
        }
 /// <summary>
 /// Creates a new ModSprite to be used with a specific TechType.
 /// Created with an Atlas Sprite.
 /// </summary>
 /// <param name="type">The techtype paired to this sprite.</param>
 /// <param name="sprite">The sprite to be added.</param>
 public ModSprite(TechType type, Atlas.Sprite sprite)
 {
     TechType = type;
     Id       = type.AsString();
     Sprite   = sprite;
     Group    = SpriteManager.Group.Item;
 }
        internal static PingType AddPingType(string name, Sprite sprite)
        {
            var cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache()
            {
                Name  = name,
                Index = cacheManager.GetNextAvailableIndex()
            };

            var pingType = (PingType)cache.Index;

            cacheManager.Add(pingType, cache.Index, cache.Name);
            ModSprite.Add(SpriteManager.Group.Pings, cache.Name, sprite);

            if (PingManager.sCachedPingTypeStrings.valueToString.ContainsKey(pingType) == false)
            {
                PingManager.sCachedPingTypeStrings.valueToString.Add(pingType, name);
            }

            if (PingManager.sCachedPingTypeTranslationStrings.valueToString.ContainsKey(pingType) == false)
            {
                PingManager.sCachedPingTypeTranslationStrings.valueToString.Add(pingType, name);
            }

            Logger.Log($"Successfully added PingType: '{name}' to Index: '{cache.Index}'", LogLevel.Debug);
            return(pingType);
        }
Example #18
0
        internal NuclearFabricator(CyclopsNuclearModule module)
            : base("NuclearFabricator",
                   "Nuclear Fabricator",
                   "A specialized fabricator for safe handling of radioactive energy sources.")
        {
            nuclearModule = module;

            OnStartedPatching += () =>
            {
                if (!nuclearModule.IsPatched)
                {
                    nuclearModule.Patch();
                }

                // Load the custom texture
                string executingLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string folderPath        = Path.Combine(executingLocation, "Assets");

                string textureLocation = Path.Combine(folderPath, "NuclearFabricatorT.png");
                customTexture = ImageUtils.LoadTextureFromFile(textureLocation);

                string spriteLocation = Path.Combine(folderPath, "NuclearFabricator.png");
                sprite = ImageUtils.LoadSpriteFromFile(spriteLocation) ?? SpriteManager.Get(TechType.Fabricator);
            };
        }
Example #19
0
        /// <summary>
        /// Creates a new <see cref="Sprite" /> from an image file.
        /// </summary>
        /// <param name="texture2D">The 2D texture to convert into a sprite.</param>
        /// <returns>
        /// Will return a new <see cref="Sprite" /> instance using the provided texture.
        /// </returns>
        public static Sprite LoadSpriteFromTexture(Texture2D texture2D)
        {
#if SUBNAUTICA
            return(new Sprite(texture2D));
#elif BELOWZERO
            return(Sprite.Create(texture2D, new Rect(0.0f, 0.0f, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f)));
#endif
        }
Example #20
0
        protected TechType register(string name, string description, Atlas.Sprite sprite)
        {
            TechType = TechTypeHandler.AddTechType(ClassID, name, description, sprite, false);

            registerPrefabAndTechData();

            return(TechType);
        }
 protected override Sprite GetItemSprite()
 {
     if (icon == null || icon == SpriteManager.defaultSprite)
     {
         icon = SpriteManager.Get(TechType.Seaglide);
     }
     return(icon);
 }
 internal ModCraftTreeTab(string modName, string nameID, string displayText, Atlas.Sprite sprite)
     : base(nameID, TreeAction.Expand, TechType.None)
 {
     DisplayText = displayText;
     Asprite     = sprite;
     Usprite     = null;
     ModName     = modName;
 }
        /// <summary>
        /// adds a new <see cref="CraftData.BackgroundType"/> into the game.
        /// </summary>
        /// <param name="backgroundTypeName">the name of the BackgroundType, should not contain special characters.</param>
        /// <param name="backgroundSprite">The sprite for this BackgroundType.</param>
        /// <returns>The new <see cref="CraftData.BackgroundType"/> that's created.</returns>
        CraftData.BackgroundType IBackgroundTypeHandler.AddBackgroundType(string backgroundTypeName, Sprite backgroundSprite)
        {
            var backgroundType = BackgroundTypePatcher.AddBackgroundType(backgroundTypeName);

            BackgroundSprites[backgroundType] = backgroundSprite;

            return(backgroundType);
        }
Example #24
0
        internal TabNode(string[] path, CraftTree.Type scheme, Atlas.Sprite sprite, string modName, string name, string displayName) : base(path, scheme)
        {
            Sprite      = sprite;
            DisplayName = displayName;
            Name        = name;

            ModSprite.Add(new ModSprite(SpriteManager.Group.Category, $"{Scheme.ToString()}_{Name}", Sprite));
            LanguagePatcher.AddCustomLanguageLine(modName, $"{Scheme.ToString()}Menu_{Name}", DisplayName);
        }
Example #25
0
 /// <summary>
 /// Adds a new tab node to the custom crafting tree of this fabricator.
 /// </summary>
 /// <param name="tabId">The internal ID for the tab node.</param>
 /// <param name="displayText">The in-game text shown for the tab node.</param>
 /// <param name="tabSprite">The sprite used for the tab node.</param>
 /// <param name="parentTabId">Optional. The parent tab of this tab.<para/>
 /// When this value is null, the tab will be added to the root of the craft tree.</param>
 public void AddTabNode(string tabId, string displayText, Sprite tabSprite, string parentTabId = null)
 {
     OrderedCraftTreeActions.Add(() =>
     {
         ModCraftTreeLinkingNode parentNode = CraftTreeLinkingNodes[parentTabId ?? RootNode];
         ModCraftTreeTab tab          = parentNode.AddTabNode(tabId, displayText, tabSprite);
         CraftTreeLinkingNodes[tabId] = tab;
     });
 }
Example #26
0
        public virtual void Patch()
        {
            Atlas.Sprite sprite = null;

            if (IconFilename != null)
            {
                string iconfilePath = $"./QMods/{IconFilename}/Assets/{IconFilename}.png";

                try
                {
                    sprite = ImageUtils.LoadSpriteFromFile(iconfilePath);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! File [{iconfilePath}] not Found! ");
                }
            }
            else if (IconTechType != TechType.None)
            {
                try
                {
                    sprite = GetResourceIcon(IconTechType);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! Resource TechType icon [{IconTechType.ToString()}] not Found! ");
                }
            }
            else
            {
                try
                {
                    sprite = GetResourceIcon(PrefabTemplate);
                }
                catch
                {
                    SNLogger.Log($"[{NameID}] ***ERROR! Resource template icon [{PrefabTemplate.ToString()}] not Found! ");
                }
            }


            TechType = TechTypeHandler.AddTechType(NameID, FriendlyName, Description, sprite, false);
            SpriteHandler.RegisterSprite(TechType, sprite);
            CraftTreeHandler.AddCraftingNode(FabricatorType, TechType, FabricatorTab);
            CraftDataHandler.SetTechData(TechType, GetRecipe());
            CraftDataHandler.AddToGroup(GroupForPDA, CategoryForPDA, TechType);
            CraftDataHandler.SetEquipmentType(TechType, TypeForEquipment);
            CraftDataHandler.SetQuickSlotType(TechType, TypeForQuickslot);
            CraftDataHandler.SetItemSize(TechType, ItemSize);
            CraftDataHandler.SetBackgroundType(TechType, BackgroundType);
            KnownTechHandler.SetAnalysisTechEntry(RequiredForUnlock, new TechType[1] {
                TechType
            }, $"{FriendlyName} blueprint discovered!");

            PrefabHandler.RegisterPrefab(this);
        }
        private void Init(IIngredient ingredient, Atlas.Sprite sprite, bool first, bool last)
        {
            this.ingredient = ingredient;
            bool mainIcon = ingredient == null;

            var quickSlots = GameObject.FindObjectOfType <uGUI_QuickSlots>();
            var bgSprite   = first ? quickSlots.spriteLeft : last ? quickSlots.spriteRight : quickSlots.spriteCenter;

            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bgSprite.rect.width);
            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, bgSprite.rect.height);

            layout           = gameObject.AddComponent <LayoutElement>();
            layout.minWidth  = bgSprite.rect.width;
            layout.minHeight = bgSprite.rect.height;

            background               = gameObject.AddComponent <Image>();
            background.color         = new Color(1, 1, 1, Mod.config.BackgroundAlpha);
            background.raycastTarget = false;
            background.material      = quickSlots.materialBackground;
            background.sprite        = bgSprite;

            icon = new GameObject("Icon").AddComponent <uGUI_ItemIcon>();
            icon.transform.SetParent(transform, false);
            icon.SetForegroundSprite(sprite);
            if (mainIcon)
            {
                icon.SetSize(Width, Width);
            }
            else
            {
                icon.SetSize(IconWidth, IconWidth);
            }
            icon.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
            icon.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
            icon.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
            icon.rectTransform.anchoredPosition = new Vector2(0, 0);
            icon.raycastTarget = false;

            if (!mainIcon)
            {
                text = ModUtils.InstantiateNewText("Text", transform);
                RectTransformExtensions.SetSize(text.rectTransform, Width, Width);
                text.rectTransform.anchorMin        = new Vector2(0.5f, 0);
                text.rectTransform.anchorMax        = new Vector2(0.5f, 0);
                text.rectTransform.pivot            = new Vector2(0.5f, 0);
                text.rectTransform.anchoredPosition = new Vector2(0, 0);
                text.alignment     = TextAnchor.LowerCenter;
                text.fontSize      = Mod.config.FontSize;
                text.raycastTarget = false;

                ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorGoodColorblind : IngredientColorGood, out goodColor);
                ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorBadColorblind : IngredientColorBad, out badColor);
            }

            UpdateText();
        }
        internal ModCraftTreeTab(string modName, string nameID, string displayText, Sprite sprite)
            : base(nameID, TreeAction.Expand, TechType.None)
        {
            DisplayText = displayText;
#if SUBNAUTICA
            Asprite = null;
#endif
            Usprite = sprite;
            ModName = modName;
        }
Example #29
0
        public void Initialize(Atlas.Sprite sprite, Color color)
        {
            imageColor = color;

            color.a            = 0.5f;
            imageDisabledColor = color;

            image.sprite = sprite;
            image.color  = imageColor;
        }
Example #30
0
        public CustomCraftTab(string path, string name, CraftScheme scheme, Atlas.Sprite sprite)
        {
            Path   = path;
            Name   = name;
            Scheme = scheme;
            Sprite = new CustomSprite(SpriteManager.Group.Category, SpriteId, sprite);

            LanguagePatcher.customLines[LanguageId] = name;
            CustomSpriteHandler.customSprites.Add(Sprite);
        }