Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Added DoorType.cs and edited CursedDoor.cs #9

Merged
merged 5 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
.vs

# NuGet Packages
*.nupkg

# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*

# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
35 changes: 34 additions & 1 deletion CursedMod/Features/Wrappers/Facility/Rooms/CursedDoor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using Interactables.Interobjects;
using CursedMod.Features.Enums;
using Interactables.Interobjects;
using Interactables.Interobjects.DoorUtils;
using MapGeneration;
using Mirror;
using System.Linq;
using UnityEngine;
using Object = UnityEngine.Object;
using DoorSpawnpoint = MapGeneration.DoorSpawnpoint;

namespace CursedMod.Features.Wrappers.Facility.Rooms;

Expand Down Expand Up @@ -84,5 +90,32 @@ public bool DestroyDoor(DoorDamageType type = DoorDamageType.ServerCommand)
return false;
}

public static CursedDoor Create(FacilityZone doorType, Vector3 Position, Vector3 Rotation, Vector3 Scale, bool spawn = false)
{
DoorSpawnpoint prefab;
switch (doorType)
{
case FacilityZone.LightContainment: prefab = Object.FindObjectsOfType<DoorSpawnpoint>().First(x => x.TargetPrefab.name.Contains("LCZ")); break;
case FacilityZone.HeavyContainment: prefab = Object.FindObjectsOfType<DoorSpawnpoint>().First(x => x.TargetPrefab.name.Contains("HCZ")); break;
case FacilityZone.Entrance: prefab = Object.FindObjectsOfType<DoorSpawnpoint>().First(x => x.TargetPrefab.name.Contains("EZ")); break;
default: prefab = Object.FindObjectsOfType<DoorSpawnpoint>().First(x => x.TargetPrefab.name.Contains("LCZ")); break;
}


var door = Object.Instantiate(prefab.TargetPrefab, Position, Quaternion.Euler(Rotation));

door.transform.localScale = Scale;

if (spawn) NetworkServer.Spawn(door.gameObject);

return new CursedDoor(door);
}

public GameObject Spawn()
{
NetworkServer.Spawn(GameObject);
return GameObject;
}

public override string ToString() => $"{nameof(CursedDoor)}: Opened: {IsOpened} | Position: {Position} | Rotation: {Rotation} | Scale: {Scale} | Permissions: {RequiredPermissions} | DoorId: {DoorId}";
}