Skip to content

Commit

Permalink
Add support for Research Site open hatches in door lock rando (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee authored Dec 25, 2023
1 parent 0b3f09b commit 5129fa0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions YAMS-LIB/SeedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
14 changes: 13 additions & 1 deletion YAMS-LIB/patches/DoorLockRando.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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})!")
};

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5129fa0

Please sign in to comment.