1
0

Initial commit

This commit is contained in:
FoxSpellCaster
2025-04-16 18:12:10 -04:00
commit 99bea1a1f0
53 changed files with 4804 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
class_name InteractableObject
extends Node3D
@export var interact_prompt : String
@export var can_interact : bool = true
func _interact():
print("Override this function.")

View File

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

View File

@@ -0,0 +1,16 @@
extends RayCast3D
@onready var interact_prompt_label : Label = get_node("InteractionPrompt")
func _process(delta):
var object = get_collider()
interact_prompt_label.text = ""
if object and object is InteractableObject:
if object.can_interact == false:
return
interact_prompt_label.text = "[E] " + object.interact_prompt
if Input.is_action_just_pressed("interact"):
object._interact()

View File

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

View File

@@ -0,0 +1,150 @@
[gd_scene load_steps=12 format=3 uid="uid://cf1pwgl0y0mi6"]
[ext_resource type="Script" uid="uid://3m03w87bcjnr" path="res://Player Controller/PlayerController.gd" id="1_krxqb"]
[ext_resource type="Script" uid="uid://0xopmg7fmfbj" path="res://Player Controller/Interaction/InteractionController.gd" id="2_66uls"]
[ext_resource type="Script" uid="uid://bgp8sred771bp" path="res://Inventory/Inventory.gd" id="3_0eju6"]
[ext_resource type="Script" uid="uid://c077ak2rge5iv" path="res://item.gd" id="4_ererc"]
[ext_resource type="PackedScene" uid="uid://c7i5cai8ud4lr" path="res://Inventory/inventory_slot.tscn" id="4_sydjo"]
[ext_resource type="Resource" uid="uid://bn62yixvjt8qa" path="res://Items/ItemData/itemGoo_resource.tres" id="5_iq2nx"]
[ext_resource type="Resource" uid="uid://ce3p2y2gmsvhm" path="res://Items/ItemData/itemIron_resource.tres" id="6_kcr7a"]
[ext_resource type="Resource" uid="uid://cfq2hlp4dfjsa" path="res://Items/ItemData/itemWood_resource.tres" id="7_inybr"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_lt5te"]
radius = 0.3
height = 1.8
[sub_resource type="LabelSettings" id="LabelSettings_cbwra"]
font_size = 24
[sub_resource type="LabelSettings" id="LabelSettings_yn5sn"]
font_size = 18
[node name="Player" type="CharacterBody3D" groups=["Player"]]
script = ExtResource("1_krxqb")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0)
shape = SubResource("CapsuleShape3D_lt5te")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
current = true
[node name="InteractionController" type="RayCast3D" parent="Camera3D"]
target_position = Vector3(0, 0, -2)
script = ExtResource("2_66uls")
[node name="InteractionPrompt" type="Label" parent="Camera3D/InteractionController"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -247.0
offset_top = -50.0
offset_right = 247.0
offset_bottom = 50.0
grow_horizontal = 2
grow_vertical = 2
label_settings = SubResource("LabelSettings_cbwra")
horizontal_alignment = 1
vertical_alignment = 1
[node name="Inventory" type="Node" parent="."]
script = ExtResource("3_0eju6")
starter_items = Array[ExtResource("4_ererc")]([ExtResource("5_iq2nx"), ExtResource("6_kcr7a"), ExtResource("7_inybr"), ExtResource("7_inybr"), ExtResource("7_inybr"), ExtResource("6_kcr7a")])
[node name="InventoryWindow" type="Panel" parent="Inventory"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -280.0
offset_top = -184.0
offset_right = 280.0
offset_bottom = 184.0
grow_horizontal = 2
grow_vertical = 2
[node name="SlotContainer" type="GridContainer" parent="Inventory/InventoryWindow"]
custom_minimum_size = Vector2(520, 312)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -260.0
offset_top = -166.0
offset_right = 260.0
offset_bottom = 146.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/h_separation = 10
theme_override_constants/v_separation = 10
columns = 5
[node name="InventorySlot" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot2" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot3" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot4" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot5" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot6" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot7" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot8" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot9" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot10" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot11" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot12" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot13" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot14" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InventorySlot15" parent="Inventory/InventoryWindow/SlotContainer" instance=ExtResource("4_sydjo")]
layout_mode = 2
[node name="InfoText" type="Label" parent="Inventory/InventoryWindow"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -280.0
offset_top = -36.0
offset_right = 280.0
offset_bottom = -10.0
grow_horizontal = 2
grow_vertical = 0
size_flags_vertical = 8
label_settings = SubResource("LabelSettings_yn5sn")
horizontal_alignment = 1

View File

@@ -0,0 +1,77 @@
class_name PlayerController
extends CharacterBody3D
@export_group("Movement")
@export var max_speed : float = 4.0
@export var acceleration : float = 20.0
@export var braking : float = 20.0
@export var air_acceleration : float = 4.0
@export var jump_force : float = 5.0
@export var gravity_modifier : float = 1.5
@export var max_run_speed : float = 6.0
var is_running : bool = false
@export_group("Camera")
@export var look_sensitivity : float = 0.005
var camera_look_input : Vector2
@onready var camera : Camera3D = get_node("Camera3D")
@onready var gravity : float = ProjectSettings.get_setting("physics/3d/default_gravity") * gravity_modifier
func _ready():
# Lock the mouse
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _physics_process(delta):
# Apply gravity
if not is_on_floor():
velocity.y -= gravity * delta
# Jumping
if Input.is_action_pressed("jump") and is_on_floor():
velocity.y = jump_force
# Movement
var move_input = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
var move_dir = (transform.basis * Vector3(move_input.x, 0, move_input.y)).normalized()
is_running = Input.is_action_pressed("sprint")
var target_speed = max_speed
if is_running:
target_speed = max_run_speed
var run_dot = -move_dir.dot(transform.basis.z)
run_dot = clamp(run_dot, 0.0, 1.0)
move_dir *= run_dot
var current_smoothing = acceleration
if not is_on_floor():
current_smoothing = air_acceleration
elif not move_dir:
current_smoothing = braking
var target_vel = move_dir * target_speed
velocity.x = lerp(velocity.x, target_vel.x, current_smoothing * delta)
velocity.z = lerp(velocity.z, target_vel.z, current_smoothing * delta)
move_and_slide()
# Camera Look
rotate_y(-camera_look_input.x * look_sensitivity)
camera.rotate_x(-camera_look_input.y * look_sensitivity)
camera.rotation.x = clamp(camera.rotation.x, -1.5, 1.5)
camera_look_input = Vector2.ZERO
# Mouse
if Input.is_action_just_pressed("ui_cancel"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
func _unhandled_input(event):
if event is InputEventMouseMotion:
camera_look_input = event.relative

View File

@@ -0,0 +1 @@
uid://3m03w87bcjnr