mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 08:18:20 -04:00
* New map selector with support for workshops + mounts * New mounts menu on main menu and pause menu to enable/disable mounts * Mount scenes multiplayer support - incl. auto-mounting the game if we can, disconnect if we can't (not installed) * MapInstance supports non-package scenes from LaunchArgs * ResourceLoader: don't use cached result if it's no longer IsValid, like after it's destroyed from a resourcelibrary clear * MapInstance: failing to load from LaunchArgs fallsback to the preconfigured map * Skip SoundFile.Create when IsHeadless * Quake mount: hide non-map bsps
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using Button = Sandbox.Mapping.Button;
|
|
|
|
partial class QuakeMap : SceneLoader<QuakeMount>
|
|
{
|
|
public string PakDir { get; init; }
|
|
public string FileName { get; init; }
|
|
|
|
private List<Texture> Textures { get; init; } = [];
|
|
private List<Texture> FullbrightTextures { get; init; } = [];
|
|
private readonly Dictionary<(int Tex, int Page), Material> _materials = [];
|
|
|
|
private readonly List<Texture[]> _lightmapPages = [];
|
|
private Texture _lightstyleTex;
|
|
private FaceSurface[] Surfaces;
|
|
|
|
private float _waterAlpha = 0.5f;
|
|
private float _lavaAlpha = 1.0f;
|
|
private float _slimeAlpha = 0.5f;
|
|
private float _teleAlpha = 0.5f;
|
|
|
|
private Model _worldModel;
|
|
private readonly Dictionary<int, Model> _brushModels = [];
|
|
|
|
private readonly List<PendingDoor> _doors = [];
|
|
private readonly List<(Button Button, string Target)> _buttons = [];
|
|
|
|
public QuakeMap( string pakDir, string fileName )
|
|
{
|
|
PakDir = pakDir;
|
|
FileName = fileName;
|
|
|
|
// hide stuff like b_shell1.bsp which isn't a map, it's a model
|
|
string fn = System.IO.Path.GetFileName( FileName );
|
|
Flags = Flags.WithFlag( ResourceFlags.DeveloperOnly, fn.StartsWith( "b_" ) );
|
|
}
|
|
|
|
protected override void BuildScene()
|
|
{
|
|
var file = new Quake.BSP.File( Host.GetFileStream( PakDir, FileName ) );
|
|
|
|
_worldModel = BuildWorldModel( file );
|
|
if ( _worldModel is null )
|
|
return;
|
|
|
|
var world = new GameObject( true, "worldspawn" );
|
|
world.AddComponent<ModelRenderer>().Model = _worldModel;
|
|
|
|
var collider = world.AddComponent<ModelCollider>();
|
|
collider.Model = _worldModel;
|
|
collider.Static = true;
|
|
|
|
SpawnEntities( file );
|
|
}
|
|
}
|