aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/game.gd4
-rw-r--r--client/map/item_factory.gd17
-rw-r--r--client/map/tile_factory.gd17
-rw-r--r--client/map/tiles/generic_tile.gd2
-rw-r--r--client/map/tiles/wall.gd12
5 files changed, 29 insertions, 23 deletions
diff --git a/client/game.gd b/client/game.gd
index 34040034..89a68be5 100644
--- a/client/game.gd
+++ b/client/game.gd
@@ -226,7 +226,7 @@ func handle_packet(p):
if p.message != null:
if "item" in p.message:
var item_name: String = item_names[p.message.item]
- var parsed_item := ItemFactory.ParsedItem.new(item_name)
+ var parsed_item := ItemFactory.ItemName.new(item_name)
var ingredients := [parsed_item.name]
ingredients.append_array(parsed_item.contents)
@@ -309,7 +309,7 @@ func handle_packet(p):
update_tutorial_running.emit(tutorial_running)
if p.success:
- var completed_item := ItemFactory.ParsedItem.new(item_names[p.item])
+ var completed_item := ItemFactory.ItemName.new(item_names[p.item])
var played: Array = Profile.read("tutorial_ingredients_played")
played.append(completed_item.name)
played.append_array(completed_item.contents)
diff --git a/client/map/item_factory.gd b/client/map/item_factory.gd
index 1e30047a..9a4200e5 100644
--- a/client/map/item_factory.gd
+++ b/client/map/item_factory.gd
@@ -16,18 +16,17 @@
class_name ItemFactory
extends Object
-class ParsedItem:
+class ItemName:
var name: String
var contents: Array
- func _init(full_name: String):
- var c = Array(full_name.split(":"))
+ func _init(raw_name: String):
+ var c = Array(raw_name.split(":"))
name = c[0]
contents = c[1].split(",") if c.size() > 1 else []
-static func produce(full_name: String, owned_by: Node3D) -> Item:
- var item = ParsedItem.new(full_name)
-
+static func produce(raw_name: String, owned_by: Node3D) -> Item:
+ var item = ItemName.new(raw_name)
match item.name:
"bun": return Bun.new(owned_by)
"cheese": return Cheese.new(owned_by)
@@ -61,7 +60,7 @@ static func produce(full_name: String, owned_by: Node3D) -> Item:
"sliced-lettuce": return SlicedLettuce.new(owned_by)
"potato": return Potato.new(owned_by)
"dirty-plate": return Plate.new(owned_by, ["dirt"])
-
+
"pot": return Pot.new(owned_by, item.contents)
"pan": return Pan.new(owned_by, item.contents)
"foodprocessor": return FoodProcessor.new(owned_by, item.contents)
@@ -69,5 +68,5 @@ static func produce(full_name: String, owned_by: Node3D) -> Item:
"plate": return Plate.new(owned_by, item.contents)
"unknown-order": return UnknownOrder.new(owned_by)
-
- _: return GenericItem.new(owned_by, full_name)
+
+ _: return GenericItem.new(owned_by, raw_name)
diff --git a/client/map/tile_factory.gd b/client/map/tile_factory.gd
index ba7d8ac3..57570263 100644
--- a/client/map/tile_factory.gd
+++ b/client/map/tile_factory.gd
@@ -16,8 +16,16 @@
class_name TileFactory
extends Object
+
+class TileName:
+ var name: String
+ var variant #: String?
+ func _init(raw_name: String):
+ var c = Array(raw_name.split(":"))
+ name = c[0]; variant = c[1] if c.size() >= 2 else null # TODO Array.get throws errors
+
class TileCC:
- var tile_name: String
+ var tile_name: TileName
var position: Vector2i
var neighbors: Array
var floor_meshers: Dictionary[String, FloorMesher]
@@ -29,13 +37,16 @@ var floor_meshers: Dictionary[String, FloorMesher] = {
"street": FloorMesher.new(Street.floor_mesh())
}
-func produce(tile_name: String, position: Vector2i, neighbors: Array) -> Tile:
+func produce(raw_name: String, position: Vector2i, neighbors: Array) -> Tile:
+ var tile_name = TileName.new(raw_name)
+
var ctx := TileCC.new()
ctx.tile_name = tile_name
ctx.position = position
ctx.neighbors = neighbors
ctx.floor_meshers = floor_meshers
- match tile_name:
+
+ match tile_name.name:
"black-hole-counter": return ItemPortal.new(ctx, false)
"black-hole": return PlayerPortal.new(ctx, false)
"book": return Book.new(ctx)
diff --git a/client/map/tiles/generic_tile.gd b/client/map/tiles/generic_tile.gd
index e6530823..345f1daa 100644
--- a/client/map/tiles/generic_tile.gd
+++ b/client/map/tiles/generic_tile.gd
@@ -19,7 +19,7 @@ extends Floor
func _init(ctx: TileFactory.TileCC):
super(ctx)
var label = Label3D.new()
- label.text = ctx.tile_name
+ label.text = ctx.tile_name.name
label.position.y = 0.5
label.billboard = BaseMaterial3D.BILLBOARD_ENABLED
item_base.add_child(label)
diff --git a/client/map/tiles/wall.gd b/client/map/tiles/wall.gd
index 86cc7435..4f9588f5 100644
--- a/client/map/tiles/wall.gd
+++ b/client/map/tiles/wall.gd
@@ -19,11 +19,7 @@ extends WallTile
func _init(ctx: TileFactory.TileCC):
super(ctx)
match kind:
- WallKind.STRAIGHT:
- base.add_child(load("res://map/tiles/wall_straight.tscn").instantiate())
- WallKind.OUTER_CORNER:
- base.add_child(load("res://map/tiles/wall_corner.tscn").instantiate())
- WallKind.T:
- base.add_child(load("res://map/tiles/wall_t.tscn").instantiate())
- WallKind.CROSS:
- base.add_child(load("res://map/tiles/wall_cross.tscn").instantiate())
+ WallKind.STRAIGHT: base.add_child(load("res://map/tiles/wall_straight.tscn").instantiate())
+ WallKind.OUTER_CORNER: base.add_child(load("res://map/tiles/wall_corner.tscn").instantiate())
+ WallKind.T: base.add_child(load("res://map/tiles/wall_t.tscn").instantiate())
+ WallKind.CROSS: base.add_child(load("res://map/tiles/wall_cross.tscn").instantiate())