From f22a85fc4af2d9b8330a8b98d5cc93240da5ccc5 Mon Sep 17 00:00:00 2001 From: Vanic Date: Sat, 30 Aug 2025 14:54:59 +0000 Subject: [PATCH] Fix my bruh --- mods/API/Mod/init.lua | 25 ++++++++++++++----- mods/API/System/init.lua | 11 -------- .../MapGen/src/MapGen/Region/Region2D.lua | 2 +- .../MapGen/src/MapGen/Region/Region3D.lua | 2 +- mods/CORE/MapGen/{ => src}/init.lua | 0 mods/CORE/Node/src/Node.lua | 2 +- 6 files changed, 22 insertions(+), 20 deletions(-) rename mods/CORE/MapGen/{ => src}/init.lua (100%) diff --git a/mods/API/Mod/init.lua b/mods/API/Mod/init.lua index 955d8fc..6e04c0f 100644 --- a/mods/API/Mod/init.lua +++ b/mods/API/Mod/init.lua @@ -33,17 +33,30 @@ end ---@return table -- TODO: возможно стоит создать какой-то абстрактный класс, -- который будет является алеасом на table и будет обозначать наш класс -function Mod:getClassInstance() +function Mod:getModClassInstance() local instance = self.Class:new() return instance end ---- Inherit from a class provided by the mod ----@param ChildClass table? +--- Inherits a child class from a parent class +---@static +---@param ParentClass table +---@param ChildClass table? ---@return table -function Mod:getClassExtended(ChildClass) - ChildClass = Api.getClassExtended(self.Class, ChildClass or {}) +function Mod:getClassExtended(ParentClass, ChildClass) + local ChildClass = setmetatable(ChildClass or {}, { __index = ParentClass }) return ChildClass -end \ No newline at end of file +end + +--- Inherits a child class from a parent public class provided by the mod. +---@static +---@param ChildClass table? +---@return table +function Mod:getModClassExtended(ChildClass) + local ChildClass = Mod:getClassExtended(self.Class, ChildClass or {}) + + return ChildClass +end + diff --git a/mods/API/System/init.lua b/mods/API/System/init.lua index 8d82e63..e7472e3 100644 --- a/mods/API/System/init.lua +++ b/mods/API/System/init.lua @@ -30,17 +30,6 @@ local allowedDomains = { Ui = true } - ---- Inherits a child class from a parent class ----@param ParentClass table ----@param ChildClass table? ----@return table -Api.getClassExtended = function(ParentClass, ChildClass) - local ChildClass = setmetatable(ChildClass or {}, { __index = ParentClass }) - - return ChildClass -end - --- Adds a mod to the global space under specified domain structure ---@param mod Mod The mod table containing functionality to expose ---@param location string Dot-separated path within domain structure (e.g. "Items.Log") diff --git a/mods/CORE/MapGen/src/MapGen/Region/Region2D.lua b/mods/CORE/MapGen/src/MapGen/Region/Region2D.lua index 8ff4770..3fcaf54 100644 --- a/mods/CORE/MapGen/src/MapGen/Region/Region2D.lua +++ b/mods/CORE/MapGen/src/MapGen/Region/Region2D.lua @@ -6,7 +6,7 @@ local modInfo = Mod.getInfo() local Region = modInfo.require("Region") ---@class MapGen.Region.Region2D : MapGen.Region -local Region2D = Api.getClassExtended(Region, {}) +local Region2D = Mod:getClassExtended(Region, {}) ---@param params table ---@return MapGen.Region.Region2D diff --git a/mods/CORE/MapGen/src/MapGen/Region/Region3D.lua b/mods/CORE/MapGen/src/MapGen/Region/Region3D.lua index 5f647f8..3925034 100644 --- a/mods/CORE/MapGen/src/MapGen/Region/Region3D.lua +++ b/mods/CORE/MapGen/src/MapGen/Region/Region3D.lua @@ -6,7 +6,7 @@ local modInfo = Mod.getInfo() local Region = modInfo.require("Region") ---@class MapGen.Region.Region3D : MapGen.Region -local Region3D = Api.getClassExtended(Region, {}) +local Region3D = Mod:getClassExtended(Region, {}) ---@param params table ---@return MapGen.Region.Region3D diff --git a/mods/CORE/MapGen/init.lua b/mods/CORE/MapGen/src/init.lua similarity index 100% rename from mods/CORE/MapGen/init.lua rename to mods/CORE/MapGen/src/init.lua diff --git a/mods/CORE/Node/src/Node.lua b/mods/CORE/Node/src/Node.lua index 7b5895e..332191d 100644 --- a/mods/CORE/Node/src/Node.lua +++ b/mods/CORE/Node/src/Node.lua @@ -1,5 +1,5 @@ ---@class Node : Item -local Node = Core.Item:getClassExtended({ +local Node = Core.Item:getModClassExtended({ --TODO: Че тут писать? })