From 3f19a92db6e5d534431c104d38b03dc2ebcdfb66 Mon Sep 17 00:00:00 2001 From: Nitsud Yarg Date: Sun, 7 Jul 2024 17:36:27 -0700 Subject: [PATCH] Wind/Conveyor belt physics state modifier implemented. --- src/Levels/Level.tscn | 23 +++++++++-- src/components/Modifier_Component.gd | 4 ++ src/playerD/states/move.gd | 7 +++- src/state_animated_actor.gd | 57 ++++++++++++++++++---------- src/state_modifier.gd | 4 +- src/state_modifier_properties.gd | 4 ++ 6 files changed, 72 insertions(+), 27 deletions(-) diff --git a/src/Levels/Level.tscn b/src/Levels/Level.tscn index b23103a..8ed24a6 100644 --- a/src/Levels/Level.tscn +++ b/src/Levels/Level.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=2] +[gd_scene load_steps=17 format=2] [ext_resource path="res://src/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/Tiles/Assets/Demo TileSet.tres" type="TileSet" id=2] @@ -25,11 +25,14 @@ extents = Vector2( 50, 2 ) [sub_resource type="RectangleShape2D" id=4] extents = Vector2( 80, 2.5 ) +[sub_resource type="RectangleShape2D" id=5] +extents = Vector2( 66.5, 80 ) + [node name="Level" type="Node2D"] script = ExtResource( 10 ) [node name="PlayerStart" type="Position2D" parent="."] -position = Vector2( 1094, 128 ) +position = Vector2( 493, 291 ) [node name="CameraBoundaries" type="Area2D" parent="."] collision_layer = 256 @@ -88,7 +91,7 @@ tile_set = ExtResource( 2 ) cell_size = Vector2( 16, 16 ) show_collision = true format = 1 -tile_data = PoolIntArray( -65536, 0, 196613, 65528, 0, 0, 0, 0, 196613, 79, 0, 196613, 65536, 0, 196613, 65615, 0, 196613, 196603, 0, 0, 131072, 0, 196613, 131151, 0, 196613, 196608, 0, 196613, 196687, 0, 196613, 262144, 0, 196613, 262172, 0, 196613, 262173, 0, 196613, 262174, 0, 196613, 262175, 0, 196613, 262176, 0, 196613, 262177, 0, 196613, 262223, 0, 196613, 327680, 0, 196613, 327759, 0, 196613, 393216, 0, 196613, 393260, 0, 196613, 393261, 0, 196613, 393295, 0, 196613, 458752, 0, 196613, 458792, 0, 196613, 458793, 0, 196613, 458794, 0, 196613, 458795, 0, 196613, 458796, 0, 196613, 458797, 0, 196613, 458831, 0, 196613, 524288, 0, 196613, 524307, 0, 196613, 524308, 0, 196613, 524327, 0, 196613, 524328, 0, 196613, 524329, 0, 196613, 524330, 0, 196613, 524334, 0, 196613, 524367, 0, 196613, 589824, 0, 196613, 589843, 0, 196613, 589844, 0, 196613, 589863, 0, 196613, 589864, 0, 196613, 589870, 0, 196613, 589903, 0, 196613, 655360, 0, 196613, 655361, 0, 2, 655362, 0, 2, 655363, 0, 2, 655364, 0, 2, 655365, 0, 2, 655366, 0, 2, 655367, 0, 2, 655368, 0, 2, 655369, 0, 2, 655370, 0, 2, 655371, 0, 2, 655372, 0, 2, 655373, 0, 2, 655374, 0, 2, 655375, 0, 2, 655376, 0, 2, 655377, 0, 2, 655378, 0, 2, 655379, 0, 196613, 655380, 0, 196613, 655381, 0, 196613, 655382, 0, 196613, 655383, 0, 196613, 655384, 0, 196613, 655385, 0, 196613, 655386, 0, 196613, 655387, 0, 196613, 655388, 0, 196613, 655389, 0, 196613, 655390, 0, 196613, 655391, 0, 196613, 655392, 0, 196613, 655393, 0, 196613, 655394, 0, 196613, 655395, 0, 196613, 655396, 0, 196613, 655397, 0, 196613, 655398, 0, 196613, 655399, 0, 196613, 655400, 0, 196613, 655406, 0, 196613, 655407, 0, 196613, 655408, 0, 196613, 655409, 0, 196613, 655410, 0, 196613, 655411, 0, 196613, 655412, 0, 196613, 655413, 0, 196613, 655414, 0, 196613, 655415, 0, 196613, 655416, 0, 196613, 655417, 0, 196613, 655418, 0, 196613, 655419, 0, 196613, 655420, 0, 196613, 655421, 0, 196613, 655422, 0, 196613, 655423, 0, 196613, 655424, 0, 196613, 655425, 0, 196613, 655426, 0, 196613, 655427, 0, 196613, 655428, 0, 196613, 655439, 0, 196613, 720896, 0, 196613, 720897, 0, 65538, 720898, 0, 65538, 720899, 0, 65538, 720900, 0, 65538, 720901, 0, 65538, 720902, 0, 65538, 720903, 0, 65538, 720904, 0, 65538, 720905, 0, 65538, 720906, 0, 65538, 720907, 0, 65538, 720908, 0, 65538, 720909, 0, 65538, 720910, 0, 65538, 720911, 0, 65538, 720912, 0, 65538, 720913, 0, 65538, 720914, 0, 65538, 720915, 0, 196613, 720916, 0, 196613, 720917, 0, 196613, 720918, 0, 196613, 720919, 0, 196613, 720920, 0, 196613, 720921, 0, 196613, 720959, 0, 0, 720961, 0, 196613, 720962, 0, 196613, 720963, 0, 196613, 720964, 0, 196613, 720965, 0, 196613, 720975, 0, 196613, 786432, 0, 196613, 786495, 0, 0, 786511, 0, 196613, 851968, 0, 196613, 852002, 0, 196613, 852031, 0, 0, 852047, 0, 196613, 917504, 0, 196613, 917583, 0, 196613, 983040, 0, 196613, 983119, 0, 196613, 1048576, 0, 196613, 1048655, 0, 196613, 1114112, 0, 196613, 1114167, 0, 196613, 1114168, 0, 196613, 1114169, 0, 196613, 1114170, 0, 196613, 1114171, 0, 196613, 1114191, 0, 196613, 1179648, 0, 196613, 1179701, 0, 196613, 1179702, 0, 196613, 1179703, 0, 196613, 1179707, 0, 196613, 1179708, 0, 196613, 1179709, 0, 196613, 1179727, 0, 196613, 1245184, 0, 196613, 1245236, 0, 196613, 1245237, 0, 196613, 1245245, 0, 196613, 1245246, 0, 196613, 1245247, 0, 196613, 1245263, 0, 196613, 1310720, 0, 196613, 1310771, 0, 196613, 1310772, 0, 196613, 1310783, 0, 196613, 1310784, 0, 196613, 1310799, 0, 196613, 1376256, 0, 196613, 1376257, 0, 196613, 1376258, 0, 196613, 1376259, 0, 196613, 1376260, 0, 196613, 1376261, 0, 196613, 1376262, 0, 196613, 1376263, 0, 196613, 1376264, 0, 196613, 1376265, 0, 196613, 1376266, 0, 196613, 1376267, 0, 196613, 1376268, 0, 196613, 1376269, 0, 196613, 1376270, 0, 196613, 1376271, 0, 196613, 1376272, 0, 196613, 1376273, 0, 196613, 1376274, 0, 196613, 1376275, 0, 196613, 1376276, 0, 196613, 1376277, 0, 196613, 1376278, 0, 196613, 1376279, 0, 196613, 1376280, 0, 196613, 1376281, 0, 196613, 1376282, 0, 196613, 1376283, 0, 196613, 1376284, 0, 196613, 1376285, 0, 196613, 1376286, 0, 196613, 1376287, 0, 196613, 1376288, 0, 196613, 1376289, 0, 196613, 1376290, 0, 196613, 1376291, 0, 196613, 1376292, 0, 196613, 1376293, 0, 196613, 1376294, 0, 196613, 1376295, 0, 196613, 1376296, 0, 196613, 1376297, 0, 196613, 1376298, 0, 196613, 1376299, 0, 196613, 1376300, 0, 196613, 1376301, 0, 196613, 1376302, 0, 196613, 1376303, 0, 196613, 1376304, 0, 196613, 1376305, 0, 196613, 1376306, 0, 196613, 1376307, 0, 196613, 1376308, 0, 196613, 1376309, 0, 196613, 1376310, 0, 196613, 1376311, 0, 196613, 1376312, 0, 196613, 1376313, 0, 196613, 1376314, 0, 196613, 1376315, 0, 196613, 1376316, 0, 196613, 1376317, 0, 196613, 1376318, 0, 196613, 1376319, 0, 196613, 1376320, 0, 196613, 1376321, 0, 196613, 1376322, 0, 196613, 1376323, 0, 196613, 1376324, 0, 196613, 1376325, 0, 131080, 1376326, 0, 131081, 1376327, 0, 131080, 1376328, 0, 131081, 1376329, 0, 131080, 1376330, 0, 131081, 1376331, 0, 131080, 1376332, 0, 131081, 1376333, 0, 131081, 1376334, 0, 131080, 1376335, 0, 196613, 1441792, 0, 196613, 1441793, 0, 196613, 1441794, 0, 196613, 1441795, 0, 196613, 1441796, 0, 196613, 1441797, 0, 196613, 1441798, 0, 196613, 1441799, 0, 196613, 1441800, 0, 196613, 1441801, 0, 196613, 1441802, 0, 196613, 1441803, 0, 196613, 1441804, 0, 196613, 1441805, 0, 196613, 1441806, 0, 196613, 1441807, 0, 196613, 1441808, 0, 196613, 1441809, 0, 196613, 1441810, 0, 196613, 1441811, 0, 196613, 1441812, 0, 196613, 1441813, 0, 196613, 1441814, 0, 196613, 1441815, 0, 196613, 1441816, 0, 196613, 1441817, 0, 196613, 1441818, 0, 196613, 1441819, 0, 196613, 1441820, 0, 196613, 1441821, 0, 196613, 1441822, 0, 196613, 1441823, 0, 196613, 1441824, 0, 196613, 1441825, 0, 196613, 1441826, 0, 196613, 1441827, 0, 196613, 1441828, 0, 196613, 1441829, 0, 196613, 1441830, 0, 196613, 1441831, 0, 196613, 1441832, 0, 196613, 1441833, 0, 196613, 1441834, 0, 196613, 1441835, 0, 196613, 1441836, 0, 196613, 1441837, 0, 196613, 1441838, 0, 196613, 1441839, 0, 196613, 1441840, 0, 196613, 1441841, 0, 196613, 1441842, 0, 196613, 1441843, 0, 196613, 1441844, 0, 196613, 1441845, 0, 196613, 1441846, 0, 196613, 1441847, 0, 196613, 1441848, 0, 196613, 1441849, 0, 196613, 1441850, 0, 196613, 1441851, 0, 196613, 1441852, 0, 196613, 1441853, 0, 196613, 1441854, 0, 196613, 1441855, 0, 196613, 1441856, 0, 196613, 1441857, 0, 196613, 1441858, 0, 196613, 1441859, 0, 196613, 1441860, 0, 196613, 1441861, 0, 196613, 1441862, 0, 196613, 1441863, 0, 196613, 1441864, 0, 196613, 1441865, 0, 196613, 1441866, 0, 196613, 1441867, 0, 196613, 1441868, 0, 196613, 1441869, 0, 196613, 1441870, 0, 196613, 1441871, 0, 196613 ) +tile_data = PoolIntArray( -65536, 0, 196613, 65528, 0, 0, 0, 0, 196613, 79, 0, 196613, 65536, 0, 196613, 65615, 0, 196613, 196603, 0, 0, 131072, 0, 196613, 131151, 0, 196613, 196608, 0, 196613, 196687, 0, 196613, 262144, 0, 196613, 262172, 0, 196613, 262173, 0, 196613, 262174, 0, 196613, 262175, 0, 196613, 262176, 0, 196613, 262177, 0, 196613, 262223, 0, 196613, 327680, 0, 196613, 327759, 0, 196613, 393216, 0, 196613, 393260, 0, 196613, 393261, 0, 196613, 393295, 0, 196613, 458752, 0, 196613, 458792, 0, 196613, 458793, 0, 196613, 458794, 0, 196613, 458795, 0, 196613, 458796, 0, 196613, 458797, 0, 196613, 458831, 0, 196613, 524288, 0, 196613, 524307, 0, 196613, 524308, 0, 196613, 524327, 0, 196613, 524328, 0, 196613, 524329, 0, 196613, 524330, 0, 196613, 524334, 0, 196613, 524367, 0, 196613, 589824, 0, 196613, 589843, 0, 196613, 589844, 0, 196613, 589863, 0, 196613, 589864, 0, 196613, 589870, 0, 196613, 589903, 0, 196613, 655360, 0, 196613, 655361, 0, 2, 655362, 0, 2, 655363, 0, 2, 655364, 0, 2, 655365, 0, 2, 655366, 0, 2, 655367, 0, 2, 655368, 0, 2, 655369, 0, 2, 655370, 0, 2, 655371, 0, 2, 655372, 0, 2, 655373, 0, 2, 655374, 0, 2, 655375, 0, 2, 655376, 0, 2, 655377, 0, 2, 655378, 0, 2, 655379, 0, 196613, 655380, 0, 196613, 655381, 0, 196613, 655382, 0, 196613, 655383, 0, 196613, 655384, 0, 196613, 655385, 0, 196613, 655386, 0, 196613, 655387, 0, 196613, 655388, 0, 196613, 655389, 0, 196613, 655390, 0, 196613, 655391, 0, 196613, 655392, 0, 196613, 655393, 0, 196613, 655394, 0, 196613, 655395, 0, 196613, 655396, 0, 196613, 655397, 0, 196613, 655398, 0, 196613, 655399, 0, 196613, 655400, 0, 196613, 655406, 0, 196613, 655407, 0, 196613, 655408, 0, 196613, 655409, 0, 196613, 655410, 0, 196613, 655411, 0, 196613, 655412, 0, 196613, 655413, 0, 196613, 655414, 0, 196613, 655415, 0, 196613, 655416, 0, 196613, 655417, 0, 196613, 655418, 0, 196613, 655419, 0, 196613, 655420, 0, 196613, 655421, 0, 196613, 655422, 0, 196613, 655423, 0, 196613, 655424, 0, 196613, 655425, 0, 196613, 655426, 0, 196613, 655427, 0, 196613, 655428, 0, 196613, 655439, 0, 196613, 720896, 0, 196613, 720897, 0, 65538, 720898, 0, 65538, 720899, 0, 65538, 720900, 0, 65538, 720901, 0, 65538, 720902, 0, 65538, 720903, 0, 65538, 720904, 0, 65538, 720905, 0, 65538, 720906, 0, 65538, 720907, 0, 65538, 720908, 0, 65538, 720909, 0, 65538, 720910, 0, 65538, 720911, 0, 65538, 720912, 0, 65538, 720913, 0, 65538, 720914, 0, 65538, 720915, 0, 196613, 720916, 0, 196613, 720917, 0, 196613, 720918, 0, 196613, 720919, 0, 196613, 720920, 0, 196613, 720921, 0, 196613, 720930, 0, 196613, 720959, 0, 0, 720961, 0, 196613, 720962, 0, 196613, 720963, 0, 196613, 720964, 0, 196613, 720965, 0, 196613, 720975, 0, 196613, 786432, 0, 196613, 786466, 0, 196613, 786495, 0, 0, 786511, 0, 196613, 851968, 0, 196613, 852002, 0, 196613, 852031, 0, 0, 852047, 0, 196613, 917504, 0, 196613, 917530, 0, 262148, 917531, 0, 262149, 917532, 0, 262150, 917533, 0, 196613, 917534, 0, 196613, 917535, 0, 196613, 917536, 0, 196613, 917537, 0, 196613, 917538, 0, 196613, 917583, 0, 196613, 983040, 0, 196613, 983066, 0, 262148, 983067, 0, 262149, 983068, 0, 262150, 983119, 0, 196613, 1048576, 0, 196613, 1048602, 0, 262148, 1048603, 0, 262149, 1048604, 0, 262150, 1048655, 0, 196613, 1114112, 0, 196613, 1114138, 0, 262148, 1114139, 0, 262149, 1114140, 0, 262150, 1114167, 0, 196613, 1114168, 0, 196613, 1114169, 0, 196613, 1114170, 0, 196613, 1114171, 0, 196613, 1114191, 0, 196613, 1179648, 0, 196613, 1179674, 0, 262148, 1179675, 0, 262149, 1179676, 0, 262150, 1179701, 0, 196613, 1179702, 0, 196613, 1179703, 0, 196613, 1179707, 0, 196613, 1179708, 0, 196613, 1179709, 0, 196613, 1179727, 0, 196613, 1245184, 0, 196613, 1245210, 0, 262148, 1245211, 0, 262149, 1245212, 0, 262150, 1245236, 0, 196613, 1245237, 0, 196613, 1245245, 0, 196613, 1245246, 0, 196613, 1245247, 0, 196613, 1245263, 0, 196613, 1310720, 0, 196613, 1310746, 0, 262148, 1310747, 0, 262149, 1310748, 0, 262150, 1310771, 0, 196613, 1310772, 0, 196613, 1310783, 0, 196613, 1310784, 0, 196613, 1310799, 0, 196613, 1376256, 0, 196613, 1376257, 0, 196613, 1376258, 0, 196613, 1376259, 0, 196613, 1376260, 0, 196613, 1376261, 0, 196613, 1376262, 0, 196613, 1376263, 0, 196613, 1376264, 0, 196613, 1376265, 0, 196613, 1376266, 0, 196613, 1376267, 0, 196613, 1376268, 0, 196613, 1376269, 0, 196613, 1376270, 0, 196613, 1376271, 0, 196613, 1376272, 0, 196613, 1376273, 0, 196613, 1376274, 0, 196613, 1376275, 0, 196613, 1376276, 0, 196613, 1376277, 0, 196613, 1376278, 0, 196613, 1376279, 0, 196613, 1376280, 0, 196613, 1376281, 0, 196613, 1376282, 0, 196613, 1376283, 0, 196613, 1376284, 0, 196613, 1376285, 0, 196613, 1376286, 0, 196613, 1376287, 0, 196613, 1376288, 0, 196613, 1376289, 0, 196613, 1376290, 0, 196613, 1376291, 0, 196613, 1376292, 0, 196613, 1376293, 0, 196613, 1376294, 0, 196613, 1376295, 0, 196613, 1376296, 0, 196613, 1376297, 0, 196613, 1376298, 0, 196613, 1376299, 0, 196613, 1376300, 0, 196613, 1376301, 0, 196613, 1376302, 0, 196613, 1376303, 0, 196613, 1376304, 0, 196613, 1376305, 0, 196613, 1376306, 0, 196613, 1376307, 0, 196613, 1376308, 0, 196613, 1376309, 0, 196613, 1376310, 0, 196613, 1376311, 0, 196613, 1376312, 0, 196613, 1376313, 0, 196613, 1376314, 0, 196613, 1376315, 0, 196613, 1376316, 0, 196613, 1376317, 0, 196613, 1376318, 0, 196613, 1376319, 0, 196613, 1376320, 0, 196613, 1376321, 0, 196613, 1376322, 0, 196613, 1376323, 0, 196613, 1376324, 0, 196613, 1376325, 0, 131080, 1376326, 0, 131081, 1376327, 0, 131080, 1376328, 0, 131081, 1376329, 0, 131080, 1376330, 0, 131081, 1376331, 0, 131080, 1376332, 0, 131081, 1376333, 0, 131081, 1376334, 0, 131080, 1376335, 0, 196613, 1441792, 0, 196613, 1441793, 0, 196613, 1441794, 0, 196613, 1441795, 0, 196613, 1441796, 0, 196613, 1441797, 0, 196613, 1441798, 0, 196613, 1441799, 0, 196613, 1441800, 0, 196613, 1441801, 0, 196613, 1441802, 0, 196613, 1441803, 0, 196613, 1441804, 0, 196613, 1441805, 0, 196613, 1441806, 0, 196613, 1441807, 0, 196613, 1441808, 0, 196613, 1441809, 0, 196613, 1441810, 0, 196613, 1441811, 0, 196613, 1441812, 0, 196613, 1441813, 0, 196613, 1441814, 0, 196613, 1441815, 0, 196613, 1441816, 0, 196613, 1441817, 0, 196613, 1441818, 0, 196613, 1441819, 0, 196613, 1441820, 0, 196613, 1441821, 0, 196613, 1441822, 0, 196613, 1441823, 0, 196613, 1441824, 0, 196613, 1441825, 0, 196613, 1441826, 0, 196613, 1441827, 0, 196613, 1441828, 0, 196613, 1441829, 0, 196613, 1441830, 0, 196613, 1441831, 0, 196613, 1441832, 0, 196613, 1441833, 0, 196613, 1441834, 0, 196613, 1441835, 0, 196613, 1441836, 0, 196613, 1441837, 0, 196613, 1441838, 0, 196613, 1441839, 0, 196613, 1441840, 0, 196613, 1441841, 0, 196613, 1441842, 0, 196613, 1441843, 0, 196613, 1441844, 0, 196613, 1441845, 0, 196613, 1441846, 0, 196613, 1441847, 0, 196613, 1441848, 0, 196613, 1441849, 0, 196613, 1441850, 0, 196613, 1441851, 0, 196613, 1441852, 0, 196613, 1441853, 0, 196613, 1441854, 0, 196613, 1441855, 0, 196613, 1441856, 0, 196613, 1441857, 0, 196613, 1441858, 0, 196613, 1441859, 0, 196613, 1441860, 0, 196613, 1441861, 0, 196613, 1441862, 0, 196613, 1441863, 0, 196613, 1441864, 0, 196613, 1441865, 0, 196613, 1441866, 0, 196613, 1441867, 0, 196613, 1441868, 0, 196613, 1441869, 0, 196613, 1441870, 0, 196613, 1441871, 0, 196613 ) __meta__ = { "_edit_lock_": true } @@ -153,3 +156,17 @@ move_modifier_move_acceleration = 45.0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Ice"] position = Vector2( 83, 9.5 ) shape = SubResource( 4 ) + +[node name="Wind" parent="." instance=ExtResource( 11 )] +position = Vector2( 582, 281 ) +collision_layer = 0 +collision_mask = 2 +directional_modifier = true +move_speed = -20.0 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Wind"] +position = Vector2( 45.5, -24 ) +shape = SubResource( 5 ) +__meta__ = { +"_edit_lock_": true +} diff --git a/src/components/Modifier_Component.gd b/src/components/Modifier_Component.gd index 13ec527..0e7c15a 100644 --- a/src/components/Modifier_Component.gd +++ b/src/components/Modifier_Component.gd @@ -7,6 +7,8 @@ export var modifier_name :String = '' var animation_name: String = '' # Not using this one var timeout_seconds: float = 0.0 # Not doing timeout based ones yet either. +export var directional_modifier: bool = false + export var move_speed: float = 0.0 export var move_acceleration: float = 0.0 export var move_speed_modifier: float = 0.0 @@ -35,6 +37,8 @@ func _ready(): move_speed_modifier, move_modifier_move_acceleration, jerk_factor) + print("Debug Direction property shy are you stopid?! ", directional_modifier) + modifier.modifier_properties.directional_modifier = directional_modifier func _on_Modifier_Component_body_entered(body): var colliding_node = body diff --git a/src/playerD/states/move.gd b/src/playerD/states/move.gd index 3e066a5..1eee763 100644 --- a/src/playerD/states/move.gd +++ b/src/playerD/states/move.gd @@ -19,12 +19,15 @@ func process_physics(delta: float) -> State: move_actor_as_desired(delta) - if move_component.velocity.x == 0.0: - return idle_state +# if move_component.velocity.x == 0.0: +# return idle_state #Flip the character before tha actual move maybe. if move_component.get_movement_direction() != 0.0: parent.transform.x.x = move_component.get_movement_direction() + + if move_component.desired_movement_vector.x == 0: + return idle_state if !parent.is_on_floor(): return fall_state diff --git a/src/state_animated_actor.gd b/src/state_animated_actor.gd index 371e21f..ffa68fb 100644 --- a/src/state_animated_actor.gd +++ b/src/state_animated_actor.gd @@ -274,7 +274,7 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0): #print(physics_modifier.name) #UiManager.debug_text = physics_modifier.name + str(round(adjusted_move_speed)) var mod_props :ModifierProperties = physics_modifier.get_modifier_properties() - if mod_props.move_speed != 0: + if mod_props.move_speed != 0 and mod_props.directional_modifier == false: _move_speed = mod_props.move_speed _move_speed_modifier += mod_props.move_speed_modifier _move_acceleration += mod_props.move_acceleration @@ -287,26 +287,6 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0): if _move_speed == 0 and move_component.desired_movement_vector.x != 0: _move_speed = abs(move_component.desired_movement_vector.x) - # Determine the maximum move speed - var MAX_SPEED :float = 0 - var MIN_SPEED :float = 0 - if sign(_move_speed_modifier) == -1: # decreased speed modifier - help_me_not_be_dumb += '-SpeedMod' - # Move speed cannot go below zero with modifier applied - MIN_SPEED = _move_speed + _move_speed_modifier - # Poor man's clamp - if MIN_SPEED < 0: - MIN_SPEED = 0 - MAX_SPEED = _move_speed - elif sign(_move_speed_modifier) == +1: # increased speed modifier - help_me_not_be_dumb += '+SpeedMod' - MIN_SPEED = _move_speed - MAX_SPEED = _move_speed + _move_speed_modifier - else: # physics won't apply here - help_me_not_be_dumb += '_Speed' # Neutral Speed - MIN_SPEED = _move_speed - MAX_SPEED = _move_speed - # Determine or physics movement direction var current_x_velocity = move_component.velocity.x #move_component.velocity.x var move_direction = 0.0 @@ -328,6 +308,41 @@ func move_actor_as_desired(delta: float, x_move_direction_override: float = 0): else: move_direction = x_move_direction_override +## TODO: I hate that I have to do this check again. + if physics_modifier: + var mod_props :ModifierProperties = physics_modifier.get_modifier_properties() + if mod_props.move_speed != 0 and mod_props.directional_modifier == true: + # Since move_direction is always positive + if sign(move_direction) == sign(mod_props.move_speed): + _move_speed += mod_props.move_speed + else: + _move_speed -= mod_props.move_speed + if sign(move_direction) == 0: + move_direction = sign(mod_props.move_speed) * -1 + #print("doing this? ") + + + + # Determine the maximum move speed + var MAX_SPEED :float = 0 + var MIN_SPEED :float = 0 + if sign(_move_speed_modifier) == -1: # decreased speed modifier + help_me_not_be_dumb += '-SpeedMod' + # Move speed cannot go below zero with modifier applied + MIN_SPEED = _move_speed + _move_speed_modifier + # Poor man's clamp + if MIN_SPEED < 0: + MIN_SPEED = 0 + MAX_SPEED = _move_speed + elif sign(_move_speed_modifier) == +1: # increased speed modifier + help_me_not_be_dumb += '+SpeedMod' + MIN_SPEED = _move_speed + MAX_SPEED = _move_speed + _move_speed_modifier + else: # physics won't apply here + help_me_not_be_dumb += '_Speed' # Neutral Speed + MIN_SPEED = _move_speed + MAX_SPEED = _move_speed + # get the latest aggregate acceleration # If we have any acceleration applying if (_move_modifier_move_acceleration + _move_acceleration) != 0: diff --git a/src/state_modifier.gd b/src/state_modifier.gd index 06be1b4..a4f4761 100644 --- a/src/state_modifier.gd +++ b/src/state_modifier.gd @@ -84,12 +84,14 @@ func merge_modifier(merging_mod: ModifierProperties): func get_modifier_properties() -> ModifierProperties: #( p_move_speed:float, p_gravity:int , p_move_acceleration , p_move_speed_modifier:float, # p_move_modifier_move_acceleration:float, p_jerk_factor: float): - return ModifierProperties.new( modifier_properties.move_speed, + var mp = ModifierProperties.new( modifier_properties.move_speed, modifier_properties.gravity, modifier_properties.move_acceleration, modifier_properties.move_speed_modifier, modifier_properties.move_modifier_move_acceleration, modifier_properties.jerk_factor) + mp.directional_modifier = modifier_properties.directional_modifier + return mp func ready(modifier_name:String, anim_name:String = '', type = TYPE.NONE, timeout : float = 0, parent:Node = null, function_name : String = "") -> Timer: name = modifier_name diff --git a/src/state_modifier_properties.gd b/src/state_modifier_properties.gd index ee5d131..f90385b 100644 --- a/src/state_modifier_properties.gd +++ b/src/state_modifier_properties.gd @@ -12,6 +12,10 @@ var jerk_factor: float = 0 var gravity:int = 0 +# Bad name. Just means that it is intended to apply in a certain direction +# (Positive or negative) not an offset of the existing values. +var directional_modifier: bool = false + func _init( p_move_speed:float, p_gravity:int , p_move_acceleration , p_move_speed_modifier:float, p_move_modifier_move_acceleration:float, p_jerk_factor: float):