From 52b5898c357ddd68007dc4ae0e0ab4bffe77f41a Mon Sep 17 00:00:00 2001
From: Smer4k <151877040+Smer4k@users.noreply.github.com>
Date: Sat, 28 Jun 2025 04:00:27 +0700
Subject: [PATCH 1/3] Doors for schematic
---
Features/Enums/BlockType.cs | 5 ++++
Features/Objects/SchematicObject.cs | 6 ++++
.../Schematics/SchematicBlockData.cs | 28 +++++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/Features/Enums/BlockType.cs b/Features/Enums/BlockType.cs
index 7555b98..650ebfa 100644
--- a/Features/Enums/BlockType.cs
+++ b/Features/Enums/BlockType.cs
@@ -44,4 +44,9 @@ public enum BlockType
/// Represents a locker.
///
Locker = 7,
+
+ ///
+ /// Represents a door.
+ ///
+ Door = 8,
}
diff --git a/Features/Objects/SchematicObject.cs b/Features/Objects/SchematicObject.cs
index 300554b..49ace51 100644
--- a/Features/Objects/SchematicObject.cs
+++ b/Features/Objects/SchematicObject.cs
@@ -170,6 +170,12 @@ private void CreateRecursiveFromID(int id, List blocks, Tran
GameObject gameObject = block.Create(this, parentTransform);
NetworkServer.Spawn(gameObject);
+
+ // We return the parent for the door so that when deleting the schematic, the door is deleted
+ if (block.BlockType == BlockType.Door)
+ {
+ gameObject.transform.SetParent(parentTransform);
+ }
// _attachedBlocks.Add(gameObject);
ObjectFromId.Add(block.ObjectId, gameObject.transform);
diff --git a/Features/Serializable/Schematics/SchematicBlockData.cs b/Features/Serializable/Schematics/SchematicBlockData.cs
index 281d7eb..c148b64 100644
--- a/Features/Serializable/Schematics/SchematicBlockData.cs
+++ b/Features/Serializable/Schematics/SchematicBlockData.cs
@@ -1,5 +1,6 @@
using AdminToys;
using GameCore;
+using Interactables.Interobjects.DoorUtils;
using InventorySystem.Items.Firearms.Attachments;
using LabApi.Features.Wrappers;
using ProjectMER.Events.Handlers.Internal;
@@ -41,6 +42,7 @@ public GameObject Create(SchematicObject schematicObject, Transform parentTransf
BlockType.Light => CreateLight(),
BlockType.Pickup => CreatePickup(schematicObject),
BlockType.Workstation => CreateWorkstation(),
+ BlockType.Door => CreateDoor(),
_ => CreateEmpty(true)
};
@@ -51,6 +53,12 @@ public GameObject Create(SchematicObject schematicObject, Transform parentTransf
transform.SetLocalPositionAndRotation(Position, Quaternion.Euler(Rotation));
transform.localScale = BlockType == BlockType.Empty && Scale == Vector3.zero ? Vector3.one : Scale;
+ // if you don't remove the parent before NetworkServer.Spawn then there won't be a door
+ if (BlockType == BlockType.Door)
+ {
+ transform.SetParent(null);
+ }
+
return gameObject;
}
@@ -138,4 +146,24 @@ private GameObject CreateWorkstation()
return workstation.gameObject;
}
+
+ private GameObject CreateDoor()
+ {
+ DoorVariant prefab = (DoorType)Convert.ToInt32(Properties["DoorType"]) switch
+ {
+ DoorType.Hcz or DoorType.HeavyContainmentDoor => PrefabManager.DoorHcz,
+ DoorType.Bulkdoor or DoorType.HeavyBulkDoor => PrefabManager.DoorHeavyBulk,
+ DoorType.Lcz or DoorType.LightContainmentDoor => PrefabManager.DoorLcz,
+ DoorType.Ez or DoorType.EntranceDoor => PrefabManager.DoorEz,
+ _ => PrefabManager.DoorEz
+ };
+
+ DoorVariant doorVariant = GameObject.Instantiate(prefab);
+ doorVariant.NetworkTargetState = Convert.ToBoolean(Properties["IsOpen"]);
+ doorVariant.ServerChangeLock(DoorLockReason.SpecialDoorFeature, Convert.ToBoolean(Properties["IsLocked"]));
+ doorVariant.RequiredPermissions = new DoorPermissionsPolicy(
+ (DoorPermissionFlags)Convert.ToUInt16(Properties["RequiredPermissions"]),
+ Convert.ToBoolean(Properties["RequireAll"]));
+ return doorVariant.gameObject;
+ }
}
From c18d73a19618dfa3af16795b0fe52c93e3129557 Mon Sep 17 00:00:00 2001
From: Smer4k <151877040+Smer4k@users.noreply.github.com>
Date: Mon, 4 Aug 2025 22:54:00 +0700
Subject: [PATCH 2/3] Added Gate type
---
Features/Serializable/Schematics/SchematicBlockData.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Features/Serializable/Schematics/SchematicBlockData.cs b/Features/Serializable/Schematics/SchematicBlockData.cs
index bf5cbe2..71cf008 100644
--- a/Features/Serializable/Schematics/SchematicBlockData.cs
+++ b/Features/Serializable/Schematics/SchematicBlockData.cs
@@ -168,6 +168,7 @@ private GameObject CreateDoor()
DoorType.Bulkdoor or DoorType.HeavyBulkDoor => PrefabManager.DoorHeavyBulk,
DoorType.Lcz or DoorType.LightContainmentDoor => PrefabManager.DoorLcz,
DoorType.Ez or DoorType.EntranceDoor => PrefabManager.DoorEz,
+ DoorType.Gate => PrefabManager.DoorGate,
_ => PrefabManager.DoorEz
};
@@ -178,6 +179,7 @@ private GameObject CreateDoor()
(DoorPermissionFlags)Convert.ToUInt16(Properties["RequiredPermissions"]),
Convert.ToBoolean(Properties["RequireAll"]));
return doorVariant.gameObject;
+ }
private GameObject CreateText()
{
From eca8977b02578235978eae993747fcf802496012 Mon Sep 17 00:00:00 2001
From: Smer4k <151877040+Smer4k@users.noreply.github.com>
Date: Mon, 4 Aug 2025 23:03:30 +0700
Subject: [PATCH 3/3] Changed number for BlockType.Door
---
Features/Enums/BlockType.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Features/Enums/BlockType.cs b/Features/Enums/BlockType.cs
index bad766d..dc98142 100644
--- a/Features/Enums/BlockType.cs
+++ b/Features/Enums/BlockType.cs
@@ -47,5 +47,5 @@ public enum BlockType
Text = 8,
Interactable = 9,
Waypoint = 10,
- Door = 11,
+ Door = 30, // when merging replace with normal serial number
}