From 59c0d5ee4dc714c22352ec047b8f39568ead560e Mon Sep 17 00:00:00 2001 From: spatialfree Date: Fri, 8 Nov 2024 21:56:48 -0500 Subject: [PATCH] inset_pos in range refactor --- src/Mono.cs | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/Mono.cs b/src/Mono.cs index a60c14b..5a0954d 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -90,26 +90,12 @@ static class Mono } XYZi next_pos = snake[0] + snake_dir; - bool around_box = false; - for (int i = 0; i < directions.Length; i++) - { - if (s_array.InRange(next_pos + directions[i])) - { - around_box = true; - break; - } - } - if (!around_box) - { - for (int i = 0; i < corners.Length; i++) - { - if (s_array.InRange(next_pos + corners[i])) - { - around_box = true; - break; - } - } - } + XYZi inset_pos = new( + next_pos.x - Maths.sign(next_pos.x), + next_pos.y - Maths.sign(next_pos.y), + next_pos.z - Maths.sign(next_pos.z) + ); + bool around_box = s_array.InRange(inset_pos); if (!around_box) { return;