init
This commit is contained in:
commit
276d43613d
1687 changed files with 109059 additions and 0 deletions
53
game/scripts/farm_zone.gd
Normal file
53
game/scripts/farm_zone.gd
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
@tool
|
||||
class_name FarmZone
|
||||
extends Node3D
|
||||
## One purposeful area of the farm: an axis-aligned rectangle on the ground, centered on this
|
||||
## node (rotation is ignored). Zones live under Zones/ in farm.tscn, and FarmZones looks them
|
||||
## up by position. In the editor each zone draws a translucent box so the layout is visible.
|
||||
|
||||
enum Kind { CROP_FIELD, ANIMAL_PEN, SUPPLY_SHED, WORK_AREA, WOOD, SCRAP, STRAW }
|
||||
|
||||
@export var kind: Kind = Kind.CROP_FIELD
|
||||
## Name shown on the HUD when the scarecrow walks in.
|
||||
@export var display_name: String = ""
|
||||
## Footprint in meters along X and Z.
|
||||
@export var size: Vector2 = Vector2(10.0, 10.0):
|
||||
set(value):
|
||||
size = value
|
||||
_update_preview()
|
||||
@export var tint: Color = Color(1.0, 1.0, 1.0):
|
||||
set(value):
|
||||
tint = value
|
||||
_update_preview()
|
||||
|
||||
var _preview: MeshInstance3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint():
|
||||
_preview = MeshInstance3D.new()
|
||||
add_child(_preview)
|
||||
_update_preview()
|
||||
|
||||
|
||||
func rect() -> Rect2:
|
||||
var p := global_position
|
||||
return Rect2(Vector2(p.x, p.z) - size * 0.5, size)
|
||||
|
||||
|
||||
func contains(point: Vector3) -> bool:
|
||||
return rect().has_point(Vector2(point.x, point.z))
|
||||
|
||||
|
||||
func _update_preview() -> void:
|
||||
if _preview == null:
|
||||
return
|
||||
var box := BoxMesh.new()
|
||||
box.size = Vector3(size.x, 0.1, size.y)
|
||||
var mat := StandardMaterial3D.new()
|
||||
mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
mat.albedo_color = Color(tint, 0.25)
|
||||
box.material = mat
|
||||
_preview.mesh = box
|
||||
_preview.position = Vector3(0.0, 0.05, 0.0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue