Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SceneLoader : Node
- {
- static SceneLoader _instance;
- WeakRef currentScene;
- ResourceInteractiveLoader loader;
- float waitFrames;
- int timeMax = 100;
- float progress = 0;
- bool artificialSlowDown = false;
- int artificialSlowDownFrames = 60;
- int artificialSlowDownCurrent = 60;
- bool done = false;
- // This is quite a long Enum if I do say so myself.
- enum error
- {
- OK = 0,
- FAILED,
- ERR_UNAVAILABLE,
- ERR_UNCONFIGURED,
- ERR_UNAUTHORIZED,
- ERR_PARAMETER_RANGE_ERROR,
- ERR_OUT_OF_MEMORY,
- ERR_FILE_NOT_FOUND,
- ERR_FILE_BAD_DRIVE,
- ERR_FILE_BAD_PATH,
- ERR_FILE_NO_PERMISSION,
- ERR_FILE_ALREADY_IN_USE,
- ERR_FILE_CANT_OPEN,
- ERR_FILE_CANT_WRITE,
- ERR_FILE_CANT_READ,
- ERR_FILE_UNRECOGNIZED,
- ERR_FILE_CORRUPT,
- ERR_FILE_MISSING_DEPENDENCIES,
- ERR_FILE_EOF,
- ERR_CANT_OPEN,
- ERR_CANT_CREATE,
- ERR_PARSE_ERROR = 43,
- ERROR_QUERY_FAILED = 21,
- ERR_ALREADY_IN_USE,
- ERR_LOCKED,
- ERR_TIMEOUT,
- ERR_CANT_AQUIRE_RESOURCE = 28,
- ERR_INVALID_DATA = 30,
- ERR_INVALID_PARAMETER,
- ERR_ALREADY_EXISTS,
- ERR_DOES_NOT_EXIST,
- ERR_DATABASE_CANT_READ,
- ERR_DATABASE_CANT_WRITE,
- ERR_COMPILATION_FAILED,
- ERR_METHOD_NOT_FOUND,
- ERR_LINK_FAILED,
- ERR_SCRIPT_FAILED,
- ERR_CYCLIC_LINK,
- ERR_BUSY = 44,
- ERR_HELP = 46,
- ERR_BUG,
- ERR_WTF = 49
- }
- public static SceneLoader Instance
- {
- get
- {
- return _instance;
- }
- }
- public WeakRef CurrentScene { get => currentScene; set => currentScene = value; }
- public override void _Init()
- {
- AddUserSignal("DONE");
- AddUserSignal("ERROR");
- AddUserSignal("PROGRESS");
- AddUserSignal("START");
- AddUserSignal("TRANSITION");
- }
- public override void _EnterTree()
- {
- _instance = this;
- // Godot.GD.Print("You should be able to use this SceneLoader now.");
- }
- public override void _ExitTree()
- {
- _instance = null;
- }
- // public void DummyMethod()
- // {
- // Godot.GD.Print("I am a dummy method");
- // Console.WriteLine("I am supposed to be under the other dummy.");
- // }
- public override void _Process(float delta)
- {
- /* Called every frame. Delta is time since last frame.
- Update game logic here. */
- }
- public void SlowDown(int frames = 60)
- {
- artificialSlowDown = true;
- artificialSlowDownCurrent = frames;
- artificialSlowDownFrames = 60;
- }
- public void FreeCurrentScene()
- {
- }
- public void LoadScene(string path, bool withTransition = true)
- {
- }
- public void UpdateProgress()
- {
- }
- public float GetProgress()
- {
- return progress;
- }
- public int GetStage()
- {
- return loader.GetStageCount();
- }
- public int GetStageCount()
- {
- return loader.GetStageCount();
- }
- public void SetNewScene(PackedScene sceneResource)
- {
- Node sceneInstance = sceneResource.Instance();
- currentScene = Godot.GD.Weakref(sceneInstance);
- done = true;
- UpdateProgress();
- EmitSignal("DONE", sceneInstance);
- EmitSignal("TRANSITION", 0);
- }
- public bool Poll()
- {
- return false;
- }
- public void OnTransitionDone()
- {
- }
- public void ShowError(int err)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement