Advertisement
xxeell

BaseMod

Oct 17th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ElementsCore
  4. {
  5.     public abstract class BaseModule<T>
  6.     {
  7.         protected bool mod_is_init;
  8.         protected bool mod_is_closed;
  9.         protected ModuleManager<T> mod_manager;
  10.  
  11.         public BaseModule()
  12.         {
  13.             mod_manager = null;
  14.             mod_is_init = false;
  15.             mod_is_closed = false;
  16.         }
  17.  
  18.         public void SetManager(ModuleManager<T> manager)
  19.         {
  20.             mod_manager = manager;
  21.         }
  22.  
  23.         protected abstract void m_init();
  24.         protected abstract bool m_key_down(KeyCommand command);
  25.         protected abstract void m_close();
  26.  
  27.         public void Init()
  28.         {
  29.             if (mod_is_init) Close();
  30.  
  31.             mod_is_init = true;
  32.             mod_is_closed = false;
  33.  
  34.             m_init();
  35.         }
  36.  
  37.         public bool KeyDown(KeyCommand command)
  38.         {
  39.             if (!mod_is_init || mod_is_closed)
  40.             {
  41.                 return false;
  42.             }
  43.             else
  44.             {
  45.                 return m_key_down(command);
  46.             }
  47.         }
  48.  
  49.         public void Close()
  50.         {
  51.             if (mod_is_init)
  52.             {
  53.                 m_close();
  54.                 mod_is_closed = true;
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement