2021-10-03 04:12:57 +00:00
|
|
|
// Checkpoint Region
|
|
|
|
// Acts like an invisible checkpoint flag.
|
|
|
|
var isCurrentCheckpoint = false;
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
Self.Hide();
|
|
|
|
setActive(false);
|
|
|
|
|
|
|
|
// Checkpoints broadcast to all of their peers so they all
|
|
|
|
// know which one is the most recently activated.
|
2022-01-17 04:09:27 +00:00
|
|
|
Message.Subscribe("broadcast:checkpoint", (currentID) => {
|
2021-10-03 04:12:57 +00:00
|
|
|
setActive(false);
|
|
|
|
});
|
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
Events.OnCollide((e) => {
|
2021-10-03 04:12:57 +00:00
|
|
|
if (isCurrentCheckpoint || !e.Settled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only care about the player character.
|
|
|
|
if (!e.Actor.IsPlayer()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the player checkpoint.
|
|
|
|
SetCheckpoint(Self.Position());
|
|
|
|
setActive(true);
|
|
|
|
Message.Broadcast("broadcast:checkpoint", Self.ID())
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setActive(v) {
|
|
|
|
if (v && !isCurrentCheckpoint) {
|
|
|
|
Flash("Checkpoint!");
|
|
|
|
}
|
|
|
|
|
|
|
|
isCurrentCheckpoint = v;
|
2022-01-17 04:09:27 +00:00
|
|
|
}
|