seeding-planets/common/game_data/scripts/planet_data.gd
Zacharie Guet f1ef41323a équilibrages, fix et évolutions
* résolution du bug de disparition des items #94
* améliorations définitives dans le camion via compost #88
* ajout de plus d'aléatoire dans le zone de départ
* suppression des récompenses de quota (pour l'instant)
* équilibrage du gain en graine
* ajout de la clarté dans les actions
2025-10-17 17:53:38 +02:00

89 lines
2.1 KiB
GDScript

extends Resource
class_name PlanetData
signal quota_number_updated(quota : int)
signal contamination_updated(decontamination_surface : float)
const MAX_DEFAULT_CONTAMINATION_ZONE_SURFACE = 3000
const DEFAULT_BASE_SIZE = Vector2(1500,1500)
@export var base_size : Vector2 = Vector2(2000,2000)
@export var contamination : TerrainData
@export var quota_number : int = 0 :
set(v):
quota_number = v
quota_number_updated.emit(v)
func _init(_base_size : Vector2 = DEFAULT_BASE_SIZE):
base_size = _base_size
contamination = TerrainData.new(base_size)
contamination.draw_random_zone(
MAX_DEFAULT_CONTAMINATION_ZONE_SURFACE,
base_size/2
)
contamination_updated.emit(get_decontamination_surface())
func impact_contamination(position : Vector2, impact_radius : float, to_value : float = 1.):
contamination.draw_circle(
position,
impact_radius,
to_value
)
contamination_updated.emit(get_decontamination_surface())
func is_in_base(point):
return (
point.x > 0
and point.y > 0
and point.x < base_size.x
and point.y < base_size.y)
func get_contamination(point : Vector2) -> float:
return contamination.get_value(point)
func get_decontamination_coverage() -> float:
return contamination.get_value_coverage()
func get_decontamination_surface() -> float:
return contamination.get_value_surface()
#endregion
#region ------------------ Objectives ------------------
func generate_objective_rewards(level = 0) -> Array[ObjectiveReward]:
var amount = level + 1
var possible_objective_rewards_path : Array[ObjectiveReward] = [
LootRandomSeedsReward.new(randi_range(4+level, 6+level))
]
var objectives_reward : Array[ObjectiveReward] = []
var i = 0
while i < amount and len(possible_objective_rewards_path) > 0:
var r = possible_objective_rewards_path.pick_random()
possible_objective_rewards_path.erase(r)
objectives_reward.append(r)
i += 1
return objectives_reward
#endregion
#region ------------------ Quotas ------------------
func get_quota(n = 0) -> int:
var first_quotas = [
5,
10,
20,
50,
]
if n >= len(first_quotas):
return pow(n, 3)
else:
return first_quotas[n]
#endregion