mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-17 21:07:56 -04:00
### Problem
NavMesh baking needed to store raw binary data in external files (`.navdata`) that should be tracked and packaged, but aren't native compiled resources.
### Solution
Reused the existing `RegisterAdditionalRelatedFile_Game` native infrastructure to track raw files similar to how `RegisterAdditionalRelatedFile_Content` is used to track content sources (.fbx, .tga...). `RegisterAdditionalRelatedFile_Game` was not used anywhere in the codebase, so it's safe to repurpose. This avoids changing the asset file format.
### Changes
**C# Asset System:**
- Split `GetAdditionalRelatedFiles()` into:
- `GetAdditionalContentFiles()` - content-side files (.fbx, .lxo, .rect, etc.) filtered by `ASSET_LOCATION_CONTENT`
- `GetAdditionalGameFiles()` - game-side data files (.navdata, etc.) filtered by `ASSET_LOCATION_GAME`
**Resource Compilation:**
- Added `FileReference` struct for JSON serialization with `{ "$reference_type: "filereference", "path": "..." }` pattern
- Added `AddGameFileReference()` to `ResourceCompileContext` which calls `RegisterAdditionalRelatedFile_Game()`
**Packaging:**
- `PackageManifest` now additionally collects game/rawfiles files for publishing (content files are still only included when publishing source)
74 lines
1.8 KiB
Modula-2
74 lines
1.8 KiB
Modula-2
|
|
|
|
native class IResourceCompilerContext
|
|
{
|
|
void SetExtension( string name );
|
|
void SetCompiler( string name );
|
|
|
|
string FullPath();
|
|
string RelativePath();
|
|
string ResourceName();
|
|
|
|
void SpecifyResourceVersion( int nVersion );
|
|
void RegisterSpecialDependency( string str, uint nUserData, uint nFingerprint );
|
|
|
|
inline bool RegisterReference( string filename )
|
|
{
|
|
CPathBufferString fixedResourceName;
|
|
|
|
if ( !FixupResourceName( filename, &fixedResourceName ) )
|
|
return false;
|
|
|
|
ResourceType_t nType = DeduceResourceTypeFromResourceName( fixedResourceName );
|
|
self->RegisterResourceReference( nType, fixedResourceName );
|
|
return true;
|
|
}
|
|
|
|
inline void RegisterInputFileDependency( string filename, int flags )
|
|
{
|
|
self->RegisterInputFileDependency( filename, (InputFileDependencyFlags_t) flags );
|
|
}
|
|
|
|
inline void RegisterAdditionalRelatedFile_Game( string filename )
|
|
{
|
|
self->RegisterAdditionalRelatedFile_Game( filename );
|
|
}
|
|
|
|
inline int WriteBlock( string blockName, void* data, int count )
|
|
{
|
|
auto blockId = MK_RSRC_BLOCK_ID( blockName[0], blockName[1], blockName[2], blockName[3] );
|
|
return self->RegisterAdditionalBlock( blockId, data, count );
|
|
}
|
|
|
|
inline CUtlBuffer GetOverrideData()
|
|
{
|
|
return self->RequestBufferArg( "___OverrideInputData___", INPUT_DEPENDENCY_NORMAL );
|
|
}
|
|
|
|
CResourceStream Data();
|
|
CResourceStream StreamingData();
|
|
IResourceCompilerContextChild CreateChildContext( string pFileName );
|
|
}
|
|
|
|
native class CResourceStream
|
|
{
|
|
void WriteBytes( void* data, int size );
|
|
|
|
void Align( int alignment, int offset );
|
|
void AlignPointer();
|
|
|
|
uint Tell();
|
|
}
|
|
|
|
native class IResourceCompilerContextChild
|
|
{
|
|
inline void SetOverrideInputData( string data )
|
|
{
|
|
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
|
|
buf.PutString( data );
|
|
self->SetOverrideInputData( buf );
|
|
}
|
|
|
|
bool CompileImmediately();
|
|
}
|