diff --git a/YAMS-LIB/SeedObject.cs b/YAMS-LIB/SeedObject.cs index 70b8a74..3dd1939 100644 --- a/YAMS-LIB/SeedObject.cs +++ b/YAMS-LIB/SeedObject.cs @@ -149,6 +149,8 @@ public enum DoorLockType Locked, [EnumMember(Value = "Hydro Station Water Turbine")] A2WaterTurbine, + [EnumMember(Value = "Research Site Open Hatch")] + ResearchHatch, } [JsonConverter(typeof(JsonStringEnumMemberConverter))] diff --git a/YAMS-LIB/patches/DoorLockRando.cs b/YAMS-LIB/patches/DoorLockRando.cs index 240ce38..144f799 100644 --- a/YAMS-LIB/patches/DoorLockRando.cs +++ b/YAMS-LIB/patches/DoorLockRando.cs @@ -68,7 +68,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC if (isGotoObject) { // Place tiles - room.Tiles.Add(CreateRoomTile(gameObject.X - doorEntry.FacingDirection == DoorFacingDirection.Left ? 32 : 0, gameObject.Y-64, -100, gmData.Backgrounds.ByName("tlDoor"), doorEntry.FacingDirection == DoorFacingDirection.Left ? (uint)64 : 96, 0, 32, 64)); + room.Tiles.Add(CreateRoomTile(gameObject.X - (doorEntry.FacingDirection == DoorFacingDirection.Left ? 32 : 0), gameObject.Y-64, -100, gmData.Backgrounds.ByName("tlDoor"), doorEntry.FacingDirection == DoorFacingDirection.Left ? (uint)64 : 96, 0, 32, 64)); // Place door door = CreateRoomObject(gameObject.X - ((doorEntry.FacingDirection == DoorFacingDirection.Left ? 1 : -1) * 24), gameObject.Y-64, gmData.GameObjects.ByName("oDoorA5"), null, doorEntry.FacingDirection == DoorFacingDirection.Left ? -1 : 1); room.GameObjects.Add(door); @@ -120,6 +120,7 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC $"if (global.event[eventToSet] > 0)" + $"{{ if (!wasAlreadyDestroyed) {{ with (wall) instance_destroy(); }} instance_destroy();}} " + $"if (wasAlreadyDestroyed && global.event[eventToSet] < 1) global.event[eventToSet] = 1;", + DoorLockType.ResearchHatch => $"facing = {(door.ScaleX >= 0 ? 1 : -1)}", _ => throw new NotSupportedException($"Door {id} has an unsupported door lock ({doorEntry.Lock})!") }; @@ -148,6 +149,17 @@ public static void Apply(UndertaleData gmData, GlobalDecompileContext decompileC } + var researchHatchObject = gmData.GameObjects.ByName("oA3LabDoor"); + if (door.ObjectDefinition != researchHatchObject && doorEntry.Lock == DoorLockType.ResearchHatch) + { + door.ObjectDefinition = researchHatchObject; + if (door.ScaleX < 0) + { + door.ScaleX = Math.Abs(door.ScaleX); + door.X -= 16; + } + } + door.CreationCode.AppendGMLInCode( codeText); doorEventIndex++; break;