diff --git a/.gitignore b/.gitignore index c8ef78f..5a0df97 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ mono_crash.*.json # Godot 4+ specific ignores .godot/ + +.idea \ No newline at end of file diff --git a/Carotrauma.csproj b/Carotrauma.csproj new file mode 100644 index 0000000..887d5d3 --- /dev/null +++ b/Carotrauma.csproj @@ -0,0 +1,8 @@ + + + net6.0 + net7.0 + net8.0 + true + + \ No newline at end of file diff --git a/Carotrauma.sln b/Carotrauma.sln new file mode 100644 index 0000000..42a2fc7 --- /dev/null +++ b/Carotrauma.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Carotrauma", "Carotrauma.csproj", "{BDD108D8-E663-4B77-9DCD-ED487C27EC83}" +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 + {BDD108D8-E663-4B77-9DCD-ED487C27EC83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDD108D8-E663-4B77-9DCD-ED487C27EC83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDD108D8-E663-4B77-9DCD-ED487C27EC83}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {BDD108D8-E663-4B77-9DCD-ED487C27EC83}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {BDD108D8-E663-4B77-9DCD-ED487C27EC83}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {BDD108D8-E663-4B77-9DCD-ED487C27EC83}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/export_presets.cfg b/export_presets.cfg index 19bae89..c95a41b 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -60,6 +60,9 @@ Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorActi ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue Remove-Item -Recurse -Force '{temp_dir}'" +dotnet/include_scripts_content=false +dotnet/include_debug_symbols=false +dotnet/embed_build_outputs=false [preset.1] @@ -100,3 +103,6 @@ unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") rm -rf \"{temp_dir}\"" +dotnet/include_scripts_content=false +dotnet/include_debug_symbols=false +dotnet/embed_build_outputs=false diff --git a/new_shader.tres b/new_shader.tres new file mode 100644 index 0000000..850b86d --- /dev/null +++ b/new_shader.tres @@ -0,0 +1,9 @@ +[gd_resource type="VisualShader" format=3 uid="uid://dxnq2lqe4hnpc"] + +[resource] +code = "shader_type spatial; +render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_lambert, specular_schlick_ggx; + + + +" diff --git a/project.godot b/project.godot index 884b87e..dce8767 100644 --- a/project.godot +++ b/project.godot @@ -11,10 +11,43 @@ config_version=5 [application] config/name="Carotrauma" -config/features=PackedStringArray("4.2", "Forward Plus") +run/main_scene="res://scenes/sandbox/sandbox_scene.tscn" +config/features=PackedStringArray("4.2", "C#", "Forward Plus") config/icon="res://icon.svg" +[dotnet] + +project/assembly_name="Carotrauma" + [editor] version_control/plugin_name="GitPlugin" version_control/autoload_on_startup=true + +[input] + +move_left={ +"deadzone": 0.5, +"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,"echo":false,"script":null) +] +} +move_right={ +"deadzone": 0.5, +"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,"echo":false,"script":null) +] +} +move_forward={ +"deadzone": 0.5, +"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,"echo":false,"script":null) +] +} +move_back={ +"deadzone": 0.5, +"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,"echo":false,"script":null) +] +} +jump={ +"deadzone": 0.5, +"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,"echo":false,"script":null) +] +} diff --git a/scenes/sandbox/player/SandboxPlayer.cs b/scenes/sandbox/player/SandboxPlayer.cs new file mode 100644 index 0000000..49a89c4 --- /dev/null +++ b/scenes/sandbox/player/SandboxPlayer.cs @@ -0,0 +1,70 @@ +using Godot; +using System; + +public partial class SandboxPlayer : CharacterBody3D +{ + + [Export] + public float Speed = 5.0f; + [Export] + public float JumpVelocity = 4.5f; + + // Get the gravity from the project settings to be synced with RigidBody nodes. + public float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle(); + + private float camera_anglev = 0; + private Camera3D cam; + + public override void _Ready() { + cam = GetChild(3, true); + } + + + public static float ToRadians (float degrees) { + // Angle in 10th of a degree + return (float)((degrees * Math.PI)/180.0f); + } + + public override void _Input(InputEvent @event) { + if (@event is InputEventMouseMotion) { + var M = (InputEventMouseMotion)@event; + cam.RotateY(ToRadians(-M.Relative.X * 0.3f)); + var changeV = -M.Relative.Y * 0.3f; + if (camera_anglev + changeV > -50 && camera_anglev + changeV < 50) { + camera_anglev += changeV; + cam.RotateX(ToRadians(changeV)); + } + GetViewport().SetInputAsHandled(); + } + } + + public override void _PhysicsProcess(double delta) { + Vector3 velocity = Velocity; + + // Add the gravity. + if (!IsOnFloor()) + velocity.Y -= gravity * (float)delta; + + // Handle Jump. + if (Input.IsActionJustPressed("jump") && IsOnFloor()) + velocity.Y = JumpVelocity; + + // Get the input direction and handle the movement/deceleration. + // As good practice, you should replace UI actions with custom gameplay actions. + Vector2 inputDir = Input.GetVector("move_left", "move_right", "move_forward", "move_back");; + Vector3 direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized(); + if (direction != Vector3.Zero) + { + velocity.X = direction.X * Speed; + velocity.Z = direction.Z * Speed; + } + else + { + velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed); + velocity.Z = Mathf.MoveToward(Velocity.Z, 0, Speed); + } + + Velocity = velocity; + MoveAndSlide(); + } +} diff --git a/scenes/sandbox/player/player_scene.tscn b/scenes/sandbox/player/player_scene.tscn new file mode 100644 index 0000000..6674ae8 --- /dev/null +++ b/scenes/sandbox/player/player_scene.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=4 format=3 uid="uid://v5iatrrwgror"] + +[ext_resource type="Script" path="res://scenes/sandbox/player/SandboxPlayer.cs" id="1_auraj"] + +[sub_resource type="CapsuleMesh" id="CapsuleMesh_orax3"] + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_4fhb2"] + +[node name="Player" type="CharacterBody3D"] +script = ExtResource("1_auraj") + +[node name="CSGMesh3D" type="CSGMesh3D" parent="."] +mesh = SubResource("CapsuleMesh_orax3") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("CapsuleShape3D_4fhb2") + +[node name="CSGBox3D" type="CSGBox3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.436351, 0.458557, 0) +size = Vector3(0.5, 0.25, 0.25) + +[node name="Camera" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.944686, 0.327976, 0, -0.327976, 0.944686, 0, 1.61751, 2.35265) diff --git a/scenes/sandbox/sandbox_scene.tscn b/scenes/sandbox/sandbox_scene.tscn new file mode 100644 index 0000000..844475a --- /dev/null +++ b/scenes/sandbox/sandbox_scene.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=6 format=3 uid="uid://c3hv3mdy52mar"] + +[ext_resource type="PackedScene" uid="uid://v5iatrrwgror" path="res://scenes/sandbox/player/player_scene.tscn" id="1_6lr48"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_tcgka"] +size = Vector3(60, 2, 60) + +[sub_resource type="BoxMesh" id="BoxMesh_u6qt5"] +size = Vector3(60, 2, 60) + +[sub_resource type="SphereShape3D" id="SphereShape3D_31ll2"] + +[sub_resource type="SphereMesh" id="SphereMesh_gsyqq"] + +[node name="Main" type="Node"] + +[node name="Ground" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Ground"] +shape = SubResource("BoxShape3D_tcgka") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"] +mesh = SubResource("BoxMesh_u6qt5") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.77844, -0.360888, 0.513606, 0, 0.81821, 0.57492, -0.627719, -0.447541, 0.636928, 7.0759, 14.6786, 9.0239) +shadow_enabled = true + +[node name="Ball" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.95648, 10.636, 6.23691) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Ball"] +shape = SubResource("SphereShape3D_31ll2") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Ball"] +mesh = SubResource("SphereMesh_gsyqq") + +[node name="Player" parent="." instance=ExtResource("1_6lr48")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.04543, 0) diff --git a/scenes/title/QuitButton.cs b/scenes/title/QuitButton.cs new file mode 100644 index 0000000..c849d2c --- /dev/null +++ b/scenes/title/QuitButton.cs @@ -0,0 +1,15 @@ +using Godot; +using System; + +public partial class QuitButton : Button +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() { + Text = "Quit"; + Pressed += OnPressed; + } + + private void OnPressed() { + GetTree().Quit(); + } +} diff --git a/scenes/title/title_scene.tscn b/scenes/title/title_scene.tscn new file mode 100644 index 0000000..67de24f --- /dev/null +++ b/scenes/title/title_scene.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://bgi564yk5w1ik"] + +[ext_resource type="PackedScene" uid="uid://6fwfumgwq52t" path="res://scenes/title/title_ui.tscn" id="1_nbtb5"] + +[node name="TitleScene" type="Node2D"] + +[node name="TitleUi" parent="." instance=ExtResource("1_nbtb5")] +size_flags_horizontal = 3 +size_flags_vertical = 3 diff --git a/scenes/title/title_ui.tscn b/scenes/title/title_ui.tscn new file mode 100644 index 0000000..7156adf --- /dev/null +++ b/scenes/title/title_ui.tscn @@ -0,0 +1,65 @@ +[gd_scene load_steps=3 format=3 uid="uid://6fwfumgwq52t"] + +[ext_resource type="Texture2D" uid="uid://5q8mhw7g6vh6" path="res://icon.svg" id="1_pcdb4"] +[ext_resource type="Script" path="res://scenes/title/QuitButton.cs" id="2_51i4u"] + +[node name="TitleUi" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 100.0 +offset_top = 100.0 +offset_right = -100.0 +offset_bottom = -100.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] +layout_mode = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="TextureRect" type="TextureRect" parent="MarginContainer/HBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 4 +size_flags_stretch_ratio = 0.0 +texture = ExtResource("1_pcdb4") + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 6 + +[node name="PlayButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/VBoxContainer"] +layout_mode = 2 +text = "New Game" + +[node name="OptionsButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/VBoxContainer"] +layout_mode = 2 +text = "Options" + +[node name="QuitButton" type="Button" parent="MarginContainer/HBoxContainer/VBoxContainer/VBoxContainer/VBoxContainer"] +layout_mode = 2 +script = ExtResource("2_51i4u") + +[node name="TextureRect2" type="TextureRect" parent="MarginContainer/HBoxContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 4 +size_flags_stretch_ratio = 0.0 +texture = ExtResource("1_pcdb4") + +[node name="VBoxContainer2" type="VBoxContainer" parent="MarginContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 diff --git a/scripts/QuitScript.gd b/scripts/QuitScript.gd new file mode 100644 index 0000000..b68bf5a --- /dev/null +++ b/scripts/QuitScript.gd @@ -0,0 +1,16 @@ +extends Node + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _notification(what): + print("NOTIFICATION: " + what) + if what == NOTIFICATION_WM_CLOSE_REQUEST: + get_tree().quit()