diff --git a/.gdextension b/.gdextension new file mode 100644 index 0000000..e69de29 diff --git a/.gdignore b/.gdignore new file mode 100644 index 0000000..3a48128 --- /dev/null +++ b/.gdignore @@ -0,0 +1,3 @@ +Containerfile +helm +rust/src diff --git a/.gitignore b/.gitignore index 4709183..0ca4e28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Godot 4+ specific ignores .godot/ +rust/target diff --git a/.woodpecker.yaml b/.woodpecker.yaml new file mode 100644 index 0000000..fc217f3 --- /dev/null +++ b/.woodpecker.yaml @@ -0,0 +1,26 @@ +--- +when: + event: + - push + +steps: + - name: Build and push a container image + image: zot.badhouseplants.net/badhouseplants/badhouseplants-builder:latest + environment: + BUILDAH_REG: zot.badhouseplants.net/badhouseplants/open-strike + privileged: true + secrets: + - registry_token + commands: + - build-container + backend_options: + kubernetes: + resources: + requests: + memory: 700Mi + cpu: 1000m + limits: + cpu: 1000m + securityContext: + privileged: true + diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..d57449d --- /dev/null +++ b/Containerfile @@ -0,0 +1,39 @@ +FROM rust:1.84.1 AS lib_builder +RUN apt-get update -y && apt-get install -y gcc musl-dev build-essential pkg-config cmake +RUN rustup toolchain install stable +WORKDIR /src +COPY rust/ . +RUN cargo build + +FROM ghcr.io/allanger/dumb-downloader as dudo +RUN apt-get update -y && apt-get install unzip -y +ENV RUST_LOG=info +ENV GODOT_VERSION=4.3 +WORKDIR /out +RUN dudo -l "https://github.com/godotengine/godot/releases/download/{{ version }}-stable/Godot_v{{ version }}-stable_{{ os }}.{{ arch }}.zip" -d /tmp/godot.zip -p $GODOT_VERSION +RUN cd /tmp && unzip godot.zip && rm -f godot.zip +RUN sh -c 'find /tmp -type f -print0 -name "Godot*" | xargs --null -I{} mv {} godot' + +RUN dudo -l "https://github.com/godotengine/godot/releases/download/{{ version }}-stable/Godot_v{{ version }}-stable_export_templates.tpz" -d /tmp/export_templates.zip -p $GODOT_VERSION +RUN cd /tmp && unzip export_templates.zip && rm -f export_templates.zip +RUN ls /tmp +RUN mkdir -p /out/templates +RUN sh -c 'cd /tmp && find . -type f -print0 -name "Godot*" | xargs --null -I{} mv {} /out/{}' +RUN chmod +x /out/godot + +FROM ubuntu as builder +RUN apt-get update -y && apt-get install fontconfig -y +WORKDIR /src +COPY --from=dudo /out/godot /usr/bin/godot +COPY --from=lib_builder /src/target/debug/libopen_strike_2.so /src/rust/target/debug/libopen_strike_2.so +RUN mkdir -p /root/.local/share/godot/export_templates/4.3.stable/ +COPY --from=dudo /out/templates /root/.local/share/godot/export_templates/4.3.stable +COPY . . +RUN mkdir /out +RUN godot --verbose --headless --export-debug "[Dedicated Server] Linux" /out/open_strike + +FROM ubuntu +RUN apt-get update -y && apt-get install fontconfig -y +WORKDIR /app +COPY --from=builder /out . +CMD ["/app/open_strike.sh"] diff --git a/addons/kenney_prototype_textures/dark/texture_01.png.import b/addons/kenney_prototype_textures/dark/texture_01.png.import index 1675cb3..6154790 100644 --- a/addons/kenney_prototype_textures/dark/texture_01.png.import +++ b/addons/kenney_prototype_textures/dark/texture_01.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://dmge3tk7w0b1n" path.s3tc="res://.godot/imported/texture_01.png-60e3b3d3143b179c069dbcbff77ff160.s3tc.ctex" +path.etc2="res://.godot/imported/texture_01.png-60e3b3d3143b179c069dbcbff77ff160.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_01.png" -dest_files=["res://.godot/imported/texture_01.png-60e3b3d3143b179c069dbcbff77ff160.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_01.png-60e3b3d3143b179c069dbcbff77ff160.s3tc.ctex", "res://.godot/imported/texture_01.png-60e3b3d3143b179c069dbcbff77ff160.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_02.png.import b/addons/kenney_prototype_textures/dark/texture_02.png.import index b1e82df..e465feb 100644 --- a/addons/kenney_prototype_textures/dark/texture_02.png.import +++ b/addons/kenney_prototype_textures/dark/texture_02.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://bawho1fs8uowk" path.s3tc="res://.godot/imported/texture_02.png-814d4f515892bb8274d285748f4a73a0.s3tc.ctex" +path.etc2="res://.godot/imported/texture_02.png-814d4f515892bb8274d285748f4a73a0.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_02.png" -dest_files=["res://.godot/imported/texture_02.png-814d4f515892bb8274d285748f4a73a0.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_02.png-814d4f515892bb8274d285748f4a73a0.s3tc.ctex", "res://.godot/imported/texture_02.png-814d4f515892bb8274d285748f4a73a0.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_03.png.import b/addons/kenney_prototype_textures/dark/texture_03.png.import index 6ffa424..6b73f73 100644 --- a/addons/kenney_prototype_textures/dark/texture_03.png.import +++ b/addons/kenney_prototype_textures/dark/texture_03.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://kijtpalgio4q" path.s3tc="res://.godot/imported/texture_03.png-eef45c22e5a84c5df22e7f80e41112c6.s3tc.ctex" +path.etc2="res://.godot/imported/texture_03.png-eef45c22e5a84c5df22e7f80e41112c6.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_03.png" -dest_files=["res://.godot/imported/texture_03.png-eef45c22e5a84c5df22e7f80e41112c6.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_03.png-eef45c22e5a84c5df22e7f80e41112c6.s3tc.ctex", "res://.godot/imported/texture_03.png-eef45c22e5a84c5df22e7f80e41112c6.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_04.png.import b/addons/kenney_prototype_textures/dark/texture_04.png.import index 0624d64..44ab4c5 100644 --- a/addons/kenney_prototype_textures/dark/texture_04.png.import +++ b/addons/kenney_prototype_textures/dark/texture_04.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://e4nd8b6f0tw7" path.s3tc="res://.godot/imported/texture_04.png-af505c12b2a7903458bb29299e718506.s3tc.ctex" +path.etc2="res://.godot/imported/texture_04.png-af505c12b2a7903458bb29299e718506.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_04.png" -dest_files=["res://.godot/imported/texture_04.png-af505c12b2a7903458bb29299e718506.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_04.png-af505c12b2a7903458bb29299e718506.s3tc.ctex", "res://.godot/imported/texture_04.png-af505c12b2a7903458bb29299e718506.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_06.png.import b/addons/kenney_prototype_textures/dark/texture_06.png.import index 8d1dc4f..7ae42ad 100644 --- a/addons/kenney_prototype_textures/dark/texture_06.png.import +++ b/addons/kenney_prototype_textures/dark/texture_06.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://du0f7hc4skged" path.s3tc="res://.godot/imported/texture_06.png-004ed3d5b88361cdfb83a20714e917e7.s3tc.ctex" +path.etc2="res://.godot/imported/texture_06.png-004ed3d5b88361cdfb83a20714e917e7.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_06.png" -dest_files=["res://.godot/imported/texture_06.png-004ed3d5b88361cdfb83a20714e917e7.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_06.png-004ed3d5b88361cdfb83a20714e917e7.s3tc.ctex", "res://.godot/imported/texture_06.png-004ed3d5b88361cdfb83a20714e917e7.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_07.png.import b/addons/kenney_prototype_textures/dark/texture_07.png.import index 66f733e..affd62e 100644 --- a/addons/kenney_prototype_textures/dark/texture_07.png.import +++ b/addons/kenney_prototype_textures/dark/texture_07.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://bg7hbu285xx3c" path.s3tc="res://.godot/imported/texture_07.png-7c77ff22e41b4a54319073cb71530d81.s3tc.ctex" +path.etc2="res://.godot/imported/texture_07.png-7c77ff22e41b4a54319073cb71530d81.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_07.png" -dest_files=["res://.godot/imported/texture_07.png-7c77ff22e41b4a54319073cb71530d81.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_07.png-7c77ff22e41b4a54319073cb71530d81.s3tc.ctex", "res://.godot/imported/texture_07.png-7c77ff22e41b4a54319073cb71530d81.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_08.png.import b/addons/kenney_prototype_textures/dark/texture_08.png.import index 4cf77b0..28b2cd3 100644 --- a/addons/kenney_prototype_textures/dark/texture_08.png.import +++ b/addons/kenney_prototype_textures/dark/texture_08.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://o0rxfy5dvpsb" path.s3tc="res://.godot/imported/texture_08.png-5883ddd047173c8b118ead887054e6fc.s3tc.ctex" +path.etc2="res://.godot/imported/texture_08.png-5883ddd047173c8b118ead887054e6fc.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_08.png" -dest_files=["res://.godot/imported/texture_08.png-5883ddd047173c8b118ead887054e6fc.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_08.png-5883ddd047173c8b118ead887054e6fc.s3tc.ctex", "res://.godot/imported/texture_08.png-5883ddd047173c8b118ead887054e6fc.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_09.png.import b/addons/kenney_prototype_textures/dark/texture_09.png.import index 81c72f1..e990591 100644 --- a/addons/kenney_prototype_textures/dark/texture_09.png.import +++ b/addons/kenney_prototype_textures/dark/texture_09.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://cxj3qslcw455r" path.s3tc="res://.godot/imported/texture_09.png-8e25cd5657e2d326068eb27bfa1aacec.s3tc.ctex" +path.etc2="res://.godot/imported/texture_09.png-8e25cd5657e2d326068eb27bfa1aacec.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_09.png" -dest_files=["res://.godot/imported/texture_09.png-8e25cd5657e2d326068eb27bfa1aacec.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_09.png-8e25cd5657e2d326068eb27bfa1aacec.s3tc.ctex", "res://.godot/imported/texture_09.png-8e25cd5657e2d326068eb27bfa1aacec.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_10.png.import b/addons/kenney_prototype_textures/dark/texture_10.png.import index 53c3f21..1d9b18a 100644 --- a/addons/kenney_prototype_textures/dark/texture_10.png.import +++ b/addons/kenney_prototype_textures/dark/texture_10.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://n25a1tlc20r2" path.s3tc="res://.godot/imported/texture_10.png-1e788999a192eabd201c3b3435475799.s3tc.ctex" +path.etc2="res://.godot/imported/texture_10.png-1e788999a192eabd201c3b3435475799.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_10.png" -dest_files=["res://.godot/imported/texture_10.png-1e788999a192eabd201c3b3435475799.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_10.png-1e788999a192eabd201c3b3435475799.s3tc.ctex", "res://.godot/imported/texture_10.png-1e788999a192eabd201c3b3435475799.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_11.png.import b/addons/kenney_prototype_textures/dark/texture_11.png.import index c32fe65..b075afd 100644 --- a/addons/kenney_prototype_textures/dark/texture_11.png.import +++ b/addons/kenney_prototype_textures/dark/texture_11.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://ciwwbgcpode0d" path.s3tc="res://.godot/imported/texture_11.png-f61ad46caf1a41d85454e490ec43c8ec.s3tc.ctex" +path.etc2="res://.godot/imported/texture_11.png-f61ad46caf1a41d85454e490ec43c8ec.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_11.png" -dest_files=["res://.godot/imported/texture_11.png-f61ad46caf1a41d85454e490ec43c8ec.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_11.png-f61ad46caf1a41d85454e490ec43c8ec.s3tc.ctex", "res://.godot/imported/texture_11.png-f61ad46caf1a41d85454e490ec43c8ec.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/dark/texture_12.png.import b/addons/kenney_prototype_textures/dark/texture_12.png.import index 504e71c..3037408 100644 --- a/addons/kenney_prototype_textures/dark/texture_12.png.import +++ b/addons/kenney_prototype_textures/dark/texture_12.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://dsf0exq5n4glb" path.s3tc="res://.godot/imported/texture_12.png-aa893b2c5354267551e55ec14bb1999b.s3tc.ctex" +path.etc2="res://.godot/imported/texture_12.png-aa893b2c5354267551e55ec14bb1999b.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/dark/texture_12.png" -dest_files=["res://.godot/imported/texture_12.png-aa893b2c5354267551e55ec14bb1999b.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_12.png-aa893b2c5354267551e55ec14bb1999b.s3tc.ctex", "res://.godot/imported/texture_12.png-aa893b2c5354267551e55ec14bb1999b.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/green/texture_01.png.import b/addons/kenney_prototype_textures/green/texture_01.png.import index ed305ab..55ac8d2 100644 --- a/addons/kenney_prototype_textures/green/texture_01.png.import +++ b/addons/kenney_prototype_textures/green/texture_01.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://brf3u1fddrxlq" path.s3tc="res://.godot/imported/texture_01.png-94ebd82494c839e91a05b9e1cc2750ca.s3tc.ctex" +path.etc2="res://.godot/imported/texture_01.png-94ebd82494c839e91a05b9e1cc2750ca.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/green/texture_01.png" -dest_files=["res://.godot/imported/texture_01.png-94ebd82494c839e91a05b9e1cc2750ca.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_01.png-94ebd82494c839e91a05b9e1cc2750ca.s3tc.ctex", "res://.godot/imported/texture_01.png-94ebd82494c839e91a05b9e1cc2750ca.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/green/texture_02.png.import b/addons/kenney_prototype_textures/green/texture_02.png.import index 7b4c3f1..b07b3b1 100644 --- a/addons/kenney_prototype_textures/green/texture_02.png.import +++ b/addons/kenney_prototype_textures/green/texture_02.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://yg2714dns88k" path.s3tc="res://.godot/imported/texture_02.png-aa1bb055b55bdc7c20e196b7286eebdf.s3tc.ctex" +path.etc2="res://.godot/imported/texture_02.png-aa1bb055b55bdc7c20e196b7286eebdf.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/green/texture_02.png" -dest_files=["res://.godot/imported/texture_02.png-aa1bb055b55bdc7c20e196b7286eebdf.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_02.png-aa1bb055b55bdc7c20e196b7286eebdf.s3tc.ctex", "res://.godot/imported/texture_02.png-aa1bb055b55bdc7c20e196b7286eebdf.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/green/texture_04.png.import b/addons/kenney_prototype_textures/green/texture_04.png.import index 8cc8d31..12252ed 100644 --- a/addons/kenney_prototype_textures/green/texture_04.png.import +++ b/addons/kenney_prototype_textures/green/texture_04.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://kbyfceu4geke" path.s3tc="res://.godot/imported/texture_04.png-4678cc1dfb831f775bdc30cfd7f78769.s3tc.ctex" +path.etc2="res://.godot/imported/texture_04.png-4678cc1dfb831f775bdc30cfd7f78769.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/green/texture_04.png" -dest_files=["res://.godot/imported/texture_04.png-4678cc1dfb831f775bdc30cfd7f78769.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_04.png-4678cc1dfb831f775bdc30cfd7f78769.s3tc.ctex", "res://.godot/imported/texture_04.png-4678cc1dfb831f775bdc30cfd7f78769.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/light/texture_01.png.import b/addons/kenney_prototype_textures/light/texture_01.png.import index 4232cf2..895ef6a 100644 --- a/addons/kenney_prototype_textures/light/texture_01.png.import +++ b/addons/kenney_prototype_textures/light/texture_01.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://dkaygit5l83nq" path.s3tc="res://.godot/imported/texture_01.png-e10423e44834e1b4a90c3134e446b32d.s3tc.ctex" +path.etc2="res://.godot/imported/texture_01.png-e10423e44834e1b4a90c3134e446b32d.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/light/texture_01.png" -dest_files=["res://.godot/imported/texture_01.png-e10423e44834e1b4a90c3134e446b32d.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_01.png-e10423e44834e1b4a90c3134e446b32d.s3tc.ctex", "res://.godot/imported/texture_01.png-e10423e44834e1b4a90c3134e446b32d.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/light/texture_02.png.import b/addons/kenney_prototype_textures/light/texture_02.png.import index dfcf621..2f6c05c 100644 --- a/addons/kenney_prototype_textures/light/texture_02.png.import +++ b/addons/kenney_prototype_textures/light/texture_02.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://bpgpb8fitgael" path.s3tc="res://.godot/imported/texture_02.png-ffde4d38b35463525c3815b255790206.s3tc.ctex" +path.etc2="res://.godot/imported/texture_02.png-ffde4d38b35463525c3815b255790206.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/light/texture_02.png" -dest_files=["res://.godot/imported/texture_02.png-ffde4d38b35463525c3815b255790206.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_02.png-ffde4d38b35463525c3815b255790206.s3tc.ctex", "res://.godot/imported/texture_02.png-ffde4d38b35463525c3815b255790206.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/orange/texture_01.png.import b/addons/kenney_prototype_textures/orange/texture_01.png.import index 1a524ca..d903d10 100644 --- a/addons/kenney_prototype_textures/orange/texture_01.png.import +++ b/addons/kenney_prototype_textures/orange/texture_01.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://dydo6bjsqw3fq" path.s3tc="res://.godot/imported/texture_01.png-2bf7db98e09b5b5073e8e8ca66419718.s3tc.ctex" +path.etc2="res://.godot/imported/texture_01.png-2bf7db98e09b5b5073e8e8ca66419718.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/orange/texture_01.png" -dest_files=["res://.godot/imported/texture_01.png-2bf7db98e09b5b5073e8e8ca66419718.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_01.png-2bf7db98e09b5b5073e8e8ca66419718.s3tc.ctex", "res://.godot/imported/texture_01.png-2bf7db98e09b5b5073e8e8ca66419718.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/orange/texture_02.png.import b/addons/kenney_prototype_textures/orange/texture_02.png.import index 5ffbaf0..455fb1a 100644 --- a/addons/kenney_prototype_textures/orange/texture_02.png.import +++ b/addons/kenney_prototype_textures/orange/texture_02.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://beclpsa6h0k4g" path.s3tc="res://.godot/imported/texture_02.png-4eab4e19c2171e5b0668b65373b74c6d.s3tc.ctex" +path.etc2="res://.godot/imported/texture_02.png-4eab4e19c2171e5b0668b65373b74c6d.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/orange/texture_02.png" -dest_files=["res://.godot/imported/texture_02.png-4eab4e19c2171e5b0668b65373b74c6d.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_02.png-4eab4e19c2171e5b0668b65373b74c6d.s3tc.ctex", "res://.godot/imported/texture_02.png-4eab4e19c2171e5b0668b65373b74c6d.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/orange/texture_09.png.import b/addons/kenney_prototype_textures/orange/texture_09.png.import index 796e535..ce0ae38 100644 --- a/addons/kenney_prototype_textures/orange/texture_09.png.import +++ b/addons/kenney_prototype_textures/orange/texture_09.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://c5uytbu1wc1bq" path.s3tc="res://.godot/imported/texture_09.png-d3e0d0da868b68102c983480f9cde71d.s3tc.ctex" +path.etc2="res://.godot/imported/texture_09.png-d3e0d0da868b68102c983480f9cde71d.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/orange/texture_09.png" -dest_files=["res://.godot/imported/texture_09.png-d3e0d0da868b68102c983480f9cde71d.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_09.png-d3e0d0da868b68102c983480f9cde71d.s3tc.ctex", "res://.godot/imported/texture_09.png-d3e0d0da868b68102c983480f9cde71d.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/orange/texture_10.png.import b/addons/kenney_prototype_textures/orange/texture_10.png.import index bd6ab0f..8483047 100644 --- a/addons/kenney_prototype_textures/orange/texture_10.png.import +++ b/addons/kenney_prototype_textures/orange/texture_10.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://fn1k1ebe2uhx" path.s3tc="res://.godot/imported/texture_10.png-6f0f09db66c0562f01b2d2954722e3af.s3tc.ctex" +path.etc2="res://.godot/imported/texture_10.png-6f0f09db66c0562f01b2d2954722e3af.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/orange/texture_10.png" -dest_files=["res://.godot/imported/texture_10.png-6f0f09db66c0562f01b2d2954722e3af.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_10.png-6f0f09db66c0562f01b2d2954722e3af.s3tc.ctex", "res://.godot/imported/texture_10.png-6f0f09db66c0562f01b2d2954722e3af.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/orange/texture_13.png.import b/addons/kenney_prototype_textures/orange/texture_13.png.import index d9c3a08..463f3f5 100644 --- a/addons/kenney_prototype_textures/orange/texture_13.png.import +++ b/addons/kenney_prototype_textures/orange/texture_13.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://d1nfjip21kjpu" path.s3tc="res://.godot/imported/texture_13.png-a11a0cfe132bc07bf4c480fd4334a284.s3tc.ctex" +path.etc2="res://.godot/imported/texture_13.png-a11a0cfe132bc07bf4c480fd4334a284.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/orange/texture_13.png" -dest_files=["res://.godot/imported/texture_13.png-a11a0cfe132bc07bf4c480fd4334a284.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_13.png-a11a0cfe132bc07bf4c480fd4334a284.s3tc.ctex", "res://.godot/imported/texture_13.png-a11a0cfe132bc07bf4c480fd4334a284.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/purple/texture_02.png.import b/addons/kenney_prototype_textures/purple/texture_02.png.import index 320c1f5..4a3e0f7 100644 --- a/addons/kenney_prototype_textures/purple/texture_02.png.import +++ b/addons/kenney_prototype_textures/purple/texture_02.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://dx31pblshvnjw" path.s3tc="res://.godot/imported/texture_02.png-fcb52d424cd62d43221e4153fa3176f8.s3tc.ctex" +path.etc2="res://.godot/imported/texture_02.png-fcb52d424cd62d43221e4153fa3176f8.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/purple/texture_02.png" -dest_files=["res://.godot/imported/texture_02.png-fcb52d424cd62d43221e4153fa3176f8.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_02.png-fcb52d424cd62d43221e4153fa3176f8.s3tc.ctex", "res://.godot/imported/texture_02.png-fcb52d424cd62d43221e4153fa3176f8.etc2.ctex"] [params] diff --git a/addons/kenney_prototype_textures/red/texture_02.png.import b/addons/kenney_prototype_textures/red/texture_02.png.import index b6e0636..da27c8c 100644 --- a/addons/kenney_prototype_textures/red/texture_02.png.import +++ b/addons/kenney_prototype_textures/red/texture_02.png.import @@ -4,15 +4,16 @@ importer="texture" type="CompressedTexture2D" uid="uid://coqym2otrhygu" path.s3tc="res://.godot/imported/texture_02.png-bb6eefc15212ba5b8098e9e672c21f12.s3tc.ctex" +path.etc2="res://.godot/imported/texture_02.png-bb6eefc15212ba5b8098e9e672c21f12.etc2.ctex" metadata={ -"imported_formats": ["s3tc_bptc"], +"imported_formats": ["s3tc_bptc", "etc2_astc"], "vram_texture": true } [deps] source_file="res://addons/kenney_prototype_textures/red/texture_02.png" -dest_files=["res://.godot/imported/texture_02.png-bb6eefc15212ba5b8098e9e672c21f12.s3tc.ctex"] +dest_files=["res://.godot/imported/texture_02.png-bb6eefc15212ba5b8098e9e672c21f12.s3tc.ctex", "res://.godot/imported/texture_02.png-bb6eefc15212ba5b8098e9e672c21f12.etc2.ctex"] [params] diff --git a/assets/models/low_poly_weapon/M9_Bayonet_M9_Bayonet.png.import b/assets/models/low_poly_weapon/M9_Bayonet_M9_Bayonet.png.import index 2973521..b8de0f0 100644 --- a/assets/models/low_poly_weapon/M9_Bayonet_M9_Bayonet.png.import +++ b/assets/models/low_poly_weapon/M9_Bayonet_M9_Bayonet.png.import @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6f437a2a35441d67e1b7dd399dc5efbefb68d5ad8e35a5b1f0340531d88122bf -size 941 +oid sha256:42ee40f7d9746ed4720b15122c3ed43c224100aed57057bfc4021b406e9b56f1 +size 1151 diff --git a/assets/models/maps/el_test_Image_0.png.import b/assets/models/maps/el_test_Image_0.png.import index 2ecc121..dff863f 100644 --- a/assets/models/maps/el_test_Image_0.png.import +++ b/assets/models/maps/el_test_Image_0.png.import @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cb95a680ea14d3b14c4c21c936092592b18e1f2612ce71f0e58d3cb494ad721b -size 912 +oid sha256:f5956a6f0ce4b074e8c041b4f241d6216939e259d181a73d860392a57b747744 +size 1110 diff --git a/assets/models/maps/el_test_Image_1.png.import b/assets/models/maps/el_test_Image_1.png.import index 4e471b2..0628ed4 100644 --- a/assets/models/maps/el_test_Image_1.png.import +++ b/assets/models/maps/el_test_Image_1.png.import @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33d661dd2502095dd1701100629225ecbfdeb94e6d66b58e896d4e26c397a4ce -size 913 +oid sha256:d6a3a96d7372090a9bd934992812823efe671b4a4de72cf0e671c7d32d2e3e30 +size 1111 diff --git a/assets/models/maps/el_test_Image_2.png.import b/assets/models/maps/el_test_Image_2.png.import index 9c3349b..835ccb0 100644 --- a/assets/models/maps/el_test_Image_2.png.import +++ b/assets/models/maps/el_test_Image_2.png.import @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:61ab462102e7ed00253e326bf2259d181ca1fb7df2c4a19c93d954c8012ec015 -size 912 +oid sha256:1c1268afe56914c6fe16703f84683540bec0b872b7c3d73aad0b525db2d6609f +size 1110 diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..95a556d --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,548 @@ +[preset.0] + +name="[Dedicated Server] MacOS" +platform="macOS" +runnable=true +advanced_options=false +dedicated_server=true +custom_features="" +export_filter="customized" +customized_files={ +"res://": "strip" +} +include_filter="" +exclude_filter="" +export_path="./Open Strike.dmg" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.0.options] + +export/distribution_type=0 +binary_format/architecture="universal" +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +application/icon="" +application/icon_interpolation=4 +application/bundle_identifier="test" +application/signature="" +application/app_category="Games" +application/short_version="" +application/version="" +application/copyright="" +application/copyright_localized={} +application/min_macos_version="10.12" +application/export_angle=0 +display/high_res=true +application/additional_plist_content="" +xcode/platform_build="14C18" +xcode/sdk_version="13.1" +xcode/sdk_build="22C55" +xcode/sdk_name="macosx13.1" +xcode/xcode_version="1420" +xcode/xcode_build="14C18" +codesign/codesign=3 +codesign/installer_identity="" +codesign/apple_team_id="" +codesign/identity="" +codesign/entitlements/custom_file="" +codesign/entitlements/allow_jit_code_execution=false +codesign/entitlements/allow_unsigned_executable_memory=false +codesign/entitlements/allow_dyld_environment_variables=false +codesign/entitlements/disable_library_validation=false +codesign/entitlements/audio_input=false +codesign/entitlements/camera=false +codesign/entitlements/location=false +codesign/entitlements/address_book=false +codesign/entitlements/calendars=false +codesign/entitlements/photos_library=false +codesign/entitlements/apple_events=false +codesign/entitlements/debugging=false +codesign/entitlements/app_sandbox/enabled=false +codesign/entitlements/app_sandbox/network_server=false +codesign/entitlements/app_sandbox/network_client=false +codesign/entitlements/app_sandbox/device_usb=false +codesign/entitlements/app_sandbox/device_bluetooth=false +codesign/entitlements/app_sandbox/files_downloads=0 +codesign/entitlements/app_sandbox/files_pictures=0 +codesign/entitlements/app_sandbox/files_music=0 +codesign/entitlements/app_sandbox/files_movies=0 +codesign/entitlements/app_sandbox/files_user_selected=0 +codesign/entitlements/app_sandbox/helper_executables=[] +codesign/custom_options=PackedStringArray() +notarization/notarization=0 +privacy/microphone_usage_description="" +privacy/microphone_usage_description_localized={} +privacy/camera_usage_description="" +privacy/camera_usage_description_localized={} +privacy/location_usage_description="" +privacy/location_usage_description_localized={} +privacy/address_book_usage_description="" +privacy/address_book_usage_description_localized={} +privacy/calendar_usage_description="" +privacy/calendar_usage_description_localized={} +privacy/photos_library_usage_description="" +privacy/photos_library_usage_description_localized={} +privacy/desktop_folder_usage_description="" +privacy/desktop_folder_usage_description_localized={} +privacy/documents_folder_usage_description="" +privacy/documents_folder_usage_description_localized={} +privacy/downloads_folder_usage_description="" +privacy/downloads_folder_usage_description_localized={} +privacy/network_volumes_usage_description="" +privacy/network_volumes_usage_description_localized={} +privacy/removable_volumes_usage_description="" +privacy/removable_volumes_usage_description_localized={} +privacy/tracking_enabled=false +privacy/tracking_domains=PackedStringArray() +privacy/collected_data/name/collected=false +privacy/collected_data/name/linked_to_user=false +privacy/collected_data/name/used_for_tracking=false +privacy/collected_data/name/collection_purposes=0 +privacy/collected_data/email_address/collected=false +privacy/collected_data/email_address/linked_to_user=false +privacy/collected_data/email_address/used_for_tracking=false +privacy/collected_data/email_address/collection_purposes=0 +privacy/collected_data/phone_number/collected=false +privacy/collected_data/phone_number/linked_to_user=false +privacy/collected_data/phone_number/used_for_tracking=false +privacy/collected_data/phone_number/collection_purposes=0 +privacy/collected_data/physical_address/collected=false +privacy/collected_data/physical_address/linked_to_user=false +privacy/collected_data/physical_address/used_for_tracking=false +privacy/collected_data/physical_address/collection_purposes=0 +privacy/collected_data/other_contact_info/collected=false +privacy/collected_data/other_contact_info/linked_to_user=false +privacy/collected_data/other_contact_info/used_for_tracking=false +privacy/collected_data/other_contact_info/collection_purposes=0 +privacy/collected_data/health/collected=false +privacy/collected_data/health/linked_to_user=false +privacy/collected_data/health/used_for_tracking=false +privacy/collected_data/health/collection_purposes=0 +privacy/collected_data/fitness/collected=false +privacy/collected_data/fitness/linked_to_user=false +privacy/collected_data/fitness/used_for_tracking=false +privacy/collected_data/fitness/collection_purposes=0 +privacy/collected_data/payment_info/collected=false +privacy/collected_data/payment_info/linked_to_user=false +privacy/collected_data/payment_info/used_for_tracking=false +privacy/collected_data/payment_info/collection_purposes=0 +privacy/collected_data/credit_info/collected=false +privacy/collected_data/credit_info/linked_to_user=false +privacy/collected_data/credit_info/used_for_tracking=false +privacy/collected_data/credit_info/collection_purposes=0 +privacy/collected_data/other_financial_info/collected=false +privacy/collected_data/other_financial_info/linked_to_user=false +privacy/collected_data/other_financial_info/used_for_tracking=false +privacy/collected_data/other_financial_info/collection_purposes=0 +privacy/collected_data/precise_location/collected=false +privacy/collected_data/precise_location/linked_to_user=false +privacy/collected_data/precise_location/used_for_tracking=false +privacy/collected_data/precise_location/collection_purposes=0 +privacy/collected_data/coarse_location/collected=false +privacy/collected_data/coarse_location/linked_to_user=false +privacy/collected_data/coarse_location/used_for_tracking=false +privacy/collected_data/coarse_location/collection_purposes=0 +privacy/collected_data/sensitive_info/collected=false +privacy/collected_data/sensitive_info/linked_to_user=false +privacy/collected_data/sensitive_info/used_for_tracking=false +privacy/collected_data/sensitive_info/collection_purposes=0 +privacy/collected_data/contacts/collected=false +privacy/collected_data/contacts/linked_to_user=false +privacy/collected_data/contacts/used_for_tracking=false +privacy/collected_data/contacts/collection_purposes=0 +privacy/collected_data/emails_or_text_messages/collected=false +privacy/collected_data/emails_or_text_messages/linked_to_user=false +privacy/collected_data/emails_or_text_messages/used_for_tracking=false +privacy/collected_data/emails_or_text_messages/collection_purposes=0 +privacy/collected_data/photos_or_videos/collected=false +privacy/collected_data/photos_or_videos/linked_to_user=false +privacy/collected_data/photos_or_videos/used_for_tracking=false +privacy/collected_data/photos_or_videos/collection_purposes=0 +privacy/collected_data/audio_data/collected=false +privacy/collected_data/audio_data/linked_to_user=false +privacy/collected_data/audio_data/used_for_tracking=false +privacy/collected_data/audio_data/collection_purposes=0 +privacy/collected_data/gameplay_content/collected=false +privacy/collected_data/gameplay_content/linked_to_user=false +privacy/collected_data/gameplay_content/used_for_tracking=false +privacy/collected_data/gameplay_content/collection_purposes=0 +privacy/collected_data/customer_support/collected=false +privacy/collected_data/customer_support/linked_to_user=false +privacy/collected_data/customer_support/used_for_tracking=false +privacy/collected_data/customer_support/collection_purposes=0 +privacy/collected_data/other_user_content/collected=false +privacy/collected_data/other_user_content/linked_to_user=false +privacy/collected_data/other_user_content/used_for_tracking=false +privacy/collected_data/other_user_content/collection_purposes=0 +privacy/collected_data/browsing_history/collected=false +privacy/collected_data/browsing_history/linked_to_user=false +privacy/collected_data/browsing_history/used_for_tracking=false +privacy/collected_data/browsing_history/collection_purposes=0 +privacy/collected_data/search_hhistory/collected=false +privacy/collected_data/search_hhistory/linked_to_user=false +privacy/collected_data/search_hhistory/used_for_tracking=false +privacy/collected_data/search_hhistory/collection_purposes=0 +privacy/collected_data/user_id/collected=false +privacy/collected_data/user_id/linked_to_user=false +privacy/collected_data/user_id/used_for_tracking=false +privacy/collected_data/user_id/collection_purposes=0 +privacy/collected_data/device_id/collected=false +privacy/collected_data/device_id/linked_to_user=false +privacy/collected_data/device_id/used_for_tracking=false +privacy/collected_data/device_id/collection_purposes=0 +privacy/collected_data/purchase_history/collected=false +privacy/collected_data/purchase_history/linked_to_user=false +privacy/collected_data/purchase_history/used_for_tracking=false +privacy/collected_data/purchase_history/collection_purposes=0 +privacy/collected_data/product_interaction/collected=false +privacy/collected_data/product_interaction/linked_to_user=false +privacy/collected_data/product_interaction/used_for_tracking=false +privacy/collected_data/product_interaction/collection_purposes=0 +privacy/collected_data/advertising_data/collected=false +privacy/collected_data/advertising_data/linked_to_user=false +privacy/collected_data/advertising_data/used_for_tracking=false +privacy/collected_data/advertising_data/collection_purposes=0 +privacy/collected_data/other_usage_data/collected=false +privacy/collected_data/other_usage_data/linked_to_user=false +privacy/collected_data/other_usage_data/used_for_tracking=false +privacy/collected_data/other_usage_data/collection_purposes=0 +privacy/collected_data/crash_data/collected=false +privacy/collected_data/crash_data/linked_to_user=false +privacy/collected_data/crash_data/used_for_tracking=false +privacy/collected_data/crash_data/collection_purposes=0 +privacy/collected_data/performance_data/collected=false +privacy/collected_data/performance_data/linked_to_user=false +privacy/collected_data/performance_data/used_for_tracking=false +privacy/collected_data/performance_data/collection_purposes=0 +privacy/collected_data/other_diagnostic_data/collected=false +privacy/collected_data/other_diagnostic_data/linked_to_user=false +privacy/collected_data/other_diagnostic_data/used_for_tracking=false +privacy/collected_data/other_diagnostic_data/collection_purposes=0 +privacy/collected_data/environment_scanning/collected=false +privacy/collected_data/environment_scanning/linked_to_user=false +privacy/collected_data/environment_scanning/used_for_tracking=false +privacy/collected_data/environment_scanning/collection_purposes=0 +privacy/collected_data/hands/collected=false +privacy/collected_data/hands/linked_to_user=false +privacy/collected_data/hands/used_for_tracking=false +privacy/collected_data/hands/collection_purposes=0 +privacy/collected_data/head/collected=false +privacy/collected_data/head/linked_to_user=false +privacy/collected_data/head/used_for_tracking=false +privacy/collected_data/head/collection_purposes=0 +privacy/collected_data/other_data_types/collected=false +privacy/collected_data/other_data_types/linked_to_user=false +privacy/collected_data/other_data_types/used_for_tracking=false +privacy/collected_data/other_data_types/collection_purposes=0 +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" + +[preset.1] + +name="macOS" +platform="macOS" +runnable=false +advanced_options=false +dedicated_server=true +custom_features="" +export_filter="customized" +customized_files={ +"res://": "strip" +} +include_filter="" +exclude_filter="" +export_path="" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.1.options] + +export/distribution_type=0 +binary_format/architecture="universal" +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +application/icon="" +application/icon_interpolation=4 +application/bundle_identifier="test" +application/signature="" +application/app_category="Games" +application/short_version="" +application/version="" +application/copyright="" +application/copyright_localized={} +application/min_macos_version="10.12" +application/export_angle=0 +display/high_res=true +application/additional_plist_content="" +xcode/platform_build="14C18" +xcode/sdk_version="13.1" +xcode/sdk_build="22C55" +xcode/sdk_name="macosx13.1" +xcode/xcode_version="1420" +xcode/xcode_build="14C18" +codesign/codesign=3 +codesign/installer_identity="" +codesign/apple_team_id="" +codesign/identity="" +codesign/entitlements/custom_file="" +codesign/entitlements/allow_jit_code_execution=false +codesign/entitlements/allow_unsigned_executable_memory=false +codesign/entitlements/allow_dyld_environment_variables=false +codesign/entitlements/disable_library_validation=false +codesign/entitlements/audio_input=false +codesign/entitlements/camera=false +codesign/entitlements/location=false +codesign/entitlements/address_book=false +codesign/entitlements/calendars=false +codesign/entitlements/photos_library=false +codesign/entitlements/apple_events=false +codesign/entitlements/debugging=false +codesign/entitlements/app_sandbox/enabled=false +codesign/entitlements/app_sandbox/network_server=false +codesign/entitlements/app_sandbox/network_client=false +codesign/entitlements/app_sandbox/device_usb=false +codesign/entitlements/app_sandbox/device_bluetooth=false +codesign/entitlements/app_sandbox/files_downloads=0 +codesign/entitlements/app_sandbox/files_pictures=0 +codesign/entitlements/app_sandbox/files_music=0 +codesign/entitlements/app_sandbox/files_movies=0 +codesign/entitlements/app_sandbox/files_user_selected=0 +codesign/entitlements/app_sandbox/helper_executables=[] +codesign/custom_options=PackedStringArray() +notarization/notarization=0 +privacy/microphone_usage_description="" +privacy/microphone_usage_description_localized={} +privacy/camera_usage_description="" +privacy/camera_usage_description_localized={} +privacy/location_usage_description="" +privacy/location_usage_description_localized={} +privacy/address_book_usage_description="" +privacy/address_book_usage_description_localized={} +privacy/calendar_usage_description="" +privacy/calendar_usage_description_localized={} +privacy/photos_library_usage_description="" +privacy/photos_library_usage_description_localized={} +privacy/desktop_folder_usage_description="" +privacy/desktop_folder_usage_description_localized={} +privacy/documents_folder_usage_description="" +privacy/documents_folder_usage_description_localized={} +privacy/downloads_folder_usage_description="" +privacy/downloads_folder_usage_description_localized={} +privacy/network_volumes_usage_description="" +privacy/network_volumes_usage_description_localized={} +privacy/removable_volumes_usage_description="" +privacy/removable_volumes_usage_description_localized={} +privacy/tracking_enabled=false +privacy/tracking_domains=PackedStringArray() +privacy/collected_data/name/collected=false +privacy/collected_data/name/linked_to_user=false +privacy/collected_data/name/used_for_tracking=false +privacy/collected_data/name/collection_purposes=0 +privacy/collected_data/email_address/collected=false +privacy/collected_data/email_address/linked_to_user=false +privacy/collected_data/email_address/used_for_tracking=false +privacy/collected_data/email_address/collection_purposes=0 +privacy/collected_data/phone_number/collected=false +privacy/collected_data/phone_number/linked_to_user=false +privacy/collected_data/phone_number/used_for_tracking=false +privacy/collected_data/phone_number/collection_purposes=0 +privacy/collected_data/physical_address/collected=false +privacy/collected_data/physical_address/linked_to_user=false +privacy/collected_data/physical_address/used_for_tracking=false +privacy/collected_data/physical_address/collection_purposes=0 +privacy/collected_data/other_contact_info/collected=false +privacy/collected_data/other_contact_info/linked_to_user=false +privacy/collected_data/other_contact_info/used_for_tracking=false +privacy/collected_data/other_contact_info/collection_purposes=0 +privacy/collected_data/health/collected=false +privacy/collected_data/health/linked_to_user=false +privacy/collected_data/health/used_for_tracking=false +privacy/collected_data/health/collection_purposes=0 +privacy/collected_data/fitness/collected=false +privacy/collected_data/fitness/linked_to_user=false +privacy/collected_data/fitness/used_for_tracking=false +privacy/collected_data/fitness/collection_purposes=0 +privacy/collected_data/payment_info/collected=false +privacy/collected_data/payment_info/linked_to_user=false +privacy/collected_data/payment_info/used_for_tracking=false +privacy/collected_data/payment_info/collection_purposes=0 +privacy/collected_data/credit_info/collected=false +privacy/collected_data/credit_info/linked_to_user=false +privacy/collected_data/credit_info/used_for_tracking=false +privacy/collected_data/credit_info/collection_purposes=0 +privacy/collected_data/other_financial_info/collected=false +privacy/collected_data/other_financial_info/linked_to_user=false +privacy/collected_data/other_financial_info/used_for_tracking=false +privacy/collected_data/other_financial_info/collection_purposes=0 +privacy/collected_data/precise_location/collected=false +privacy/collected_data/precise_location/linked_to_user=false +privacy/collected_data/precise_location/used_for_tracking=false +privacy/collected_data/precise_location/collection_purposes=0 +privacy/collected_data/coarse_location/collected=false +privacy/collected_data/coarse_location/linked_to_user=false +privacy/collected_data/coarse_location/used_for_tracking=false +privacy/collected_data/coarse_location/collection_purposes=0 +privacy/collected_data/sensitive_info/collected=false +privacy/collected_data/sensitive_info/linked_to_user=false +privacy/collected_data/sensitive_info/used_for_tracking=false +privacy/collected_data/sensitive_info/collection_purposes=0 +privacy/collected_data/contacts/collected=false +privacy/collected_data/contacts/linked_to_user=false +privacy/collected_data/contacts/used_for_tracking=false +privacy/collected_data/contacts/collection_purposes=0 +privacy/collected_data/emails_or_text_messages/collected=false +privacy/collected_data/emails_or_text_messages/linked_to_user=false +privacy/collected_data/emails_or_text_messages/used_for_tracking=false +privacy/collected_data/emails_or_text_messages/collection_purposes=0 +privacy/collected_data/photos_or_videos/collected=false +privacy/collected_data/photos_or_videos/linked_to_user=false +privacy/collected_data/photos_or_videos/used_for_tracking=false +privacy/collected_data/photos_or_videos/collection_purposes=0 +privacy/collected_data/audio_data/collected=false +privacy/collected_data/audio_data/linked_to_user=false +privacy/collected_data/audio_data/used_for_tracking=false +privacy/collected_data/audio_data/collection_purposes=0 +privacy/collected_data/gameplay_content/collected=false +privacy/collected_data/gameplay_content/linked_to_user=false +privacy/collected_data/gameplay_content/used_for_tracking=false +privacy/collected_data/gameplay_content/collection_purposes=0 +privacy/collected_data/customer_support/collected=false +privacy/collected_data/customer_support/linked_to_user=false +privacy/collected_data/customer_support/used_for_tracking=false +privacy/collected_data/customer_support/collection_purposes=0 +privacy/collected_data/other_user_content/collected=false +privacy/collected_data/other_user_content/linked_to_user=false +privacy/collected_data/other_user_content/used_for_tracking=false +privacy/collected_data/other_user_content/collection_purposes=0 +privacy/collected_data/browsing_history/collected=false +privacy/collected_data/browsing_history/linked_to_user=false +privacy/collected_data/browsing_history/used_for_tracking=false +privacy/collected_data/browsing_history/collection_purposes=0 +privacy/collected_data/search_hhistory/collected=false +privacy/collected_data/search_hhistory/linked_to_user=false +privacy/collected_data/search_hhistory/used_for_tracking=false +privacy/collected_data/search_hhistory/collection_purposes=0 +privacy/collected_data/user_id/collected=false +privacy/collected_data/user_id/linked_to_user=false +privacy/collected_data/user_id/used_for_tracking=false +privacy/collected_data/user_id/collection_purposes=0 +privacy/collected_data/device_id/collected=false +privacy/collected_data/device_id/linked_to_user=false +privacy/collected_data/device_id/used_for_tracking=false +privacy/collected_data/device_id/collection_purposes=0 +privacy/collected_data/purchase_history/collected=false +privacy/collected_data/purchase_history/linked_to_user=false +privacy/collected_data/purchase_history/used_for_tracking=false +privacy/collected_data/purchase_history/collection_purposes=0 +privacy/collected_data/product_interaction/collected=false +privacy/collected_data/product_interaction/linked_to_user=false +privacy/collected_data/product_interaction/used_for_tracking=false +privacy/collected_data/product_interaction/collection_purposes=0 +privacy/collected_data/advertising_data/collected=false +privacy/collected_data/advertising_data/linked_to_user=false +privacy/collected_data/advertising_data/used_for_tracking=false +privacy/collected_data/advertising_data/collection_purposes=0 +privacy/collected_data/other_usage_data/collected=false +privacy/collected_data/other_usage_data/linked_to_user=false +privacy/collected_data/other_usage_data/used_for_tracking=false +privacy/collected_data/other_usage_data/collection_purposes=0 +privacy/collected_data/crash_data/collected=false +privacy/collected_data/crash_data/linked_to_user=false +privacy/collected_data/crash_data/used_for_tracking=false +privacy/collected_data/crash_data/collection_purposes=0 +privacy/collected_data/performance_data/collected=false +privacy/collected_data/performance_data/linked_to_user=false +privacy/collected_data/performance_data/used_for_tracking=false +privacy/collected_data/performance_data/collection_purposes=0 +privacy/collected_data/other_diagnostic_data/collected=false +privacy/collected_data/other_diagnostic_data/linked_to_user=false +privacy/collected_data/other_diagnostic_data/used_for_tracking=false +privacy/collected_data/other_diagnostic_data/collection_purposes=0 +privacy/collected_data/environment_scanning/collected=false +privacy/collected_data/environment_scanning/linked_to_user=false +privacy/collected_data/environment_scanning/used_for_tracking=false +privacy/collected_data/environment_scanning/collection_purposes=0 +privacy/collected_data/hands/collected=false +privacy/collected_data/hands/linked_to_user=false +privacy/collected_data/hands/used_for_tracking=false +privacy/collected_data/hands/collection_purposes=0 +privacy/collected_data/head/collected=false +privacy/collected_data/head/linked_to_user=false +privacy/collected_data/head/used_for_tracking=false +privacy/collected_data/head/collection_purposes=0 +privacy/collected_data/other_data_types/collected=false +privacy/collected_data/other_data_types/linked_to_user=false +privacy/collected_data/other_data_types/used_for_tracking=false +privacy/collected_data/other_data_types/collection_purposes=0 +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +open \"{temp_dir}/{exe_name}.app\" --args {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name}.app/Contents/MacOS/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" + +[preset.2] + +name="[Dedicated Server] Linux" +platform="Linux" +runnable=true +advanced_options=false +dedicated_server=true +custom_features="" +export_filter="customized" +customized_files={ +"res://": "strip" +} +include_filter="" +exclude_filter="" +export_path="./Open Strike.x86_64" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.2.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=false +texture_format/s3tc_bptc=true +texture_format/etc2_astc=false +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" diff --git a/helm/.helmignore b/helm/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/Chart.lock b/helm/Chart.lock new file mode 100644 index 0000000..c4551e7 --- /dev/null +++ b/helm/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: helm-library + repository: oci://ghcr.io/allanger/allangers-helm-library + version: 0.2.1 +digest: sha256:1a2c38771fede69ddcb6fa6da8927780f1dc36e1f0f92233d747e943cd76dedb +generated: "2025-01-13T14:09:55.344423+01:00" diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..0b3e8a8 --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: open-strike-2 +type: application +version: 0.1.0 +appVersion: 0.1.0 +maintainers: + - name: allanger + email: allanger@zohomail.com + url: https://badhouseplants.net +dependencies: + - name: helm-library + version: 0.2.1 + repository: oci://ghcr.io/allanger/allangers-helm-library +annotations: + allowed_workload_kinds: "Deployment" diff --git a/helm/charts/helm-library-0.2.1.tgz b/helm/charts/helm-library-0.2.1.tgz new file mode 100644 index 0000000..6dd144c Binary files /dev/null and b/helm/charts/helm-library-0.2.1.tgz differ diff --git a/helm/charts/helm-library/.helmignore b/helm/charts/helm-library/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helm/charts/helm-library/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm/charts/helm-library/Chart.lock b/helm/charts/helm-library/Chart.lock new file mode 100644 index 0000000..637f463 --- /dev/null +++ b/helm/charts/helm-library/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: raw + repository: https://bedag.github.io/helm-charts/ + version: 2.0.0 +digest: sha256:12c18557553d75f5e57efa02a359517b9d95e47e80be270af17c63f9ccaff3d1 +generated: "2024-12-29T11:06:41.044864+01:00" diff --git a/helm/charts/helm-library/Chart.yaml b/helm/charts/helm-library/Chart.yaml new file mode 100644 index 0000000..ac554ba --- /dev/null +++ b/helm/charts/helm-library/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +description: A Helm library to be reused by allanger's charts. It's supposed to become + an alternative for k8s-at-home +keywords: +- allanger +- k8s-at-home +maintainers: +- email: allanger@badhouseplants.net + name: allanger +name: helm-library +type: library +version: 0.2.0+09454ec diff --git a/helm/charts/helm-library/templates/_chart.tpl b/helm/charts/helm-library/templates/_chart.tpl new file mode 100644 index 0000000..2946721 --- /dev/null +++ b/helm/charts/helm-library/templates/_chart.tpl @@ -0,0 +1,57 @@ +{{/* + * Expand the name of the chart. +*/}} +{{- define "lib.chart.name" -}} {{- /* define[0] */}} +{{- include "lib.error.noCtx" . -}} +{{- default .ctx.Chart.Name .ctx.Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} {{- /*/define[0] */}} + +{{/* + * Create chart name and version as used by the chart label. +*/}} +{{- define "lib.chart.chart" -}} {{- /* define[0] */}} +{{- include "lib.error.noCtx" . -}} +{{- printf "%s-%s" .ctx.Chart.Name .ctx.Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} {{- /*/define[0] */}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "lib.chart.fullname" -}} +{{- include "lib.error.noCtx" . -}} +{{- if .ctx.Values.fullnameOverride }} +{{- .ctx.Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .ctx.Chart.Name .ctx.Values.nameOverride }} +{{- if contains $name .ctx.Release.Name }} +{{- .ctx.Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .ctx.Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* + * Common labels +*/}} +{{- define "lib.chart.labels" -}} {{- /* define[0] */}} +{{- include "lib.error.noCtx" . -}} +helm.sh/chart: {{ include "lib.chart.chart" (dict "ctx" .ctx) }} +{{ include "lib.chart.selectorLabels" (dict "ctx" .ctx) }} +{{- if .ctx.Chart.AppVersion }} {{- /* if[1] */}} +app.kubernetes.io/version: {{ .ctx.Chart.AppVersion | quote }} +{{- end }} {{- /* /if[1] */}} +app.kubernetes.io/managed-by: {{ .ctx.Release.Service }} +{{- end }} {{- /*/define[0] */}} + +{{/* + * Selector labels +*/}} +{{- define "lib.chart.selectorLabels" -}} {{- /* define[0] */}} +{{- include "lib.error.noCtx" . -}} +app.kubernetes.io/name: {{ include "lib.chart.name" (dict "ctx" .ctx) }} +app.kubernetes.io/instance: {{ .ctx.Release.Name }} +{{- end }} {{- /*/define[0] */}} + diff --git a/helm/charts/helm-library/templates/_errors.tpl b/helm/charts/helm-library/templates/_errors.tpl new file mode 100644 index 0000000..0a48286 --- /dev/null +++ b/helm/charts/helm-library/templates/_errors.tpl @@ -0,0 +1,15 @@ +{{- define "lib.error.noCtx" -}} {{- /* define[0] */ -}} +{{- if not .ctx -}}{{- fail "no context provided" -}}{{- end -}} +{{- if not (kindIs "map" .ctx) -}} {{- /* if[1] */ -}} +{{- fail "unexpected type of ctx" -}} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.error.noKey" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- if not .key -}}{{ fail "error handler must receive a key to find" }}{{- end -}} +{{- if not (hasKey .ctx .key) -}} {{- /* if[1] */ -}} +{{- fail (printf "key %s must be not null" .key) -}} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + diff --git a/helm/charts/helm-library/templates/components/_crd.tpl b/helm/charts/helm-library/templates/components/_crd.tpl new file mode 100644 index 0000000..bd8f782 --- /dev/null +++ b/helm/charts/helm-library/templates/components/_crd.tpl @@ -0,0 +1,17 @@ +{{/* + * CRDs should always be managed as a separate chart + * They must be written to the ./crd folder and then + * they will be read by the .Files helm feature +*/}} +{{- define "lib.component.crd" -}} {{- /* define[0] */ -}} +{{- + $metadata := include "lib.metadata" + (dict "ctx" $ "annotations" .Values.workload.annotations) +}} +{{ $currentScope := .}} +{{ range $path, $_ := .Files.Glob "**.yaml" }} + {{- with $currentScope}} + {{ .Files.Get $path }} + {{- end }} +{{ end }} +{{- end -}} {{- /* define[0] */ -}} diff --git a/helm/charts/helm-library/templates/components/_environment.tpl b/helm/charts/helm-library/templates/components/_environment.tpl new file mode 100644 index 0000000..b352ced --- /dev/null +++ b/helm/charts/helm-library/templates/components/_environment.tpl @@ -0,0 +1,46 @@ +{{/* + * This component should make it easier to create sets + * of environment variables via configmaps and secrets +*/}} +{{- define "lib.component.environment" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- range $k, $v := .ctx.Values.config.env }} {{- /* range[0] */}} +{{- $customName := include "lib.component.env.name" (dict "ctx" $.ctx "name" $k) }} +{{- if $v.enabled }} {{- /* if[0] */}} +{{- + $labels := include "lib.metadata.mergeLabels" + (dict + "ctx" $.ctx + "global" ($.ctx.Values.metadata).labels + "local" ($v.metadata).labels + ) +}} +{{- + $metadata := include "lib.metadata" + (dict + "ctx" $.ctx + "name" $customName + "annotations" ($v.metadata).annotations + "labels" $labels + ) +}} +{{- $data := dict -}} +{{- range $key, $value := $v.data }} {{- /* range[1] */}} +{{- if not (has $key ($v.remove)) }} {{- /* if[1] */}} +{{- $_ := set $data $key (tpl (toString $value) $.ctx) }} +{{- end }} {{- /* /if[1] */}} +{{- end }} {{- /* /range[1] */}} +{{- if $v.sensitive }} {{- /* if[1] */}} +{{ include "lib.core.secret" (dict "ctx" $ "metadata" $metadata "data" $data) }} +{{- else }} +{{ include "lib.core.configmap" (dict "ctx" $ "metadata" $metadata "data" $data) }} +{{- end -}} {{- /* /if[1] */}} +{{- end }} {{- /* /if[0] */}} +{{- end }} {{- /* /range[0] */}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.component.env.name" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}} +{{ printf "%s-%s-env" .ctx.Release.Name .name }} +{{- end -}} {{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/components/_extra_templates.yaml b/helm/charts/helm-library/templates/components/_extra_templates.yaml new file mode 100644 index 0000000..557f0c2 --- /dev/null +++ b/helm/charts/helm-library/templates/components/_extra_templates.yaml @@ -0,0 +1,16 @@ +{{- define "lib.component.templates" }} {{- /* define[0] */}} +{{- include "lib.error.noCtx" . -}} +{{- + $labels := include "lib.metadata.mergeLabels" + (dict + "ctx" .ctx + "global" ((.ctx.Values).metadata).labels + ) +}} +{{- with (.ctx.Values.extra).templates }} {{- /* with[1] */}} +{{- range . }} {{- /* range[2] */}} +--- +{{- tpl . $.ctx | indent 0 }} +{{- end }} {{- /* /range[2] */}} +{{- end }} {{- /* /with[1] */}} +{{- end }} {{- /* /define[0] */}} diff --git a/helm/charts/helm-library/templates/components/_files.tpl b/helm/charts/helm-library/templates/components/_files.tpl new file mode 100644 index 0000000..66c2dd9 --- /dev/null +++ b/helm/charts/helm-library/templates/components/_files.tpl @@ -0,0 +1,64 @@ +{{/* + * This component should make it easier to create sets + * of environment variables via configmaps and secrets +*/}} +{{- define "lib.component.files" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- range $k, $v := .ctx.Values.config.files }} {{- /* range[0] */}} +{{- $customName := include "lib.component.file.name" (dict "ctx" $.ctx "name" $k) }} +{{- if $v.enabled }} {{- /* if[0] */}} +{{- + $labels := include "lib.metadata.mergeLabels" + (dict + "ctx" $.ctx + "global" ($.ctx.Values.metadata).labels + "local" ($v.metadata).labels + ) +}} +{{- + $metadata := include "lib.metadata" + (dict + "ctx" $.ctx + "name" $customName + "annotations" $v.annotations + "labels" $labels + ) +}} +{{- $entries := dict -}} +{{- range $key, $value := $v.entries }} {{- /* range[1] */}} +{{- if not (has $key ($v.remove)) }} {{- /* if[1] */}} +{{- $data := $value.data }} +{{- if and (kindIs "string" $data) ($value.convertTo) }} {{- /* if[2] */}} +{{- fail "convering is only possible for plain yaml, strings are not supported" -}} +{{- end }} {{- /* /if[2] */}} +{{- if $value.convertTo -}} {{- /* if[2] */ -}} +{{- if eq $value.convertTo "json" }} {{- /* if[3] */}} +{{- $data = include "lib.helpers.convertToJson" $data -}} +{{- else if eq $value.convertTo "toml" -}} +{{- $data = include "lib.helpers.convertToToml" $data -}} +{{- else if eq $value.convertTo "yaml" -}} +{{- $data = include "lib.helpers.convertToYaml" $data -}} +{{- else -}} +{{- fail (printf "converion to %s is not supported yet" $value.convertTo) -}} +{{- end -}} {{- /* /if[3] */ -}} +{{- end -}} {{- /* /if[2] */ -}} +{{- if not (kindIs "string" $data) -}} +{{- fail (printf "it must be a string, but it's a %s: %v" (kindOf $data) $data) -}} +{{- end -}} +{{- $_ := set $entries $key (tpl $data $.ctx) }} +{{- end }} {{- /* /if[1] */}} +{{- end }} {{- /* /range[1] */}} +{{- if $v.sensitive }} {{- /* if[1] */}} +{{ include "lib.core.secret" (dict "ctx" $ "metadata" $metadata "data" $entries) }} +{{- else }} +{{ include "lib.core.configmap" (dict "ctx" $ "metadata" $metadata "data" $entries) }} +{{- end -}} {{- /* /if[1] */}} +{{- end }} {{- /* /if[0] */}} +{{- end }} {{- /* /range[0] */}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.component.file.name" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}} +{{ printf "%s-%s-file" .ctx.Release.Name .name }} +{{- end -}} {{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/components/_ingress.tpl b/helm/charts/helm-library/templates/components/_ingress.tpl new file mode 100644 index 0000000..1a7eab8 --- /dev/null +++ b/helm/charts/helm-library/templates/components/_ingress.tpl @@ -0,0 +1,33 @@ +{{- define "lib.component.ingress" }} +{{- range $k, $v := .ctx.Values.ingress }} +{{- $customName := include "lib.component.ingress.name" (dict "ctx" $.ctx "name" $k) }} +{{- if $v.enabled }} {{- /* if[0] */}} +{{- + $labels := include "lib.metadata.mergeLabels" + (dict + "ctx" $.ctx + "global" ($.ctx.Values.metadata).labels + "local" ($v.metadata).labels + ) +}} +{{- + $metadata := include "lib.metadata" + (dict + "ctx" $.ctx + "annotations" ($v.metadata).annotations + "labels" $labels + "name" $customName + ) +}} +{{- $spec := $v -}} +{{- $_ := unset $spec "enabled" -}} +{{ include "lib.core.ingress" (dict "ctx" $.ctx "metadata" $metadata "spec" $spec ) }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "lib.component.ingress.name" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}} +{{ printf "%s-%s" .ctx.Release.Name .name }} +{{- end -}} {{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/components/_service.tpl b/helm/charts/helm-library/templates/components/_service.tpl new file mode 100644 index 0000000..b438cee --- /dev/null +++ b/helm/charts/helm-library/templates/components/_service.tpl @@ -0,0 +1,42 @@ +{{/* + * This component should make it easier to create pvc +*/}} +{{- define "lib.component.service" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- range $k, $v := .ctx.Values.services }} {{- /* range[1] */}} +{{- $customName := include "lib.component.service.name" (dict "ctx" $.ctx "name" $k) }} +{{- if $v.enabled }} {{- /* if[2] */}} +{{- + $labels := include "lib.metadata.mergeLabels" + (dict + "ctx" $.ctx + "global" ($.ctx.Values.metadata).labels + "local" ($v.metadata).labels + ) +}} +{{- + $metadata := include "lib.metadata" + (dict + "ctx" $.ctx + "name" $customName + "annotations" ($v.metadata).annotations + "labels" $labels + ) +}} +{{ $spec := $v }} +{{- if not $spec.type -}} +{{- set $spec "type" "ClusterIP" -}} +{{- end }} +{{ + include "lib.core.service" + (dict "ctx" $.ctx "metadata" $metadata "spec" $spec) +}} +{{- end }} +{{- end }} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.component.service.name" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}} +{{ printf "%s-%s" .ctx.Release.Name .name }} +{{- end -}} {{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/components/_storage.tpl b/helm/charts/helm-library/templates/components/_storage.tpl new file mode 100644 index 0000000..0ef83e2 --- /dev/null +++ b/helm/charts/helm-library/templates/components/_storage.tpl @@ -0,0 +1,35 @@ +{{/* + * This component should make it easier to create pvc +*/}} +{{- define "lib.component.storage" -}} +{{- include "lib.error.noCtx" . -}} +{{- range $k, $v := .ctx.Values.storage }} +{{- $customName := include "lib.component.storage.name" (dict "ctx" $.ctx "name" $k) }} +{{- if $v.enabled }} {{- /* if[0] */}} +{{- + $labels := include "lib.metadata.mergeLabels" + (dict + "ctx" $.ctx + "global" ($.ctx.Values.metadata).labels + "local" ($v.metadata).labels + ) +}} +{{- + $metadata := include "lib.metadata" + (dict + "ctx" $.ctx + "annotations" ($v.metadata).annotations + "labels" $labels + "name" $customName + ) +}} +{{ include "lib.core.pvc" (dict "metadata" $metadata "spec" $v) }} +{{- end }} {{- /* /if[0] */}} +{{- end }} +{{- end -}} + +{{- define "lib.component.storage.name" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}} +{{ printf "%s-%s-storage" .ctx.Release.Name .name }} +{{- end -}} {{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/components/_workloads.yaml b/helm/charts/helm-library/templates/components/_workloads.yaml new file mode 100644 index 0000000..844bda9 --- /dev/null +++ b/helm/charts/helm-library/templates/components/_workloads.yaml @@ -0,0 +1,65 @@ +{{- define "lib.component.workload.allowed" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{ index .ctx.Chart.Annotations "allowed_workload_kinds" }} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.component.workload" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- + $labels := include "lib.metadata.mergeLabels" + (dict + "ctx" .ctx + "global" ((.ctx.Values).metadata).labels + "local" (((.ctx.Values.base).workload).metadata).labels + ) +}} +{{- + $metadata := include "lib.metadata" + (dict + "ctx" .ctx + "annotations" (((.ctx.Values.base).workload).metadata).annotations + "labels" $labels + ) +}} +{{- + $securityContext := include "lib.core.pod.securityContext" + (dict + "securityContext" .ctx.Values.base.workload.securityContext + ) +}} + +{{ + $containers := include "lib.core.pod.containers" + (dict + "ctx" .ctx + "containers" .ctx.Values.base.workload.containers + ) +}} + +{{ + $volumes := include "lib.core.pod.volumes" + (dict + "ctx" .ctx + "files" (.ctx.Values.config).files + "storage" .ctx.Values.storage + "extraVolumes" .ctx.Values.extraVolumes + ) +}} + +{{- if eq .ctx.Values.base.workload.kind "Deployment" -}} {{- /* if[0] */ -}} +{{- if contains .ctx.Values.base.workload.kind (include "lib.component.workload.allowed" (dict "ctx" .ctx)) }}{{- /* if[0] */ -}} +{{- + include "lib.core.deployment" + (dict + "ctx" .ctx + "metadata" $metadata + "securityContext" $securityContext + "containers" $containers + "volumes" $volumes + ) +}} +{{- else -}} +{{- fail (printf "workload kind is not allowed: %s" .ctx.Values.base.workload.kind) -}} +{{- end }}{{- /* if[1] */ -}} +{{- end -}} {{- /* /if[0]*/ -}} +{{- end -}}{{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/core/_configmap.yaml b/helm/charts/helm-library/templates/core/_configmap.yaml new file mode 100644 index 0000000..2c1de4d --- /dev/null +++ b/helm/charts/helm-library/templates/core/_configmap.yaml @@ -0,0 +1,18 @@ +{{- define "lib.core.configmap" -}} {{- /* define[0] */}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "metadata") -}} +--- +# --------------------------------------------------------------------- +# -- This resource is managed by the allanger's helm library +# --------------------------------------------------------------------- +apiVersion: v1 +kind: ConfigMap +metadata: +{{ .metadata | indent 2 }} +data: +{{- range $key, $value := .data }} + {{- if $value }} + {{ $key }}: {{ tpl $value $.Context | quote }} + {{- end }} +{{- end }} +{{- end -}} {{- /* /define[0]) */ -}} diff --git a/helm/charts/helm-library/templates/core/_deployment.yaml b/helm/charts/helm-library/templates/core/_deployment.yaml new file mode 100644 index 0000000..b627542 --- /dev/null +++ b/helm/charts/helm-library/templates/core/_deployment.yaml @@ -0,0 +1,78 @@ +{{/* + * Bootstrap a deployment + * It should always receive a dict as an argument +*/}} +{{- define "lib.core.deployment" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "securityContext") -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "metadata") -}} +--- +# --------------------------------------------------------------------- +# -- This resource is managed by the allanger's helm library +# --------------------------------------------------------------------- +apiVersion: apps/v1 +kind: Deployment +metadata: +{{ .metadata | indent 2 }} +spec: +{{- + include "lib.core.deployment.spec" + (dict + "ctx" .ctx + "securityContext" .securityContext + "metadata" .metadata + "containers" .containers + "volumes" .volumes + ) + | indent 2 +}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.deployment.spec" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . }} +{{- include "lib.error.noKey" (dict "ctx" . "key" "securityContext") -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "metadata") }} +replicas: {{ .ctx.Values.base.workload.replicas | default 1 }} +selector: + matchLabels: + {{- include "lib.chart.selectorLabels" (dict "ctx" .ctx) | nindent 6 }} +{{ + include "lib.core.deployment.template" + (dict + "ctx" .ctx + "securityContext" .securityContext + "metadata" .metadata + "containers" .containers + "volumes" .volumes + ) +}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- /* A deployment temopalte goes here */ -}} +{{- define "lib.core.deployment.template" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "securityContext") -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "metadata") -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "containers") -}} +{{- $labels := toYaml (index (fromYaml .metadata) "labels") -}} +{{- $annotations := toYaml (index (fromYaml .metadata) "annotations") -}} +template: + metadata: + labels: + {{- $labels | nindent 6 }} + annotations: + {{- if not (eq $annotations "null") }} + {{- $annotations | nindent 6 }} + {{- end }} + {{ + include "lib.helpers.hashes" + (dict + "env" (.ctx.Values.config).env + "files" (.ctx.Values.config).files) + | nindent 6 + }} + spec: + {{- .securityContext | nindent 4 }} + {{ .containers | nindent 4 }} + {{ .volumes | nindent 4 }} +{{- end -}} {{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/core/_ingress.tpl b/helm/charts/helm-library/templates/core/_ingress.tpl new file mode 100644 index 0000000..25630ef --- /dev/null +++ b/helm/charts/helm-library/templates/core/_ingress.tpl @@ -0,0 +1,20 @@ +{{- define "lib.core.ingress" }} +--- +# --------------------------------------------------------------------- +# -- This resource is managed by the allanger's helm library +# --------------------------------------------------------------------- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + {{- .metadata | nindent 2 }} +spec: + ingressClassName: {{ .spec.class }} + {{- with .spec.rules }} + rules: + {{- tpl ( . | toYaml | nindent 4 | toString) $.ctx }} + {{- end }} + {{- with .spec.tls }} + tls: + {{- tpl ( . | toYaml | nindent 4 | toString) $.ctx }} + {{- end }} +{{- end }} diff --git a/helm/charts/helm-library/templates/core/_pod.tpl b/helm/charts/helm-library/templates/core/_pod.tpl new file mode 100644 index 0000000..c98ddb2 --- /dev/null +++ b/helm/charts/helm-library/templates/core/_pod.tpl @@ -0,0 +1,117 @@ +{{- define "lib.core.pod" -}} {{- /* define[0] */ -}} +{{- fail "pods are not implemented net" -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{/* + * This function should accept a seucrityContext + * from values, so please use it with values + * directly + * SecurityContext is not templated, so it will be + * added as is +*/}} +{{- define "lib.core.pod.securityContext" -}} {{- /* define[0] */ -}} +securityContext: +{{- if not .securityContext }} {{- /* if[1] */}} +# --------------------------------------------------------------------- +# Using the default security context, if it doesn't work for you, +# please update `.Values.base.workload.securityContext` +# --------------------------------------------------------------------- + runAsUser: 1000 + runAsGroup: 3000 + fsGroup: 2000 + seccompProfile: + type: RuntimeDefault +{{- else -}} +{{- with .securityContext }} {{- /* with[2] */}} +{{ toYaml . | indent 2 }} +{{- end -}} {{- /* /with[2] */}} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* define[0] */ -}} + + +{{- define "lib.core.pod.volumes" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "storage") -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "files") -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "extraVolumes") -}} +{{- if or (or .storage .files) .extraVolumes -}} {{- /* if[0]*/ -}} +volumes: + {{- /* If storage is defined, mount a pvc */ -}} + {{- if .storage }} {{- /* if[1] */}} + {{- range $k, $v := .storage }} {{- /* range[0] */}} + {{- if $v.enabled }} + {{- $name := include "lib.component.storage.name" (dict "ctx" $.ctx "name" $k) }} + - name: {{ $k }}-storage + persistentVolumeClaim: + claimName: {{ $name }} + {{- end }} + {{- end }} {{- /* /range[0] */}} + {{- end }} {{- /* /if[1] */}} + {{- if .extraVolumes}} {{- /* if[1] */}} + {{- range $k, $v := .extraVolumes}} {{- /* range[0] */}} + - name: {{ $k }}-extra + {{- $v | toYaml | nindent 4 }} + {{- end }} {{- /* /range[0] */}} + {{- end }} {{- /* /if[1] */}} + {{- if .files }} {{- /* if[1] */}} + {{- range $k, $v := .files }} {{- /* range[0] */}} + - name: {{ $k }}-file + {{- $name := include "lib.component.file.name" (dict "ctx" $.ctx "name" $k) }} + {{- if $v.sensitive }} {{- /* if[2] */}} + secret: + defaultMode: 420 + secretName: {{ $name }} + {{- else }} + configMap: + name: {{ $name }} + {{- end }} {{- /* /if[2] */}} + {{- end }} {{- /* /range[0] */}} + {{- end }} {{- /* /if[1] */}} +{{- end -}} {{- /* /if[0] */ -}} +{{- end -}} {{- /* define[0] */ -}} + +{{/* + * This template should generate a valid container + * defintion that should be used by both + * containers and initContainers +*/}} + +{{- define "lib.core.pod.containers" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "containers") -}} +{{- $ctx := .ctx }} +containers: +{{- $containers := list }} +{{- range $k, $v := .containers }} {{- /* range[1] */}} +{{- $containerRaw := include "lib.core.pod.container" + (dict + "ctx" $ctx + "name" $k + "data" $v + ) +}} +{{- $container := fromYaml $containerRaw }} +{{- if hasKey $container "Error" }} {{- /* if[2] */}} +{{- fail (printf "%s\n%v" $container $containerRaw) }} +{{- end }} {{- /* /if[1] */}} +{{- $containers = append $containers $container }} +{{- end }} {{- /* /range[1] */}} +{{ $containers | toYaml | indent 2 }} +{{- end -}} {{- /* define[0] */ -}} + +{{- define "lib.core.pod.initContainers" -}} {{- /* define[0] */ -}} +{{- end -}} {{- /* define[0] */ -}} + +{{- define "lib.core.pod.container.image.tag" -}} {{/* define[0] */}} +{{- if or .tag .appVersion -}} {{/* if[1] */}} + {{- if .tag -}} {{/* if[2] */}} + {{- .tag -}} + {{- else -}} + {{- .appVersion -}} + {{- end -}} {{/* /if[2] */}} +{{- else -}} + {{ fail ".tag or .appVersion must be passed to this helper"}} +{{- end -}} {{/* /if[1] */}} +{{- end -}} {{/* /define[0] */}} + + diff --git a/helm/charts/helm-library/templates/core/_pvc.tpl b/helm/charts/helm-library/templates/core/_pvc.tpl new file mode 100644 index 0000000..4904811 --- /dev/null +++ b/helm/charts/helm-library/templates/core/_pvc.tpl @@ -0,0 +1,21 @@ +{{- define "lib.core.pvc" -}} +--- +# --------------------------------------------------------------------- +# -- This resource is managed by the allanger's helm library +# --------------------------------------------------------------------- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + {{- .metadata | nindent 2 }} +spec: +{{- with .spec.accessModes }} + accessModes: +{{ toYaml . | indent 4}} +{{- end }} + resources: + requests: + storage: {{ .spec.size }} +{{- if ne .spec.storageClassName "default" }} + storageClassName: {{ .spec.storageClassName }} +{{- end }} +{{- end -}} diff --git a/helm/charts/helm-library/templates/core/_secret.yaml b/helm/charts/helm-library/templates/core/_secret.yaml new file mode 100644 index 0000000..5c9d108 --- /dev/null +++ b/helm/charts/helm-library/templates/core/_secret.yaml @@ -0,0 +1,16 @@ +{{- define "lib.core.secret" -}} {{- /* define[0] */}} +--- +# --------------------------------------------------------------------- +# -- This resource is managed by the allanger's helm library +# --------------------------------------------------------------------- +apiVersion: v1 +kind: Secret +metadata: + {{- .metadata | nindent 2 }} +data: +{{- range $key, $value := .data }} + {{- if $value }} + {{ $key }}: {{ tpl $value $.Context | b64enc }} + {{- end }} +{{- end }} +{{- end -}} {{- /* /define[0]) */ -}} diff --git a/helm/charts/helm-library/templates/core/_service.tpl b/helm/charts/helm-library/templates/core/_service.tpl new file mode 100644 index 0000000..56bc76a --- /dev/null +++ b/helm/charts/helm-library/templates/core/_service.tpl @@ -0,0 +1,21 @@ +{{- define "lib.core.service" }} +--- +# --------------------------------------------------------------------- +# -- This resource is managed by the allanger's helm library +# --------------------------------------------------------------------- +apiVersion: v1 +kind: Service +metadata: + {{- .metadata | nindent 2 }} +spec: + type: {{ .spec.type }} + selector: + {{- include "lib.chart.selectorLabels" (dict "ctx" .ctx) | nindent 4 }} + ports: +{{- range $k,$v := .spec.ports }} {{- /* range[0] */}} + - name: {{ $k }} + port: {{ $v.port }} + targetPort: {{ $v.targetPort}} + protocol: {{ $v.protocol}} +{{- end }} {{- /* /range[0] */}} +{{- end }} diff --git a/helm/charts/helm-library/templates/core/pod/_container.tpl b/helm/charts/helm-library/templates/core/pod/_container.tpl new file mode 100644 index 0000000..a28649d --- /dev/null +++ b/helm/charts/helm-library/templates/core/pod/_container.tpl @@ -0,0 +1,214 @@ +{{/* + * This template should be able to create a valid container spec +*/}} +{{- define "lib.core.pod.container" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "data") -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "name") -}} +name: {{ .name }} +{{ include "lib.core.pod.container.securityContext" (dict "securityContext" .data.securityContext) }} +{{ include "lib.core.pod.container.command" (dict "command" .data.command) }} +{{ include "lib.core.pod.container.args" (dict "args" .data.command) }} +{{ include "lib.core.pod.container.livenessProbe" (dict "ctx" .ctx "probe" .data.livenessProbe) }} +{{ include "lib.core.pod.container.readinessProbe" (dict "ctx" .ctx "probe" .data.readinessProbe) }} +{{ include "lib.core.pod.container.startupProbe" (dict "ctx" .ctx "probe" .data.readinessProbe) }} +{{ include "lib.core.pod.container.image" (dict "ctx" .ctx "image" .data.image) }} +{{ include "lib.core.pod.container.envFrom" (dict "ctx" .ctx "envFrom" .data.envFrom) }} +{{ include "lib.core.pod.container.volumeMounts" (dict "ctx" .ctx "mounts" .data.volumeMounts) }} +{{ include "lib.core.pod.container.ports" (dict "ctx" .ctx "ports" .data.ports) }} +{{- /* +{{- + include "lib.core.pod.container.ports" + (dict "Context" .Context "Container" .ContainerData) + | indent 2 +-}} +{{- + include "lib.core.pod.container.volumeMounts" + .ContainerData | indent 2 +-}} +*/}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.pod.container.securityContext" }} {{- /* define[0] */ -}} +securityContext: +{{- if not .securityContext }} {{- /* if[1] */}} +# --------------------------------------------------------------------- +# Using the default security context, if it doesn't work for you, +# please update `.Values.base.workload.containers[].securityContext` +# --------------------------------------------------------------------- + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL +{{- else }} +{{- with .securityContext }} {{- /* with[2] */}} +{{ toYaml . | indent 2 }} +{{- end }} {{- /* /with[2] */}} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{/* + * Command and Args are accepting a dict as an argument + * dict should contain the following keys: + * - ctx + * - command/args (optional list) - When empty, entry is not added +*/}} +{{- define "lib.core.pod.container.command" -}} {{- /* define[0] */ -}} +{{- with .command -}} {{- /* with[1] */ -}} +command: +{{ . | toYaml | indent 2 }} +{{- end -}} {{- /* /with[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.pod.container.args" -}} {{- /* define[0] */ -}} +{{- with .args -}} {{- /* with[1] */ -}} +args: +{{ . | toYaml | indent 2 }} +{{- end -}} {{- /* /with[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{/* + * Probes are accepting a dict as an argument + * dict should contain the following keys: + * - ctx + * - probe (optional) - When empty, probe is not added + * + * Notes: Probes can be tempalted, because some kinds of probes + * need to be aware of a port to be checking against. And to avoid + * copypaste all the probes are tempalted +*/}} + +{{- define "lib.core.pod.container.readinessProbe" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "probe") -}} +{{- if .probe }} {{- /* if[1] */}} +{{- $probe := tpl (toYaml .probe) .ctx -}} +readinessProbe: +{{ $probe | indent 2}} +{{- end }} {{- /* /if[1] */}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.pod.container.livenessProbe" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "probe") -}} +{{- if .probe }} {{- /* if[1] */}} +{{- $probe := tpl (toYaml .probe) .ctx -}} +livenessProbe: +{{ $probe | indent 2}} +{{- end }} {{- /* /if[1] */}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.pod.container.startupProbe" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "probe") -}} +{{- if .probe }} {{- /* if[1] */}} +{{- $probe := tpl (toYaml .probe) .ctx -}} +startupProbe: +{{ $probe | indent 2}} +{{- end }} {{- /* /if[1] */}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.pod.container.image" -}} {{/* define[0] */}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "image") -}} +image: {{ printf "%s/%s:%s" + .image.registry .image.repository + (include "lib.core.pod.container.image.tag" + (dict "appVersion" .ctx.Chart.AppVersion "tag" .image.tag)) +}} +imagePullPolicy: {{ .image.pullPolicy | default "Always" }} +{{- end -}} {{/* /define[0] */}} + +{{/* + * EnvFrom can either take values from predefined env values + * or add a raw envFrom entries to the manifests + * When using the predefined env, it's possible to remove entries + * using the '.remove' entry from the env mountpoint + * + * Should accept a dict with the followibg keys + * ctx + * envFrom + * +*/}} +{{- define "lib.core.pod.container.envFrom" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "envFrom") -}} +{{- /* If env should be set from a Configmap/Secret */ -}} +{{- if .envFrom -}} {{- /* if[1] */ -}} +envFrom: +{{- range $k, $v := .envFrom -}} {{- /* range[2] */ -}} +{{- if not (eq $k "raw") -}} {{- /* if[3] */ -}} +{{- $source := include "lib.helpers.lookup.env" (dict "ctx" $.ctx "key" $k) | fromYaml }} +{{- if $source.sensitive }} + - secretRef: +{{- else }} + - configMapRef: +{{- end }} + name: {{ include "lib.component.env.name" (dict "ctx" $.ctx "name" $k) }} +{{- else -}} + {{ $v | toYaml | nindent 2}} +{{- end }} {{- /* if[3] */}} +{{- end }} {{- /* /range[2] */}} + +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.pod.container.volumeMounts" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "mounts") -}} +{{- if .mounts }} {{- /* if[1] */}} +volumeMounts: +{{- range $mountKind, $mountData := .mounts }} {{- /* range[1] */}} +{{- if eq $mountKind "storage" }} {{- /* if[2] */}} +{{- range $mountName, $mountEntry := $mountData }} {{- /* range[3] */}} +{{- $name := include "lib.component.storage.name" (dict "ctx" $.ctx "name" $mountName) }} + - name: {{ $mountName }}-storage + mountPath: {{ $mountEntry.path }} +{{- end }} {{- /* /range[1] */}} +{{- end }} {{- /* /if[1] */}} +{{- if eq $mountKind "files" }} {{- /* if[1] */}} +{{- range $mountName, $mountEntry := $mountData }} {{- /* range[1] */}} +{{- $name := include "lib.component.file.name" (dict "ctx" $.ctx "name" $mountName) }} + - name: {{ $name }} + mountPath: {{ $mountEntry.path }} +{{- if $mountEntry.subPath }} {{- /* if[2] */}} + subPath: {{ $mountEntry.subPath }} +{{- end }} {{- /* /if[2] */}} +{{- end }} {{- /* /range[1] */}} +{{- end }} {{- /* /if[1] */}} +{{- if eq $mountKind "extraVolumes" }} {{- /* if[1] */}} +{{- range $mountName, $mountEntry := $mountData }} {{- /* range[1] */}} + - name: {{ printf "%s-extra" $mountName }} + mountPath: {{ $mountEntry.path }} +{{- end }} {{- /* /range[1] */}} +{{- end }} {{- /* /if[1] */}} +{{- end }} {{- /* /range[0] */}} +{{- end }} {{- /* /if[0] */}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.core.pod.container.ports" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "ports") -}} +{{- if .ports }} {{- /* if[0] */}} +ports: +{{- range $k, $v := .ports }} {{- /* range[0] */}} +{{- if and (kindIs "string" $v) (eq $k "raw") }} {{- /* if[1] */}} +{{- fail "raw port should be an array of ports" -}} +{{- end -}} + +{{- if ne $k "raw" }} +{{- $service := include "lib.helpers.lookup.service" (dict "ctx" $.ctx "key" $k) | fromYaml -}} +{{- $ports := index $service "ports" }} +{{- range $port := $v }} +{{- $protocol := index (index $ports $port) "protocol" }} +{{- $containerPort := index (index $ports $port) "targetPort" }} + - containerPort: {{ $containerPort }} + protocol: {{ $protocol }} +{{- end }} +{{- else }} +{{ $v | toYaml | indent 2 -}} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /range[0] */ -}} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + diff --git a/helm/charts/helm-library/templates/helpers/_chart.tpl b/helm/charts/helm-library/templates/helpers/_chart.tpl new file mode 100644 index 0000000..297f418 --- /dev/null +++ b/helm/charts/helm-library/templates/helpers/_chart.tpl @@ -0,0 +1,31 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "chart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "chart.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "chart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} diff --git a/helm/charts/helm-library/templates/helpers/_converter.tpl b/helm/charts/helm-library/templates/helpers/_converter.tpl new file mode 100644 index 0000000..40ecd5f --- /dev/null +++ b/helm/charts/helm-library/templates/helpers/_converter.tpl @@ -0,0 +1,11 @@ +{{- define "lib.helpers.convertToJson" -}} +{{ toString (toJson . ) }} +{{- end -}} + +{{- define "lib.helpers.convertToToml" -}} +{{ toString (toToml .) }} +{{- end -}} + +{{- define "lib.helpers.convertToYaml" -}} +{{ toString (toYaml .) }} +{{- end -}} diff --git a/helm/charts/helm-library/templates/helpers/_hash.tpl b/helm/charts/helm-library/templates/helpers/_hash.tpl new file mode 100644 index 0000000..918bc59 --- /dev/null +++ b/helm/charts/helm-library/templates/helpers/_hash.tpl @@ -0,0 +1,31 @@ +{{/* + * Populate hashes from configmaps and secret to + * trigger pod restart after config was changed + * TODO: Remove the extra empty line after annotations +*/}} +{{- define "lib.helpers.hashes" -}} {{- /* define[0] */ -}} +# --------------------------------------------------------------------- +# -- A note from the library: +# -- Pod annotations currently only support hashes of mounted +# -- config files and env variables and annotations inherited from +# -- the deployment +# --------------------------------------------------------------------- +{{ range $k, $v := .env -}} {{/* range[1] */ -}} +{{- if $v.enabled -}} {{- /* if[2] */ -}} +{{ + include "lib.helpers.hash" + (dict "kind" "env" "name" $k "data" $v.data) +}} +{{ end -}} {{/* /if[2] */ -}} +{{- end -}} {{- /* /range[1] */ -}} +{{ range $k, $v := .files -}} {{/* range[1] */ -}} +{{ + include "lib.helpers.hash" + (dict "kind" "file" "name" $k "data" ($v).entries) +}} +{{- end -}} {{- /* /range[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.helpers.hash" -}} {{- /* define[0] */ -}} +{{ printf "helm.badhouseplants.net/%s-%s" .kind .name }}: {{ .data | toString | sha256sum }} +{{- end -}} {{- /* /end[0] */ -}} diff --git a/helm/charts/helm-library/templates/helpers/_lookup.tpl b/helm/charts/helm-library/templates/helpers/_lookup.tpl new file mode 100644 index 0000000..5361902 --- /dev/null +++ b/helm/charts/helm-library/templates/helpers/_lookup.tpl @@ -0,0 +1,32 @@ +{{- define "lib.helpers.lookup.env" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "key") -}} +{{- $data := (index .ctx.Values.config.env .key) -}} +{{- if not $data }} {{- /* if[1] */}} +{{- fail (printf "entry %s is not found in env" .key) }} +{{- else -}} {{- /* .if[1] */ -}} +{{ toYaml $data }} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.helpers.lookup.storage" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "key") -}} +{{- $data := (index .ctx.Values.storage .key) -}} +{{- if not $data }} {{- /* if[1] */}} +{{- fail (printf "entry %s is not found in storage" .key) }} +{{- else -}} {{- /* .if[1] */ -}} +{{ toYaml $data }} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} + +{{- define "lib.helpers.lookup.service" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "key") -}} +{{- $data := (index .ctx.Values.services .key) -}} +{{- if not $data }} {{- /* if[1] */}} +{{- fail (printf "entry %s is not found in services" .key) }} +{{- else -}} {{- /* .if[1] */ -}} +{{ toYaml $data }} +{{- end -}} {{- /* /if[1] */ -}} +{{- end -}} {{- /* /define[0] */ -}} diff --git a/helm/charts/helm-library/templates/metadata/_metadata.tpl b/helm/charts/helm-library/templates/metadata/_metadata.tpl new file mode 100644 index 0000000..a1599cf --- /dev/null +++ b/helm/charts/helm-library/templates/metadata/_metadata.tpl @@ -0,0 +1,46 @@ +{{/* + * Metadata is accepting a dict as an argument + * dict should contain the following keys: + * - ctx + * - name (optional) + * - labels + * - annotations (optional) + * TODO: Add a check to labels for an empty map (Labels must not be empty) + * TODO: Think about whether it's a good idea to let this function create resoutce with any namy +*/}} +{{- define "lib.metadata" -}} {{- /* define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{- include "lib.error.noKey" (dict "ctx" . "key" "labels") -}} +{{- if .name -}} {{- /* if[1] */ -}} +name: {{ .name }} +{{- else -}} +name: {{ include "lib.chart.fullname" (dict "ctx" .ctx) }} +{{- end }} {{- /* /if[1] */}} +labels: +{{ .labels | indent 2 }} +{{- if .annotations }} {{- /* if[1] */}} +annotations: +{{ toYaml .annotations | indent 2 }} +{{- end }} {{- /* /if[1] */}} +{{- end }} {{- /* /define[0] */ -}} + +{{/* + * Merge global helm labels with custom ones + * accepts: + * ctx + * global (optional) - Labels that are defined for + * all resources + * local (optional) - Labels that are define only for + * the current resource +*/}} +{{- define "lib.metadata.mergeLabels" -}} {{- /* /define[0] */ -}} +{{- include "lib.error.noCtx" . -}} +{{ include "lib.chart.labels" (dict "ctx" .ctx) }} +{{- range $key, $val := .global }} {{- /* /range[1] */}} +{{ $key }}: {{ $val | quote }} +{{- end }} {{- /* /range[1] */}} +{{- range $key, $val := .local }} {{- /* /range[1] */}} +{{ $key }}: {{ $val | quote }} +{{- end }} {{- /* /range[1] */}} +{{- end -}} {{- /* /define[0] */ -}} + diff --git a/helm/charts/helm-library/values.yaml b/helm/charts/helm-library/values.yaml new file mode 100644 index 0000000..c435ec1 --- /dev/null +++ b/helm/charts/helm-library/values.yaml @@ -0,0 +1,5 @@ +# @schema +# type: string +# @schema +# -- helm-docs description here +test: test diff --git a/helm/templates/install.yaml b/helm/templates/install.yaml new file mode 100644 index 0000000..799fad1 --- /dev/null +++ b/helm/templates/install.yaml @@ -0,0 +1,4 @@ +{{ include "lib.component.workload" (dict "ctx" .)}} +{{ include "lib.component.service" (dict "ctx" .) }} +{{ include "lib.component.ingress" (dict "ctx" .) }} +{{ include "lib.component.templates" (dict "ctx" .) }} diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..b4205de --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,25 @@ +--- +base: + workload: + kind: Deployment + strategy: + type: RollingUpdate + containers: + open-strike: + image: + registry: zot.badhouseplants.net + repository: badhouseplants/open-strike + tag: latest + pullPolicy: Always + ports: + main: + - open-strike +services: + main: + enabled: true + type: ClusterIP + ports: + open-strike: + port: 27015 + targetPort: 27015 + protocol: TCP diff --git a/project.godot b/project.godot index b03a6e4..ccfa43e 100644 --- a/project.godot +++ b/project.godot @@ -13,7 +13,7 @@ config_version=5 config/name="Open Strike" run/main_scene="res://scenes/utils/menus/main/main_menu.tscn" config/features=PackedStringArray("4.3", "Forward Plus") -run/max_fps=120 +run/max_fps=60 config/icon="res://icon.svg" [autoload] @@ -100,5 +100,6 @@ crouch={ [rendering] +textures/vram_compression/import_etc2_astc=true anti_aliasing/quality/msaa_3d=1 anti_aliasing/quality/screen_space_aa=1 diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 0000000..08c7816 --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,265 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "gdextension-api" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8707eca996b28193b772a4a9a28a97364bb93c97e3c313542e812f2963fb93" + +[[package]] +name = "gensym" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913dce4c5f06c2ea40fc178c06f777ac89fc6b1383e90c254fafb1abe4ba3c82" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "uuid", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glam" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" + +[[package]] +name = "godot" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6985eb6c22a0370c40d67db1f225f62222a2e04966f76d0beb53245e745744fa" +dependencies = [ + "godot-core", + "godot-macros", +] + +[[package]] +name = "godot-bindings" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77d85815de344b419513c9854b82c49aad45c7dd9fa4fcc10302aaf6ce6e07c7" +dependencies = [ + "gdextension-api", +] + +[[package]] +name = "godot-cell" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4750f0da2c2286f8a0f1e2b0aeb5adb2178251086119e1a96186c34cd8857ba1" + +[[package]] +name = "godot-codegen" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd9382da869c3e5f4ba9614f43157bb96f5acf3d1f8341bc25147b7aeebd49a" +dependencies = [ + "godot-bindings", + "heck", + "nanoserde", + "proc-macro2", + "quote", + "regex", +] + +[[package]] +name = "godot-core" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d014ea57227d84955d9db7bba53654e5e9040f3b5a41d6aad370707cad5b7a" +dependencies = [ + "glam", + "godot-bindings", + "godot-cell", + "godot-codegen", + "godot-ffi", +] + +[[package]] +name = "godot-ffi" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a93bc8ea912fc629cc7c6ad889f919e99b4e7f32cd912cc65b9be2a986dc6eb" +dependencies = [ + "gensym", + "godot-bindings", + "godot-codegen", + "libc", + "paste", +] + +[[package]] +name = "godot-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66b16a49485735010c107030dc2e9fa8701fb3bf45194e34b14d1305ad5a8b4f" +dependencies = [ + "godot-bindings", + "proc-macro2", + "quote", + "venial", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "nanoserde" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de9cf844ab1e25a0353525bd74cb889843a6215fa4a0d156fd446f4857a1b99" +dependencies = [ + "nanoserde-derive", +] + +[[package]] +name = "nanoserde-derive" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e943b2c21337b7e3ec6678500687cdc741b7639ad457f234693352075c082204" + +[[package]] +name = "open-strike-2" +version = "0.1.0" +dependencies = [ + "godot", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "syn" +version = "2.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "uuid" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +dependencies = [ + "getrandom", +] + +[[package]] +name = "venial" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6816bc32f30bf8dd1b3adb04de8406c7bf187d2f923bd9e4c0b99365d012613f" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..f62c96c --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "open-strike-2" +version = "0.1.0" +edition = "2021" + +[dependencies] +godot = "0.2.3" + +[lib] +crate-type = ["cdylib"] diff --git a/rust/src/lib.rs b/rust/src/lib.rs new file mode 100644 index 0000000..f048531 --- /dev/null +++ b/rust/src/lib.rs @@ -0,0 +1,7 @@ +use godot::prelude::*; +struct MyExtension; + +mod player; + +#[gdextension] +unsafe impl ExtensionLibrary for MyExtension {} diff --git a/rust/src/player/client_node.rs b/rust/src/player/client_node.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/rust/src/player/client_node.rs @@ -0,0 +1 @@ + diff --git a/rust/src/player/mod.rs b/rust/src/player/mod.rs new file mode 100644 index 0000000..67ca6f4 --- /dev/null +++ b/rust/src/player/mod.rs @@ -0,0 +1,2 @@ +mod client_node; +mod server_node; diff --git a/rust/src/player/server_node.rs b/rust/src/player/server_node.rs new file mode 100644 index 0000000..f95e1e8 --- /dev/null +++ b/rust/src/player/server_node.rs @@ -0,0 +1,95 @@ +use godot::classes::{CharacterBody3D, ICharacterBody3D}; +use godot::obj::WithBaseField; +use godot::prelude::*; + +#[derive(GodotClass)] +#[class(base=CharacterBody3D)] +struct PlayerServerNode { + base: Base, + jumping: bool, + input_direction: Vector2, + input_rotation: Vector3, +} + +const JUMP_VELOCITY: f32 = 4.5; +const SPEED: f32 = 5.0; + +#[godot_api] +impl ICharacterBody3D for PlayerServerNode { + fn init(base: Base) -> Self { + Self { + base, + jumping: false, + input_direction: Vector2::new(0.0, 0.0), + input_rotation: Vector3::new(0.0, 0.0, 0.0), + } + } + + fn ready(&mut self) {} + + fn physics_process(&mut self, delta: f64) { + if !self.base().is_on_floor() { + let new_gravity = self.base().get_gravity() * delta as f32; + let new_velocity = self.base().get_velocity() + new_gravity; + self.base_mut().set_velocity(new_velocity); + } + + if self.base().is_on_floor() && self.jumping { + let mut new_velocity = self.base().get_velocity(); + new_velocity.y = JUMP_VELOCITY; + self.base_mut().set_velocity(new_velocity); + } + self.jumping = false; + + if self.base().is_on_floor() { + let direction = self.base().get_transform().basis + * Vector3::new(self.input_direction.x, 0.0, self.input_direction.y); + if direction.length() > 0.0 { + let direction = direction.normalized(); + let new_velocity = Vector3::new( + direction.x * SPEED, + self.base().get_velocity().y, + direction.z * SPEED, + ); + self.base_mut().set_velocity(new_velocity); + } else { + let moved = self + .base() + .get_velocity() + .clone() + .move_toward(Vector3::new(0.0, 0.0, 0.0), SPEED); + let new_velocity = Vector3::new(moved.x, self.base().get_velocity().y, moved.z); + self.base_mut().set_velocity(new_velocity); + } + } + + self.base_mut().move_and_slide(); + } +} + +#[godot_api] +impl PlayerServerNode { + #[rpc(any_peer, call_local, unreliable_ordered)] + fn jump(&mut self) { + self.jumping = true + } + + #[rpc(any_peer, call_local, unreliable_ordered)] + fn set_input_direction(&mut self, new_input_direction: Vector2) { + self.input_direction = new_input_direction; + } + + #[rpc(any_peer, call_local, unreliable_ordered)] + fn set_rotation_x(&mut self, x: f32) { + let mut new_rotation = self.base().get_rotation(); + new_rotation.x = x; + self.base_mut().set_rotation(new_rotation); + } + + #[rpc(any_peer, call_local, unreliable_ordered)] + fn set_rotation_y(&mut self, y: f32) { + let mut new_rotation = self.base().get_rotation(); + new_rotation.y = y; + self.base_mut().set_rotation(new_rotation); + } +} diff --git a/rust_bindings.gdextension b/rust_bindings.gdextension new file mode 100644 index 0000000..62184d8 --- /dev/null +++ b/rust_bindings.gdextension @@ -0,0 +1,14 @@ +[configuration] +entry_symbol = "gdext_rust_init" +compatibility_minimum = 4.1 +reloadable = true + +[libraries] +linux.debug.x86_64 = "res://rust/target/debug/libopen_strike_2.so" +linux.release.x86_64 = "res://rust/target/release/libopen_strike_2.so" +windows.debug.x86_64 = "res://rust/target/debug/open_strike_2.dll" +windows.release.x86_64 = "res://rust/target/release/open_strike_2.dll" +macos.debug = "res://rust/target/debug/libopen_strike_2.dylib" +macos.release = "res://rust/target/release/libopen_strike_2.dylib" +macos.debug.arm64 = "res://rust/target/debug/libopen_strike_2.dylib" +macos.release.arm64 = "res://rust/target/release/libopen_strike_2.dylib" diff --git a/scenes/characters/blue/dummy.gd b/scenes/characters/blue/dummy.gd index 9ce37fb..aabd963 100644 --- a/scenes/characters/blue/dummy.gd +++ b/scenes/characters/blue/dummy.gd @@ -15,8 +15,6 @@ func _process(delta: float) -> void: func _on_head_collision_body_part_hit(dam: Variant) -> void: - #print("head is hit" + str(dam)) - #print(owner_placeholder) #if owner_placeholder.has_method("take_damage"): if owner_placeholder: owner_placeholder.take_damage(dam) diff --git a/scenes/characters/blue/dummy.tscn b/scenes/characters/blue/dummy.tscn index 5b46334..7e2291b 100644 --- a/scenes/characters/blue/dummy.tscn +++ b/scenes/characters/blue/dummy.tscn @@ -1419,12 +1419,12 @@ shape = SubResource("SphereShape3D_axep3") [node name="PhysicalBoneSimulator3D" type="PhysicalBoneSimulator3D" parent="Body/Armature/Skeleton3D"] [node name="Physical Bone mixamorig_Hips" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] -transform = Transform3D(82.5044, -54.0559, -16.4615, 55.0482, 83.4649, 1.8195, 12.756, -10.5629, 98.619, 1.31498, 0.290624, -87.4646) +transform = Transform3D(82.5044, -54.0559, -16.4615, 55.0482, 83.4649, 1.8195, 12.756, -10.5629, 98.619, 1.31498, 0.290625, -87.4646) collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.35312e-08, -5.58794e-09, 0.0499956) -body_offset = Transform3D(100, -0.0695305, -0.00860751, -1.19209e-05, 12.2744, -99.2438, 0.0700493, 99.2438, 12.2744, 0.00043869, 4.96175, -0.613665) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.11306e-07, -5.58794e-09, 0.0499956) +body_offset = Transform3D(100, -0.0695305, -0.00860918, -1.4782e-05, 12.2744, -99.2438, 0.0700493, 99.2438, 12.2744, 0.000441551, 4.96175, -0.613665) mass = 20.0 bone_name = "mixamorig_Hips" joint_constraints/bias = 0.3 @@ -1436,12 +1436,12 @@ transform = Transform3D(0.01, 0, 0, 0, -4.37114e-10, 0.01, 0, -0.01, -4.37114e-1 shape = SubResource("CapsuleShape3D_0ptuo") [node name="Physical Bone mixamorig_Spine" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] -transform = Transform3D(80.9412, -58.546, -4.56913, 57.6046, 80.6695, -13.1964, 11.4119, 8.0493, 99.0201, 2.40599, 0.973749, -98.2036) +transform = Transform3D(80.9412, -58.546, -4.56913, 57.6046, 80.6695, -13.1964, 11.4119, 8.04929, 99.0201, 2.40599, 0.973749, -98.2036) collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.2222e-09, 2.2377e-09, 0.05866) -body_offset = Transform3D(100, 7.62939e-06, 9.05991e-06, 4.76837e-06, -1.90735e-06, -100, -1.52588e-05, 100, -3.8147e-06, -9.53674e-07, 5.866, 0) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.10332e-09, 5.59426e-10, 0.05866) +body_offset = Transform3D(100, 7.62939e-06, 1.09673e-05, 4.76837e-06, 0, -100, -1.52588e-05, 100, -9.53674e-07, -9.53674e-07, 5.866, 0) mass = 20.0 bone_name = "mixamorig_Spine" joint_constraints/bias = 0.3 @@ -1457,8 +1457,8 @@ transform = Transform3D(-97.8019, 4.47329, 20.366, -15.8369, -79.4709, -58.5966, collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.90306e-08, -1.39698e-07, 0.0981531) -body_offset = Transform3D(-100, -0.00220013, -0.000778198, -5.24521e-06, 33.8066, -94.1122, 0.00232792, -94.1122, -33.8066, 7.24792e-05, 9.23741, 3.31821) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.71765e-08, -1.39698e-07, 0.0981531) +body_offset = Transform3D(-100, -0.00220013, -0.000778198, -5.24521e-06, 33.8066, -94.1122, 0.00232792, -94.1122, -33.8066, 6.86646e-05, 9.23741, 3.31821) mass = 7.0 bone_name = "mixamorig_Head" joint_constraints/bias = 0.3 @@ -1470,12 +1470,12 @@ transform = Transform3D(0.01, 0, 0, 0, -4.37114e-10, 0.01, 0, -0.01, -4.37114e-1 shape = SubResource("CapsuleShape3D_1gw5y") [node name="Physical Bone mixamorig_LeftArm" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] -transform = Transform3D(86.1165, 14.0252, -48.8594, -45.4995, 64.1262, -61.787, 22.6659, 75.4396, 61.6046, 16.1942, 31.0309, -132.592) +transform = Transform3D(86.1165, 14.0252, -48.8594, -45.4995, 64.1262, -61.787, 22.6659, 75.4395, 61.6046, 16.1942, 31.0309, -132.592) collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.65892e-08, 2.39336e-07, 0.137023) -body_offset = Transform3D(100, -3.05176e-05, -2.67029e-05, 2.09808e-05, 100, -7.62939e-06, 1.71661e-05, -3.8147e-06, 100, 0, -2.28882e-05, -13.7023) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.17137e-09, 2.34109e-07, 0.137023) +body_offset = Transform3D(100, -4.19617e-05, -2.47955e-05, 2.86102e-05, 100, -3.8147e-06, 1.71661e-05, -3.8147e-06, 100, 3.8147e-06, -2.28882e-05, -13.7023) mass = 3.0 bone_name = "mixamorig_LeftArm" joint_constraints/bias = 0.3 @@ -1487,12 +1487,12 @@ transform = Transform3D(0.01, 0, 0, 0, 0.00997432, -0.000716193, 0, 0.000716193, shape = SubResource("CapsuleShape3D_krlof") [node name="Physical Bone mixamorig_LeftForeArm" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] -transform = Transform3D(-48.2566, -12.058, 86.752, -78.7312, -37.4258, -48.997, 38.3757, -91.9452, 8.56699, 1.36485, 46.9033, -104.66) +transform = Transform3D(-48.2566, -12.058, 86.752, -78.7312, -37.4258, -48.997, 38.3757, -91.9452, 8.56699, 1.36484, 46.9033, -104.66) collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.47239e-07, 6.31263e-08, 0.138072) -body_offset = Transform3D(100, 3.05176e-05, -4.19617e-05, -3.8147e-05, 0, -100, -3.8147e-06, 100, 9.53674e-06, 3.05176e-05, 13.8072, -7.62939e-06) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.99827e-07, 6.04928e-08, 0.138072) +body_offset = Transform3D(100, 3.05176e-05, -4.19617e-05, -3.8147e-05, 0, -100, -3.8147e-06, 100, 1.14441e-05, 4.57764e-05, 13.8072, -7.62939e-06) mass = 3.0 bone_name = "mixamorig_LeftForeArm" joint_constraints/bias = 0.3 @@ -1541,8 +1541,8 @@ transform = Transform3D(24.3552, 37.4063, 89.4852, -25.0101, 91.5653, -31.4688, collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.40737e-07, -2.80688e-08, 0.138072) -body_offset = Transform3D(100, -1.14441e-05, 8.58307e-06, -3.8147e-06, 100, 9.53674e-06, 5.72205e-06, -5.72205e-06, 100, -1.52588e-05, 1.49012e-06, -13.8072) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.40737e-07, -5.19106e-08, 0.138072) +body_offset = Transform3D(100, -1.14441e-05, 8.58307e-06, -3.8147e-06, 100, 9.53674e-06, 5.72205e-06, -5.72205e-06, 100, -1.52588e-05, 3.8743e-06, -13.8072) mass = 3.0 bone_name = "mixamorig_RightForeArm" joint_constraints/bias = 0.3 @@ -1558,8 +1558,8 @@ transform = Transform3D(89.0767, -24.8074, -38.0781, 5.05123, 88.6726, -45.9527, collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.86265e-08, 2.31434e-07, 0.0264903) -body_offset = Transform3D(-58.5197, -57.9893, -56.6805, -1.19209e-05, 69.8991, -71.5131, 81.0891, -41.8492, -40.9048, 1.5015, 1.89439, 1.08359) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.86265e-08, 2.30502e-07, 0.0264903) +body_offset = Transform3D(-58.5197, -57.9893, -56.6805, -1.33514e-05, 69.8991, -71.5131, 81.0891, -41.8492, -40.9048, 1.5015, 1.89439, 1.08359) bone_name = "mixamorig_RightHand" joint_constraints/bias = 0.3 joint_constraints/damping = 1.0 @@ -1575,7 +1575,7 @@ collision_layer = 4 collision_mask = 4 joint_type = 1 joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.78612e-08, -7.74374e-09, 0.202997) -body_offset = Transform3D(100, -2.86102e-05, 9.53674e-06, 7.62939e-06, 7.62939e-06, -100, 3.71933e-05, 100, 3.8147e-06, -5.72205e-06, 20.2997, 0) +body_offset = Transform3D(100, -4.3869e-05, 9.53674e-06, 9.53674e-06, 7.62939e-06, -100, 4.673e-05, 100, 3.8147e-06, -5.72205e-06, 20.2997, 0) mass = 5.0 bone_name = "mixamorig_LeftUpLeg" joint_constraints/bias = 0.3 @@ -1604,12 +1604,12 @@ transform = Transform3D(0.01, 0, 0, 0, -4.37114e-10, 0.01, 0, -0.01, -4.37114e-1 shape = SubResource("CapsuleShape3D_vwdij") [node name="Physical Bone mixamorig_LeftFoot" type="PhysicalBone3D" parent="Body/Armature/Skeleton3D/PhysicalBoneSimulator3D"] -transform = Transform3D(-93.6712, -34.5296, 5.78095, -34.9451, 91.207, -21.4506, 2.13418, -22.1132, -97.501, 11.7385, 3.12728, -14.5678) +transform = Transform3D(-93.6712, -34.5296, 5.78095, -34.9451, 91.207, -21.4506, 2.13419, -22.1132, -97.501, 11.7385, 3.12728, -14.5678) collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.66258e-09, 5.6483e-08, 0.078608) -body_offset = Transform3D(100, 5.72205e-06, -2.38419e-06, -2.86102e-06, -1.52588e-05, -100, -5.72205e-06, 100, -3.24249e-05, 9.53674e-07, 7.8608, -3.09944e-06) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.41225e-09, 7.07881e-08, 0.078608) +body_offset = Transform3D(100, 5.72205e-06, -1.43051e-06, -9.53674e-07, -1.52588e-05, -100, -5.72205e-06, 100, -3.24249e-05, 9.53674e-07, 7.8608, -4.52995e-06) bone_name = "mixamorig_LeftFoot" joint_constraints/bias = 0.3 joint_constraints/damping = 1.0 @@ -1641,8 +1641,8 @@ transform = Transform3D(-91.8175, -23.5086, -31.8888, -36.0103, 83.0805, 42.437, collision_layer = 4 collision_mask = 4 joint_type = 1 -joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.27453e-09, -2.4944e-07, 0.210495) -body_offset = Transform3D(100, -1.71661e-05, 1.33514e-05, -9.53674e-07, 4.19617e-05, -100, 1.90735e-05, 100, 6.86646e-05, -3.33786e-06, 21.0495, 1.04904e-05) +joint_offset = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.48112e-08, -2.68514e-07, 0.210495) +body_offset = Transform3D(100, -1.71661e-05, 1.33514e-05, -9.53674e-07, 4.19617e-05, -100, 1.90735e-05, 100, 6.86646e-05, -4.29153e-06, 21.0495, 1.23978e-05) mass = 5.0 bone_name = "mixamorig_RightLeg" joint_constraints/bias = 0.3 diff --git a/scenes/characters/placeholder.tscn b/scenes/characters/placeholder.tscn index 0de9c44..a7696d3 100644 --- a/scenes/characters/placeholder.tscn +++ b/scenes/characters/placeholder.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=11 format=3 uid="uid://b10lpwfjgxds4"] +[gd_scene load_steps=13 format=3 uid="uid://b10lpwfjgxds4"] [ext_resource type="Script" path="res://scripts/player/player_input_controller.gd" id="1_q75ai"] [ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="2_lsd7c"] +[ext_resource type="Script" path="res://scenes/characters/player_input_controller.gd" id="3_n3epd"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jc50w"] margin = 0.5 @@ -10,14 +11,20 @@ height = 1.6 [sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_tl74a"] properties/0/path = NodePath(".:position") -properties/0/spawn = false +properties/0/spawn = true properties/0/replication_mode = 1 properties/1/path = NodePath(".:rotation") -properties/1/spawn = false +properties/1/spawn = true properties/1/replication_mode = 1 properties/2/path = NodePath(".:health") -properties/2/spawn = false +properties/2/spawn = true properties/2/replication_mode = 2 +properties/3/path = NodePath(".:velocity") +properties/3/spawn = true +properties/3/replication_mode = 1 +properties/4/path = NodePath(".:owner_id") +properties/4/spawn = true +properties/4/replication_mode = 1 [sub_resource type="Animation" id="Animation_falg4"] length = 0.001 @@ -83,11 +90,23 @@ font_size = 70 font_size = 100 font_color = Color(0.756874, 0, 0.223924, 1) +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_eour5"] +properties/0/path = NodePath(".:input_direction") +properties/0/spawn = false +properties/0/replication_mode = 2 +properties/1/path = NodePath(".:jumping") +properties/1/spawn = false +properties/1/replication_mode = 2 + [node name="CharacterPlaceholder" type="CharacterBody3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.799455, 0) collision_layer = 9 collision_mask = 9 script = ExtResource("1_q75ai") +health = null +owner_id = null +jump_height = null +camera_sens = null [node name="Collision" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0150437, 0) @@ -118,6 +137,7 @@ libraries = { } [node name="HUD" type="Control" parent="FirstPersonCameraMount"] +visible = false layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -163,3 +183,8 @@ label_settings = SubResource("LabelSettings_1j1uq") [node name="ModelMount" type="Node3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.790262, 0) + +[node name="PlayerInput" type="MultiplayerSynchronizer" parent="."] +root_path = NodePath(".") +replication_config = SubResource("SceneReplicationConfig_eour5") +script = ExtResource("3_n3epd") diff --git a/scenes/characters/player_input_controller.gd b/scenes/characters/player_input_controller.gd new file mode 100644 index 0000000..d62ba3b --- /dev/null +++ b/scenes/characters/player_input_controller.gd @@ -0,0 +1,35 @@ +extends MultiplayerSynchronizer + +@export var jumping := false +@export var input_direction := Vector2() + +@onready var camera_mount = $"../FirstPersonCameraMount" +@onready var placeholder = $".." + +func _ready() -> void: + pass + #set_process(get_multiplayer_authority() == multiplayer.get_unique_id()) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + # Add the gravity. + if multiplayer.get_unique_id() == get_multiplayer_authority(): + input_direction = Input.get_vector("move_left", "move_right", "move_forward", "move_backwards") + set_input_direction.rpc(input_direction) + if Input.is_action_just_pressed("jump"): + jump.rpc_id(1) + +var camera_sens: float = 0.002 +func _input(event): + if multiplayer.get_unique_id() == get_multiplayer_authority(): + if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED: + placeholder.rotate_y(-event.relative.x * camera_sens) + + +@rpc("any_peer", "call_local", "reliable") +func set_input_direction(direction: Vector2): + input_direction = direction + +@rpc("any_peer", "call_local", "reliable") +func jump(): + jumping = true diff --git a/scenes/maps/base/map_loader.gd b/scenes/maps/base/map_loader.gd index 69ebadf..4ddf7b2 100644 --- a/scenes/maps/base/map_loader.gd +++ b/scenes/maps/base/map_loader.gd @@ -20,30 +20,34 @@ func _ready() -> void: err = _add_player_spawner() if err != OK: - print("Couldn't load player spawner") + push_error("Couldn't load player spawner") err = _add_object_spawner() if err != OK: - print("Couldn't load object spawner") + push_error("Couldn't load object spawner") # add objects spawner - if multiplayer.is_server(): - _spawn_player(1) - else: + if not OS.has_feature("dedicated_server"): _request_spawn.rpc_id(1, multiplayer.get_unique_id()) pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: - pass + if multiplayer.is_server(): + var active_players = player_spawner._get_root().get_children() + for n in active_players: + if not GameServerManager.players.has(n.owner_id): + _remove_player(n.owner_id) @rpc("call_local", "reliable", "any_peer") func _request_spawn(id: int): _spawn_player(id) func _spawn_player(id: int): - var char : Node3D = null player_spawner.spawn_players(spawn_locations, id) +func _remove_player(id: int): + player_spawner.remove_player(id) + func _add_player_spawner() -> Error : if not ResourceLoader.exists(PLAYER_SPAWNER): return ERR_DOES_NOT_EXIST diff --git a/scenes/maps/base/player_spawner/player_spawner.gd b/scenes/maps/base/player_spawner/player_spawner.gd index cb5eaaa..c6ca1a0 100644 --- a/scenes/maps/base/player_spawner/player_spawner.gd +++ b/scenes/maps/base/player_spawner/player_spawner.gd @@ -21,13 +21,21 @@ func spawn_players(spawn_location: SpawnController, id: int) -> Error: if multiplayer.is_server(): var char : Node3D = null var player_data: PlayerState = GameServerManager.players[id] - char = ResourceLoader.load("res://scenes/characters/placeholder.tscn").instantiate() + char = ResourceLoader.load("res://scenes/player/placeholder.tscn").instantiate() char.name = "PlayerPlaceholder_" + str(player_data.id) - print(player_data) - var position = spawn_location.get_spawner(SpawnController.Sides.BLUE) - char.global_position = position - char.global_position = position - #_get_spawner().spawn(char) + char.owner_id = id + var position: Vector3 = spawn_location.get_spawner(SpawnController.Sides.BLUE) + char.set_server_position(position) _get_root().add_child(char) return OK return ERR_UNAUTHORIZED + +func remove_player(id: int) -> Error: + if multiplayer.is_server(): + var found_childen: Array[Node] =_get_root().get_children() + for found_child in found_childen: + if found_child.owner_id: + if found_child.owner_id == id: + found_child.queue_free() + return OK + return ERR_UNAUTHORIZED diff --git a/scenes/maps/base/player_spawner/player_spawner.tscn b/scenes/maps/base/player_spawner/player_spawner.tscn index 2fea67d..8c3c34b 100644 --- a/scenes/maps/base/player_spawner/player_spawner.tscn +++ b/scenes/maps/base/player_spawner/player_spawner.tscn @@ -6,7 +6,7 @@ script = ExtResource("1_2hsyd") [node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."] -_spawnable_scenes = PackedStringArray("res://scenes/characters/placeholder.tscn") +_spawnable_scenes = PackedStringArray("res://scenes/characters/placeholder.tscn", "res://scenes/player/placeholder.tscn") spawn_path = NodePath("../Players") spawn_limit = 10 diff --git a/scenes/maps/base/spawn_controller.gd b/scenes/maps/base/spawn_controller.gd index 91e4beb..21ae968 100644 --- a/scenes/maps/base/spawn_controller.gd +++ b/scenes/maps/base/spawn_controller.gd @@ -31,9 +31,7 @@ func _get_available_spawn(spawn_set: Node3D) -> Node3D: for spawn: Node3D in spawn_set.get_children(): if not spawn.busy: spawns.push_back(spawn) - print(spawns.size()) var random_index: int = randi_range(0, spawns.size() - 1) - print(random_index) return spawns[random_index] return null @@ -47,6 +45,5 @@ func get_spawner(team: Sides) -> Vector3: print("red") return Vector3(0,0,0) _: - print("хз") return Vector3(0,0,0) # Get all spawners for each team diff --git a/scenes/maps/maps/lowpoly_tdm_2.tscn b/scenes/maps/maps/lowpoly_tdm_2.tscn index 8a03531..825e6c9 100644 --- a/scenes/maps/maps/lowpoly_tdm_2.tscn +++ b/scenes/maps/maps/lowpoly_tdm_2.tscn @@ -961,13 +961,37 @@ script = ExtResource("2_1ss1b") [node name="Blue" type="Node3D" parent="SpawnLocations"] +[node name="Spawn4" type="Node3D" parent="SpawnLocations/Blue"] +transform = Transform3D(-0.332276, 0, 0.943182, 0, 1, 0, -0.943182, 0, -0.332276, 53.1487, -0.0093751, -8.68195) + [node name="Spawn1" type="Node3D" parent="SpawnLocations/Blue"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.234959, 25.2818, 2.12756) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 52.9098, -0.00937462, 10.3532) [node name="Spawn2" type="Node3D" parent="SpawnLocations/Blue"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 29.4253, 15.2112, 4.25512) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 52.8486, -0.00937653, 4.25512) + +[node name="Spawn3" type="Node3D" parent="SpawnLocations/Blue"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 53.6493, -0.00937504, -4.34097) + +[node name="Spawn5" type="Node3D" parent="SpawnLocations/Blue"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 51.5453, -0.0187502, -17.3639) [node name="Red" type="Node3D" parent="SpawnLocations"] +[node name="Spawn4" type="Node3D" parent="SpawnLocations/Red"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -40.9916, -0.0093751, -8.68195) + +[node name="Spawn1" type="Node3D" parent="SpawnLocations/Red"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -41.2305, -0.00937462, 10.3532) + +[node name="Spawn2" type="Node3D" parent="SpawnLocations/Red"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -41.2917, -0.00937653, 4.25512) + +[node name="Spawn3" type="Node3D" parent="SpawnLocations/Red"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -40.491, -0.00937504, -4.34097) + +[node name="Spawn5" type="Node3D" parent="SpawnLocations/Red"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -42.595, -0.0187502, -17.3639) + [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_3ha0j") diff --git a/scenes/player/placeholder.gd b/scenes/player/placeholder.gd new file mode 100644 index 0000000..6a7dcb8 --- /dev/null +++ b/scenes/player/placeholder.gd @@ -0,0 +1,115 @@ +extends Node3D +class_name PlayerPlaceholder + +@export var owner_id: int = 0 +@export var initial_position: Vector3 = Vector3(0, 0, 0) +# -- Components +@onready var client_node: CharacterBody3D = $PlayerControlledNode +@onready var server_node: PlayerServerNode = $ServerControlledNode +@export var character_speed: int = 5 + + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + set_multiplayer_authority(1) + client_node.set_multiplayer_authority(owner_id) + $PlayerControlledNode/CameraMount.set_multiplayer_authority(owner_id) + switch_players_camera.rpc_id(owner_id) + server_node.global_position = initial_position + client_node.global_position = server_node.global_position + client_node.rotation.y = server_node.rotation.y + client_node.rotation.x = server_node.rotation.x + + if multiplayer.is_server(): + $Timer.start() + if owner_id != multiplayer.get_unique_id(): + client_node.queue_free() + else: + pass + #client_node._add_legs_to_first_view() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + #if desired_player_state.globa_position != real_player_state.globa_position: + #desired_player_state.globa_position = real_player_state.globa_position + + pass + +func _physics_process(delta: float) -> void: + pass + +@rpc("authority", "call_local", "reliable") +func switch_players_camera(): + $PlayerControlledNode/CameraMount/Camera3D.make_current() + +func set_server_position(position: Vector3): + initial_position = position + + +func _on_Timer_timeout(): + $Timer.start() + + +func _on_timer_timeout() -> void: + if multiplayer.is_server(): + verify_position.rpc_id(owner_id) + verify_rotation.rpc_id(owner_id) + $Timer.start() + + pass # Replace with function body. + +@rpc("authority", "call_local") +func verify_position(): + var desired_position: Vector3 = client_node.global_position + send_position.rpc_id(1, desired_position.x, desired_position.y, desired_position.z) + +@rpc("any_peer", "call_local") +func send_position(x: float, y: float, z: float): + var desired_position: Vector3 = Vector3(x, y, z) + if multiplayer.is_server(): + var real_position: Vector3 = server_node.global_position + var difference: Vector3 = desired_position - real_position + if is_vector_a_lower_than_b(difference, Vector3(0.3, 0.3, 0.3)): + server_node.global_position = desired_position + else: + var new_position: Vector3 = desired_position.lerp(real_position, 0.5) + adjust_position.rpc_id(owner_id, new_position.x, new_position.y, new_position.z) + +@rpc("authority", "call_local") +func adjust_position(x: float, y: float, z: float): + var desired_position: Vector3 = Vector3(x, y, z) + if owner_id == multiplayer.get_unique_id(): + push_warning("player position is not valid, adjusting") + client_node.global_position = desired_position + + +@rpc("authority", "call_local") +func verify_rotation(): + var desired_rotation: Vector3 = client_node.rotation + send_rotation.rpc_id(1, desired_rotation.x, desired_rotation.y, desired_rotation.z) + +@rpc("any_peer", "call_local") +func send_rotation(x: float, y: float, z: float): + var desired_rotation: Vector3 = Vector3(x, y, z) + if multiplayer.is_server(): + var real_rotation: Vector3 = server_node.rotation + var difference: Vector3 = desired_rotation - real_rotation + if is_vector_a_lower_than_b(difference, Vector3(0.3, 0.3, 0.3)): + server_node.rotation = desired_rotation + else: + var new_rotation: Vector3 = desired_rotation.lerp(real_rotation, 0.5) + adjust_rotation.rpc_id(owner_id, new_rotation.x, new_rotation.y, new_rotation.z) + +@rpc("any_peer", "call_local") +func adjust_rotation(x: float, y: float, z: float): + var desired_rotation: Vector3 = Vector3(x, y, z) + if owner_id == multiplayer.get_unique_id(): + push_warning("player rotation is not valid, adjusting") + client_node.rotation = desired_rotation + + + +func is_vector_a_lower_than_b(vec_a: Vector3, vec_b: Vector3) -> bool: + return vec_a.x < vec_b.x and vec_a.y < vec_b.y and vec_a.z < vec_b.z diff --git a/scenes/player/placeholder.tscn b/scenes/player/placeholder.tscn new file mode 100644 index 0000000..00b76bf --- /dev/null +++ b/scenes/player/placeholder.tscn @@ -0,0 +1,224 @@ +[gd_scene load_steps=15 format=3 uid="uid://bmm3brgvr4d86"] + +[ext_resource type="Script" path="res://scenes/player/player_input_controller.gd" id="1_m6tul"] +[ext_resource type="Script" path="res://scenes/player/placeholder.gd" id="1_ts455"] +[ext_resource type="Texture2D" uid="uid://oopj5mj1vdp0" path="res://assets/crosshairs/crosshair_default.png" id="3_8ulsx"] +[ext_resource type="Script" path="res://scenes/player/server_player_controller.gd" id="3_f1bhn"] +[ext_resource type="PackedScene" uid="uid://dtvo21mk1webd" path="res://scenes/weapon/guns/ak/with_hands.tscn" id="3_xxv4y"] +[ext_resource type="PackedScene" uid="uid://1txob6jskn5s" path="res://scenes/characters/blue/dummy.tscn" id="6_e3cnh"] + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_taqso"] +radius = 0.4 +height = 1.6 + +[sub_resource type="LabelSettings" id="LabelSettings_3bk8i"] +font_size = 70 + +[sub_resource type="LabelSettings" id="LabelSettings_adbcb"] +font_size = 100 +font_color = Color(0.756874, 0, 0.223924, 1) + +[sub_resource type="Animation" id="Animation_falg4"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0.125), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector3(0, 0, 0)] +} + +[sub_resource type="Animation" id="Animation_mkk0p"] +resource_name = "move" +length = 0.5 +loop_mode = 2 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.125, 0.25, 0.375, 0.5), +"transitions": PackedFloat32Array(1, 2, 1, 2, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(-0.1, 0.1, -0.1), Vector3(0, 0, 0), Vector3(-0.1, 0.1, -0.1), Vector3(0, 0, 0)] +} + +[sub_resource type="Animation" id="Animation_ah507"] +resource_name = "shooting" +length = 0.2 +loop_mode = 1 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.1, 0.2), +"transitions": PackedFloat32Array(1, 0.233258, 8.57419), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, -0.01, -0.01), Vector3(0, 0, 0)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_u1b6p"] +_data = { +"RESET": SubResource("Animation_falg4"), +"move": SubResource("Animation_mkk0p"), +"shooting": SubResource("Animation_ah507") +} + +[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_7vlrn"] +properties/0/path = NodePath("ServerControlledNode:position") +properties/0/spawn = true +properties/0/replication_mode = 1 +properties/1/path = NodePath(".:owner_id") +properties/1/spawn = true +properties/1/replication_mode = 2 +properties/2/path = NodePath("ServerControlledNode:rotation") +properties/2/spawn = true +properties/2/replication_mode = 1 +properties/3/path = NodePath(".:initial_position") +properties/3/spawn = true +properties/3/replication_mode = 2 + +[node name="Placeholder" type="Node3D"] +script = ExtResource("1_ts455") + +[node name="PlayerControlledNode" type="CharacterBody3D" parent="."] +collision_layer = 2 +script = ExtResource("1_m6tul") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerControlledNode"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.786919, 0) +shape = SubResource("CapsuleShape3D_taqso") + +[node name="CameraMount" type="Node3D" parent="PlayerControlledNode"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.29568, -0.412934) + +[node name="Camera3D" type="Camera3D" parent="PlayerControlledNode/CameraMount"] +cull_mask = 524287 + +[node name="HUD" type="Control" parent="PlayerControlledNode/CameraMount/Camera3D"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 8.0 +offset_right = 8.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 + +[node name="TextureRect" type="TextureRect" parent="PlayerControlledNode/CameraMount/Camera3D/HUD"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -36.0 +offset_top = -36.0 +offset_right = 36.0 +offset_bottom = 36.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_8ulsx") + +[node name="HealthIndicator" type="Label" parent="PlayerControlledNode/CameraMount/Camera3D/HUD"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -23.0 +offset_right = 40.0 +grow_vertical = 0 +text = "100" +label_settings = SubResource("LabelSettings_3bk8i") + +[node name="FPS" type="Label" parent="PlayerControlledNode/CameraMount/Camera3D/HUD" groups=["player_placeholder"]] +layout_mode = 1 +offset_right = 40.0 +offset_bottom = 23.0 +text = "0" +label_settings = SubResource("LabelSettings_adbcb") + +[node name="SubViewportContainer" type="SubViewportContainer" parent="PlayerControlledNode/CameraMount/Camera3D/HUD"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +stretch = true + +[node name="SubViewport" type="SubViewport" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer"] +transparent_bg = true +handle_input_locally = false +msaa_2d = 1 +msaa_3d = 1 +canvas_cull_mask = 4294443008 +size = Vector2i(1920, 1964) +render_target_update_mode = 4 + +[node name="Camera3D" type="Camera3D" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport"] +cull_mask = 524288 +fov = 40.0 + +[node name="GunMount" type="Node3D" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D"] + +[node name="AnimationPlayer" type="AnimationPlayer" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D/GunMount"] +active = false +libraries = { +"": SubResource("AnimationLibrary_u1b6p") +} + +[node name="WithHands" parent="PlayerControlledNode/CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D/GunMount" instance=ExtResource("3_xxv4y")] +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0.51335, -0.655058, -1.67097) +visible = false + +[node name="BulletStartingPoint" type="Node3D" parent="PlayerControlledNode/CameraMount"] +transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, -0.42185) + +[node name="AimRay" type="RayCast3D" parent="PlayerControlledNode/CameraMount/BulletStartingPoint"] +target_position = Vector3(0, 0, 1000) +hit_from_inside = true +collide_with_areas = true + +[node name="Node3D" type="Node3D" parent="PlayerControlledNode"] + +[node name="ServerControlledNodeBak" type="CharacterBody3D" parent="."] +collision_layer = 4 +script = ExtResource("3_f1bhn") + +[node name="Dummy" parent="ServerControlledNodeBak" instance=ExtResource("6_e3cnh")] +visible = false + +[node name="CollisionShape3D" type="CollisionShape3D" parent="ServerControlledNodeBak"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.57384, 0) +shape = SubResource("CapsuleShape3D_taqso") + +[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] +replication_config = SubResource("SceneReplicationConfig_7vlrn") + +[node name="Timer" type="Timer" parent="."] +wait_time = 0.1 + +[node name="ServerControlledNode" type="PlayerServerNode" parent="."] +collision_layer = 4 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="ServerControlledNode"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.786919, 0) +shape = SubResource("CapsuleShape3D_taqso") + +[node name="CSGBox3D" type="CSGBox3D" parent="ServerControlledNode"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.47058, 0) + +[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/scenes/player/player_input_controller.gd b/scenes/player/player_input_controller.gd new file mode 100644 index 0000000..9b39e57 --- /dev/null +++ b/scenes/player/player_input_controller.gd @@ -0,0 +1,146 @@ +# --------------------------------------------------------------------- +# --------------------------------------------------------------------- +# This script is supposed to control the node that is rendered on the +# client side, and send the changes to the server node +# --------------------------------------------------------------------- + +extends CharacterBody3D + +@export var jumping := false +@export var input_direction := Vector2() + +@onready var camera_mount = $CameraMount +@onready var camera = $CameraMount/Camera3D +@onready var placeholder: Node3D = $'..' +var paused := false +const JUMP_VELOCITY = 4.5 + + +#func _ready() -> void: +var current_gun: String = "ak" +@onready var gun_mount: Node3D = $CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D/GunMount +@onready var gun_mount_anim: AnimationPlayer = $CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D/GunMount/AnimationPlayer +var gun_with_hands: Node3D = null +@onready var bullet_starting_point: Node3D = $CameraMount/BulletStartingPoint +@onready var aim_ray: RayCast3D = $CameraMount/BulletStartingPoint/AimRay +@onready var gun_camera: Camera3D = $CameraMount/Camera3D/HUD/SubViewportContainer/SubViewport/Camera3D +var current_weapon_damage: int +var current_weapon_bullet_speed: int +var current_weapon_cooldown_interwal: float +var look_dir: Vector2 +func _ready() -> void: + global_position = $"..".initial_position + # -- TODO: It should not be hardcoded + # Define a format string with placeholder '%s' + var path_tmpl := "res://scenes/weapon/guns/%s/with_hands.tscn" + var path := path_tmpl % current_gun + var scene: PackedScene = ResourceLoader.load(path) + var node: Node3D = scene.instantiate() + node.scale = Vector3(0.5,0.5,0.5) + node.position = Vector3(0.5, -0.5, -1.5) + current_weapon_bullet_speed = node.bullet_speed + current_weapon_cooldown_interwal = node.cooldown + current_weapon_damage = node.damage + gun_with_hands = node + gun_mount.add_child(node) + +func _input(event): + if multiplayer.get_unique_id() == get_multiplayer_authority(): + if Input.is_action_just_pressed("jump"): jumping = true + + if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED: + look_dir = event.relative * 1 + rotation.y -= look_dir.x * camera_sens * 1.0 + camera_mount.rotation.x = clamp(camera_mount.rotation.x - look_dir.y * camera_sens * 1.0, -1.5, 1.5) + server_node.set_rotation_y.rpc_id(1, rotation.y) + server_node.set_rotation_x.rpc_id(1, rotation.x) + #server_node.set_input_direction.rpc_id(1, rotation.x, rotation.y) + +@onready var server_node: PlayerServerNode = $"../ServerControlledNode" +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _physics_process(delta: float) -> void: + if multiplayer.get_unique_id() == get_multiplayer_authority(): + if !paused: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + input_direction = Input.get_vector("move_left", "move_right", "move_forward", "move_backwards") + server_node.set_input_direction.rpc_id(1, input_direction) + if Input.is_action_just_pressed("jump"): + server_node.jump.rpc_id(1) + if Input.is_action_pressed("shot"): _shoot() + if multiplayer.get_unique_id() == get_multiplayer_authority(): + if not is_on_floor(): + velocity += get_gravity() * delta + if is_on_floor() && jumping: + velocity.y = JUMP_VELOCITY + jumping = false + var direction := (transform.basis * Vector3(input_direction.x, 0, input_direction.y)).normalized() + if is_on_floor(): + if direction: + #first_view_legs_anim.play("Run Forward") + gun_mount_anim.play("move") + velocity.x = direction.x * placeholder.character_speed + velocity.z = direction.z * placeholder.character_speed + else: + velocity.x = move_toward(velocity.x, 0, placeholder.character_speed) + velocity.z = move_toward(velocity.z, 0, placeholder.character_speed) +func _process(delta: float) -> void: + move_and_slide() + + +var cant_shoot: bool = false +func _shoot(): + if not cant_shoot: + gun_with_hands.shoot() + cant_shoot = true + await get_tree().create_timer(current_weapon_cooldown_interwal).timeout + cant_shoot = false + +#func _physics_process(delta: float) -> void: + #if multiplayer.get_unique_id() == get_multiplayer_authority(): + #if not is_on_floor(): + #velocity += get_gravity() * delta + #if is_on_floor() && jumping: + #velocity.y = JUMP_VELOCITY + #jumping = false + #var direction := (transform.basis * Vector3(input_direction.x, 0, input_direction.y)).normalized() + #if is_on_floor(): + #if direction: + #velocity.x = direction.x * placeholder.character_speed + #velocity.z = direction.z * placeholder.character_speed + #else: + #velocity.x = move_toward(velocity.x, 0, placeholder.character_speed) + #velocity.z = move_toward(velocity.z, 0, placeholder.character_speed) + #move_and_slide() +var first_view_legs_anim: AnimationPlayer = null +func _add_legs_to_first_view() -> Error : + # -- TODO: It should not be hardcoded + var path := "res://scenes/characters/blue/dummy.tscn" + if not ResourceLoader.exists(path): + return ERR_DOES_NOT_EXIST + var scene: PackedScene = ResourceLoader.load(path) + if not scene.can_instantiate(): + return ERR_CANT_OPEN + var node: Node3D = scene.instantiate() + var skeleton: Skeleton3D = node.find_child("Skeleton3D") + var bone := skeleton.find_bone("mixamorig_Spine") + if bone != -1: + skeleton.set_bone_pose_scale(bone, Vector3(0, 0, 0)) + add_child(node) + var animation_node: AnimationPlayer = node.find_child("AnimationPlayer") + if animation_node != null: + first_view_legs_anim = animation_node + return OK + +var camera_sens: float = 0.002 + +@rpc("authority", "reliable") +func set_current_rotation(rotation: Vector3): + rotation = rotation + +@rpc("any_peer", "reliable") +func set_current_position(x: float, y: float, z: float): + global_position = Vector3(x, y ,z) + +@rpc("any_peer", "call_local", "reliable") +func jump(): + jumping = true diff --git a/scenes/player/server_player_controller.gd b/scenes/player/server_player_controller.gd new file mode 100644 index 0000000..0a41285 --- /dev/null +++ b/scenes/player/server_player_controller.gd @@ -0,0 +1,48 @@ +class_name ServerControlledPlayer +extends CharacterBody3D +const JUMP_VELOCITY = 4.5 + +func _ready() -> void: + pass + +@export_category("ServerControlledPlayer") +@onready var placeholder: Node3D = $'..' + +var input_direction := Vector2() +var input_rotation_y + +@rpc("call_local", "any_peer", "unreliable_ordered") +func set_input_direction(new_input_direction: Vector2): + input_direction = new_input_direction + +@rpc("call_local", "any_peer", "unreliable_ordered") +func set_rotation_y(new_rotation_y: float): + rotation.y = new_rotation_y + +@rpc("call_local", "any_peer", "unreliable_ordered") +func set_rotation_x(new_rotation_x: float): + rotation.x = new_rotation_x + +@rpc("call_local", "any_peer", "unreliable_ordered") +func jump(): + jumping = true + +var jumping := false +func _process(delta: float) -> void: + if not is_on_floor(): + velocity += get_gravity() * delta + if is_on_floor() && jumping: + velocity.y = JUMP_VELOCITY + jumping = false + if is_on_floor(): + var direction := (transform.basis * Vector3(input_direction.x, 0, input_direction.y)).normalized() + #if is_on_floor(): + if direction: + velocity.x = direction.x * placeholder.character_speed + velocity.z = direction.z * placeholder.character_speed + else: + velocity.x = move_toward(velocity.x, 0, placeholder.character_speed) + velocity.z = move_toward(velocity.z, 0, placeholder.character_speed) + +func _physics_process(delta: float) -> void: + move_and_slide() diff --git a/scenes/utils/menu.gd b/scenes/utils/menu.gd index 8f7f77f..aabab56 100644 --- a/scenes/utils/menu.gd +++ b/scenes/utils/menu.gd @@ -60,7 +60,6 @@ func remove_multiplayer_peer(): func load_game(): var chosen_map_index = $Maps.get_selected_items()[0] var chosen_map = $Maps.get_item_text(chosen_map_index) - print(chosen_map) var path_tmpl := "res://scenes/maps/maps/%s" var path := path_tmpl % chosen_map get_tree().change_scene_to_file(path) diff --git a/scenes/utils/menus/main/main_menu.gd b/scenes/utils/menus/main/main_menu.gd index bb9b2d1..a493bed 100644 --- a/scenes/utils/menus/main/main_menu.gd +++ b/scenes/utils/menus/main/main_menu.gd @@ -4,14 +4,24 @@ var player_manager: PlayerManager = PlayerManager.new() # Called when the node enters the scene tree for the first time. func _ready() -> void: - var map_dir := DirAccess.open("res://scenes/maps/maps/") - - if map_dir: - map_dir.list_dir_begin() - var file_name = map_dir.get_next() - while file_name != "": - $UI/CreateServer/Maps.add_item(file_name) - file_name = map_dir.get_next() + if OS.has_feature("dedicated_server"): + var chosen_map = "lowpoly_tdm_2.tscn" + var path_tmpl := "res://scenes/maps/maps/%s" + var path := path_tmpl % chosen_map + GameServerManager.current_map = path + var err := GameServerManager.create_server(player_manager) + if err != OK: + push_error("couldn't create a server") + change_level.call_deferred(path) + print(get_tree().get_root()) + else: + var map_dir := DirAccess.open("res://scenes/maps/maps/") + if map_dir: + map_dir.list_dir_begin() + var file_name = map_dir.get_next() + while file_name != "": + $UI/CreateServer/Maps.add_item(file_name) + file_name = map_dir.get_next() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: @@ -34,20 +44,28 @@ func _on_create_button_pressed() -> void: GameServerManager.current_map = path var err := GameServerManager.create_server(player_manager) if err != OK: - print("couldn't create a server") + push_error("couldn't create a server") $UI.hide() - change_level.call_deferred(load(path)) + change_level.call_deferred(path) # Call this function deferred and only on the main authority (server). -func change_level(scene: PackedScene): - +func change_level(path: String): # Remove old level if any. var level = $LevelLoader/CurrentLevel + print("cleaning up the mount node") for c in level.get_children(): level.remove_child(c) c.queue_free() # Add new level. - level.add_child(scene.instantiate()) + if not ResourceLoader.exists(path): + print(ERR_DOES_NOT_EXIST) + var scene: PackedScene = ResourceLoader.load(path) + if scene.can_instantiate(): + var node: Node3D = scene.instantiate() + print("loading map: " + node.name) + level.add_child(node) + else: + print("Can't initialize") func _on_text_edit_text_changed() -> void: diff --git a/scenes/weapon/bullet.gd b/scenes/weapon/bullet.gd index a25d24a..b3f1a3a 100644 --- a/scenes/weapon/bullet.gd +++ b/scenes/weapon/bullet.gd @@ -30,7 +30,6 @@ func _process(delta): rigid_body_3d.visible = false particles.emitting = true #if ray.get_collider().is_in_group("body"): - #print("head") await get_tree().create_timer(1.0).timeout queue_free() diff --git a/scenes/weapon/misc/bullet_trail_generic.tscn b/scenes/weapon/misc/bullet_trail_generic.tscn index b077075..186f0de 100644 --- a/scenes/weapon/misc/bullet_trail_generic.tscn +++ b/scenes/weapon/misc/bullet_trail_generic.tscn @@ -11,6 +11,7 @@ emission_energy_multiplier = 16.0 distance_fade_min_distance = 2.0 [node name="BulletTrailGeneric" type="MeshInstance3D"] +layers = 524288 material_override = SubResource("StandardMaterial3D_ybqvs") visibility_range_end = 1891.27 script = ExtResource("1_k8eg1") diff --git a/scripts/character_controller.gd b/scripts/character_controller.gd index 4c41396..92ad340 100644 --- a/scripts/character_controller.gd +++ b/scripts/character_controller.gd @@ -39,7 +39,6 @@ func _ready() -> void: add_child(dummy) enable_camera() capture_mouse() - #print("I am " + str(multiplayer.get_unique_id()) + "I'm controling " + str($"../MultiplayerSynchronizer".get_multiplayer_authority())) func _unhandled_input(event: InputEvent) -> void: if event is InputEventMouseMotion: diff --git a/scripts/game_server_manager.gd b/scripts/game_server_manager.gd index ddff5cd..37e7c70 100644 --- a/scripts/game_server_manager.gd +++ b/scripts/game_server_manager.gd @@ -16,20 +16,31 @@ func _on_connected_ok(): @rpc("any_peer", "reliable", "call_remote") func register_player(id: int, name: String): - var player_state := PlayerState.new() - player_state.id = id - player_state.name = name - players[multiplayer.get_remote_sender_id()] = player_state + if multiplayer.is_server(): + var player_state := PlayerState.new() + player_state.id = id + player_state.name = name + players[multiplayer.get_remote_sender_id()] = player_state +@rpc("any_peer", "reliable", "call_local") +func remove_player(id: int): + if multiplayer.is_server(): + if players.has(id): + players.erase(id) + + + +func _on_player_disconnected(id): + remove_player.rpc_id(1, id) + func _on_player_connected(id): - pass - #if multiplayer.is_server(): - #GameServerManager.load_map.rpc_id(id, GameServerManager.current_map) + if multiplayer.is_server(): + print("Player is connected with id: " + str(id)) func _ready() -> void: multiplayer.peer_connected.connect(_on_player_connected) + multiplayer.peer_disconnected.connect(_on_player_disconnected) multiplayer.connected_to_server.connect(_on_connected_ok) - print("started") pass # Replace with function body. # Called every frame. 'delta' is the elapsed time since the previous frame. @@ -42,10 +53,10 @@ func set_map(name: String): func create_server(player_data: PlayerManager) -> Error: var peer = ENetMultiplayerPeer.new() var err = peer.create_server(27015, 30) + multiplayer.multiplayer_peer = peer if err: return err - multiplayer.multiplayer_peer = peer - if DisplayServer.get_name() != "headless": + if not OS.has_feature("dedicated_server"): var player_state := PlayerState.new() player_state.id = 1 player_state.name = player_data.name @@ -54,7 +65,8 @@ func create_server(player_data: PlayerManager) -> Error: func join_server(player_data: PlayerManager, ip: String, port: int) -> Error: var peer = ENetMultiplayerPeer.new() - var err = peer.create_client("127.0.0.1", 27015) + print("trying to connect to: " + ip + ":" + str(port)) + var err = peer.create_client(ip, port) if err != OK: return err player_state_global.id = multiplayer.get_remote_sender_id() diff --git a/scripts/player/player_input_controller.gd b/scripts/player/player_input_controller.gd index 17930f4..3020145 100644 --- a/scripts/player/player_input_controller.gd +++ b/scripts/player/player_input_controller.gd @@ -22,14 +22,17 @@ var model: Node3D = null # -- This node is supposed to be spawned per player, and since each # -- player has an id, it is used for giving a node a name. So we can # -- use it here to tell a controlled node from the rest models -@onready var owner_id: int = str($".".name).to_int() +@onready var owner_id_detected: int = str($".".name).to_int() +@export var owner_id: int = 0 var multiplayer_id: int = 0 # -- Character state var alive: bool = true func _ready() -> void: - player_synchronizer.set_multiplayer_authority(owner_id) + owner_id = owner_id_detected + $PlayerInput.set_multiplayer_authority(owner_id) + player_synchronizer.set_multiplayer_authority(1) multiplayer_id = multiplayer.get_unique_id() # -- Separate logic for player and other models that are controlled # -- by other players on the server @@ -39,19 +42,19 @@ func _ready() -> void: if _is_current_player(): var err := _add_first_view_model() if err != OK: - print("Error occured: " + str(err)) + push_error("Error occured: " + str(err)) err = _add_legs_to_first_view() if err != OK: - print("Error occured: " + str(err)) + push_error("Error occured: " + str(err)) var world_model := _add_world_model() if world_model == null: - print("Error occured: " + "couldn't load the world model") + push_error("Error occured: " + "couldn't load the world model") _enable_camera() else: var world_model := _add_world_model() if world_model == null: - print("Error occured: " + "couldn't load the world model") + push_error("Error occured: " + "couldn't load the world model") _hide_camera_mount() _capture_mouse() @@ -182,10 +185,17 @@ func _unhandled_input(event: InputEvent) -> void: #if Input.is_action_just_pressed("reload"): $Body/UpperTorso/CameraMount/Camera.reload() func _rotate_camera(sens_mod: float = 1.0) -> void: + pass #if str($"..".name).to_int() == multiplayer.get_unique_id(): rotation.y -= look_dir.x * camera_sens * sens_mod first_view_camera_mount.rotation.x = clamp(first_view_camera_mount.rotation.x - look_dir.y * camera_sens * sens_mod, -1.5, 1.5) +#@export var player := 1: + #set(id): + #player = id + #$PlayerInput.set_multiplayer_authority(id) + +@onready var input = $PlayerInput @onready var hud = $FirstPersonCameraMount/HUD @onready var health_indicator = $FirstPersonCameraMount/HUD/HealthIndicator @onready var fps_indicator = $FirstPersonCameraMount/HUD/FPS @@ -209,16 +219,15 @@ func _physics_process(delta: float) -> void: velocity += get_gravity() * delta # Handle jump. - if Input.is_action_just_pressed("jump") and is_on_floor(): + if input.jumping and is_on_floor(): velocity.y = JUMP_VELOCITY - + input.jumping = false # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. #var input_dir := Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") # -- It shouldn't be possible to change direction during the jumps if is_on_floor(): - var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_backwards") - var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() + var direction := (transform.basis * Vector3(input.input_direction.x, 0, input.input_direction.y)).normalized() if direction: gun_mount_anim.play("move") if first_view_legs_anim != null: @@ -274,7 +283,6 @@ func _get_camera_collision(): var intersection = get_world_3d().direct_space_state.intersect_ray(new_intersection) if not intersection.is_empty(): var collision_point = intersection.position - print("gotcha") return collision_point else: return ray_end @@ -286,12 +294,10 @@ func _hit_scan_collision(collision_point): var new_intersection = PhysicsRayQueryParameters3D.create(ray_origin, ray_end) var bullet_collision = get_world_3d().direct_space_state.intersect_ray(new_intersection) if bullet_collision: - print(bullet_collision) _hit_scan_damage(bullet_collision.collider) func _hit_scan_damage(Collider): #if Collider.is_in_group("target") and Collider.has_method("take_damage"): - print("damaged") func take_damage(dam: int): var new_health = health - dam