Add basic npc entity script.

This commit is contained in:
2025-01-19 21:53:28 -06:00
parent 05481adc3a
commit 163c37ffe3
18 changed files with 173 additions and 84 deletions

View File

@@ -1,15 +0,0 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://dm7ee4aqjr2dl"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_l4fss"]
bg_color = Color(9.14484e-07, 0.446448, 0.577112, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
[resource]
MarginContainer/constants/margin_bottom = 16
MarginContainer/constants/margin_left = 16
MarginContainer/constants/margin_right = 16
MarginContainer/constants/margin_top = 16
PanelContainer/styles/panel = SubResource("StyleBoxFlat_l4fss")

View File

@@ -1,7 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://dr4b2pmsknuhc"] [gd_scene load_steps=8 format=3 uid="uid://dr4b2pmsknuhc"]
[ext_resource type="Script" path="res://scripts/Entities/TestNPCController.gd" id="1_61g2d"] [ext_resource type="Script" path="res://scripts/Entities/BasicNPCEntity.gd" id="1_1muh7"]
[ext_resource type="Shader" path="res://shaders/NPC Shader.gdshader" id="1_xgcv1"] [ext_resource type="Shader" path="res://shaders/NPC Shader.gdshader" id="1_xgcv1"]
[ext_resource type="Script" path="res://scripts/Cutscene/TestCutscene.gd" id="2_jwvuu"]
[ext_resource type="Texture2D" uid="uid://boa4hvwyoslv0" path="res://textures/characters/base_male.png" id="3_20w6p"] [ext_resource type="Texture2D" uid="uid://boa4hvwyoslv0" path="res://textures/characters/base_male.png" id="3_20w6p"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dw1sy"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dw1sy"]
@@ -18,7 +19,9 @@ shader_parameter/direction = 1
shader_parameter/npcTexture = ExtResource("3_20w6p") shader_parameter/npcTexture = ExtResource("3_20w6p")
[node name="TestNpc" type="CharacterBody3D"] [node name="TestNpc" type="CharacterBody3D"]
script = ExtResource("1_61g2d") script = ExtResource("1_1muh7")
interactType = 1
interactCutscene = ExtResource("2_jwvuu")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.126485) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.126485)

View File

@@ -1,8 +1,3 @@
[gd_scene load_steps=2 format=3 uid="uid://w1q5eoiejmy3"] [gd_scene format=3 uid="uid://w1q5eoiejmy3"]
[ext_resource type="PackedScene" uid="uid://yhtpoum3eek7" path="res://scenes/Entities/Rosa.tscn" id="1_0sbv6"]
[node name="MainMenu" type="Node3D"] [node name="MainMenu" type="Node3D"]
[node name="Rosa" parent="." instance=ExtResource("1_0sbv6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.837138, 0, 0.904558)

View File

@@ -1,7 +1,37 @@
[gd_scene load_steps=2 format=3 uid="uid://dx6fv8n4jl5ku"] [gd_scene load_steps=7 format=3 uid="uid://dx6fv8n4jl5ku"]
[ext_resource type="PackedScene" uid="uid://mr2ako4ox2gq" path="res://models/maps/SomeMap/SomeMapModel.tscn" id="1_sbtr5"] [ext_resource type="PackedScene" uid="uid://mr2ako4ox2gq" path="res://models/maps/SomeMap/SomeMapModel.tscn" id="1_sbtr5"]
[ext_resource type="PackedScene" uid="uid://yhtpoum3eek7" path="res://scenes/Entities/Rosa.tscn" id="2_2h4bv"]
[ext_resource type="PackedScene" uid="uid://dr4b2pmsknuhc" path="res://scenes/Entities/TestNPC.tscn" id="3_q0pj2"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_e1h75"]
sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1)
sky_energy_multiplier = 0.0
ground_bottom_color = Color(0, 0, 0, 1)
ground_horizon_color = Color(0.59625, 0.6135, 0.6375, 1)
[sub_resource type="Sky" id="Sky_weucl"]
sky_material = SubResource("ProceduralSkyMaterial_e1h75")
[sub_resource type="Environment" id="Environment_nyivo"]
sky = SubResource("Sky_weucl")
ambient_light_source = 1
[node name="Some-map" type="Node3D"] [node name="Some-map" type="Node3D"]
[node name="some map" parent="." instance=ExtResource("1_sbtr5")] [node name="some map" parent="." instance=ExtResource("1_sbtr5")]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_nyivo")
[node name="Rosa" parent="." instance=ExtResource("2_2h4bv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.651853, 0.684572, -0.0593004)
[node name="TestNpc" parent="." instance=ExtResource("3_q0pj2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.68747, 0.459578, -0.399262)
direction = 1
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.1432, 54.7591, -25.7675)
light_energy = 15.315
omni_range = 281.646

View File

@@ -1,38 +1,9 @@
[gd_scene load_steps=8 format=3 uid="uid://tmbx2kit0jyq"] [gd_scene load_steps=3 format=3 uid="uid://tmbx2kit0jyq"]
[ext_resource type="PackedScene" uid="uid://yhtpoum3eek7" path="res://scenes/Entities/Rosa.tscn" id="1_xny00"]
[ext_resource type="Script" path="res://scripts/Scenes/OverworldScene.gd" id="1_yv6j0"] [ext_resource type="Script" path="res://scripts/Scenes/OverworldScene.gd" id="1_yv6j0"]
[ext_resource type="PackedScene" uid="uid://dr4b2pmsknuhc" path="res://scenes/Entities/TestNPC.tscn" id="2_p8bk2"]
[ext_resource type="PackedScene" uid="uid://dx6fv8n4jl5ku" path="res://scenes/Maps/SomeMap.tscn" id="4_8dvtu"] [ext_resource type="PackedScene" uid="uid://dx6fv8n4jl5ku" path="res://scenes/Maps/SomeMap.tscn" id="4_8dvtu"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_asdol"]
sky_horizon_color = Color(0.59625, 0.6135, 0.6375, 1)
sky_energy_multiplier = 0.0
ground_bottom_color = Color(0, 0, 0, 1)
ground_horizon_color = Color(0.59625, 0.6135, 0.6375, 1)
[sub_resource type="Sky" id="Sky_weucl"]
sky_material = SubResource("ProceduralSkyMaterial_asdol")
[sub_resource type="Environment" id="Environment_pyuof"]
sky = SubResource("Sky_weucl")
ambient_light_source = 1
[node name="Overworld" type="Node3D"] [node name="Overworld" type="Node3D"]
script = ExtResource("1_yv6j0") script = ExtResource("1_yv6j0")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_pyuof")
[node name="Rosa" parent="." instance=ExtResource("1_xny00")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.651853, 0.684572, -0.0593004)
[node name="TestNpc" parent="." instance=ExtResource("2_p8bk2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.68747, 0.459578, -0.399262)
[node name="OmniLight3D" type="OmniLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -38.1432, 54.7591, -25.7675)
light_energy = 15.315
omni_range = 281.646
[node name="Some-map" parent="." instance=ExtResource("4_8dvtu")] [node name="Some-map" parent="." instance=ExtResource("4_8dvtu")]

View File

@@ -10,5 +10,3 @@ script = ExtResource("1_xu06r")
[node name="Systems" parent="." instance=ExtResource("2_et43v")] [node name="Systems" parent="." instance=ExtResource("2_et43v")]
[node name="UI" parent="." instance=ExtResource("3_fwr0j")] [node name="UI" parent="." instance=ExtResource("3_fwr0j")]
offset_right = -1152.0
offset_bottom = -648.0

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://dfwwtbs3ywcyq"] [gd_scene load_steps=4 format=3 uid="uid://dfwwtbs3ywcyq"]
[ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://Themes/UI Theme.tres" id="1_3b1y4"] [ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://ui/UI Theme.tres" id="1_3b1y4"]
[ext_resource type="Script" path="res://scripts/Scenes/UIScene.gd" id="2_5efuf"] [ext_resource type="Script" path="res://scripts/Scenes/UIScene.gd" id="2_5efuf"]
[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/UI/VNTextbox.tscn" id="2_x0c4l"] [ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/UI/VNTextbox.tscn" id="2_x0c4l"]
@@ -15,6 +15,5 @@ theme = ExtResource("1_3b1y4")
script = ExtResource("2_5efuf") script = ExtResource("2_5efuf")
[node name="VNTextbox" parent="." instance=ExtResource("2_x0c4l")] [node name="VNTextbox" parent="." instance=ExtResource("2_x0c4l")]
visible = false
layout_mode = 1 layout_mode = 1
offset_top = -133.0 offset_top = -133.0

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://bkx3l0kckf4a8"] [gd_scene load_steps=3 format=3 uid="uid://bkx3l0kckf4a8"]
[ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://Themes/UI Theme.tres" id="1_wx4lp"] [ext_resource type="Theme" uid="uid://dm7ee4aqjr2dl" path="res://ui/UI Theme.tres" id="1_wx4lp"]
[ext_resource type="Script" path="res://scripts/UI/VNTextbox.gd" id="2_uo1gm"] [ext_resource type="Script" path="res://scripts/UI/VNTextbox.gd" id="2_uo1gm"]
[node name="VNTextbox" type="PanelContainer"] [node name="VNTextbox" type="PanelContainer"]
@@ -8,7 +8,7 @@ anchors_preset = 12
anchor_top = 1.0 anchor_top = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_top = -134.0 offset_top = -140.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 0 grow_vertical = 0
theme = ExtResource("1_wx4lp") theme = ExtResource("1_wx4lp")
@@ -24,4 +24,5 @@ theme = ExtResource("1_wx4lp")
bbcode_enabled = true bbcode_enabled = true
text = "test text = "test
test test
test
test" test"

View File

@@ -0,0 +1,26 @@
class_name BasicNPCEntity extends "res://scripts/Entities/OverworldEntity.gd"
const Cutscene = preload("res://scripts/Cutscene/Cutscene.gd")
enum BasicNPCInteractType {
NONE,
CUTSCENE
};
@export var interactType:BasicNPCInteractType = BasicNPCInteractType.NONE;
@export var interactCutscene:Resource;
func interact(interactor:OverworldEntity) -> void:
if interactType == BasicNPCInteractType.NONE:
return
if interactType == BasicNPCInteractType.CUTSCENE:
# Cutscene in this manner must take two entities
# (self, speaker, and interactor, player)
var instance:Cutscene = interactCutscene.new(self, interactor);
getSystems().CUTSCENE.setCurrentCutscene(instance);
return
pass
func updateMovement(delta:float) -> void:
pass

View File

@@ -1,5 +1,4 @@
extends CharacterBody3D class_name OverworldEntity extends CharacterBody3D
class_name OverworldEntity
const PauseSystem = preload("res://scripts/System/PauseSystem.gd") const PauseSystem = preload("res://scripts/System/PauseSystem.gd")
@@ -14,7 +13,11 @@ var speed:float = 150;
var friction:float = 8.5; var friction:float = 8.5;
var gravity:float = 30; var gravity:float = 30;
var direction = Direction.SOUTH; @export var direction = Direction.SOUTH:
set(newDirection):
direction = newDirection;
_updateMaterial();
var meshInstance:MeshInstance3D; var meshInstance:MeshInstance3D;
var underFootTile:int = -1; var underFootTile:int = -1;
var underFootPosition:Vector3; var underFootPosition:Vector3;
@@ -22,6 +25,14 @@ var underFootPosition:Vector3;
var withinMapBounds:MapBounds; var withinMapBounds:MapBounds;
var withinBoundsLastFrame:bool = true; var withinBoundsLastFrame:bool = true;
func _updateMaterial():
if !meshInstance:
return
var material:ShaderMaterial = meshInstance.get_surface_override_material(0)
if !material:
return
material.set_shader_parameter("direction", direction)
func getSystems() -> Systems: func getSystems() -> Systems:
return get_tree().current_scene.get_node("Systems") as Systems; return get_tree().current_scene.get_node("Systems") as Systems;
@@ -128,6 +139,7 @@ func _updateTileData() -> void:
func _ready() -> void: func _ready() -> void:
meshInstance = get_node("MeshInstance3D") meshInstance = get_node("MeshInstance3D")
_updateTileData(); _updateTileData();
_updateMaterial();
pass pass
func _process(delta:float) -> void: func _process(delta:float) -> void:
@@ -144,10 +156,6 @@ func _process(delta:float) -> void:
# Update logic # Update logic
updateOverworldLogic(delta) updateOverworldLogic(delta)
# Set shader direction.
var material:ShaderMaterial = meshInstance.get_surface_override_material(0)
material.set_shader_parameter("direction", direction)
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if isPaused(): if isPaused():

View File

@@ -1,15 +0,0 @@
class_name TestNPCController extends "res://scripts/Entities/OverworldEntity.gd"
const TestCutscene = preload("res://scripts/Cutscene/TestCutscene.gd")
func interact(interactor:OverworldEntity) -> void:
# var battle = Battle.new();
# getSystems().BATTLE.startBattle(battle);
# var game = CookingGame.new(VerticalSlice.new());
# getSystems().COOKING.setCookingGame(game);
getSystems().CUTSCENE.setCurrentCutscene(TestCutscene.new(interactor, self));
pass
func updateMovement(delta:float) -> void:
pass

View File

@@ -1 +1 @@
class_name UIScene extends Control class_name UIScene extends Control

BIN
textures/ui/ui_frame.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://63qoqwcwjrdr"
path="res://.godot/imported/ui_frame.png-30b876d1de3012af765e0e33ed431a25.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/ui/ui_frame.png"
dest_files=["res://.godot/imported/ui_frame.png-30b876d1de3012af765e0e33ed431a25.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

BIN
textures/ui/ui_split.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ddwqq0mthg8e7"
path="res://.godot/imported/ui_split.png-404d87f656179f2ebbb5cf9344e99106.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/ui/ui_split.png"
dest_files=["res://.godot/imported/ui_split.png-404d87f656179f2ebbb5cf9344e99106.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

1
textures/ui/ui_split.txt Normal file
View File

@@ -0,0 +1 @@
https://opengameart.org/content/golden-ui

19
ui/UI Theme.tres Normal file
View File

@@ -0,0 +1,19 @@
[gd_resource type="Theme" load_steps=3 format=3 uid="uid://dm7ee4aqjr2dl"]
[ext_resource type="Texture2D" uid="uid://63qoqwcwjrdr" path="res://textures/ui/ui_frame.png" id="1_wss1l"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_linbi"]
texture = ExtResource("1_wss1l")
texture_margin_left = 14.0
texture_margin_top = 14.0
texture_margin_right = 14.0
texture_margin_bottom = 14.0
axis_stretch_horizontal = 1
axis_stretch_vertical = 1
[resource]
MarginContainer/constants/margin_bottom = 8
MarginContainer/constants/margin_left = 8
MarginContainer/constants/margin_right = 8
MarginContainer/constants/margin_top = 8
PanelContainer/styles/panel = SubResource("StyleBoxTexture_linbi")