GameDataManager

Namespace: Murder.Data
Assembly: Murder.dll

public class GameDataManager : IDisposable

Implements: IDisposable

⭐ Constructors

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>

_gameProfile

protected GameProfile _gameProfile;

Returns
GameProfile

_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

AvailableUniqueTextures

public ImmutableArray<T> AvailableUniqueTextures;

Returns
ImmutableArray<T>

BinResourcesDirectoryPath

public string BinResourcesDirectoryPath { get; }

Returns
string

BloomShader

public Effect BloomShader;

A shader that can blur and find brightness areas in images

Returns
Effect

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>

CustomGameShader

public Effect[] CustomGameShader;

Custom optional game shader, provided by GameDataManager._game.

Returns
Effect[]

DitherTexture

public Texture2D DitherTexture;

Returns
Texture2D

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

LoadContentProgress

public Task LoadContentProgress;

Returns
Task

LoadedAtlasses

public readonly Dictionary<TKey, TValue> LoadedAtlasses;

Returns
Dictionary<TKey, TValue>

Localization

public LocalizationAsset Localization { get; }

Returns
LocalizationAsset

MaskShader

public Effect MaskShader;

A shader that mask images

Returns
Effect

OtherEffects

public virtual Effect[] OtherEffects { get; }

Returns
Effect[]

PackedBinDirectoryPath

public string PackedBinDirectoryPath { get; }

Returns
string

PendingSave

public T? PendingSave;

Returns
T?

PosterizerShader

public Effect PosterizerShader;

A shader that can blur and find brightness areas in images

Returns
Effect

Preferences

public GamePreferences Preferences { get; }

Returns
GamePreferences

SaveBasePath

public static string SaveBasePath { get; }

Save directory path used when serializing user data.

Returns
string

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

⭐ Methods

FetchAssetsAtPath(string, bool, bool, bool, bool)

protected IEnumerable<T> FetchAssetsAtPath(string fullPath, bool recursive, bool skipFailures, bool stopOnFailure, bool hasEditorPath)

Fetch all assets at a given path.

Parameters
fullPath string

recursive bool

skipFailures bool

stopOnFailure bool

hasEditorPath bool

Returns
IEnumerable<T>

LoadContentAsync()

protected Task LoadContentAsync()

Returns
Task

ShouldSkipAsset(FileInfo)

protected virtual bool ShouldSkipAsset(FileInfo f)

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
f FileInfo

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

LoadContentAsyncImpl()

protected virtual Task LoadContentAsyncImpl()

Returns
Task

OnAfterPreloadLoaded()

protected virtual void OnAfterPreloadLoaded()

Immediately fired once the "fast" loading finishes.

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

LoadAssetsAtPath(String&, bool)

protected void LoadAssetsAtPath(String& relativePath, bool hasEditorPath)

Parameters
relativePath string&
hasEditorPath bool

PreloadContent()

protected void PreloadContent()

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>

FilterAllAssetsWithImplementation(Type[])

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

Filter all the assets and any types that implement those types. Cautious: this may be slow or just imply extra allocations.

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

FetchTexture(string)

public Texture2D FetchTexture(string path)

Parameters
path string

Returns
Texture2D

TryFetchTexture(string)

public Texture2D TryFetchTexture(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

LoadSounds(bool)

public ValueTask LoadSounds(bool reload)

This will load all the sounds to the game.

Parameters
reload bool

Returns
ValueTask

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

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()

LoadFontsAndTextures()

public virtual void LoadFontsAndTextures()

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()

InitializeAssets()

public void InitializeAssets()

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

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.