diff --git a/Nautilus/Utility/PrefabUtils.cs b/Nautilus/Utility/PrefabUtils.cs index 5eb5e2bc..dcf5265a 100644 --- a/Nautilus/Utility/PrefabUtils.cs +++ b/Nautilus/Utility/PrefabUtils.cs @@ -111,6 +111,21 @@ public static void AddBasicComponents(GameObject prefab, string classId, TechTyp /// This should be a child of , and NOT the root. If it is the same value as , you have done something wrong! /// A reference to the added instance. public static Constructable AddConstructable(GameObject prefab, TechType techType, ConstructableFlags constructableFlags, GameObject model = null) + { + return AddConstructable(prefab, techType, constructableFlags, model); + } + + /// + /// Adds and configures the component or a derived type on the specified prefab. + /// + /// The prefab to operate on. + /// The tech type associated with the specified prefab. + /// A bitmask comprised of one or more that specify how the prefab should be treated during placement. + /// The child GameObject that holds all the renderers that are used for the ghost model. + /// If assigned, this parameter will control the field. This field MUST BE ASSIGNED A VALUE to avoid errors when building! + /// This should be a child of , and NOT the root. If it is the same value as , you have done something wrong! + /// A reference to the added instance. + public static T AddConstructable(GameObject prefab, TechType techType, ConstructableFlags constructableFlags, GameObject model = null) where T : Constructable { if (techType is TechType.None) { @@ -118,7 +133,7 @@ public static Constructable AddConstructable(GameObject prefab, TechType techTyp return null; } - var constructable = prefab.EnsureComponent(); + var constructable = prefab.EnsureComponent(); constructable.controlModelState = true; // TODO: Add ghost material for BZ #if SUBNAUTICA @@ -189,6 +204,25 @@ public static VFXFabricating AddVFXFabricating(GameObject prefabRoot, string pat /// If true, you cannot destroy this prefab unless all of its storage containers are empty. /// A reference to the added instance. public static StorageContainer AddStorageContainer(GameObject prefabRoot, string storageRootName, string storageRootClassId, int width, int height, bool preventDeconstructionIfNotEmpty = true) + { + return AddStorageContainer(prefabRoot, storageRootName, storageRootClassId, width, height, + preventDeconstructionIfNotEmpty); + } + + /// + /// Adds a component of the type or a derived class to the given prefab, for basic use cases with lockers and such. + /// Due to how this component needs to be initialized, this method will disable the object and re-enable it after the component is added (assuming it was already active). This all happens within the same frame and will not be seen. + /// + /// The prefab that the component is added onto. This does not necessarily NEED to be the "prefab root". You can set it to a + /// child collider if you want a smaller area of interaction or to have multiple storage containers on one prefab. + /// The name of the object that internally holds all of the items. + /// A unique string for the component. + /// The width of this container's face. + /// The height of this container's interface. + /// If true, you cannot destroy this prefab unless all of its storage containers are empty. + /// A reference to the added instance. + public static T AddStorageContainer(GameObject prefabRoot, string storageRootName, string storageRootClassId, + int width, int height, bool preventDeconstructionIfNotEmpty = true) where T : StorageContainer { var wasActive = prefabRoot.activeSelf; @@ -200,7 +234,7 @@ public static StorageContainer AddStorageContainer(GameObject prefabRoot, string var childObjectIdentifier = storageRoot.AddComponent(); childObjectIdentifier.ClassId = storageRootClassId; - var container = prefabRoot.AddComponent(); + var container = prefabRoot.AddComponent(); container.prefabRoot = prefabRoot; container.width = width; container.height = height;