Skip to content

Instantly share code, notes, and snippets.

@DirtyHarryE
DirtyHarryE / GameState.cs
Last active March 6, 2023 17:42
Game State
using System;
using UnityEngine;
/*
============================================================================================================================================================
GameState : A static helper class for GameState<T>. Holds the Current State and handles Transitions (calls OnEnter and OnExit where Necessary).
Necessary, since interfaces cannot have static members, and generic classes' static members are not shared across different types.
GameState<T> : The actual State Object. Can be referenced via Singleton Instance.
@DirtyHarryE
DirtyHarryE / ILoadable.cs
Last active March 6, 2023 18:18
Universal Loader
/*
The Universal Loader automatically searches the project and adds scriptable objects that implement "ILoadable" to a list.
The problem this was meant to solve was to be able to access Scriptableobjects easily within code. One could have serialized
references wherever they are needed, but those can be changed and if code needs to access the SAME scriptable object, this
can be a problem. So the idea came to having a static reference to the scriptable object within it, but if the scriptable
object isn't loaded, its Awake() method is never called. Having a Universal Loader Scriptable object that is referenced
in the scene that automatically calls a method on that scriptable object that implements ILoadable will allow you to make
that reference quickly and easily.
*/
namespace ItalicPig.PaleoPines.Loading
using ItalicPig.PaleoPines.Loading;
using UnityEngine;
using UnityEngine.Serialization;
/*
* Copyright © 2020, Italic Pig, All Rights Reserved
*
* Author: Harry Evans
* Date: 25/02/2020
*/