Merge branch 'demo'

This commit is contained in:
2026-06-22 20:19:48 +02:00
427 changed files with 12288 additions and 2329 deletions

View File

@@ -6,27 +6,24 @@
[sub_resource type="AtlasTexture" id="AtlasTexture_khbsd"]
atlas = ExtResource("1_yh7e0")
region = Rect2(4497, 2359, 335, 454)
region = Rect2(1914, 1843, 213, 199)
[node name="Sprite" type="Sprite2D" unique_id=1642167049 node_paths=PackedStringArray("root", "attaches")]
texture = SubResource("AtlasTexture_khbsd")
script = ExtResource("2_a5yje")
part_name = "Base3"
part_name = "LeafE9"
type = 2
root = NodePath("Root")
attaches = NodePath("Attaches")
[node name="Root" type="Node2D" parent="." unique_id=1437082577]
position = Vector2(15, 184)
position = Vector2(-81, -42)
script = ExtResource("3_yh7e0")
attach_types = Array[int]([3])
[node name="Attaches" type="Node" parent="." unique_id=1834697767]
[node name="attach2" type="Node2D" parent="Attaches" unique_id=1063061640]
position = Vector2(-89, 45)
script = ExtResource("3_yh7e0")
attach_types = Array[int]([3])
[node name="attach1" type="Node2D" parent="Attaches" unique_id=539833351]
position = Vector2(-7, -161)
position = Vector2(-1, -24)
script = ExtResource("3_yh7e0")
attach_types = Array[int]([2])

View File

@@ -5,8 +5,8 @@
[ext_resource type="Texture2D" uid="uid://do3wxh7k38m7u" path="res://entities/plants/assets/sprites/seed_buried_texture.png" id="3_rbgiq"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_rbgiq"]
radius = 22.0
height = 50.0
radius = 26.0
height = 52.0
[sub_resource type="AtlasTexture" id="AtlasTexture_wyuub"]
atlas = ExtResource("3_j6jm5")
@@ -164,7 +164,7 @@ _data = {
script = ExtResource("1_pq8o7")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1893251777]
position = Vector2(0, -14)
position = Vector2(0, -2)
shape = SubResource("CapsuleShape2D_rbgiq")
[node name="Sprite" type="Sprite2D" parent="." unique_id=1693882598]
@@ -186,6 +186,7 @@ texture = ExtResource("3_rbgiq")
[node name="LifeTimeSprite" type="Sprite2D" parent="." unique_id=799762981]
unique_name_in_owner = true
visible = false
scale = Vector2(0.26000002, 0.26000005)
texture = SubResource("ViewportTexture_rbgiq")

View File

@@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="PlantPart" format=3 uid="uid://cqxmyd07qyj4g"]
[ext_resource type="Script" uid="uid://co46ywm8bgnfh" path="res://entities/plants/scripts/texture_builder/plant_attach.gd" id="1_us16y"]
[ext_resource type="Script" path="res://entities/plants/scripts/texture_builder/plant_attach.gd" id="1_us16y"]
[ext_resource type="Script" uid="uid://b3jwglylqdqtw" path="res://entities/plants/scripts/texture_builder/plant_part.gd" id="2_ux8f6"]
[ext_resource type="Texture2D" uid="uid://bdwmandgxrjgn" path="res://entities/plants/assets/sprites/asset_plantes.png" id="3_qn1v0"]

View File

@@ -4,34 +4,24 @@
[ext_resource type="Script" uid="uid://b3jwglylqdqtw" path="res://entities/plants/scripts/texture_builder/plant_part.gd" id="2_nwj5t"]
[ext_resource type="Texture2D" uid="uid://bdwmandgxrjgn" path="res://entities/plants/assets/sprites/asset_plantes.png" id="3_n3ftt"]
[sub_resource type="Resource" id="Resource_0ss64"]
[sub_resource type="Resource" id="Resource_h5ver"]
script = ExtResource("1_h5ver")
position = Vector2(-46, 17)
position = Vector2(-41, -47)
attach_types = Array[int]([2])
[sub_resource type="Resource" id="Resource_0oofm"]
[sub_resource type="Resource" id="Resource_nwj5t"]
script = ExtResource("1_h5ver")
position = Vector2(116, 72)
attach_types = Array[int]([2])
[sub_resource type="Resource" id="Resource_yyxoq"]
script = ExtResource("1_h5ver")
position = Vector2(-38, -137)
attach_types = Array[int]([2])
[sub_resource type="Resource" id="Resource_0artd"]
script = ExtResource("1_h5ver")
position = Vector2(-11, -70)
attach_types = Array[int]([1, 3])
position = Vector2(60, -86)
attach_types = Array[int]([1])
[sub_resource type="AtlasTexture" id="AtlasTexture_yh7e0"]
atlas = ExtResource("3_n3ftt")
region = Rect2(1914, 1843, 213, 199)
region = Rect2(2802, 1568, 295, 348)
[resource]
resource_name = "LeafE7"
script = ExtResource("2_nwj5t")
texture = SubResource("AtlasTexture_yh7e0")
type = 2
root = SubResource("Resource_0artd")
attaches = Array[ExtResource("1_h5ver")]([SubResource("Resource_0ss64"), SubResource("Resource_0oofm"), SubResource("Resource_yyxoq")])
root = SubResource("Resource_nwj5t")
attaches = Array[ExtResource("1_h5ver")]([SubResource("Resource_h5ver")])

View File

@@ -4,34 +4,34 @@
[ext_resource type="Script" uid="uid://b3jwglylqdqtw" path="res://entities/plants/scripts/texture_builder/plant_part.gd" id="2_msfms"]
[ext_resource type="Texture2D" uid="uid://bdwmandgxrjgn" path="res://entities/plants/assets/sprites/asset_plantes.png" id="3_6eoa5"]
[sub_resource type="Resource" id="Resource_c3714"]
[sub_resource type="Resource" id="Resource_jbdpq"]
script = ExtResource("1_04w7e")
position = Vector2(-185, 82)
attach_types = Array[int]([2])
[sub_resource type="Resource" id="Resource_ia8hj"]
[sub_resource type="Resource" id="Resource_n4gj3"]
script = ExtResource("1_04w7e")
position = Vector2(-9, -37)
attach_types = Array[int]([2])
[sub_resource type="Resource" id="Resource_5a0lt"]
[sub_resource type="Resource" id="Resource_ymggq"]
script = ExtResource("1_04w7e")
position = Vector2(143, 24)
attach_types = Array[int]([2])
[sub_resource type="Resource" id="Resource_ee445"]
[sub_resource type="Resource" id="Resource_fbydt"]
script = ExtResource("1_04w7e")
position = Vector2(-196, 104)
attach_types = Array[int]([1, 3])
[sub_resource type="AtlasTexture" id="AtlasTexture_yh7e0"]
atlas = ExtResource("3_6eoa5")
region = Rect2(20, 2801, 461, 266)
region = Rect2(20, 2820, 461, 231)
[resource]
resource_name = "LeafH3"
resource_name = "LeafHA3"
script = ExtResource("2_msfms")
texture = SubResource("AtlasTexture_yh7e0")
type = 2
root = SubResource("Resource_ee445")
attaches = Array[ExtResource("1_04w7e")]([SubResource("Resource_c3714"), SubResource("Resource_ia8hj"), SubResource("Resource_5a0lt")])
root = SubResource("Resource_fbydt")
attaches = Array[ExtResource("1_04w7e")]([SubResource("Resource_jbdpq"), SubResource("Resource_n4gj3"), SubResource("Resource_ymggq")])

View File

@@ -9,10 +9,10 @@ const HARVESTED_SEED_DISPLACEMENT_FACTOR = 100
const RANDOM_MAX_GROW_INTERVAL = Region.MIN_PASS_DAY_ANIMATION_TIME/2. - 0.1
const PLANT_TYPE_ICON = preload("res://common/icons/seedling.svg")
const SCORE_ICON = preload("res://common/icons/growth.svg")
const DURATION_ICON = preload("res://common/icons/calendar-week.svg")
const DURATION_ICON = preload("res://common/icons/clock.svg")
const SHOVEL_ICON = preload("res://common/icons/shovel.svg")
const GROWING_ICON = preload("res://common/icons/chevrons-up.svg")
const LIFETIME_ICON= preload("res://common/icons/clock.svg")
const GROWING_ICON = preload("res://common/icons/clock-up.svg")
const LIFETIME_ICON= preload("res://common/icons/clock-death.svg")
const SEED_ICON = preload("res://common/icons/seeds.svg")
const SPRITE_SCENE : PackedScene = preload("res://entities/plants/plant_sprite.tscn")

View File

@@ -67,12 +67,12 @@ func get_growing_time() -> int:
for m in mutations:
growing_time = m.mutate_growing_time(self , growing_time)
return growing_time
return max(1,growing_time)
func get_score(state: State = get_state()) -> int:
var score = get_plant_info().get_base_score() if state == State.MATURE else 0
var mult := 1
var mult := 1.
for m in mutations:
score = m.mutate_score(self , score)
@@ -81,7 +81,7 @@ func get_score(state: State = get_state()) -> int:
for pd in nearby_plants:
score += pd.get_score_buff()
return max(0,score) * max(0,mult)
return ceili(max(0,score) * max(0,mult))
func get_state() -> State:
if day >= get_lifetime():

View File

@@ -5,26 +5,26 @@ var radius : int
var sprite : Circle
var collision_shape : CollisionShape2D
var show_influence : bool = false :
set(v):
show_influence = v
if sprite:
sprite.visible = v
set(v):
show_influence = v
if sprite:
sprite.visible = v
func _init(_radius = 100):
radius = _radius
radius = _radius
func _ready():
sprite = Circle.new()
# sprite.z_index = 100
sprite.radius = radius
sprite.fill = false
sprite.width = 1
sprite.opacity = 0.5
sprite.visible = show_influence
add_child(sprite)
sprite = Circle.new()
# sprite.z_index = 100
sprite.radius = radius
sprite.fill = false
sprite.width = 1
sprite.opacity = 0.5
sprite.visible = show_influence
add_child(sprite)
collision_shape = CollisionShape2D.new()
var circle_shape : CircleShape2D = CircleShape2D.new()
circle_shape.radius = radius
collision_shape.shape = circle_shape
add_child(collision_shape)
collision_shape = CollisionShape2D.new()
var circle_shape : CircleShape2D = CircleShape2D.new()
circle_shape.radius = radius
collision_shape.shape = circle_shape
add_child(collision_shape)

View File

@@ -2,6 +2,8 @@
extends Resource
class_name PlantMutation
const MAX_RARITY = 6
@export var level: int = 1
var id: String: get = get_mutation_id
@@ -32,7 +34,7 @@ func has_score(_plant_data: PlantData) -> bool:
func mutate_score(_plant_data: PlantData, score: int) -> int:
return score
func mutate_score_multiplier(_plant_data: PlantData, multiplier: int) -> int:
func mutate_score_multiplier(_plant_data: PlantData, multiplier: float) -> float:
return multiplier
func mutate_lifetime(_plant_data: PlantData, lifetime: int) -> int:
@@ -124,10 +126,11 @@ static func get_rarity_text(rarity) -> String:
static func get_rarity_color(rarity: int) -> Color:
var rarity_colors: Array[Color] = [
Color("2364AA"),
Color("25C147"),
Color("8B2DFF"),
Color("FF006E"),
Color("25c147"),
Color("00c6ca"),
Color("8b2dff"),
Color("ff006e"),
Color("ff5427"),
Color("FFA617"),
]

View File

@@ -2,7 +2,7 @@
extends PlantMutation
class_name AncientMutation
const DEFAULT_DAY_FACTOR = 4
const DEFAULT_DAY_FACTOR = 3
func get_icon() -> Texture:
return preload("res://common/icons/wood.svg")

View File

@@ -21,11 +21,15 @@ func get_mutation_description() -> String:
"score_icon": Text.bbcode_icon(Plant.SCORE_ICON),
})
func mutate_seed_buff(_plant_data: PlantData, seed_buff) -> int:
return seed_buff + get_seed_buff()
func mutate_seed_buff(data: PlantData, seed_buff) -> int:
if data.get_state() == PlantData.State.MATURE:
return seed_buff + get_seed_buff()
return seed_buff
func mutate_score(_plant_data: PlantData, score: int) -> int:
return score + get_score_change()
func mutate_score(data: PlantData, score: int) -> int:
if data.get_state() == PlantData.State.MATURE:
return score + get_score_change()
return score
func get_seed_buff():
return level

View File

@@ -16,8 +16,8 @@ func get_mutation_description() -> String:
"score_icon": Text.bbcode_icon(Plant.SCORE_ICON)
})
func mutate_score_multiplier(plant_data: PlantData, multiplier: int) -> int:
return multiplier - 1
func mutate_score_multiplier(_pd: PlantData, _m: float) -> float:
return 0
func mutate_score_buff(plant_data: PlantData, score_buff : int) -> int:
if plant_data.get_state() == PlantData.State.MATURE:

View File

@@ -2,7 +2,7 @@ extends PlantMutation
class_name ProlificMutation
func get_icon() -> Texture:
return preload("res://common/icons/droplets.svg")
return preload("res://common/icons/seeds.svg")
func get_mutation_id() -> String:
return "PROLIFIC"

View File

@@ -16,7 +16,7 @@ func get_mutation_description() -> String:
"score_multiplier": get_score_multiplier() + 1,
})
func mutate_score_multiplier(plant_data: PlantData, multiplier: int) -> int:
func mutate_score_multiplier(plant_data: PlantData, multiplier: float) -> float:
if plant_data.decontamination_area_factor == 1.0:
return multiplier + get_score_multiplier()
return multiplier

View File

@@ -1,7 +1,7 @@
extends PlantMutation
class_name SocialMutation
const DEFAULT_PLANT_BY_POINT = 4
const DEFAULT_PLANT_BY_POINT = 3
func get_icon() -> Texture:
return preload("res://common/icons/users-group.svg")

View File

@@ -13,19 +13,19 @@ func get_mutation_name() -> String:
func get_mutation_description() -> String:
return tr("TOUGH_EFFECT_TEXT").format({
"score_icon": Text.bbcode_icon(Plant.SCORE_ICON),
"score_multiplier": get_score_multiplier(),
"score_multiplier": get_score_multiplier() + 1.,
"growing_time": get_growing_time_increase(),
"growing_icon": Text.bbcode_icon(Plant.GROWING_ICON)
})
func mutate_score_multiplier(_plant_data: PlantData, multiplier: int) -> int:
return multiplier * get_score_multiplier()
func mutate_score_multiplier(_plant_data: PlantData, multiplier: float) -> float:
return multiplier + get_score_multiplier()
func mutate_growing_time(_plant_data: PlantData, growing_time: int) -> int:
return maxi(0, growing_time + get_growing_time_increase())
return growing_time + maxi(0, get_growing_time_increase())
func get_growing_time_increase()->int:
return 4 - level
func get_score_multiplier()->int:
return 2
func get_score_multiplier()->float:
return 0.5 * level

View File

@@ -56,8 +56,8 @@ func start_harvest_animation():
func set_display_lifetime_sprite(d := display_lifetime_sprite):
display_lifetime_sprite = d
if is_node_ready():
%LifeTimeSprite.visible = d
# if is_node_ready():
# %LifeTimeSprite.visible = d
func set_sprite_modulate(c := sprite_modulate):
sprite_modulate = c

View File

@@ -77,7 +77,7 @@ func shuffle_weighted(array: Array, weights: Array[int]):
weights[i] = originalWeights[indices[i]]
func get_mutation_weight(level: int) -> int:
return 3 * level
return 2 * level
func build_seed_texture(random_seed: int) -> Texture:
rng.seed = random_seed
@@ -126,16 +126,19 @@ func build_plant_texture(plant_data: PlantData) -> Texture:
var weight_per_origin_type: Array[int] = origin_weights_base.values().duplicate()
var parts_to_place: Dictionary[OriginType, Array] # BRANCH_ORIGIN : Array[PlantPart], MUTATION_ORIGIN : Array[Array[PlantPart]], BASE_LEAF_ORIGIN : Array[PlantPart]
parts_to_place[OriginType.BRANCH_ORIGIN] = branches
parts_to_place[OriginType.BRANCH_ORIGIN] = branches.duplicate()
parts_to_place[OriginType.MUTATION_ORIGIN] = []
parts_to_place[OriginType.BASE_LEAF_ORIGIN] = base_leaves
parts_to_place[OriginType.BASE_LEAF_ORIGIN] = base_leaves.duplicate()
var mutation_weights: Array[int] = []
for mutation in plant_data.mutations:
if mutation.id in parts_mutation_associations:
parts_to_place[OriginType.MUTATION_ORIGIN].append(parts_mutation_associations[mutation.id].parts)
var mutation_parts := parts_mutation_associations[mutation.id].parts
parts_to_place[OriginType.MUTATION_ORIGIN].append(mutation_parts)
var mutation_weight := get_mutation_weight(mutation.level)
mutation_weights.append(mutation_weight)
weight_per_origin_type[OriginType.MUTATION_ORIGIN] += mutation_weight
if len(parts_to_place[OriginType.BASE_LEAF_ORIGIN]) > 0 and mutation_parts[0].type == PlantPart.PartType.LEAF_PART:
parts_to_place[OriginType.BASE_LEAF_ORIGIN].clear()
var flipped: bool = rng.randi() % 2 == 0
@@ -197,8 +200,8 @@ func get_part(all_parts: Dictionary[OriginType, Array], weight_per_origin_type:
var ind := find_random_matching_attach_ind(attach, all_parts[origin])
if ind >= 0:
weight_per_origin_type[origin] -= origin_weight_loss
weight_per_origin_type[((origin + 1) % 3) as OriginType] += origin_weight_gain
weight_per_origin_type[((origin + 2) % 3) as OriginType] += origin_weight_gain
for i in range(len(weight_per_origin_type) - 1):
weight_per_origin_type[((origin + i + 1) % 3)] += origin_weight_gain
return all_parts[origin][ind]
else: # find a mutation part to place
if weight_copy[originIndInd] < 0:
@@ -213,8 +216,8 @@ func get_part(all_parts: Dictionary[OriginType, Array], weight_per_origin_type:
mutation_weights[i] += mutation_weight_gain
mutation_weights[mutation_parts_ind] -= mutation_weight_gain + mutation_weight_loss
weight_per_origin_type[origin] -= origin_weight_loss
weight_per_origin_type[(origin + 1) % 3] += origin_weight_gain
weight_per_origin_type[(origin + 2) % 3] += origin_weight_gain
for i in range(len(weight_per_origin_type) - 1):
weight_per_origin_type[((origin + i + 1) % 3)] += origin_weight_gain
return parts_per_mutations[mutation_parts_ind][ind]
return null