GameDataManager

Namespace: Murder.Data
Assembly: Murder.dll

public class GameDataManager : IDisposable

Implements: IDisposable

⭐ Constructors

protected GameDataManager(IMurderGame game, FileManager fileManager)

Creates a new game data manager.

Parameters
game IMurderGame

fileManager FileManager

public GameDataManager(IMurderGame game)

Creates a new game data manager.

Parameters
game IMurderGame

⭐ Properties

_allAssets

protected readonly Dictionary<TKey, TValue> _allAssets;

Maps: [Guid] -> [Asset]

Returns
Dictionary<TKey, TValue>

_allSavedData

protected readonly Dictionary<TKey, TValue> _allSavedData;

This is the collection of save data according to the slots.

Returns
Dictionary<TKey, TValue>

_assetsBinDirectoryPath

protected string _assetsBinDirectoryPath;

Returns
string

_binResourcesDirectory

protected string _binResourcesDirectory;

Returns
string

_database

protected readonly Dictionary<TKey, TValue> _database;

Maps: [Game asset type] -> [Guid]

Returns
Dictionary<TKey, TValue>

_fonts

public ImmutableDictionary<TKey, TValue> _fonts;

Returns
ImmutableDictionary<TKey, TValue>

_game

protected readonly IMurderGame _game;

Returns
IMurderGame

_gameProfile

protected GameProfile _gameProfile;

Returns
GameProfile

_packedGameDataDirectory

protected static const string _packedGameDataDirectory;

Relative path where the published game content are expected to be. Expected to be: [bin]/resources/content/ or [source]/packed/content/

Returns
string

_skipLoadingAssetAtPaths

protected readonly HashSet<T> _skipLoadingAssetAtPaths;

Perf: In order to avoid reloading assets that were generated by the importers, track which ones were reloaded completely here.

Returns
HashSet<T>

ActiveSaveData

public SaveData ActiveSaveData { get; }

Active saved run in the game.

Returns
SaveData

AssetsBinDirectoryPath

public string AssetsBinDirectoryPath { get; }

Returns
string

AssetsLock

public Object AssetsLock;

Used for loading the editor asynchronously.

Returns
Object

BinResourcesDirectoryPath

public string BinResourcesDirectoryPath { get; }

Returns
string

CachedUniqueTextures

public readonly CacheDictionary<TKey, TValue> CachedUniqueTextures;

Returns
CacheDictionary<TKey, TValue>

CallAfterLoadContent

public bool CallAfterLoadContent;

Whether we should call the methods after an async load has happened.

Returns
bool

CurrentLocalization

public LanguageIdData CurrentLocalization { get; private set; }

Current localization data.

Returns
LanguageIdData

CurrentPalette

public ImmutableArray<T> CurrentPalette;

Returns
ImmutableArray<T>

CustomGameShaders

public Effect[] CustomGameShaders;

Custom optional game shaders, provided by GameDataManager._game.

Returns
Effect[]

DitherTexture

public Texture2D DitherTexture;

Returns
Texture2D

FileManager

public readonly FileManager FileManager;

Returns
FileManager

GameDirectory

public virtual string GameDirectory { get; }

Directory used for saving custom data.

Returns
string

GameProfile

public GameProfile GameProfile { get; protected set; }

Returns
GameProfile

GameProfileFileName

public static const string GameProfileFileName;

Returns
string

HiddenAssetsRelativePath

public static const string HiddenAssetsRelativePath;

Returns
string

IgnoreSerializationErrors

public virtual bool IgnoreSerializationErrors { get; }

Whether we will continue trying to deserialize a file after finding an issue.

Returns
bool

LoadContentProgress

public Task LoadContentProgress;

Returns
Task

LoadedAtlasses

public readonly Dictionary<TKey, TValue> LoadedAtlasses;

Returns
Dictionary<TKey, TValue>

Localization

public LocalizationAsset Localization { get; }

Returns
LocalizationAsset

OtherEffects

public virtual Effect[] OtherEffects { get; }

Returns
Effect[]

PackedBinDirectoryPath

public string PackedBinDirectoryPath { get; }

Returns
string

PendingSave

public T? PendingSave;

Returns
T?

Preferences

public GamePreferences Preferences { get; }

Returns
GamePreferences

PublishedPackedAssetsFullPath

protected virtual string PublishedPackedAssetsFullPath { get; }

File path of the packed contents for the released game.

Returns
string

SaveBasePath

public string SaveBasePath { get; }

Save directory path used when serializing user data.

Returns
string

SerializationOptions

public JsonSerializerOptions SerializationOptions { get; }

Returns
JsonSerializerOptions

ShaderPixel

public Effect ShaderPixel;

A shader specialized for rendering pixel art.

Returns
Effect

ShaderRelativePath

protected readonly string ShaderRelativePath;

Returns
string

ShaderSimple

public Effect ShaderSimple;

The cheapest and simplest shader.

Returns
Effect

ShaderSprite

public Effect ShaderSprite;

Actually a fancy shader, has some sprite effect tools for us, like different color blending modes.

Returns
Effect

SKIP_CHAR

public static const char SKIP_CHAR;

Returns
char

WaitPendingSaveTrackerOperation

public bool WaitPendingSaveTrackerOperation { get; }

Returns
bool

⭐ Methods

LoadContentAsync()

protected Task LoadContentAsync()

Returns
Task

ShouldSkipAsset(string)

protected virtual bool ShouldSkipAsset(string fullFilename)

This will skip loading assets that start with a certain char. This is used to filter assets that are only used in the editor.

Parameters
fullFilename string

Returns
bool

TryCompileShader(string, out Effect&)

protected virtual bool TryCompileShader(string name, Effect& result)

Parameters
name string
result Effect&

Returns
bool

CreateGameProfile()

protected virtual GameProfile CreateGameProfile()

Returns
GameProfile

FetchSystemsToStartWith()

protected virtual ImmutableArray<T> FetchSystemsToStartWith()

This has the collection of systems which will be added to any world that will be created. Used when hooking new systems into the editor.

Returns
ImmutableArray<T>

GetLocalization(LanguageId)

protected virtual LocalizationAsset GetLocalization(LanguageId id)

Parameters
id LanguageId

Returns
LocalizationAsset

CreateSaveDataWithVersion(int)

protected virtual SaveData CreateSaveDataWithVersion(int slot)

Creates an implementation of SaveData for the game.

Parameters
slot int

Returns
SaveData

LoadAllAssetsAsync()

protected virtual Task LoadAllAssetsAsync()

Returns
Task

LoadContentAsyncImpl()

protected virtual Task LoadContentAsyncImpl()

Returns
Task

LoadFontsAndTexturesAsync()

protected virtual Task LoadFontsAndTexturesAsync()

Returns
Task

LoadSoundsImplAsync(bool)

protected virtual Task LoadSoundsImplAsync(bool reload)

Implemented by custom implementations of data manager that want to do some preprocessing on the sounds.

Parameters
reload bool

Returns
Task

OnAfterPreloadLoaded()

protected virtual void OnAfterPreloadLoaded()

Immediately fired once the "fast" loading finishes.

OnAssetLoadError(GameAsset)

protected virtual void OnAssetLoadError(GameAsset asset)

Let implementations deal with a custom handling of errors. This is called when the asset was successfully loaded but failed to fill some of its fields.

Parameters
asset GameAsset

PreloadContentImpl()

protected virtual void PreloadContentImpl()

PreprocessSoundFiles()

protected virtual void PreprocessSoundFiles()

Implemented by custom implementations of data manager that want to do some preprocessing on the sounds.

RemoveAsset(Type, Guid)

protected virtual void RemoveAsset(Type t, Guid assetGuid)

Parameters
t Type
assetGuid Guid

PreloadContent()

protected void PreloadContent()

TrackFont(FontAsset)

protected void TrackFont(FontAsset asset)

Parameters
asset FontAsset

GetAsepriteFrame(Guid)

public AtlasCoordinates GetAsepriteFrame(Guid id)

Quick and dirty way to get a aseprite frame, animated when you don't want to deal with the animation system.

Parameters
id Guid

Returns
AtlasCoordinates

AddAssetForCurrentSave(GameAsset)

public bool AddAssetForCurrentSave(GameAsset asset)

Parameters
asset GameAsset

Returns
bool

CanLoadSaveData(int)

public bool CanLoadSaveData(int slot)

Parameters
slot int

Returns
bool

HasAsset(Guid)

public bool HasAsset(Guid id)

Parameters
id Guid

Returns
bool

IsPathOnSkipLoading(string)

public bool IsPathOnSkipLoading(string name)

Parameters
name string

Returns
bool

LoadAllSaves()

public bool LoadAllSaves()

Returns
bool

LoadSaveAsCurrentSave(int)

public bool LoadSaveAsCurrentSave(int slot)

Load a save as the current save. If more than one, it will grab whatever is first available in all saved data.

Parameters
slot int

Returns
bool

LoadShader(string, out Effect&, bool, bool)

public bool LoadShader(string name, Effect& effect, bool breakOnFail, bool forceReload)

Parameters
name string
effect Effect&
breakOnFail bool
forceReload bool

Returns
bool

RemoveAssetForCurrentSave(Guid)

public bool RemoveAssetForCurrentSave(Guid guid)

Parameters
guid Guid

Returns
bool

TryGetDynamicAsset(out T&)

public bool TryGetDynamicAsset(T& asset)

Parameters
asset T&

Returns
bool

GetAllSaves()

public Dictionary<TKey, TValue> GetAllSaves()

List all the available saves within the game.

Returns
Dictionary<TKey, TValue>

GetAsset(Guid)

public GameAsset GetAsset(Guid id)

Parameters
id Guid

Returns
GameAsset

TryGetAsset(Guid)

public GameAsset TryGetAsset(Guid id)

Get a generic asset with a .

Parameters
id Guid

Returns
GameAsset

TryGetAssetForCurrentSave(Guid)

public GameAsset TryGetAssetForCurrentSave(Guid guid)

Retrieve a dynamic asset within the current save data based on a guid.

Parameters
guid Guid

Returns
GameAsset

TryLoadAsset(string, string, bool, bool)

public GameAsset TryLoadAsset(string path, string relativePath, bool skipFailures, bool hasEditorPath)

Parameters
path string
relativePath string
skipFailures bool
hasEditorPath bool

Returns
GameAsset

GetAllAssets()

public IEnumerable<T> GetAllAssets()

Returns
IEnumerable<T>

FilterAllAssets(Type[])

public ImmutableDictionary<TKey, TValue> FilterAllAssets(Type[] types)

Parameters
types Type[]

Returns
ImmutableDictionary<TKey, TValue>

FilterOutAssets(Type[])

public ImmutableDictionary<TKey, TValue> FilterOutAssets(Type[] types)

Return all the assets except the ones in .

Parameters
types Type[]

Returns
ImmutableDictionary<TKey, TValue>

FindAllNamesForAsset(Type)

public ImmutableHashSet<T> FindAllNamesForAsset(Type t)

Find all the assets names for an asset type .

Parameters
t Type

Returns
ImmutableHashSet<T>

GetDefaultLocalization()

public LocalizationAsset GetDefaultLocalization()

Returns
LocalizationAsset

CreateWorldInstanceFromSave(Guid, Camera2D)

public MonoWorld CreateWorldInstanceFromSave(Guid guid, Camera2D camera)

Parameters
guid Guid
camera Camera2D

Returns
MonoWorld

GetFont(int)

public PixelFont GetFont(int index)

Parameters
index int

Returns
PixelFont

GetPrefab(Guid)

public PrefabAsset GetPrefab(Guid id)

Parameters
id Guid

Returns
PrefabAsset

TryGetPrefab(Guid)

public PrefabAsset TryGetPrefab(Guid id)

Parameters
id Guid

Returns
PrefabAsset

ResetActiveSave()

public SaveData ResetActiveSave()

This resets the active save data.

Returns
SaveData

TryGetActiveSaveData()

public SaveData TryGetActiveSaveData()

Active saved run in the game.

Returns
SaveData

GetAsset(Guid)

public T GetAsset(Guid id)

Parameters
id Guid

Returns
T

GetDynamicAsset()

public T GetDynamicAsset()

Retrieve a dynamic asset within the current save data. If no dynamic asset is found, it creates a new one to the save data.

Returns
T

TryGetAsset(Guid)

public T TryGetAsset(Guid id)

Parameters
id Guid

Returns
T

LoadSoundsAsync(bool)

public Task LoadSoundsAsync(bool reload)

This will load all the sounds to the game.

Parameters
reload bool

Returns
Task

TryLoadAssetAsync(string, string, bool, bool)

public Task<TResult> TryLoadAssetAsync(string path, string relativePath, bool skipFailures, bool hasEditorPath)

Parameters
path string
relativePath string
skipFailures bool
hasEditorPath bool

Returns
Task<TResult>

FetchTexture(string)

public Texture2D FetchTexture(string path)

Parameters
path string

Returns
Texture2D

FetchAtlas(AtlasId, bool)

public TextureAtlas FetchAtlas(AtlasId atlas, bool warnOnError)

Parameters
atlas AtlasId
warnOnError bool

Returns
TextureAtlas

TryFetchAtlas(AtlasId)

public TextureAtlas TryFetchAtlas(AtlasId atlas)

Parameters
atlas AtlasId

Returns
TextureAtlas

SerializeSaveAsync()

public ValueTask<TResult> SerializeSaveAsync()

Returns
ValueTask<TResult>

DeleteSaveAt(int)

public virtual bool DeleteSaveAt(int slot)

Parameters
slot int

Returns
bool

CreateSave(int)

public virtual SaveData CreateSave(int slot)

Create a new save data based on a name.

Parameters
slot int

Returns
SaveData

AfterContentLoadedFromMainThread()

public virtual void AfterContentLoadedFromMainThread()

Called after the content was loaded back from the main thread.

DeleteAllSaves()

public virtual void DeleteAllSaves()

Dispose()

public virtual void Dispose()

Initialize(string)

public virtual void Initialize(string resourcesBinPath)

Parameters
resourcesBinPath string

InitShaders()

public virtual void InitShaders()

LoadContent()

public virtual void LoadContent()

OnAssetRenamedOrAddedOrDeleted()

public virtual void OnAssetRenamedOrAddedOrDeleted()

AddAsset(T, bool)

public void AddAsset(T asset, bool overwriteDuplicateGuids)

Parameters
asset T
overwriteDuplicateGuids bool

ChangeLanguage(LanguageId)

public void ChangeLanguage(LanguageId id)

Parameters
id LanguageId

ChangeLanguage(LanguageIdData)

public void ChangeLanguage(LanguageIdData data)

Parameters
data LanguageIdData

ClearContent()

public void ClearContent()

DisposeAtlas(AtlasId)

public void DisposeAtlas(AtlasId atlasId)

Parameters
atlasId AtlasId

DisposeAtlases()

public void DisposeAtlases()

LoadShaders(bool, bool)

public void LoadShaders(bool breakOnFail, bool forceReload)

Override this to load all shaders present in the game.

Parameters
breakOnFail bool

forceReload bool

OnErrorLoadingAsset()

public void OnErrorLoadingAsset()

QuickSave()

public void QuickSave()

Quickly serialize our save assets.

RemoveAsset(Guid)

public void RemoveAsset(Guid assetGuid)

Parameters
assetGuid Guid

RemoveAsset(T)

public void RemoveAsset(T asset)

Parameters
asset T

ReplaceAtlas(AtlasId, TextureAtlas)

public void ReplaceAtlas(AtlasId atlasId, TextureAtlas newAtlas)

Parameters
atlasId AtlasId
newAtlas TextureAtlas

SaveWorld(MonoWorld)

public void SaveWorld(MonoWorld world)

Parameters
world MonoWorld

SkipLoadingAssetsAt(string)

public void SkipLoadingAssetsAt(string path)

Parameters
path string

UnloadAllSaves()

public void UnloadAllSaves()

Used to clear all saves files currently active.