Merge task #20: lettuce and corn fields on the south soil, map 60 x 80
Lettuce (x -6..4) and corn (x 24..34, both z 20..30) sit on the bare SW/SE soil with cabbage and corn-stalk prefabs and matching crop tokens; playable map extends south to z 35; SouthFields moved off the map; per-field thief rects. test_targets conflict resolved in favour of #21 (dropped animals no longer run for the edge). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
11d19d874a
10 changed files with 676 additions and 508 deletions
|
|
@ -8,8 +8,10 @@ extends Node3D
|
|||
|
||||
@export var unit_id: int = 0
|
||||
@export var plot: int = 0
|
||||
## "sunflower" (the original field), "lettuce", or "corn" (#13). Cosmetic only; LootSystem
|
||||
## groups theft rules by category, not by this.
|
||||
## "sunflower" (the original field), "lettuce", or "corn" (#13). Cosmetic only: it picks the
|
||||
## token a carried or dropped unit shows (#20, LootSystem.CROP_TOKENS), while theft rules go by
|
||||
## category, not by this. The plants under the unit are the scene's (sunflowers plant_007/008,
|
||||
## cabbage heads plant_004/005, corn stalks plant_001).
|
||||
@export var crop: String = "sunflower"
|
||||
## The night that must be survived (FarmState.nights_survived) before this unit sprouts and
|
||||
## becomes stealable. 0 = already grown, in play from the first morning.
|
||||
|
|
|
|||
|
|
@ -131,12 +131,12 @@ func _ready() -> void:
|
|||
shed_stock.setup(campaign, shed_zone, player) # every pile prop in place for the navigation
|
||||
nav.build(get_parent(), zones.playable.grow(5.0), config.nav_cell_size, config.enemy_radius + config.nav_inflate_margin)
|
||||
shed_stock.refresh()
|
||||
# #13: three CROP_FIELD zones now (the original field, lettuce/cabbage, corn); field_rect is
|
||||
# their bounding box (ThiefBehavior.area_for: "close enough, go straight" once inside it).
|
||||
var crop_zones := zones.zones_of(FarmZone.Kind.CROP_FIELD)
|
||||
var field_rect := crop_zones[0].rect()
|
||||
for i in range(1, crop_zones.size()):
|
||||
field_rect = field_rect.merge(crop_zones[i].rect())
|
||||
# #13: three CROP_FIELD zones (the original field, lettuce/cabbage, corn). #20: each keeps its
|
||||
# own rectangle (ThiefBehavior.area_for: "close enough, go straight" once inside the target's
|
||||
# field); their bounding box would span most of the map now that the later fields lie south.
|
||||
var field_rects: Array[Rect2] = []
|
||||
for z in zones.zones_of(FarmZone.Kind.CROP_FIELD):
|
||||
field_rects.append(z.rect())
|
||||
# Goals are the crop rows themselves (not the whole zone), so a fence around the crops
|
||||
# encloses every goal and thieves have to break in. Likewise the inside of the pen.
|
||||
var crop_goals := PackedInt32Array()
|
||||
|
|
@ -167,7 +167,7 @@ func _ready() -> void:
|
|||
animals = AnimalSystem.new()
|
||||
animals.name = "Animals"
|
||||
add_child(animals)
|
||||
behavior.setup(config, nav, loot, crop_field, escape_field, field_rect)
|
||||
behavior.setup(config, nav, loot, crop_field, escape_field, field_rects)
|
||||
behavior.pen_rect = pen_zone.rect()
|
||||
behavior.shed_rect = shed_zone.rect()
|
||||
behavior.farm_rect = zones.playable
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ extends Node3D
|
|||
## (WaveDirector). Beyond the map the scarecrow can roam out to the old farm's outer fences
|
||||
## (Perimeter/PlayerBounds), where outside zones hold more to gather.
|
||||
|
||||
@export var playable := Rect2(-13.0, -45.0, 60.0, 60.0)
|
||||
## 60 x 80 m, x -13..47, z -45..35. #20: it reaches 20 m further south than the original 60 x 60 m
|
||||
## map, over the old plowed soil where the lettuce/cabbage and corn fields now grow.
|
||||
@export var playable := Rect2(-13.0, -45.0, 60.0, 80.0)
|
||||
## Where the scarecrow can go: out to the old farm's outer fences.
|
||||
@export var roam := Rect2(-27.6, -59.6, 82.4, 106.6)
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,14 @@ const BADGE_FILL := {
|
|||
Category.ANIMAL: [Color(1.0, 0.62, 0.78), Color(1.0, 0.92, 0.95)],
|
||||
Category.SUPPLY: [Color(0.78, 0.62, 0.4), Color(0.35, 0.8, 1.0)],
|
||||
}
|
||||
const TOKEN_SCENE := "res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_007.tscn"
|
||||
## The token a carried or dropped crop shows, by CropUnit.crop (#20): the plant that grows in its
|
||||
## field (a sunflower, a cabbage head, a corn stalk), scaled to about a meter at its largest. Any
|
||||
## other crop shows a sunflower.
|
||||
const CROP_TOKENS := {
|
||||
"sunflower": ["res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_007.tscn", 0.6],
|
||||
"lettuce": ["res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_004.tscn", 1.2],
|
||||
"corn": ["res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_001.tscn", 0.4],
|
||||
}
|
||||
const SACK_SCENE := "res://assets/farm/ithappy/farm/prefabs/assets/prop/bag_002.tscn"
|
||||
const THREAT_COLORS := {
|
||||
Threat.TARGETED: Color(1.0, 0.6, 0.1),
|
||||
|
|
@ -142,7 +149,10 @@ func setup(p_campaign: CampaignController, units: Array[CropUnit], p_enemies: En
|
|||
_outline[c] = outline_material(CATEGORY_COLORS[c])
|
||||
var ring_shader := load("res://game/resources/steal_ring.gdshader") as Shader
|
||||
var icon_shader := load("res://game/resources/loot_icon.gdshader") as Shader
|
||||
var token_scene := load(TOKEN_SCENE) as PackedScene
|
||||
var crop_of := {} # unit id -> a CROP_TOKENS key
|
||||
for u in units:
|
||||
crop_of[u.unit_id] = u.crop if CROP_TOKENS.has(u.crop) else "sunflower"
|
||||
var token_scenes := {} # loaded once per crop: an instance doesn't keep its PackedScene alive
|
||||
var sack_scene := load(SACK_SCENE) as PackedScene
|
||||
for id in range(1, n):
|
||||
category[id] = _category_of(id)
|
||||
|
|
@ -159,8 +169,11 @@ func setup(p_campaign: CampaignController, units: Array[CropUnit], p_enemies: En
|
|||
var token: Node3D = null
|
||||
match category[id]:
|
||||
Category.CROP:
|
||||
token = token_scene.instantiate() as Node3D
|
||||
token.scale = Vector3.ONE * 0.6
|
||||
var crop: String = crop_of.get(id, "sunflower")
|
||||
if not token_scenes.has(crop):
|
||||
token_scenes[crop] = load(CROP_TOKENS[crop][0])
|
||||
token = (token_scenes[crop] as PackedScene).instantiate() as Node3D
|
||||
token.scale = Vector3.ONE * float(CROP_TOKENS[crop][1])
|
||||
Category.SUPPLY:
|
||||
token = sack_scene.instantiate() as Node3D
|
||||
token.scale = Vector3.ONE * 0.85
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ var loot: LootSystem
|
|||
var nav: FarmNavigation
|
||||
var crop_field: PackedInt32Array
|
||||
var escape_field: PackedInt32Array
|
||||
var field_rect: Rect2
|
||||
## Every crop field's rectangle (#20: one per field, not their bounding box, now that the fields
|
||||
## lie far apart). A crop thief inside the field its target grows in goes straight at it.
|
||||
var field_rects: Array[Rect2] = []
|
||||
## Set by FarmSim: the flow fields toward the pen, each shed pile (material -> field), and the
|
||||
## barriers guarding valuables; those areas; the farm (flyers leave over its edge); and, every
|
||||
## tick, where the scarecrow is.
|
||||
|
|
@ -83,13 +85,13 @@ var _dir := PackedFloat32Array([0.0, 0.0])
|
|||
|
||||
|
||||
func setup(p_cfg: GameConfig, p_nav: FarmNavigation, p_loot: LootSystem, p_crop_field: PackedInt32Array,
|
||||
p_escape_field: PackedInt32Array, p_field_rect: Rect2) -> void:
|
||||
p_escape_field: PackedInt32Array, p_field_rects: Array[Rect2]) -> void:
|
||||
cfg = p_cfg
|
||||
nav = p_nav
|
||||
loot = p_loot
|
||||
crop_field = p_crop_field
|
||||
escape_field = p_escape_field
|
||||
field_rect = p_field_rect
|
||||
field_rects = p_field_rects
|
||||
|
||||
|
||||
func update(es: EnemySystem, dt: float) -> void:
|
||||
|
|
@ -236,7 +238,7 @@ func _seek(es: EnemySystem, i: int, dt: float) -> void:
|
|||
return
|
||||
es.pace[i] = 1.0
|
||||
var field := field_for(unit)
|
||||
if (area_for(loot.category[unit]).has_point(p) or d < cfg.direct_seek_distance) and nav.line_clear(p.x, p.y, goal.x, goal.y):
|
||||
if (area_for(loot.category[unit], goal).has_point(p) or d < cfg.direct_seek_distance) and nav.line_clear(p.x, p.y, goal.x, goal.y):
|
||||
es.desire_x[i] = to.x / d
|
||||
es.desire_z[i] = to.y / d
|
||||
es.timer[i] = 0.0
|
||||
|
|
@ -437,13 +439,19 @@ func field_for(id: int) -> PackedInt32Array:
|
|||
return crop_field
|
||||
|
||||
|
||||
func area_for(c: int) -> Rect2:
|
||||
## The area around an item's home where a thief stops following the flow field and goes straight
|
||||
## (given a clear line): the pen, the shed, or the crop field holding goal (none for a crop lying
|
||||
## outside every field).
|
||||
func area_for(c: int, goal: Vector2) -> Rect2:
|
||||
match c:
|
||||
LootSystem.Category.ANIMAL:
|
||||
return pen_rect
|
||||
LootSystem.Category.SUPPLY:
|
||||
return shed_rect
|
||||
return field_rect
|
||||
for r in field_rects:
|
||||
if r.has_point(goal):
|
||||
return r
|
||||
return Rect2()
|
||||
|
||||
|
||||
func _steal(es: EnemySystem, i: int, dt: float) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue