#58 ajout d'un item package servant à déployer des machines

This commit is contained in:
2025-09-05 17:01:59 +02:00
parent 165a4d129b
commit 18b48f5320
29 changed files with 149 additions and 62 deletions

View File

@@ -62,16 +62,16 @@ func impact_contamination(position : Vector2, impact_radius : int, to_value : fl
Color(1., 1., 1., to_value)
)
func get_contamination(point : Vector2) -> float:
var pixel_point : Vector2 = (
Vector2(point) / float(TERRAIN_IMAGE_GAME_FACTOR)
- Vector2.ONE / 2
)
if (
func is_in_image(pixel_point : Vector2, image : Image):
return (
pixel_point.x > 0
and pixel_point.y > 0
and pixel_point.x < contamination.get_width()
and pixel_point.y < contamination.get_height()):
and pixel_point.x < image.get_width()
and pixel_point.y < image.get_height())
func get_contamination(point : Vector2) -> float:
var pixel_point : Vector2 = get_pixel_point(point)
if (is_in_image(pixel_point, contamination)):
return contamination.get_pixel(
int(round(pixel_point.x)),
int(round(pixel_point.y))
@@ -80,3 +80,9 @@ func get_contamination(point : Vector2) -> float:
func get_decontamination_coverage() -> float:
return ImageTools.get_color_coverage(contamination)
func get_pixel_point(point : Vector2) -> Vector2:
return (
Vector2(point) / float(TERRAIN_IMAGE_GAME_FACTOR)
- Vector2.ONE / 2
)

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-package"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 3l8 4.5l0 9l-8 4.5l-8 -4.5l0 -9l8 -4.5" /><path d="M12 12l8 -4.5" /><path d="M12 12l0 9" /><path d="M12 12l-8 -4.5" /><path d="M16 5.25l-8 4.5" /></svg>

After

Width:  |  Height:  |  Size: 468 B

View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://0xg54agef5gh"
path="res://.godot/imported/package.svg-a9602fd424cfb199cd9405d02663e7df.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://common/inventory/assets/icons/package.svg"
dest_files=["res://.godot/imported/package.svg-a9602fd424cfb199cd9405d02663e7df.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

View File

@@ -0,0 +1,15 @@
[gd_resource type="Resource" script_class="Package" load_steps=4 format=3 uid="uid://bya8sm6rm6747"]
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/inventory/assets/icons/package.svg" id="1_lhhdv"]
[ext_resource type="Script" uid="uid://b6kubqgq0k7vj" path="res://common/inventory/scripts/items/package.gd" id="1_x02bb"]
[ext_resource type="PackedScene" uid="uid://bkwh1ntvgkkrt" path="res://entities/interactables/machines/compost/compost.tscn" id="2_uulso"]
[resource]
script = ExtResource("1_x02bb")
scene = ExtResource("2_uulso")
name = "Compost"
description = "Compost"
icon = ExtResource("1_lhhdv")
use_zone_radius = 5
use_energy = 1
metadata/_custom_type_script = "uid://b6kubqgq0k7vj"

View File

@@ -0,0 +1,22 @@
extends Item
class_name Package
@export var scene: PackedScene
func _init(_scene : PackedScene = null):
scene = _scene
func use_text() -> String:
return "Build " + name
func is_one_time_use():
return true
func can_use(player : Player, zone : Area2D) -> bool:
print(zone.global_position)
return player.planet.is_in_zone(zone.global_position)
func use(player : Player, zone : Area2D) -> bool:
print(zone.global_position)
player.planet.instantiate_entity(scene, zone.global_position)
return true

View File

@@ -0,0 +1 @@
uid://b6kubqgq0k7vj