diff options
author | metamuffin <metamuffin@disroot.org> | 2024-09-25 16:07:46 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-09-25 16:07:46 +0200 |
commit | cea8b52bc34e5df49e2ded3de742b928ad0671c3 (patch) | |
tree | fd3f29d99ac95c97e042efd6aabf4eb4faaf138c /server/bot/src/algos | |
parent | d84b55f3a28b42f8c5f33a8d07a10fbc97dfdfbb (diff) | |
download | hurrycurry-cea8b52bc34e5df49e2ded3de742b928ad0671c3.tar hurrycurry-cea8b52bc34e5df49e2ded3de742b928ad0671c3.tar.bz2 hurrycurry-cea8b52bc34e5df49e2ded3de742b928ad0671c3.tar.zst |
bot: stronger rotation alignment
Diffstat (limited to 'server/bot/src/algos')
-rw-r--r-- | server/bot/src/algos/customer.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs index 0c38c79d..64ae726f 100644 --- a/server/bot/src/algos/customer.rs +++ b/server/bot/src/algos/customer.rs @@ -285,7 +285,7 @@ impl BotAlgo for Customer { } } BotInput { - direction: (chair.as_vec2() + 0.5) - pos + *facing * 0.3, + direction: dir_input(pos, *chair, *facing), ..Default::default() } } @@ -322,7 +322,7 @@ impl BotAlgo for Customer { }; } BotInput { - direction: (chair.as_vec2() + 0.5) - pos + (*table - *chair).as_vec2() * 0.3, + direction: dir_input(pos, *chair, (*table - *chair).as_vec2()), ..Default::default() } } @@ -380,3 +380,12 @@ impl BotAlgo for Customer { } } } + +fn dir_input(pos: Vec2, target: IVec2, facing: Vec2) -> Vec2 { + let diff = (target.as_vec2() + 0.5) - pos; + (if diff.length() > 0.3 { + diff.normalize() + } else { + diff * 0.5 + }) + facing.clamp_length_max(1.) * 0.3 +} |