diff options
author | nokoe <nokoe@mailbox.org> | 2024-06-22 01:47:28 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:28:31 +0200 |
commit | 8442047d929d896b5c3992d766adf386d71358a3 (patch) | |
tree | 12f8eb2587b32daabea9286881f020ae5147f757 /client/scripts | |
parent | 66ab776143b0108167a7714b4a1b3e98c54722e2 (diff) | |
download | hurrycurry-8442047d929d896b5c3992d766adf386d71358a3.tar hurrycurry-8442047d929d896b5c3992d766adf386d71358a3.tar.bz2 hurrycurry-8442047d929d896b5c3992d766adf386d71358a3.tar.zst |
add more tiles
Diffstat (limited to 'client/scripts')
-rw-r--r-- | client/scripts/controllable_player.gd | 2 | ||||
-rw-r--r-- | client/scripts/map.gd | 6 | ||||
-rw-r--r-- | client/scripts/multiplayer.gd | 4 | ||||
-rw-r--r-- | client/scripts/tiles/counter.gd | 7 | ||||
-rw-r--r-- | client/scripts/tiles/crate.gd | 3 | ||||
-rw-r--r-- | client/scripts/tiles/flour_counter.gd | 9 | ||||
-rw-r--r-- | client/scripts/tiles/full_tile.gd | 8 | ||||
-rw-r--r-- | client/scripts/tiles/raw_steak_crate.gd | 6 | ||||
-rw-r--r-- | client/scripts/tiles/tomato_crate.gd | 6 | ||||
-rw-r--r-- | client/scripts/tiles/trash.gd | 2 | ||||
-rw-r--r-- | client/scripts/tiles/window.gd | 3 |
11 files changed, 47 insertions, 9 deletions
diff --git a/client/scripts/controllable_player.gd b/client/scripts/controllable_player.gd index adf3f2c0..58ac4401 100644 --- a/client/scripts/controllable_player.gd +++ b/client/scripts/controllable_player.gd @@ -24,7 +24,7 @@ func _process(delta): if input.length() > 0.1: facing = lerp_vector2_exp(facing, input, delta * 10.) - self.rotation.y = facing.angle() + self.rotation.y = -facing.angle() velocity.x += input.x * delta * SPEED velocity.y += input.y * delta * SPEED diff --git a/client/scripts/map.gd b/client/scripts/map.gd index 685c1d69..9d9453e4 100644 --- a/client/scripts/map.gd +++ b/client/scripts/map.gd @@ -14,17 +14,17 @@ func update(pos, tile_name, neighbors): "trash": instance = Trash.new(node_name, neighbors) "tomato-crate": - instance = CounterBase.new(node_name, neighbors) + instance = TomatoCrate.new(node_name, neighbors) "cuttingboard": instance = CuttingBoard.new(node_name, neighbors) "counter": instance = CounterBase.new(node_name, neighbors) "flour-crate": - instance = CounterBase.new(node_name, neighbors) + instance = FlourCounter.new(node_name, neighbors) "oven": instance = Oven.new(node_name, neighbors) "raw-steak-crate": - instance = CounterBase.new(node_name, neighbors) + instance = RawSteakCrate.new(node_name, neighbors) "stove": instance = Stove.new(node_name, neighbors) "sink": diff --git a/client/scripts/multiplayer.gd b/client/scripts/multiplayer.gd index 79c5df76..f3f16387 100644 --- a/client/scripts/multiplayer.gd +++ b/client/scripts/multiplayer.gd @@ -14,6 +14,7 @@ var socket := WebSocketPeer.new() var item_names = [] var tile_names = [] +var item_idx_from_name: Dictionary = {} var player_id = -1 var other_players = {} @@ -52,13 +53,14 @@ func handle_packet(bytes: PackedByteArray): player_id = decoded["id"] item_names = decoded["data"]["item_names"] tile_names = decoded["data"]["tile_names"] + for i in range(item_names.size()): + item_idx_from_name[item_names[i]] = i emit_signal("init", player_id) "add_player": var id = decoded["id"] var player_name = decoded["name"] var pos = decoded["position"] var char = decoded["character"] - other_players[id] = [player_name, char] emit_signal("add_player", id, player_name, pos_to_vec2(pos), char) "remove_player": diff --git a/client/scripts/tiles/counter.gd b/client/scripts/tiles/counter.gd index 22802d36..f4b609d5 100644 --- a/client/scripts/tiles/counter.gd +++ b/client/scripts/tiles/counter.gd @@ -16,6 +16,9 @@ enum CounterKind { var kind: CounterKind = CounterKind.STRAIGHT +static func interact_target() -> Vector3: + return Vector3(0, 0.5, 0) + func _init(rename: String, neighbors: Array): super(rename, neighbors) var facing = 0 @@ -57,7 +60,7 @@ func _init(rename: String, neighbors: Array): turn_facing(facing) -func is_counter(tile_name_t) -> bool: +static func is_counter(tile_name_t) -> bool: if tile_name_t == null: return false - return name.ends_with("crate")||counters.has(name) + return tile_name_t.ends_with("crate")||counters.has(tile_name_t) diff --git a/client/scripts/tiles/crate.gd b/client/scripts/tiles/crate.gd index de154609..3fe43525 100644 --- a/client/scripts/tiles/crate.gd +++ b/client/scripts/tiles/crate.gd @@ -1,7 +1,8 @@ class_name Crate extends Counter -const KIND: int = -1 +static func interact_target() -> Vector3: + return Vector3(0, 0.25, 0) func _init(rename: String, neighbors: Array): super(rename, neighbors) diff --git a/client/scripts/tiles/flour_counter.gd b/client/scripts/tiles/flour_counter.gd new file mode 100644 index 00000000..6c512d92 --- /dev/null +++ b/client/scripts/tiles/flour_counter.gd @@ -0,0 +1,9 @@ +class_name FlourCounter +extends CounterBase + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + var bag = load("res://models/prefabs/map/bag.tscn").instantiate() + bag.position = interact_target() + bag.rotation_degrees.y = 45 + base.add_child(bag) diff --git a/client/scripts/tiles/full_tile.gd b/client/scripts/tiles/full_tile.gd index 863046ba..7ee1e1fc 100644 --- a/client/scripts/tiles/full_tile.gd +++ b/client/scripts/tiles/full_tile.gd @@ -13,3 +13,11 @@ func _init(rename: String, neighbors: Array): static_body.add_child(shape) static_body.name = "Body" base.add_child(static_body) + +# defines where items go when interacting +static func interact_target() -> Vector3: + return Vector3(0, 0, 0) + +# actions when interacting, e.g. animations +func interact(): + pass diff --git a/client/scripts/tiles/raw_steak_crate.gd b/client/scripts/tiles/raw_steak_crate.gd new file mode 100644 index 00000000..3a15b942 --- /dev/null +++ b/client/scripts/tiles/raw_steak_crate.gd @@ -0,0 +1,6 @@ +class_name RawSteakCrate +extends Crate + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/crate_steak.tscn").instantiate()) diff --git a/client/scripts/tiles/tomato_crate.gd b/client/scripts/tiles/tomato_crate.gd new file mode 100644 index 00000000..f19bdd08 --- /dev/null +++ b/client/scripts/tiles/tomato_crate.gd @@ -0,0 +1,6 @@ +class_name TomatoCrate +extends Crate + +func _init(rename: String, neighbors: Array): + super(rename, neighbors) + base.add_child(load("res://models/prefabs/map/crate_tomatoes.tscn").instantiate()) diff --git a/client/scripts/tiles/trash.gd b/client/scripts/tiles/trash.gd index fd24cbd6..c680e72d 100644 --- a/client/scripts/tiles/trash.gd +++ b/client/scripts/tiles/trash.gd @@ -1,5 +1,5 @@ class_name Trash -extends FullTile +extends Crate func _init(rename: String, neighbors: Array): super(rename, neighbors) diff --git a/client/scripts/tiles/window.gd b/client/scripts/tiles/window.gd index 907377d6..7df5e9db 100644 --- a/client/scripts/tiles/window.gd +++ b/client/scripts/tiles/window.gd @@ -1,6 +1,9 @@ class_name WallWindow extends WallTile +static func interact_target() -> Vector3: + return Vector3(0, 0.625, 0) + func _init(rename: String, neighbors: Array): super(rename, neighbors) match kind: |