├── shaders
├── vfx
│ ├── flat.ini
│ ├── shaded.ini
│ ├── wall.ini
│ ├── billboard.ini
│ ├── flat_pc_50_ps.vcs
│ ├── flat_pc_50_vs.vcs
│ ├── shaded_pc_50_ps.vcs
│ ├── shaded_pc_50_vs.vcs
│ ├── wall_pc_50_ps.vcs
│ ├── wall_pc_50_vs.vcs
│ ├── billboard_pc_50_ps.vcs
│ ├── billboard_pc_50_vs.vcs
│ ├── flat_pc_50_features.vcs
│ ├── wall_pc_50_features.vcs
│ ├── shaded_pc_50_features.vcs
│ └── billboard_pc_50_features.vcs
├── wall.vfx
├── shaded.vfx
└── flat.vfx
├── config
└── sbox-maze_modeldata.fgd
├── .gitattributes
├── sounds
├── intro.ogg
├── intro.sound_c
├── intro.vsnd_c
└── intro.sound
├── textures
├── rat.png
├── floor.png
├── start.png
├── wall.png
├── ceiling.png
├── directx.png
├── hampter1.png
├── hampter2.png
├── pattern1.png
├── pattern2.png
├── pattern3.png
├── pattern4.png
├── smiley.png
├── openglwall.png
├── directx_alpha.png
├── wall_png_46fdcd20.vtex_c
├── wall_png_60c60ae6.vtex_c
├── wall_png_67ab7f61.vtex_c
├── wall_png_76682a4c.vtex_c
├── ceiling_png_6b56c701.vtex_c
├── ceiling_png_c9221ee0.vtex_c
├── ceiling_png_d33ea5d2.vtex_c
├── ceiling_png_d5899a68.vtex_c
├── directx_png_2abd4816.vtex_c
├── directx_png_4932c64f.vtex_c
├── directx_png_4ab7a224.vtex_c
├── directx_png_4f628309.vtex_c
├── directx_png_dd024405.vtex_c
├── floor_png_1d1cc760.vtex_c
├── floor_png_260282e2.vtex_c
├── floor_png_d45c4c10.vtex_c
├── directx_alpha_png_12cd1c2c.vtex_c
├── directx_alpha_png_4cfe9c8b.vtex_c
├── ceiling.txt
├── directx.txt
├── floor.txt
└── wall.txt
├── materials
├── wall.vmat_c
├── floor.vmat_c
├── ceiling.vmat_c
├── directx.vmat_c
├── floor_vmat_g_trma_66505ca3.vtex_c
├── wall_vmat_g_trma_2d546cbc.vtex_c
├── ceiling_vmat_g_trma_2d546cbc.vtex_c
├── ceiling_vmat_g_trma_66505ca3.vtex_c
├── default
│ ├── default_tga_e48e6edb.vtex_c
│ ├── default_ao_tga_559f1ac6.vtex_c
│ ├── default_color_tga_47b1af3d.vtex_c
│ ├── default_rough_tga_8918b8fc.vtex_c
│ ├── default_normal_tga_36476129.vtex_c
│ └── default_normal_tga_7be61377.vtex_c
├── directx_vmat_g_trma_2d546cbc.vtex_c
├── ceiling_vmat_g_talphamask_5b4d349c.vtex_c
├── directx_vmat_g_talphamask_c520ba96.vtex_c
├── directx_vmat_g_talphamask_fb083391.vtex_c
├── floor_vmat_g_talphamask_5b4d349c.vtex_c
├── directx.vmat
├── ceiling.vmat
├── floor.vmat
└── wall.vmat
├── .addon
├── .gitignore
├── code
├── Level.Utils.cs
├── Level.cs
├── BillboardEntity.cs
├── EnvEntity.cs
├── WallEntity.cs
├── Player.cs
└── Game.cs
└── LICENSE
/shaders/vfx/flat.ini:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/shaders/vfx/shaded.ini:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/shaders/vfx/wall.ini:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/shaders/vfx/billboard.ini:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config/sbox-maze_modeldata.fgd:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/sounds/intro.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/sounds/intro.ogg
--------------------------------------------------------------------------------
/textures/rat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/rat.png
--------------------------------------------------------------------------------
/textures/floor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/floor.png
--------------------------------------------------------------------------------
/textures/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/start.png
--------------------------------------------------------------------------------
/textures/wall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/wall.png
--------------------------------------------------------------------------------
/materials/wall.vmat_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/wall.vmat_c
--------------------------------------------------------------------------------
/sounds/intro.sound_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/sounds/intro.sound_c
--------------------------------------------------------------------------------
/sounds/intro.vsnd_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/sounds/intro.vsnd_c
--------------------------------------------------------------------------------
/textures/ceiling.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/ceiling.png
--------------------------------------------------------------------------------
/textures/directx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx.png
--------------------------------------------------------------------------------
/textures/hampter1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/hampter1.png
--------------------------------------------------------------------------------
/textures/hampter2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/hampter2.png
--------------------------------------------------------------------------------
/textures/pattern1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/pattern1.png
--------------------------------------------------------------------------------
/textures/pattern2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/pattern2.png
--------------------------------------------------------------------------------
/textures/pattern3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/pattern3.png
--------------------------------------------------------------------------------
/textures/pattern4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/pattern4.png
--------------------------------------------------------------------------------
/textures/smiley.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/smiley.png
--------------------------------------------------------------------------------
/.addon:
--------------------------------------------------------------------------------
1 | {
2 | "ident": "tesa.maze",
3 | "sharedassets": "*.*",
4 | "type": "game"
5 | }
6 |
--------------------------------------------------------------------------------
/materials/floor.vmat_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/floor.vmat_c
--------------------------------------------------------------------------------
/textures/openglwall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/openglwall.png
--------------------------------------------------------------------------------
/materials/ceiling.vmat_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/ceiling.vmat_c
--------------------------------------------------------------------------------
/materials/directx.vmat_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/directx.vmat_c
--------------------------------------------------------------------------------
/textures/directx_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_alpha.png
--------------------------------------------------------------------------------
/shaders/vfx/flat_pc_50_ps.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/flat_pc_50_ps.vcs
--------------------------------------------------------------------------------
/shaders/vfx/flat_pc_50_vs.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/flat_pc_50_vs.vcs
--------------------------------------------------------------------------------
/shaders/vfx/shaded_pc_50_ps.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/shaded_pc_50_ps.vcs
--------------------------------------------------------------------------------
/shaders/vfx/shaded_pc_50_vs.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/shaded_pc_50_vs.vcs
--------------------------------------------------------------------------------
/shaders/vfx/wall_pc_50_ps.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/wall_pc_50_ps.vcs
--------------------------------------------------------------------------------
/shaders/vfx/wall_pc_50_vs.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/wall_pc_50_vs.vcs
--------------------------------------------------------------------------------
/textures/wall_png_46fdcd20.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/wall_png_46fdcd20.vtex_c
--------------------------------------------------------------------------------
/textures/wall_png_60c60ae6.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/wall_png_60c60ae6.vtex_c
--------------------------------------------------------------------------------
/textures/wall_png_67ab7f61.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/wall_png_67ab7f61.vtex_c
--------------------------------------------------------------------------------
/textures/wall_png_76682a4c.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/wall_png_76682a4c.vtex_c
--------------------------------------------------------------------------------
/shaders/vfx/billboard_pc_50_ps.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/billboard_pc_50_ps.vcs
--------------------------------------------------------------------------------
/shaders/vfx/billboard_pc_50_vs.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/billboard_pc_50_vs.vcs
--------------------------------------------------------------------------------
/shaders/vfx/flat_pc_50_features.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/flat_pc_50_features.vcs
--------------------------------------------------------------------------------
/shaders/vfx/wall_pc_50_features.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/wall_pc_50_features.vcs
--------------------------------------------------------------------------------
/textures/ceiling_png_6b56c701.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/ceiling_png_6b56c701.vtex_c
--------------------------------------------------------------------------------
/textures/ceiling_png_c9221ee0.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/ceiling_png_c9221ee0.vtex_c
--------------------------------------------------------------------------------
/textures/ceiling_png_d33ea5d2.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/ceiling_png_d33ea5d2.vtex_c
--------------------------------------------------------------------------------
/textures/ceiling_png_d5899a68.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/ceiling_png_d5899a68.vtex_c
--------------------------------------------------------------------------------
/textures/directx_png_2abd4816.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_png_2abd4816.vtex_c
--------------------------------------------------------------------------------
/textures/directx_png_4932c64f.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_png_4932c64f.vtex_c
--------------------------------------------------------------------------------
/textures/directx_png_4ab7a224.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_png_4ab7a224.vtex_c
--------------------------------------------------------------------------------
/textures/directx_png_4f628309.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_png_4f628309.vtex_c
--------------------------------------------------------------------------------
/textures/directx_png_dd024405.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_png_dd024405.vtex_c
--------------------------------------------------------------------------------
/textures/floor_png_1d1cc760.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/floor_png_1d1cc760.vtex_c
--------------------------------------------------------------------------------
/textures/floor_png_260282e2.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/floor_png_260282e2.vtex_c
--------------------------------------------------------------------------------
/textures/floor_png_d45c4c10.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/floor_png_d45c4c10.vtex_c
--------------------------------------------------------------------------------
/shaders/vfx/shaded_pc_50_features.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/shaded_pc_50_features.vcs
--------------------------------------------------------------------------------
/shaders/vfx/billboard_pc_50_features.vcs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/shaders/vfx/billboard_pc_50_features.vcs
--------------------------------------------------------------------------------
/materials/floor_vmat_g_trma_66505ca3.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/floor_vmat_g_trma_66505ca3.vtex_c
--------------------------------------------------------------------------------
/materials/wall_vmat_g_trma_2d546cbc.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/wall_vmat_g_trma_2d546cbc.vtex_c
--------------------------------------------------------------------------------
/textures/directx_alpha_png_12cd1c2c.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_alpha_png_12cd1c2c.vtex_c
--------------------------------------------------------------------------------
/textures/directx_alpha_png_4cfe9c8b.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/textures/directx_alpha_png_4cfe9c8b.vtex_c
--------------------------------------------------------------------------------
/materials/ceiling_vmat_g_trma_2d546cbc.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/ceiling_vmat_g_trma_2d546cbc.vtex_c
--------------------------------------------------------------------------------
/materials/ceiling_vmat_g_trma_66505ca3.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/ceiling_vmat_g_trma_66505ca3.vtex_c
--------------------------------------------------------------------------------
/materials/default/default_tga_e48e6edb.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/default/default_tga_e48e6edb.vtex_c
--------------------------------------------------------------------------------
/materials/directx_vmat_g_trma_2d546cbc.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/directx_vmat_g_trma_2d546cbc.vtex_c
--------------------------------------------------------------------------------
/materials/default/default_ao_tga_559f1ac6.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/default/default_ao_tga_559f1ac6.vtex_c
--------------------------------------------------------------------------------
/materials/ceiling_vmat_g_talphamask_5b4d349c.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/ceiling_vmat_g_talphamask_5b4d349c.vtex_c
--------------------------------------------------------------------------------
/materials/default/default_color_tga_47b1af3d.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/default/default_color_tga_47b1af3d.vtex_c
--------------------------------------------------------------------------------
/materials/default/default_rough_tga_8918b8fc.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/default/default_rough_tga_8918b8fc.vtex_c
--------------------------------------------------------------------------------
/materials/directx_vmat_g_talphamask_c520ba96.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/directx_vmat_g_talphamask_c520ba96.vtex_c
--------------------------------------------------------------------------------
/materials/directx_vmat_g_talphamask_fb083391.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/directx_vmat_g_talphamask_fb083391.vtex_c
--------------------------------------------------------------------------------
/materials/floor_vmat_g_talphamask_5b4d349c.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/floor_vmat_g_talphamask_5b4d349c.vtex_c
--------------------------------------------------------------------------------
/materials/default/default_normal_tga_36476129.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/default/default_normal_tga_36476129.vtex_c
--------------------------------------------------------------------------------
/materials/default/default_normal_tga_7be61377.vtex_c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rndtrash/sbox-maze/master/materials/default/default_normal_tga_7be61377.vtex_c
--------------------------------------------------------------------------------
/textures/ceiling.txt:
--------------------------------------------------------------------------------
1 | "settings"
2 | {
3 | "clampu" "1"
4 | "clampv" "1"
5 | "clampw" "1"
6 | "nocompress" "1"
7 | "nolod" "1"
8 | "nomip" "1"
9 | }
10 |
--------------------------------------------------------------------------------
/textures/directx.txt:
--------------------------------------------------------------------------------
1 | "settings"
2 | {
3 | "clampu" "1"
4 | "clampv" "1"
5 | "clampw" "1"
6 | "nocompress" "1"
7 | "nolod" "1"
8 | "nomip" "1"
9 | }
10 |
--------------------------------------------------------------------------------
/textures/floor.txt:
--------------------------------------------------------------------------------
1 | "settings"
2 | {
3 | "clampu" "1"
4 | "clampv" "1"
5 | "clampw" "1"
6 | "nocompress" "1"
7 | "nolod" "1"
8 | "nomip" "1"
9 | }
10 |
--------------------------------------------------------------------------------
/textures/wall.txt:
--------------------------------------------------------------------------------
1 | "settings"
2 | {
3 | "clampu" "1"
4 | "clampv" "1"
5 | "clampw" "1"
6 | "nocompress" "1"
7 | "nolod" "1"
8 | "nomip" "1"
9 | }
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | code/*.csproj
2 | code/obj
3 | code/Properties/launchSettings.json
4 | .intermediate
5 | tools_asset_info.bin
6 | _bakeresourcecache
7 | tools_thumbnail_cache.bin
8 |
--------------------------------------------------------------------------------
/sounds/intro.sound:
--------------------------------------------------------------------------------
1 |
2 | {
3 | data =
4 | {
5 | sounds =
6 | [
7 | "sounds/intro.vsnd",
8 | ]
9 | UI = true
10 | Volume = 1.0
11 | VolumeRandom = 0.0
12 | Pitch = 1.0
13 | PitchRandom = 0.0
14 | DistanceMax = 1000.0
15 | }
16 | }
--------------------------------------------------------------------------------
/code/Level.Utils.cs:
--------------------------------------------------------------------------------
1 | namespace Maze
2 | {
3 | public partial class Level
4 | {
5 | public static class Side
6 | {
7 | public const uint North = 1;
8 | public const uint East = 2;
9 | public const uint South = 4;
10 | public const uint West = 8;
11 | };
12 |
13 | public readonly Vector2 CellCenter = new(-64, 64);
14 |
15 | public Vector2 CellToWorld( int x, int y )
16 | {
17 | return new Vector2( x * -128, y * 128 );
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/code/Level.cs:
--------------------------------------------------------------------------------
1 | using Sandbox;
2 |
3 | namespace Maze
4 | {
5 | public partial class Level : BaseNetworkable
6 | {
7 | public int Width => 16;
8 | public WallEntity Walls { get; internal set; }
9 |
10 | public void InitClient()
11 | {
12 | Log.Info( "level: before assert" );
13 | Host.AssertClient();
14 | Log.Info( "level: after assert" );
15 |
16 | Walls = new();
17 | _ = new BillboardEntity { Position = CellToWorld( 1, 1 ) + CellCenter }; // TEST
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/materials/directx.vmat:
--------------------------------------------------------------------------------
1 | // THIS FILE IS AUTO-GENERATED
2 |
3 | Layer0
4 | {
5 | shader "flat.vfx"
6 |
7 | //---- Color ----
8 | AlphaTexture "textures/directx_alpha.png"
9 | g_flModelTintAmount "1.000"
10 | g_vColorTint "[1.000000 1.000000 1.000000 0.000000]"
11 |
12 | //---- Fade ----
13 | g_flFadeExponent "1.000"
14 |
15 | //---- Fog ----
16 | g_bFogEnabled "1"
17 |
18 | //---- Material ----
19 | TextureAmbientOcclusion "materials/default/default_ao.tga"
20 | TextureBlendMask "[1.000000 1.000000 1.000000 0.000000]"
21 | TextureColor "textures/directx.png"
22 | TextureMetalness "materials/default/default_metal.tga"
23 | TextureNormal "materials/default/default_normal.tga"
24 | TextureRoughness "[1.000000 1.000000 1.000000 0.000000]"
25 | TextureTranslucency "materials/default/default_trans.tga"
26 |
27 | //---- Texture Coordinates ----
28 | g_nScaleTexCoordUByModelScaleAxis "0"
29 | g_nScaleTexCoordVByModelScaleAxis "0"
30 | g_vTexCoordOffset "[0.000 0.000]"
31 | g_vTexCoordScale "[1.000 1.000]"
32 | g_vTexCoordScrollSpeed "[0.000 0.000]"
33 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Tea Sanctuary
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/materials/ceiling.vmat:
--------------------------------------------------------------------------------
1 | // THIS FILE IS AUTO-GENERATED
2 |
3 | Layer0
4 | {
5 | shader "flat.vfx"
6 |
7 | //---- Color ----
8 | AlphaTexture "[1.000000 1.000000 1.000000 0.000000]"
9 | g_flModelTintAmount "1.000"
10 | g_vColorTint "[1.000000 1.000000 1.000000 0.000000]"
11 |
12 | //---- Fade ----
13 | g_flFadeExponent "1.000"
14 |
15 | //---- Fog ----
16 | g_bFogEnabled "0"
17 |
18 | //---- Material ----
19 | TextureAmbientOcclusion "[1.000000 1.000000 1.000000 0.000000]"
20 | TextureBlendMask "[1.000000 1.000000 1.000000 0.000000]"
21 | TextureColor "textures/ceiling.png"
22 | TextureMetalness "materials/default/default_metal.tga"
23 | TextureNormal "materials/default/default_normal.tga"
24 | TextureRoughness "[1.000000 1.000000 1.000000 0.000000]"
25 | TextureTranslucency "materials/default/default_trans.tga"
26 |
27 | //---- Texture Coordinates ----
28 | g_nScaleTexCoordUByModelScaleAxis "0"
29 | g_nScaleTexCoordVByModelScaleAxis "0"
30 | g_vTexCoordOffset "[0.000 0.000]"
31 | g_vTexCoordScale "[1.000 1.000]"
32 | g_vTexCoordScrollSpeed "[0.000 0.000]"
33 |
34 | DynamicParams
35 | {
36 | g_vTexCoordScale "float2(mazewidth, mazewidth)"
37 | }
38 | }
--------------------------------------------------------------------------------
/materials/floor.vmat:
--------------------------------------------------------------------------------
1 | // THIS FILE IS AUTO-GENERATED
2 |
3 | Layer0
4 | {
5 | shader "flat.vfx"
6 |
7 | //---- Color ----
8 | AlphaTexture "[1.000000 1.000000 1.000000 0.000000]"
9 | g_flModelTintAmount "1.000"
10 | g_vColorTint "[1.000000 1.000000 1.000000 0.000000]"
11 |
12 | //---- Fade ----
13 | g_flFadeExponent "1.000"
14 |
15 | //---- Fog ----
16 | g_bFogEnabled "1"
17 |
18 | //---- Material ----
19 | g_flTintColor "[1.000000 1.000000 1.000000 0.000000]"
20 | TextureAmbientOcclusion "[1.000000 1.000000 1.000000 0.000000]"
21 | TextureBlendMask "[1.000000 1.000000 1.000000 0.000000]"
22 | TextureColor "textures/floor.png"
23 | TextureMetalness "materials/default/default_metal.tga"
24 | TextureNormal "materials/default/default_normal.tga"
25 | TextureRoughness "[1.000000 1.000000 1.000000 0.000000]"
26 | TextureTintMask "[1.000000 1.000000 1.000000 0.000000]"
27 |
28 | //---- Texture Coordinates ----
29 | g_nScaleTexCoordUByModelScaleAxis "0"
30 | g_nScaleTexCoordVByModelScaleAxis "0"
31 | g_vTexCoordOffset "[0.000 0.000]"
32 | g_vTexCoordScale "[1.000 1.000]"
33 | g_vTexCoordScrollSpeed "[0.000 0.000]"
34 |
35 | DynamicParams
36 | {
37 | g_vTexCoordScale "float2(mazewidth, mazewidth)"
38 | }
39 | }
--------------------------------------------------------------------------------
/materials/wall.vmat:
--------------------------------------------------------------------------------
1 | // THIS FILE IS AUTO-GENERATED
2 |
3 | Layer0
4 | {
5 | shader "wall.vfx"
6 |
7 | //---- Rendering ----
8 | F_RENDER_BACKFACES 1
9 |
10 | //---- aMazeing ----
11 | WallHeight "1.000"
12 |
13 | //---- Color ----
14 | g_flModelTintAmount "1.000"
15 | g_vColorTint "[1.000000 1.000000 1.000000 0.000000]"
16 |
17 | //---- Fade ----
18 | g_flFadeExponent "1.000"
19 |
20 | //---- Fog ----
21 | g_bFogEnabled "1"
22 |
23 | //---- Material ----
24 | g_flTintColor "[1.000000 1.000000 1.000000 0.000000]"
25 | TextureAmbientOcclusion "materials/default/default_ao.tga"
26 | TextureBlendMask "[1.000000 1.000000 1.000000 0.000000]"
27 | TextureColor "textures/wall.png"
28 | TextureMetalness "materials/default/default_metal.tga"
29 | TextureNormal "materials/default/default_normal.tga"
30 | TextureRoughness "[1.000000 1.000000 1.000000 0.000000]"
31 | TextureTintMask "[1.000000 1.000000 1.000000 0.000000]"
32 |
33 | //---- Texture Coordinates ----
34 | g_nScaleTexCoordUByModelScaleAxis "0"
35 | g_nScaleTexCoordVByModelScaleAxis "0"
36 | g_vTexCoordOffset "[0.000 0.000]"
37 | g_vTexCoordScale "[1.000 1.000]"
38 | g_vTexCoordScrollSpeed "[0.000 0.000]"
39 |
40 | DynamicParams
41 | {
42 | WallHeight "wallheight"
43 | }
44 | }
--------------------------------------------------------------------------------
/code/BillboardEntity.cs:
--------------------------------------------------------------------------------
1 | using Sandbox;
2 | using Sandbox.UI;
3 |
4 | namespace Maze
5 | {
6 | public partial class BillboardEntity : RenderEntity
7 | {
8 | public virtual Material SpriteMaterial { get; set; } = Material.Load( "materials/directx.vmat" );
9 | public float SpriteScale { get; set; } = 128f;
10 |
11 | public override void DoRender( SceneObject obj )
12 | {
13 | if ( Game.Current.State == Game.GameState.Invalid || Local.Pawn.Camera is not Camera camera )
14 | return;
15 |
16 | var vb = Render.GetDynamicVB();
17 | var normal = -camera.Rotation.Angles().Direction.Normal;
18 | var w = normal.Cross( Vector3.Down ).Normal;
19 | var h = normal.Cross( w ).Normal;
20 | var halfSpriteSize = SpriteScale / 2;
21 |
22 | // vb.AddQuad( new Ray( default, normal ), w * halfSpriteSize, h * halfSpriteSize ); // ffs why tf does it flip the plane
23 | Position = Position.WithZ( 64 * Game.Current.WallHeight );
24 | AddQuad( vb, new Ray( default, normal ), w * halfSpriteSize, h * halfSpriteSize * Game.Current.WallHeight );
25 | Render.CullMode = CullMode.FrontFace;
26 | vb.Draw( SpriteMaterial );
27 | }
28 |
29 | protected static void AddQuad( VertexBuffer self, Ray origin, Vector3 width, Vector3 height )
30 | {
31 | self.Default.Normal = origin.Direction;
32 | self.Default.Tangent = new Vector4( width.Normal, 1 );
33 |
34 | self.AddQuad(
35 | origin.Origin - width + height,
36 | origin.Origin + width + height,
37 | origin.Origin + width - height,
38 | origin.Origin - width - height
39 | );
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/code/EnvEntity.cs:
--------------------------------------------------------------------------------
1 | using Sandbox;
2 |
3 | namespace Maze
4 | {
5 | public partial class EnvEntity : RenderEntity
6 | {
7 | Material floorMaterial = Material.Load( "materials/floor.vmat" );
8 | Material ceilingMaterial = Material.Load( "materials/ceiling.vmat" );
9 | VertexBuffer floorVB;
10 | VertexBuffer ceilingVB;
11 |
12 | public EnvEntity()
13 | {
14 | Transmit = TransmitType.Always;
15 | }
16 |
17 | public override void Spawn()
18 | {
19 | Host.AssertClient();
20 |
21 | base.Spawn();
22 |
23 | RenderBounds = new BBox( new Vector3( -12800, 0, 0 ), new Vector3( 0, 1, 12800 ) );
24 | }
25 |
26 | [Event( "maze.level" )]
27 | public void LevelLoaded()
28 | {
29 | floorVB = new();
30 | floorVB.Init( true );
31 | floorVB.AddQuad( Vector3.Zero, new( Game.Current.Level.Width * -128, 0 ), new( Game.Current.Level.Width * -128, Game.Current.Level.Width * 128 ), new( 0, Game.Current.Level.Width * 128 ) );
32 |
33 | ceilingVB = new();
34 | ceilingVB.Init( true );
35 | ceilingVB.AddQuad( new Vector3( 0, 0, 128 ), new( Game.Current.Level.Width * -128, 0, 128 ), new( Game.Current.Level.Width * -128, Game.Current.Level.Width * 128, 128 ), new( 0, Game.Current.Level.Width * 128, 128 ) );
36 | }
37 |
38 | public override void DoRender( SceneObject obj )
39 | {
40 | base.DoRender( obj );
41 |
42 | if ( floorVB == null || ceilingVB == null )
43 | return;
44 |
45 | Render.Set( "mazewidth", Game.Current.Level.Width );
46 |
47 | Render.CullMode = CullMode.FrontFace;
48 | floorVB.Draw( floorMaterial );
49 |
50 | Render.CullMode = CullMode.Backface;
51 | ceilingVB.Draw( ceilingMaterial );
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/code/WallEntity.cs:
--------------------------------------------------------------------------------
1 | using Sandbox;
2 | using System;
3 |
4 | namespace Maze
5 | {
6 | public partial class WallEntity : RenderEntity
7 | {
8 | Material wallMaterial = Material.Load( "materials/wall.vmat" );
9 | Material speciaWallMaterial = Material.Load( "materials/directx.vmat" );
10 | VertexBuffer wallVB;
11 | VertexBuffer specialWallVB;
12 |
13 | bool ready = false;
14 |
15 | public WallEntity()
16 | {
17 | Transmit = TransmitType.Always;
18 | }
19 |
20 | protected void AddWall( int cellX, int cellY, uint flags )
21 | {
22 | if ( flags == 0 )
23 | return;
24 |
25 | int worldX = cellX * 128;
26 | int worldY = cellY * 128;
27 |
28 | if ( (flags | Level.Side.North) > 0 )
29 | {
30 | wallVB.AddQuad( new Vector3( worldX - 128, worldY, 128 ), new( worldX, worldY, 128 ), new( worldX, worldY, 0 ), new( worldX - 128, worldY, 0 ) );
31 | }
32 |
33 | if ( (flags | Level.Side.East) > 0 )
34 | {
35 | wallVB.AddQuad( new Vector3( worldX - 128, worldY + 128, 128 ), new( worldX - 128, worldY, 128 ), new( worldX - 128, worldY, 0 ), new( worldX - 128, worldY + 128, 0 ) );
36 | }
37 |
38 | if ( (flags | Level.Side.South) > 0 )
39 | {
40 | wallVB.AddQuad( new Vector3( worldX, worldY + 128, 128 ), new( worldX - 128, worldY + 128, 128 ), new( worldX - 128, worldY + 128, 0 ), new( worldX, worldY + 128, 0 ) );
41 | }
42 |
43 | if ( (flags | Level.Side.West) > 0 )
44 | {
45 | wallVB.AddQuad( new Vector3( worldX, worldY, 128 ), new( worldX, worldY + 128, 128 ), new( worldX, worldY + 128, 0 ), new( worldX, worldY, 0 ) );
46 | }
47 | }
48 |
49 | public override void Spawn()
50 | {
51 | Host.AssertClient();
52 |
53 | base.Spawn();
54 |
55 | //RenderBounds = new BBox( new Vector3( -12800, -12800, -12800 ), new Vector3( 12800, 12800, 12800 ) );
56 |
57 | // implying that the walls are created as soon as the level was made
58 | wallVB = new();
59 | wallVB.Init( true );
60 |
61 | AddWall( 0, 0, Level.Side.North | Level.Side.East | Level.Side.South | Level.Side.West );
62 |
63 | specialWallVB = new();
64 | specialWallVB.Init( true );
65 |
66 | ready = true;
67 | }
68 |
69 | public override void DoRender( SceneObject obj )
70 | {
71 | base.DoRender( obj );
72 |
73 | if ( !ready )
74 | return;
75 |
76 | Render.Set( "wallheight", Game.Current.WallHeight );
77 |
78 | //Render.CullMode = CullMode.Backface;
79 | wallVB.Draw( wallMaterial );
80 |
81 | //Render.CullMode = CullMode.FrontFace;
82 | specialWallVB.Draw( speciaWallMaterial );
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/shaders/wall.vfx:
--------------------------------------------------------------------------------
1 | //=========================================================================================================================
2 | // Optional
3 | //=========================================================================================================================
4 | HEADER
5 | {
6 | CompileTargets = ( IS_SM_50 && ( PC || VULKAN ) );
7 | Description = "Maze wall height";
8 | }
9 |
10 | //=========================================================================================================================
11 | // Optional
12 | //=========================================================================================================================
13 | FEATURES
14 | {
15 | #include "common/features.hlsl"
16 | }
17 |
18 | MODES
19 | {
20 | VrForward();
21 |
22 | ToolsVis( S_MODE_TOOLS_VIS );
23 | ToolsWireframe( "vr_tools_wireframe.vfx" );
24 | }
25 |
26 | //=========================================================================================================================
27 | COMMON
28 | {
29 | //#define S_TRANSLUCENT 1
30 | #define S_UNLIT 1
31 | #define STENCIL_ALREADY_SET
32 | #define DEPTH_STATE_ALREADY_SET
33 | #define BLEND_MODE_ALREADY_SET
34 | #define COLOR_WRITE_ALREADY_SET
35 | #include "common/shared.hlsl"
36 | }
37 |
38 | //=========================================================================================================================
39 |
40 | struct VertexInput
41 | {
42 | #include "common/vertexinput.hlsl"
43 | };
44 |
45 | //=========================================================================================================================
46 |
47 | struct PixelInput
48 | {
49 | #include "common/pixelinput.hlsl"
50 | };
51 |
52 | //=========================================================================================================================
53 |
54 | VS
55 | {
56 | #include "common/vertex.hlsl"
57 |
58 | float WallHeight< UiGroup("aMazeing"); UiType(Slider); Default(0); Range(0.0f, 1.0f); >;
59 | FloatAttribute( WallHeight, true );
60 | //VS_CommonProcessing_Post
61 | // Main
62 | //
63 | PixelInput MainVs( INSTANCED_SHADER_PARAMS( VS_INPUT i ) )
64 | {
65 | i.vPositionOs.z *= WallHeight;
66 | PixelInput o = ProcessVertex( i );
67 | return FinalizeVertex( o );
68 | }
69 | }
70 |
71 | //=========================================================================================================================
72 |
73 | PS
74 | {
75 | #include "common/pixel.hlsl"
76 |
77 | RenderState( BlendEnable, true );
78 | RenderState( SrcBlend, SRC_ALPHA );
79 | RenderState( DstBlend, INV_SRC_ALPHA );
80 | RenderState( ColorWriteEnable0, RGBA );
81 |
82 | PixelOutput MainPs( PixelInput i )
83 | {
84 | Material m = GatherMaterial( i );
85 | PixelOutput o = FinalizePixelMaterial( i, m );
86 |
87 | if (o.vColor.a < 1.0)
88 | discard;
89 |
90 | return o;
91 | }
92 | }
--------------------------------------------------------------------------------
/shaders/shaded.vfx:
--------------------------------------------------------------------------------
1 | //=========================================================================================================================
2 | // Optional
3 | //=========================================================================================================================
4 | HEADER
5 | {
6 | CompileTargets = ( IS_SM_50 && ( PC || VULKAN ) );
7 | Description = "Low quality shit";
8 | }
9 |
10 | //=========================================================================================================================
11 | // Optional
12 | //=========================================================================================================================
13 | FEATURES
14 | {
15 | #include "common/features.hlsl"
16 | }
17 |
18 | MODES
19 | {
20 | VrForward();
21 |
22 | ToolsVis( S_MODE_TOOLS_VIS );
23 | ToolsWireframe( "vr_tools_wireframe.vfx" );
24 | }
25 |
26 | //=========================================================================================================================
27 | COMMON
28 | {
29 | //#define S_TRANSLUCENT 1
30 | #define S_UNLIT 1
31 | #define STENCIL_ALREADY_SET
32 | #define DEPTH_STATE_ALREADY_SET
33 | #define BLEND_MODE_ALREADY_SET
34 | #define COLOR_WRITE_ALREADY_SET
35 | #include "common/shared.hlsl"
36 | }
37 |
38 | //=========================================================================================================================
39 |
40 | struct VertexInput
41 | {
42 | #include "common/vertexinput.hlsl"
43 | };
44 |
45 | //=========================================================================================================================
46 |
47 | struct PixelInput
48 | {
49 | #include "common/pixelinput.hlsl"
50 | };
51 |
52 | //=========================================================================================================================
53 |
54 | VS
55 | {
56 | #include "common/vertex.hlsl"
57 | //VS_CommonProcessing_Post
58 | // Main
59 | //
60 | PixelInput MainVs( INSTANCED_SHADER_PARAMS( VS_INPUT i ) )
61 | {
62 | PixelInput o = ProcessVertex( i );
63 | return FinalizeVertex( o );
64 | }
65 | }
66 |
67 | //=========================================================================================================================
68 |
69 | PS
70 | {
71 | #include "common/pixel.hlsl"
72 |
73 | RenderState( BlendEnable, true );
74 | RenderState( SrcBlend, SRC_ALPHA );
75 | RenderState( DstBlend, INV_SRC_ALPHA );
76 | RenderState( ColorWriteEnable0, RGBA );
77 |
78 | PixelOutput MainPs( PixelInput i )
79 | {
80 | Material m = GatherMaterial( i );
81 | PixelOutput o = FinalizePixelMaterial( i, m );
82 |
83 | if (o.vColor.a < 1.0)
84 | discard;
85 |
86 | float3 sun = 0;
87 | sun.xy = 0.2;
88 | sun.z = 1;
89 |
90 | float v = 0.5 * (1 + dot(normalize(sun), i.vNormalWs.xyz));
91 | o.vColor.rgb *= (v * 0.75 + 0.25);
92 |
93 | return o;
94 | }
95 | }
--------------------------------------------------------------------------------
/shaders/flat.vfx:
--------------------------------------------------------------------------------
1 | //=========================================================================================================================
2 | // Optional
3 | //=========================================================================================================================
4 | HEADER
5 | {
6 | CompileTargets = ( IS_SM_50 && ( PC || VULKAN ) );
7 | Description = "Lowest quality shit";
8 | }
9 |
10 | //=========================================================================================================================
11 | // Optional
12 | //=========================================================================================================================
13 | FEATURES
14 | {
15 | #include "common/features.hlsl"
16 | }
17 |
18 | MODES
19 | {
20 | VrForward();
21 |
22 | ToolsVis( S_MODE_TOOLS_VIS );
23 | ToolsWireframe( "vr_tools_wireframe.vfx" );
24 | }
25 |
26 | //=========================================================================================================================
27 | COMMON
28 | {
29 | #define S_TRANSLUCENT 1
30 | #define S_UNLIT 1
31 | #define STENCIL_ALREADY_SET
32 | #define DEPTH_STATE_ALREADY_SET
33 | #define BLEND_MODE_ALREADY_SET
34 | #define COLOR_WRITE_ALREADY_SET
35 | #include "common/shared.hlsl"
36 | }
37 |
38 | //=========================================================================================================================
39 |
40 | struct VertexInput
41 | {
42 | #include "common/vertexinput.hlsl"
43 | };
44 |
45 | //=========================================================================================================================
46 |
47 | struct PixelInput
48 | {
49 | #include "common/pixelinput.hlsl"
50 | };
51 |
52 | //=========================================================================================================================
53 |
54 | VS
55 | {
56 | #include "common/vertex.hlsl"
57 | //VS_CommonProcessing_Post
58 | // Main
59 | //
60 | PixelInput MainVs( INSTANCED_SHADER_PARAMS( VS_INPUT i ) )
61 | {
62 | PixelInput o = ProcessVertex( i );
63 | return FinalizeVertex( o );
64 | }
65 | }
66 |
67 | //=========================================================================================================================
68 |
69 | PS
70 | {
71 | #include "common.fxc"
72 | #include "common/pixel.hlsl"
73 |
74 | RenderState( BlendEnable, true );
75 | RenderState( SrcBlend, SRC_ALPHA );
76 | RenderState( DstBlend, INV_SRC_ALPHA );
77 | RenderState( ColorWriteEnable0, RGBA );
78 |
79 | CreateInputTexture2D( AlphaTexture, Linear, 8, "", "_alpha", "Color", Default3( 1.0, 1.0, 1.0 ) );
80 | CreateTexture2D( g_tAlphaMask ) < Channel( R, Box( AlphaTexture ), Linear ); OutputFormat( BC7 ); SrgbRead( false ); >;
81 | TextureAttribute( AlphaTexture, g_tAlphaMask );
82 |
83 | PixelOutput MainPs( PixelInput i )
84 | {
85 | Material m = GatherMaterial( i );
86 | PixelOutput o = FinalizePixelMaterial( i, m );
87 |
88 | o.vColor.a = Tex2D( g_tAlphaMask, i.vTextureCoords.xy ).r;
89 |
90 | return o;
91 | }
92 | }
--------------------------------------------------------------------------------
/code/Player.cs:
--------------------------------------------------------------------------------
1 | using Sandbox;
2 | using System.Threading.Tasks;
3 |
4 | namespace Maze
5 | {
6 | public partial class Player : AnimEntity
7 | {
8 | enum State
9 | {
10 | Shittin,
11 | Poopin,
12 | Moving,
13 | Flipping
14 | };
15 |
16 | public float Height => 64f;
17 |
18 | public bool OnGround { get; internal set; } = true;
19 | public bool StopMovement { get; internal set; } = false;
20 | public float TargetRoll { get; internal set; } = 0.0f;
21 |
22 | [Net, Predicted]
23 | public PawnController Controller { get; set; }
24 |
25 | [Net, Predicted]
26 | public PawnController DevController { get; set; }
27 |
28 | [AdminCmd( "maze_forceflip" )]
29 | public static async void ForceFlip()
30 | {
31 | Log.Info( "alright" );
32 | await (Local.Pawn as Player)?.Flip();
33 | }
34 |
35 | public async Task Flip()
36 | {
37 | StopMovement = true;
38 | TargetRoll = 180.0f;
39 | await Task.Delay( 1000 );
40 | StopMovement = false;
41 | }
42 |
43 | public virtual PawnController GetActiveController()
44 | {
45 | if ( DevController != null ) return DevController;
46 |
47 | return Controller;
48 | }
49 |
50 | public override void Simulate( Client cl )
51 | {
52 | var controller = GetActiveController();
53 | controller?.Simulate( cl, this, null );
54 |
55 | //EyePos = EyePos.WithX( MathF.Sin( Time.Now / 2 * MathF.PI ) * 64 ).WithY( MathF.Cos( Time.Now / 2 * MathF.PI ) * 64 );
56 | //EyeRot = Rotation.FromYaw(EyeRot.Yaw() + 30 * Time.Delta );
57 | }
58 |
59 | public override void FrameSimulate( Client cl )
60 | {
61 | base.FrameSimulate( cl );
62 |
63 | var controller = GetActiveController();
64 | controller?.FrameSimulate( cl, this, null );
65 | }
66 |
67 | public override void OnKilled()
68 | {
69 | }
70 |
71 | public virtual void Respawn()
72 | {
73 | Host.AssertServer();
74 |
75 | Velocity = Vector3.Zero;
76 |
77 | ResetInterpolation();
78 |
79 | Transform = Transform.Zero;
80 | Position = new Vector3( Game.Current.Level.CellToWorld( 0, 0 ) ) + new Vector3( -64, 64, 64 ); // TODO: random position
81 | EyeRot = Rotation.From( new Angles( 0, 0, 0 ) );
82 | Log.Info( $"Player pos {Position}" );
83 |
84 | Controller = new NoclipController();
85 |
86 | Camera = new FirstPersonCamera();
87 |
88 | EnableAllCollisions = true;
89 | EnableDrawing = true;
90 | EnableHideInFirstPerson = true;
91 | EnableShadowInFirstPerson = true;
92 | }
93 |
94 | ///
95 | /// Called from the gamemode, clientside only.
96 | ///
97 | public override void BuildInput( InputBuilder input )
98 | {
99 | if ( input.StopProcessing )
100 | return;
101 |
102 | ActiveChild?.BuildInput( input );
103 |
104 | GetActiveController()?.BuildInput( input );
105 |
106 | if ( input.StopProcessing )
107 | return;
108 | }
109 |
110 |
111 | ///
112 | /// Called after the camera setup logic has run. Allow the player to
113 | /// do stuff to the camera, or using the camera. Such as positioning entities
114 | /// relative to it, like viewmodels etc.
115 | ///
116 | public override void PostCameraSetup( ref CameraSetup setup )
117 | {
118 | Host.AssertClient();
119 |
120 | ActiveChild?.PostCameraSetup( ref setup );
121 | }
122 |
123 | public override void StartTouch( Entity other )
124 | {
125 | if ( IsClient ) return;
126 |
127 | if ( other is PickupTrigger )
128 | {
129 | StartTouch( other.Parent );
130 | }
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/code/Game.cs:
--------------------------------------------------------------------------------
1 | using Sandbox;
2 | using System;
3 |
4 | namespace Maze
5 | {
6 | public partial class Game : GameBase
7 | {
8 | public enum GameState
9 | {
10 | Invalid,
11 | Intro,
12 | InGame,
13 | Outro
14 | }
15 | public float IntroDelay => 3.5f;
16 |
17 | public static Game Current { get; protected set; }
18 | [Net, Change] public Level Level { get; protected set; }
19 | [Net, Change] public GameState State { get; protected set; }
20 | [Net] public float WallHeight { get; protected set; }
21 | [Net] public float WallTargetHeight { get; protected set; }
22 | protected TimeSince TimeSinceReset { get; set; }
23 |
24 | public Game()
25 | {
26 | Current = this;
27 |
28 | Transmit = TransmitType.Always;
29 |
30 | if ( IsServer )
31 | {
32 | Level = new();
33 | }
34 | else
35 | {
36 | _ = new EnvEntity();
37 | }
38 | }
39 |
40 | public void OnLevelChanged()
41 | {
42 | Host.AssertClient();
43 |
44 | Level.InitClient();
45 |
46 | Event.Run( "maze.level" );
47 | }
48 |
49 | protected void ChangeState( GameState newState )
50 | {
51 | Host.AssertServer( nameof( ChangeState ) );
52 |
53 | Log.Info( $"New server state: {newState}" );
54 |
55 | switch ( newState )
56 | {
57 | case GameState.Intro:
58 | TimeSinceReset = 0;
59 | WallHeight = 0;
60 | WallTargetHeight = 1;
61 | break;
62 | case GameState.InGame:
63 | WallHeight = WallTargetHeight = 1;
64 | break;
65 | case GameState.Outro:
66 | TimeSinceReset = 0;
67 | WallHeight = 1;
68 | WallTargetHeight = 0;
69 | break;
70 | }
71 |
72 | State = newState;
73 | }
74 |
75 | public void OnStateChanged()
76 | {
77 | Host.AssertClient();
78 |
79 | Log.Info( $"New client state: {State}" );
80 |
81 | Event.Run( "maze.state", State );
82 |
83 | switch ( State )
84 | {
85 | case GameState.Intro:
86 | Sound.FromScreen( "intro" );
87 | break;
88 | }
89 | }
90 |
91 | public override void Spawn()
92 | {
93 | base.Spawn();
94 |
95 | ChangeState( GameState.Intro );
96 | }
97 |
98 | ///
99 | /// A client has joined the server. Make them a pawn to play with
100 | ///
101 | public override void ClientJoined( Client client )
102 | {
103 | var player = new Player();
104 | client.Pawn = player;
105 |
106 | player.Respawn();
107 | }
108 |
109 | ///
110 | /// Called when the game is shutting down
111 | ///
112 | public override void Shutdown()
113 | {
114 | if ( Current == this )
115 | Current = null;
116 | }
117 |
118 | ///
119 | /// Client has disconnected from the server. Remove their entities etc.
120 | ///
121 | public override void ClientDisconnect( Client cl, NetworkDisconnectionReason reason )
122 | {
123 | if ( cl.Pawn.IsValid() )
124 | {
125 | cl.Pawn.Delete();
126 | cl.Pawn = null;
127 | }
128 |
129 | }
130 |
131 | protected void UpdateWallHeight()
132 | {
133 | if ( State == GameState.InGame )
134 | return;
135 |
136 | WallHeight = MathF.Abs( WallTargetHeight > 0 ? TimeSinceReset / IntroDelay : 1 - TimeSinceReset / IntroDelay );
137 | }
138 |
139 | [Event.Tick.Server]
140 | public void Tick()
141 | {
142 | switch ( State )
143 | {
144 | case GameState.Intro:
145 | UpdateWallHeight();
146 | Log.Info( $"server tick {WallHeight}" );
147 | if ( TimeSinceReset > IntroDelay )
148 | ChangeState( GameState.InGame );
149 | break;
150 | }
151 | }
152 |
153 | ///
154 | /// Called each tick.
155 | /// Serverside: Called for each client every tick
156 | /// Clientside: Called for each tick for local client. Can be called multiple times per tick.
157 | ///
158 | public override void Simulate( Client cl )
159 | {
160 | if ( !cl.Pawn.IsValid() ) return;
161 |
162 | // Block Simulate from running clientside
163 | // if we're not predictable.
164 | if ( !cl.Pawn.IsAuthority ) return;
165 |
166 | cl.Pawn.Simulate( cl );
167 | }
168 |
169 | ///
170 | /// Called each frame on the client only to simulate things that need to be updated every frame. An example
171 | /// of this would be updating their local pawn's look rotation so it updates smoothly instead of at tick rate.
172 | ///
173 | public override void FrameSimulate( Client cl )
174 | {
175 | Host.AssertClient();
176 |
177 | if ( !cl.Pawn.IsValid() ) return;
178 |
179 | // Block Simulate from running clientside
180 | // if we're not predictable.
181 | if ( !cl.Pawn.IsAuthority ) return;
182 |
183 | cl.Pawn?.FrameSimulate( cl );
184 | }
185 |
186 | ///
187 | /// Should we send voice data to this player
188 | ///
189 | public override bool CanHearPlayerVoice( Client source, Client dest )
190 | {
191 | Host.AssertServer();
192 |
193 | return false;
194 | }
195 |
196 | ///
197 | /// Which camera should we be rendering from?
198 | ///
199 | public virtual ICamera FindActiveCamera()
200 | {
201 | if ( Local.Client.DevCamera != null ) return Local.Client.DevCamera;
202 | if ( Local.Client.Camera != null ) return Local.Client.Camera;
203 | if ( Local.Pawn != null ) return Local.Pawn.Camera;
204 |
205 | return null;
206 | }
207 |
208 | [Predicted]
209 | public Camera LastCamera { get; set; }
210 |
211 | ///
212 | /// Called to set the camera up, clientside only.
213 | ///
214 | public override CameraSetup BuildCamera( CameraSetup camSetup )
215 | {
216 | var cam = FindActiveCamera();
217 |
218 | if ( LastCamera != cam )
219 | {
220 | LastCamera?.Deactivated();
221 | LastCamera = cam as Camera;
222 | LastCamera?.Activated();
223 | }
224 |
225 | cam?.Build( ref camSetup );
226 |
227 | PostCameraSetup( ref camSetup );
228 |
229 | return camSetup;
230 | }
231 |
232 | ///
233 | /// Clientside only. Called every frame to process the input.
234 | /// The results of this input are encoded\ into a user command and
235 | /// passed to the PlayerController both clientside and serverside.
236 | /// This routine is mainly responsible for taking input from mouse/controller
237 | /// and building look angles and move direction.
238 | ///
239 | public override void BuildInput( InputBuilder input )
240 | {
241 | Event.Run( "buildinput", input );
242 |
243 | // the camera is the primary method here
244 | LastCamera?.BuildInput( input );
245 |
246 | Local.Pawn?.BuildInput( input );
247 | }
248 |
249 | ///
250 | /// Called after the camera setup logic has run. Allow the gamemode to
251 | /// do stuff to the camera, or using the camera. Such as positioning entities
252 | /// relative to it, like viewmodels etc.
253 | ///
254 | public override void PostCameraSetup( ref CameraSetup camSetup )
255 | {
256 | if ( Local.Pawn != null )
257 | {
258 | // VR anchor default is at the pawn's location
259 | VR.Anchor = Local.Pawn.Transform;
260 |
261 | Local.Pawn.PostCameraSetup( ref camSetup );
262 | }
263 |
264 | //
265 | // Position any viewmodels
266 | //
267 | BaseViewModel.UpdateAllPostCamera( ref camSetup );
268 |
269 | CameraModifier.Apply( ref camSetup );
270 | }
271 |
272 | ///
273 | /// Called right after the level is loaded and all entities are spawned.
274 | ///
275 | public override void PostLevelLoaded()
276 | {
277 | }
278 |
279 | public override void OnVoicePlayed( long playerId, float level )
280 | {
281 | }
282 | }
283 |
284 | }
285 |
--------------------------------------------------------------------------------