From 2a033b87e0215b49320f668e1dcd9b8bd0033c18 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 3 Nov 2023 18:01:01 -0700 Subject: [PATCH] rethink ordered checkpoints - do not support non-teleporting (backtracking) --- src/model.rs | 8 +++++--- src/physics.rs | 44 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/model.rs b/src/model.rs index 8df7f01..9ea4170 100644 --- a/src/model.rs +++ b/src/model.rs @@ -176,7 +176,11 @@ pub enum StageElementBehaviour{ //Note that all stage elements act like this for the next stage. Checkpoint, //OrderedCheckpoint. You must pass through all of these in ascending order. - Ordered(u32), + //If you hit them out of order it acts like a trigger. + //Do not support backtracking at all for now. + Ordered{ + checkpoint_id:u32, + }, //UnorderedCheckpoint. You must pass through all of these in any order. Unordered, //If you get reset by a jump limit @@ -208,7 +212,6 @@ pub enum TeleportBehaviour{ pub struct GameMechanicAttributes{ pub zone:Option, pub booster:Option, - pub checkpoint:Option, pub trajectory:Option, pub teleport_behaviour:Option, pub accelerator:Option, @@ -217,7 +220,6 @@ impl GameMechanicAttributes{ pub fn any(&self)->bool{ self.zone.is_some() ||self.booster.is_some() - ||self.checkpoint.is_some() ||self.trajectory.is_some() ||self.teleport_behaviour.is_some() ||self.accelerator.is_some() diff --git a/src/physics.rs b/src/physics.rs index 30d0751..5c4ca0c 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -1120,9 +1120,13 @@ fn teleport_to_spawn(body:&mut Body,touching:&mut TouchingState,style:&StyleModi } fn run_teleport_behaviour(teleport_behaviour:&Option,game:&mut GameMechanicsState,models:&PhysicsModels,modes:&Modes,style:&StyleModifiers,touching:&mut TouchingState,body:&mut Body,model_id:usize)->Option{ + //TODO: jump count and checkpoints are always reset on teleport. + //Map makers are expected to use tools to prevent + //multi-boosting on JumpLimit boosters such as spawning into a SetVelocity match teleport_behaviour{ Some(crate::model::TeleportBehaviour::StageElement(stage_element))=>{ if stage_element.force||game.stage_idNone, + &crate::model::StageElementBehaviour::Checkpoint=>{ + // let mode=modes.get_mode(stage_element.mode_id)?; + // if mode.ordered_checkpoint_id.map_or(true,|id|id{ + if checkpoint_id{ + //count model id in accumulated unordered checkpoints + game.unordered_checkpoints.insert(model_id); + None + }, &crate::model::StageElementBehaviour::JumpLimit(jump_limit)=>{ //let count=game.jump_counts.get(&model.id); //TODO None }, - &crate::model::StageElementBehaviour::Checkpoint{ordered_checkpoint_id,unordered_checkpoint_count}=>{ - if ordered_checkpoint_id.map_or(true,|id|id{