21 lines
2.5 KiB
C#
21 lines
2.5 KiB
C#
using asap.core;
|
|
namespace asap.core { public interface IConfig { T Get<T>(string key, T fallback); } public interface IEventAggregator {void Publish<T>(T x);Stream<T> GetEvent<T>();} public class EventAggregator:IEventAggregator { readonly Dictionary<Type,object> events=new();public Stream<T> GetEvent<T>(){if(!events.ContainsKey(typeof(T)))events[typeof(T)]=new Stream<T>();return (Stream<T>)events[typeof(T)];} public void Publish<T>(T x)=>GetEvent<T>().Emit(x); } public interface IStageService{Task SwitchStageAsync(string s);} }
|
|
public class Stream<T> {public event Action<T> Event;public IDisposable Subscribe(Action<T> action){Event+=action;return new Subscription(()=>Event-=action);}public void Emit(T x)=>Event?.Invoke(x);}
|
|
public class Subscription:IDisposable {Action end;public Subscription(Action a){end=a;}public void Dispose(){end?.Invoke();end=null;}}
|
|
public static class GContext {static EventAggregator events=new();public static Stream<T> OnEvent<T>()=>events.GetEvent<T>();public static void Publish<T>(T x)=>events.Publish(x);public static Container container=new();}
|
|
public class Container {public T Resolve<T>()=>default;}
|
|
namespace game {public class EvtAPISvrLoginSuccess{} public static class QuitStage{public static bool Logout;}}
|
|
namespace UniRx {} namespace GameCore {}
|
|
namespace UnityEngine {public static class Debug {public static void Log(object x){Console.WriteLine(x); } public static void LogError(object x){Console.WriteLine("PRODUCTION ERROR: "+x);}public static void LogException(Exception x){if(x is not OperationCanceledException)throw x;}}public class GameObject{public T GetComponent<T>() where T:new()=>new();}}
|
|
public static class Awaiters { public static Task NextFrame=>Task.CompletedTask; }
|
|
public class UIManager {public static UIManager Instance=new();public Task<UnityEngine.GameObject> ShowUI(object x)=>Task.FromResult(new UnityEngine.GameObject());}
|
|
public static class UITypes {public static object NoticeConfirmPopupPanel=new();}
|
|
public class NoticeConfirmPopupPanel {public void Init(int i,string title,string info,Action onClickLeft,Action onClose,string btn_left_text){}}
|
|
public static class LocalizationMgr {public static string GetText(string s)=>s;}
|
|
public static class LoadingScreen {public static Task Show()=>Task.CompletedTask;}
|
|
|
|
namespace LitJson {}
|
|
public static class GConstant {public const string K_Event_API_URL="EventApiURL";}
|
|
namespace game {public class EvtAPISvrUnauthorized{public int SessionVersion{get;set;}}}
|
|
class Config(string url):asap.core.IConfig {public T Get<T>(string key,T fallback)=>(T)(object)url;}
|