Initial commit
This commit is contained in:
11
.editorconfig
Normal file
11
.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
|
||||
[*.cs]
|
||||
csharp_preserve_static_keyword_spacing = true
|
||||
csharp_new_line_before_open_brace = none
|
||||
csharp_new_line_before_else = false
|
||||
csharp_new_line_before_catch = false
|
||||
csharp_new_line_before_finally = false
|
||||
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
||||
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
/android/
|
||||
|
||||
.vs/
|
||||
.vscode/
|
||||
|
||||
.fake
|
||||
12
Factory Game.csproj
Normal file
12
Factory Game.csproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Godot.NET.Sdk/4.6.1">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net9.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<RootNamespace>FactoryGame</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="source/Utils/" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
19
Factory Game.sln
Normal file
19
Factory Game.sln
Normal file
@@ -0,0 +1,19 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Factory Game", "Factory Game.csproj", "{657BE22A-8A04-45B8-8196-1C187CBE8007}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{657BE22A-8A04-45B8-8196-1C187CBE8007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{657BE22A-8A04-45B8-8196-1C187CBE8007}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{657BE22A-8A04-45B8-8196-1C187CBE8007}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||
{657BE22A-8A04-45B8-8196-1C187CBE8007}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||
{657BE22A-8A04-45B8-8196-1C187CBE8007}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||
{657BE22A-8A04-45B8-8196-1C187CBE8007}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
21
addons/godot-git-plugin/LICENSE
Normal file
21
addons/godot-git-plugin/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2023 The Godot Engine community
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1346
addons/godot-git-plugin/THIRDPARTY.md
Normal file
1346
addons/godot-git-plugin/THIRDPARTY.md
Normal file
File diff suppressed because it is too large
Load Diff
10
addons/godot-git-plugin/git_plugin.gdextension
Normal file
10
addons/godot-git-plugin/git_plugin.gdextension
Normal file
@@ -0,0 +1,10 @@
|
||||
[configuration]
|
||||
|
||||
entry_symbol = "git_plugin_init"
|
||||
compatibility_minimum = "4.2.0"
|
||||
|
||||
[libraries]
|
||||
|
||||
linux.editor.x86_64 = "linux/libgit_plugin.linux.editor.x86_64.so"
|
||||
macos.editor = "macos/libgit_plugin.macos.editor.universal.dylib"
|
||||
windows.editor.x86_64 = "windows/libgit_plugin.windows.editor.x86_64.dll"
|
||||
1
addons/godot-git-plugin/git_plugin.gdextension.uid
Normal file
1
addons/godot-git-plugin/git_plugin.gdextension.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://biqxyjsf64sux
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/textures/debug/16px.png
Normal file
BIN
assets/textures/debug/16px.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 292 B |
41
assets/textures/debug/16px.png.import
Normal file
41
assets/textures/debug/16px.png.import
Normal file
@@ -0,0 +1,41 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bcojlpp18chv2"
|
||||
path.s3tc="res://.godot/imported/16px.png-fc629192c69cc840b3b1dc1a3f480bd4.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/textures/debug/16px.png"
|
||||
dest_files=["res://.godot/imported/16px.png-fc629192c69cc840b3b1dc1a3f480bd4.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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=0
|
||||
BIN
assets/textures/debug/32.png
Normal file
BIN
assets/textures/debug/32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 391 B |
41
assets/textures/debug/32.png.import
Normal file
41
assets/textures/debug/32.png.import
Normal file
@@ -0,0 +1,41 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cl65sdce7cjce"
|
||||
path.s3tc="res://.godot/imported/32.png-c60785513c12bf519f10a74d61636b58.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/textures/debug/32.png"
|
||||
dest_files=["res://.godot/imported/32.png-c60785513c12bf519f10a74d61636b58.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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=0
|
||||
BIN
assets/textures/debug/64.png
Normal file
BIN
assets/textures/debug/64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 565 B |
41
assets/textures/debug/64.png.import
Normal file
41
assets/textures/debug/64.png.import
Normal file
@@ -0,0 +1,41 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bq6kfyf88kofe"
|
||||
path.s3tc="res://.godot/imported/64.png-83621268d26d20755a3d5fdce5844072.s3tc.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/textures/debug/64.png"
|
||||
dest_files=["res://.godot/imported/64.png-83621268d26d20755a3d5fdce5844072.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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=0
|
||||
1
icon.svg
Normal file
1
icon.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
|
||||
|
After Width: | Height: | Size: 995 B |
43
icon.svg.import
Normal file
43
icon.svg.import
Normal file
@@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dp1b88ej6s7e1"
|
||||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.svg"
|
||||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
|
||||
105
project.godot
Normal file
105
project.godot
Normal file
@@ -0,0 +1,105 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Factory Game"
|
||||
run/main_scene="uid://d3wq6hfxq4rd6"
|
||||
config/features=PackedStringArray("4.6", "C#", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
DebugScreen="*uid://dfywog3xvaatq"
|
||||
|
||||
[dotnet]
|
||||
|
||||
project/assembly_name="Factory Game"
|
||||
|
||||
[editor]
|
||||
|
||||
version_control/plugin_name="GitPlugin"
|
||||
version_control/autoload_on_startup=true
|
||||
|
||||
[input]
|
||||
|
||||
move_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
move_forward={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
|
||||
]
|
||||
}
|
||||
move_backward={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
move_jump={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
camera_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
|
||||
]
|
||||
}
|
||||
camera_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
camera_up={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
|
||||
]
|
||||
}
|
||||
camera_down={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
action_crouch={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":7,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
action_sprint={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
3d/physics_engine="Jolt Physics"
|
||||
|
||||
[rendering]
|
||||
|
||||
rendering_device/driver.windows="d3d12"
|
||||
8
scenes/components/CollisionComponent.tscn
Normal file
8
scenes/components/CollisionComponent.tscn
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_scene format=3 uid="uid://dwcik0e4ixs0u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b1683v4e4gh38" path="res://source/Scripts/Components/CollisionComponent.cs" id="1_e6uy1"]
|
||||
|
||||
[node name="CollisionComponent" type="Area3D" unique_id=1105156486 node_paths=PackedStringArray("WhiteList", "BlackList")]
|
||||
script = ExtResource("1_e6uy1")
|
||||
WhiteList = []
|
||||
BlackList = []
|
||||
76
scenes/entities/Player.tscn
Normal file
76
scenes/entities/Player.tscn
Normal file
@@ -0,0 +1,76 @@
|
||||
[gd_scene format=3 uid="uid://f2oncv0p7qxy"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://chuyrnjbwvvf5" path="res://source/Scripts/PlayerController.cs" id="1_o7et6"]
|
||||
[ext_resource type="Script" uid="uid://cyl680l0b3hej" path="res://source/Scripts/CameraController.cs" id="3_24gqh"]
|
||||
[ext_resource type="PackedScene" uid="uid://dwcik0e4ixs0u" path="res://scenes/components/CollisionComponent.tscn" id="3_j1g85"]
|
||||
[ext_resource type="Texture2D" uid="uid://bcojlpp18chv2" path="res://assets/textures/debug/16px.png" id="3_yjynp"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_o7et6"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_24gqh"]
|
||||
height = 1.0
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_yjynp"]
|
||||
radius = 0.475
|
||||
height = 0.95
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_7jddb"]
|
||||
height = 1.5
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_g13of"]
|
||||
albedo_texture = ExtResource("3_yjynp")
|
||||
uv1_triplanar = true
|
||||
texture_filter = 0
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_yjynp"]
|
||||
material = SubResource("StandardMaterial3D_g13of")
|
||||
|
||||
[node name="Player" type="CharacterBody3D" unique_id=654871017 node_paths=PackedStringArray("StandCollision", "CrouchCollision", "HeadCollisionComponent", "BottomCollisionComponent", "Camera", "StandCameraPosition", "CrouchCameraPosition")]
|
||||
script = ExtResource("1_o7et6")
|
||||
StandCollision = NodePath("StandCollisionShape3D")
|
||||
CrouchCollision = NodePath("CrouchCollisionShape3D")
|
||||
HeadCollisionComponent = NodePath("HeadAreaCollisionComponent")
|
||||
BottomCollisionComponent = NodePath("BottomCollisionComponent")
|
||||
Camera = NodePath("Camera3D")
|
||||
StandCameraPosition = NodePath("StandCameraMarker3D")
|
||||
CrouchCameraPosition = NodePath("CrouchCameraMarker3D")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1744916979]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
script = ExtResource("3_24gqh")
|
||||
|
||||
[node name="RayCast3D" type="RayCast3D" parent="Camera3D" unique_id=126273469]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0)
|
||||
|
||||
[node name="StandCameraMarker3D" type="Marker3D" parent="." unique_id=1201495111]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
|
||||
[node name="CrouchCameraMarker3D" type="Marker3D" parent="." unique_id=659387861]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.25, 0)
|
||||
|
||||
[node name="StandCollisionShape3D" type="CollisionShape3D" parent="." unique_id=1333295902]
|
||||
shape = SubResource("CapsuleShape3D_o7et6")
|
||||
|
||||
[node name="CrouchCollisionShape3D" type="CollisionShape3D" parent="." unique_id=899067076]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
|
||||
shape = SubResource("CapsuleShape3D_24gqh")
|
||||
|
||||
[node name="HeadAreaCollisionComponent" parent="." unique_id=1105156486 node_paths=PackedStringArray("BlackList") instance=ExtResource("3_j1g85")]
|
||||
UseBlackList = true
|
||||
BlackList = [NodePath("..")]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="HeadAreaCollisionComponent" unique_id=1935674248]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.525, 0)
|
||||
shape = SubResource("CapsuleShape3D_yjynp")
|
||||
|
||||
[node name="BottomCollisionComponent" parent="." unique_id=2140658375 node_paths=PackedStringArray("BlackList") instance=ExtResource("3_j1g85")]
|
||||
UseBlackList = true
|
||||
BlackList = [NodePath("..")]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="BottomCollisionComponent" unique_id=659234250]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.75, 0)
|
||||
shape = SubResource("CapsuleShape3D_7jddb")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1046949660]
|
||||
mesh = SubResource("CapsuleMesh_yjynp")
|
||||
109
scenes/levels/Playground.tscn
Normal file
109
scenes/levels/Playground.tscn
Normal file
@@ -0,0 +1,109 @@
|
||||
[gd_scene format=3 uid="uid://d3wq6hfxq4rd6"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bq6kfyf88kofe" path="res://assets/textures/debug/64.png" id="1_pwpi7"]
|
||||
[ext_resource type="PackedScene" uid="uid://f2oncv0p7qxy" path="res://scenes/entities/Player.tscn" id="2_x5x4g"]
|
||||
[ext_resource type="PackedScene" uid="uid://b58fh1sxljslo" path="res://scenes/objects/Cube.tscn" id="3_17ysi"]
|
||||
[ext_resource type="Texture2D" uid="uid://cl65sdce7cjce" path="res://assets/textures/debug/32.png" id="5_qlr2e"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_x5x4g"]
|
||||
size = Vector3(100, 0, 100)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pwpi7"]
|
||||
albedo_texture = ExtResource("1_pwpi7")
|
||||
uv1_triplanar = true
|
||||
texture_filter = 0
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_x5x4g"]
|
||||
size = Vector2(100, 100)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_3tfcg"]
|
||||
size = Vector3(1, 1, 0.5)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1soqn"]
|
||||
albedo_texture = ExtResource("5_qlr2e")
|
||||
uv1_triplanar = true
|
||||
texture_filter = 0
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_p6fnf"]
|
||||
radius = 2.0
|
||||
height = 4.0
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_4kj4k"]
|
||||
radius = 2.0
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_17ysi"]
|
||||
radius = 6.0
|
||||
|
||||
[node name="Playground" type="Node3D" unique_id=17957055]
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1480957267]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=1646882894]
|
||||
shape = SubResource("BoxShape3D_x5x4g")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D" unique_id=809606401]
|
||||
material_override = SubResource("StandardMaterial3D_pwpi7")
|
||||
mesh = SubResource("PlaneMesh_x5x4g")
|
||||
|
||||
[node name="Player" parent="." unique_id=654871017 instance=ExtResource("2_x5x4g")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=672101208]
|
||||
transform = Transform3D(0.70710677, -0.49999994, 0.49999994, 0, 0.7071067, 0.7071067, -0.70710677, -0.49999994, 0.49999994, 0, 10, 0)
|
||||
light_energy = 2.0
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="Cube" parent="." unique_id=719944821 instance=ExtResource("3_17ysi")]
|
||||
transform = Transform3D(3, 0, 0, 0, 3, 0, 0, 0, 3, -3, 3, 0)
|
||||
|
||||
[node name="Cube2" parent="." unique_id=1962198599 instance=ExtResource("3_17ysi")]
|
||||
transform = Transform3D(2.598076, 1.5, 0, -1.5, 2.598076, 0, 0, 0, 3, 2, 3, 0)
|
||||
|
||||
[node name="Cube3" parent="." unique_id=1118073292 instance=ExtResource("3_17ysi")]
|
||||
transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 1, 0, 5, -6)
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="Cube3" unique_id=1790961879]
|
||||
transform = Transform3D(0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0, 1, 0, 0, 1)
|
||||
gravity_space_override = 3
|
||||
gravity_point_center = Vector3(0, 0, -1)
|
||||
gravity_direction = Vector3(0, 0, -1)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Cube3/Area3D" unique_id=915921693]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.25)
|
||||
shape = SubResource("BoxShape3D_3tfcg")
|
||||
|
||||
[node name="Cube4" parent="." unique_id=1726519300 instance=ExtResource("3_17ysi")]
|
||||
transform = Transform3D(8.693331, 2.3293712, 0, -2.3293712, 8.693331, 0, 0, 0, 9, 11.696152, -2.2057714, 9)
|
||||
|
||||
[node name="StaticBody3D2" type="StaticBody3D" parent="." unique_id=1146809951]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10, 8, 0)
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="StaticBody3D2" unique_id=2073891869]
|
||||
material_override = SubResource("StandardMaterial3D_1soqn")
|
||||
mesh = SubResource("SphereMesh_p6fnf")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D2" unique_id=2114568472]
|
||||
shape = SubResource("SphereShape3D_4kj4k")
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="StaticBody3D2" unique_id=2012831209]
|
||||
gravity_space_override = 3
|
||||
gravity_point = true
|
||||
gravity_point_center = Vector3(0, 0, 0)
|
||||
gravity_direction = Vector3(0, 0, 0)
|
||||
gravity = 4.9
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D2/Area3D" unique_id=1081208726]
|
||||
shape = SubResource("SphereShape3D_17ysi")
|
||||
|
||||
[node name="Cube5" parent="." unique_id=1676247518 instance=ExtResource("3_17ysi")]
|
||||
transform = Transform3D(-4.3711384e-07, 0, 0.99999994, 0, 9.999999, 0, -10, 0, -4.371139e-08, -5, 5, -1)
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="Cube5" unique_id=1308065252]
|
||||
transform = Transform3D(0.99999994, 0, 0, 0, 0.99999994, 0, 0, 0, 1, 0, 0, 1)
|
||||
gravity_space_override = 3
|
||||
gravity_point_center = Vector3(-1, 0, 0)
|
||||
gravity_direction = Vector3(-1, 0, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Cube5/Area3D" unique_id=927684454]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.25)
|
||||
shape = SubResource("BoxShape3D_3tfcg")
|
||||
22
scenes/objects/Cube.tscn
Normal file
22
scenes/objects/Cube.tscn
Normal file
@@ -0,0 +1,22 @@
|
||||
[gd_scene format=3 uid="uid://b58fh1sxljslo"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cl65sdce7cjce" path="res://assets/textures/debug/32.png" id="1_1r700"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_odh56"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dtkl6"]
|
||||
albedo_texture = ExtResource("1_1r700")
|
||||
uv1_triplanar = true
|
||||
texture_filter = 0
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_5l2nu"]
|
||||
|
||||
[node name="Cube" type="StaticBody3D" unique_id=719944821]
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=98294870]
|
||||
shape = SubResource("BoxShape3D_odh56")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=259688884]
|
||||
material_override = SubResource("StandardMaterial3D_dtkl6")
|
||||
mesh = SubResource("BoxMesh_5l2nu")
|
||||
22
scenes/ui/DebugScreen.tscn
Normal file
22
scenes/ui/DebugScreen.tscn
Normal file
@@ -0,0 +1,22 @@
|
||||
[gd_scene format=3 uid="uid://dfywog3xvaatq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bxfhkc44lo88c" path="res://source/Scripts/DebugScreen.cs" id="1_rvq7n"]
|
||||
|
||||
[node name="DebugScreen" type="Control" unique_id=412746030 node_paths=PackedStringArray("Text")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_rvq7n")
|
||||
Text = NodePath("RichTextLabel")
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="." unique_id=869388311]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = " FPS: {FPS}"
|
||||
24
scenes/ui/MainMenu.tscn
Normal file
24
scenes/ui/MainMenu.tscn
Normal file
@@ -0,0 +1,24 @@
|
||||
[gd_scene format=3 uid="uid://c86aaee0t6unc"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_0rmrm"]
|
||||
|
||||
[node name="MainMenu" type="Control" unique_id=1487626196]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = SubResource("Theme_0rmrm")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1745174404]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Button" type="Button" parent="VBoxContainer" unique_id=1720039221]
|
||||
layout_mode = 2
|
||||
text = "Exit"
|
||||
21
source/ComponentUtils.cs
Normal file
21
source/ComponentUtils.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace FactoryGame;
|
||||
|
||||
public class ComponentUtils {
|
||||
public static Array<T> GetComponents<[MustBeVariant] T>(Node node, int iterations = 1) where T : IComponent {
|
||||
var result = new Array<T>();
|
||||
|
||||
var children = node.GetChildren();
|
||||
foreach (var item in children) {
|
||||
if (item is T component)
|
||||
result.Add(component);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public static T? GetComponent<[MustBeVariant] T>(Node node, int index = 0) where T : IComponent =>
|
||||
GetComponents<T>(node)[index];
|
||||
}
|
||||
1
source/ComponentUtils.cs.uid
Normal file
1
source/ComponentUtils.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ruibfbsgsvnv
|
||||
3
source/Entities/IComponent.cs
Normal file
3
source/Entities/IComponent.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace FactoryGame.Entities;
|
||||
|
||||
public interface IComponent { }
|
||||
1
source/Entities/IComponent.cs.uid
Normal file
1
source/Entities/IComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://01l4dxjmuufm
|
||||
7
source/Entities/PlayerMovingState.cs
Normal file
7
source/Entities/PlayerMovingState.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace FactoryGame.Entities;
|
||||
|
||||
public enum PlayerMovingState {
|
||||
Walking,
|
||||
Crouching,
|
||||
Sprinting
|
||||
}
|
||||
1
source/Entities/PlayerMovingState.cs.uid
Normal file
1
source/Entities/PlayerMovingState.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bw5i8tvduw6xb
|
||||
47
source/Scripts/CameraController.cs
Normal file
47
source/Scripts/CameraController.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Godot;
|
||||
|
||||
using static FactoryGame.Utils.Constants.PropertyHints;
|
||||
|
||||
public partial class CameraController : Camera3D {
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float MouseSensitivity { get; set; } = 0.5f;
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float JoystickSensitivity { get; set; } = 0.5f;
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float DeadZone { get; set; } = 0.1f;
|
||||
|
||||
private float _lastX = 0f;
|
||||
private float _lastY = 0f;
|
||||
|
||||
private Node3D? _parent;
|
||||
|
||||
public override void _Ready() {
|
||||
_parent = GetParent<Node3D>();
|
||||
Input.MouseMode = Input.MouseModeEnum.Captured;
|
||||
}
|
||||
|
||||
public override void _Process(double delta) {
|
||||
var input = Input.GetVector("camera_left", "camera_right", "camera_up", "camera_down", DeadZone);
|
||||
RotateCamera(input * -(JoystickSensitivity / 10f));
|
||||
|
||||
base._Process(delta);
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event) {
|
||||
if (@event is InputEventMouseMotion mouseMotion)
|
||||
RotateCamera(new Vector2(mouseMotion.Relative.X, mouseMotion.Relative.Y) * -(MouseSensitivity / 100f));
|
||||
|
||||
base._Input(@event);
|
||||
}
|
||||
|
||||
private void RotateCamera(Vector2 direction) {
|
||||
if (direction == Vector2.Zero) return;
|
||||
|
||||
_parent?.RotateObjectLocal(Vector3.Up, direction.X);
|
||||
//_parent!.RotateY(direction.X);
|
||||
|
||||
var rotationX = Rotation.X + direction.Y;
|
||||
rotationX = Mathf.Clamp(rotationX, Mathf.DegToRad(-90), Mathf.DegToRad(90));
|
||||
Rotation = new Vector3(rotationX, Rotation.Y, Rotation.Z);
|
||||
}
|
||||
}
|
||||
1
source/Scripts/CameraController.cs.uid
Normal file
1
source/Scripts/CameraController.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cyl680l0b3hej
|
||||
75
source/Scripts/Components/CollisionComponent.cs
Normal file
75
source/Scripts/Components/CollisionComponent.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using FactoryGame.Entities;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class CollisionComponent : Area3D, IComponent {
|
||||
public enum CollisionComponentMode {
|
||||
Body,
|
||||
BodyShape,
|
||||
Area,
|
||||
AreaShape
|
||||
}
|
||||
[Export]
|
||||
public CollisionComponentMode Mode { get; set; } = CollisionComponentMode.Body;
|
||||
[ExportGroup("White List")]
|
||||
[Export]
|
||||
public bool UseWhiteList { get; set; }
|
||||
[Export]
|
||||
public Node3D[]? WhiteList { get; set; }
|
||||
[ExportGroup("Black List")]
|
||||
[Export]
|
||||
public bool UseBlackList { get; set; }
|
||||
[Export]
|
||||
public Node3D[]? BlackList { get; set; }
|
||||
|
||||
public IReadOnlyList<Node3D> Collisions => _collisions;
|
||||
private List<Node3D> _collisions = new();
|
||||
public override void _Ready() {
|
||||
switch (Mode) {
|
||||
case CollisionComponentMode.Body: {
|
||||
BodyEntered += (body) => Enter(body);
|
||||
BodyExited += (body) => Exit(body);
|
||||
}
|
||||
; break;
|
||||
case CollisionComponentMode.BodyShape: {
|
||||
BodyShapeEntered += (_, body, _, _) => Enter(body);
|
||||
BodyShapeExited += (_, body, _, _) => Exit(body);
|
||||
}
|
||||
; break;
|
||||
case CollisionComponentMode.Area: {
|
||||
AreaEntered += Enter;
|
||||
AreaEntered += Exit;
|
||||
}
|
||||
; break;
|
||||
case CollisionComponentMode.AreaShape: {
|
||||
AreaShapeEntered += (_, body, _, _) => Enter(body);
|
||||
AreaShapeEntered += (_, body, _, _) => Exit(body);
|
||||
}
|
||||
; break;
|
||||
}
|
||||
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
private void Enter(Node3D body) {
|
||||
if (CheckBody(body))
|
||||
_collisions.Add(body);
|
||||
}
|
||||
private void Exit(Node3D body) {
|
||||
if (_collisions.Contains(body))
|
||||
_collisions.Remove(body);
|
||||
}
|
||||
|
||||
private bool CheckBody(Node3D body) {
|
||||
if (UseBlackList && BlackList != null && BlackList.Contains(body))
|
||||
return false;
|
||||
if (UseWhiteList && WhiteList != null && !WhiteList.Contains(body))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsCollide() => _collisions.Count > 0;
|
||||
public bool IsCollide(Node3D body) => _collisions.Contains(body);
|
||||
}
|
||||
1
source/Scripts/Components/CollisionComponent.cs.uid
Normal file
1
source/Scripts/Components/CollisionComponent.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b1683v4e4gh38
|
||||
20
source/Scripts/DebugScreen.cs
Normal file
20
source/Scripts/DebugScreen.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Godot;
|
||||
|
||||
public partial class DebugScreen : Control {
|
||||
public static DebugScreen? Instance { get; private set; }
|
||||
|
||||
[Export]
|
||||
public RichTextLabel? Text { get; set; }
|
||||
|
||||
private string layout = string.Empty;
|
||||
public override void _Ready() {
|
||||
layout = Text!.Text;
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public override void _Process(double delta) {
|
||||
var text = layout;
|
||||
Text!.Text = layout.Replace("{FPS}", Engine.GetFramesPerSecond().ToString());
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
1
source/Scripts/DebugScreen.cs.uid
Normal file
1
source/Scripts/DebugScreen.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bxfhkc44lo88c
|
||||
193
source/Scripts/PlayerController.cs
Normal file
193
source/Scripts/PlayerController.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using FactoryGame.Entities;
|
||||
using Godot;
|
||||
|
||||
using static FactoryGame.Utils.Constants.PropertyHints;
|
||||
|
||||
public partial class PlayerController : CharacterBody3D {
|
||||
[ExportGroup("Nodes")]
|
||||
[Export]
|
||||
public CollisionShape3D? StandCollision { get; set; }
|
||||
[Export]
|
||||
public CollisionShape3D? CrouchCollision { get; set; }
|
||||
[Export]
|
||||
public CollisionComponent? HeadCollisionComponent { get; set; }
|
||||
[Export]
|
||||
public CollisionComponent? BottomCollisionComponent { get; set; }
|
||||
[Export]
|
||||
public Camera3D? Camera { get; set; }
|
||||
[Export]
|
||||
public Marker3D? StandCameraPosition { get; set; }
|
||||
[Export]
|
||||
public Marker3D? CrouchCameraPosition { get; set; }
|
||||
|
||||
[ExportGroup("Behavior")]
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float CameraSpeed { get; set; } = 0.25f;
|
||||
[Export(PropertyHint.Range, OctaveRange)]
|
||||
public float PushImpulse { get; set; } = 0.5f;
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float CeilingBounce { get; set; } = 0.3f;
|
||||
[Export]
|
||||
public PlayerMovingState MovingState {
|
||||
get => _movingState; set {
|
||||
if (_movingState == value) return;
|
||||
if (crouchLock) { _movingState = PlayerMovingState.Crouching; return; }
|
||||
|
||||
_movingState = value;
|
||||
StandCollision!.Disabled = !(_movingState == PlayerMovingState.Walking || _movingState == PlayerMovingState.Sprinting);
|
||||
CrouchCollision!.Disabled = _movingState != PlayerMovingState.Crouching;
|
||||
if (_movingState == PlayerMovingState.Walking || _movingState == PlayerMovingState.Sprinting)
|
||||
_cameraTargetPosition = StandCameraPosition!.Position;
|
||||
if (_movingState == PlayerMovingState.Crouching)
|
||||
_cameraTargetPosition = CrouchCameraPosition!.Position;
|
||||
}
|
||||
}
|
||||
private PlayerMovingState _movingState = PlayerMovingState.Walking;
|
||||
private bool crouchLock = false;
|
||||
|
||||
[ExportSubgroup("Gravity Stabilization")]
|
||||
[Export(PropertyHint.Range, TwoOctaveRange)]
|
||||
public float FlyGravityStabilizationSpeed { get; set; } = 2f;
|
||||
[Export(PropertyHint.Range, TwoOctaveRange)]
|
||||
public float FloorGravityStabilizationSpeed { get; set; } = 15f;
|
||||
public float GetCurrentGravityStabilizationSpeed() => BottomCollisionComponent!.IsCollide() ? FloorGravityStabilizationSpeed : FlyGravityStabilizationSpeed;
|
||||
|
||||
[ExportSubgroup("Movement")]
|
||||
[Export(PropertyHint.Range, OctaveRange)]
|
||||
public float MoveVelocity { get; set; } = 4f;
|
||||
[Export(PropertyHint.Range, OctaveRange)]
|
||||
public float CrouchVelocity { get; set; } = 2f;
|
||||
[Export(PropertyHint.Range, OctaveRange)]
|
||||
public float SprintVelocity { get; set; } = 8f;
|
||||
[Export(PropertyHint.Range, QuartRange)]
|
||||
public float FlyVelocityMultiplier { get; set; } = 1.05f;
|
||||
private float GetCurrentSpeed() {
|
||||
var speed = MovingState switch {
|
||||
PlayerMovingState.Walking => MoveVelocity,
|
||||
PlayerMovingState.Crouching => CrouchVelocity,
|
||||
PlayerMovingState.Sprinting => SprintVelocity,
|
||||
_ => MoveVelocity
|
||||
};
|
||||
|
||||
if (!IsOnFloor()) return FlyVelocityMultiplier * speed;
|
||||
return speed;
|
||||
}
|
||||
[Export(PropertyHint.Range, OctaveRange)]
|
||||
public float JumpVelocity { get; set; } = 4f;
|
||||
|
||||
[ExportSubgroup("Friction")]
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float MoveFriction { get; set; } = 0.5f;
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float CrouchFriction { get; set; } = 0.2f;
|
||||
[Export(PropertyHint.Range, OctaveRange)]
|
||||
public float SprintFriction { get; set; } = 0.6f;
|
||||
[Export(PropertyHint.Range, PrimaRange)]
|
||||
public float FlyFriction { get; set; } = 0.1f;
|
||||
private float GetCurrentFriction() => !IsOnFloor() ? FlyFriction : MovingState switch {
|
||||
PlayerMovingState.Walking => MoveFriction,
|
||||
PlayerMovingState.Crouching => CrouchFriction,
|
||||
PlayerMovingState.Sprinting => SprintFriction,
|
||||
_ => MoveFriction
|
||||
};
|
||||
|
||||
public override void _Ready() {
|
||||
_cameraTargetPosition = Camera!.Position;
|
||||
HeadCollisionComponent!.BodyEntered += (_) => ProceedCrouchingCheck(HeadCollisionComponent!);
|
||||
HeadCollisionComponent!.BodyExited += (_) => ProceedCrouchingCheck(HeadCollisionComponent!);
|
||||
|
||||
base._Ready();
|
||||
}
|
||||
public override void _PhysicsProcess(double delta) {
|
||||
var fDelta = (float)delta;
|
||||
UpdatePlayerOrientation(fDelta);
|
||||
|
||||
var gravity = ProceedGravityVelocity(fDelta);
|
||||
var move = ProceedMoveVelocity(fDelta);
|
||||
|
||||
Velocity = gravity + move;
|
||||
MoveAndSlide();
|
||||
|
||||
Push();
|
||||
|
||||
base._PhysicsProcess(delta);
|
||||
}
|
||||
|
||||
private void ProceedCrouchingCheck(CollisionComponent collisionComponent) {
|
||||
if (collisionComponent.IsCollide()) {
|
||||
crouchLock = true;
|
||||
MovingState = PlayerMovingState.Crouching;
|
||||
} else crouchLock = false;
|
||||
}
|
||||
|
||||
private void UpdatePlayerOrientation(float delta) {
|
||||
var gravity = GetGravity();
|
||||
if (gravity == Vector3.Zero) return;
|
||||
|
||||
UpDirection = -gravity;
|
||||
var objectBottomDirection = -Transform.Basis.Y;
|
||||
var angleToTarget = objectBottomDirection.AngleTo(gravity);
|
||||
|
||||
var rotationAxis = objectBottomDirection.Cross(gravity).Normalized();
|
||||
|
||||
var interpolatedAngle = Mathf.Lerp(0, angleToTarget, GetCurrentGravityStabilizationSpeed() * delta);
|
||||
if (rotationAxis.IsNormalized())
|
||||
Rotate(rotationAxis, interpolatedAngle);
|
||||
}
|
||||
|
||||
private Vector3 _gravityVelocity = Vector3.Zero;
|
||||
private Vector3 ProceedGravityVelocity(float delta) {
|
||||
var localUp = GlobalTransform.Basis.Y;
|
||||
var gravityForce = GetGravity();
|
||||
|
||||
if (IsOnFloor()) {
|
||||
_gravityVelocity = gravityForce.Normalized() * 0.1f;
|
||||
|
||||
if (Input.IsActionPressed("move_jump"))
|
||||
_gravityVelocity = localUp * JumpVelocity;
|
||||
|
||||
return _gravityVelocity;
|
||||
}
|
||||
|
||||
if (IsOnCeiling() && GetSlideCollisionCount() > 0) {
|
||||
var normal = GetLastSlideCollision().GetNormal();
|
||||
if (_gravityVelocity.Dot(localUp) > 0 && normal.Dot(localUp) < -0.5f)
|
||||
_gravityVelocity = _gravityVelocity.Bounce(normal) * CeilingBounce;
|
||||
}
|
||||
|
||||
_gravityVelocity += gravityForce * delta;
|
||||
return _gravityVelocity;
|
||||
}
|
||||
|
||||
private Vector3 _cameraTargetPosition;
|
||||
private Vector3 _moveVelocity = Vector3.Zero;
|
||||
private Vector3 ProceedMoveVelocity(float delta) {
|
||||
var movingState = Input.IsActionPressed("action_sprint") ? PlayerMovingState.Sprinting : PlayerMovingState.Walking;
|
||||
movingState = Input.IsActionPressed("action_crouch") ? PlayerMovingState.Crouching : movingState;
|
||||
MovingState = movingState;
|
||||
|
||||
Camera!.Position = Camera!.Position.Lerp(_cameraTargetPosition, CameraSpeed);
|
||||
|
||||
var inputDir = Input.GetVector("move_left", "move_right", "move_forward", "move_backward");
|
||||
|
||||
var dir = (GlobalTransform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
||||
|
||||
if (inputDir == Vector2.Zero)
|
||||
_moveVelocity = _moveVelocity.Lerp(Vector3.Zero, GetCurrentFriction());
|
||||
else
|
||||
_moveVelocity = dir * GetCurrentSpeed();
|
||||
|
||||
return _moveVelocity;
|
||||
}
|
||||
|
||||
private void Push() {
|
||||
for (int i = 0; i < GetSlideCollisionCount(); i++) {
|
||||
var collision = GetSlideCollision(i);
|
||||
if (collision.GetCollider() is RigidBody3D body) {
|
||||
var pushDir = -collision.GetNormal();
|
||||
|
||||
body.ApplyCentralImpulse(pushDir * _moveVelocity.Length() * PushImpulse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
source/Scripts/PlayerController.cs.uid
Normal file
1
source/Scripts/PlayerController.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://chuyrnjbwvvf5
|
||||
11
source/Utils/Constants.cs
Normal file
11
source/Utils/Constants.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace FactoryGame.Utils;
|
||||
|
||||
public static class Constants {
|
||||
public static class PropertyHints {
|
||||
public const string PrimaRange = "0, 1, 0.05";
|
||||
public const string SecondRange = "0, 2, 0.1";
|
||||
public const string QuartRange = "0, 4, 0.2";
|
||||
public const string OctaveRange = "0, 8, 0.4";
|
||||
public const string TwoOctaveRange = "0, 16, 0.8";
|
||||
}
|
||||
}
|
||||
1
source/Utils/Constants.cs.uid
Normal file
1
source/Utils/Constants.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cdy0yx7vgsl64
|
||||
Reference in New Issue
Block a user