示例#1
0
        public static void Init(ICharacter currentCharacter)
        {
            Reset();

            isInitialized = true;

            if (currentCharacter is null)
            {
                return;
            }

            ClientCurrentCharacterHelper.Init(currentCharacter);
            InitCallback?.Invoke(currentCharacter);

            if (currentCharacter.ProtoCharacter == Api.GetProtoEntity <PlayerCharacter>() ||
                currentCharacter.ProtoCharacter == Api.GetProtoEntity <PlayerCharacterSpectator>() ||
                currentCharacter.ProtoCharacter == Api.GetProtoEntity <PlayerCharacterMob>())
            {
                InitGameplayMode(currentCharacter);
            }

            CreativeModeSystem.ClientRequestCurrentUserIsInCreativeMode();
            ServerOperatorSystem.ClientRequestCurrentUserIsOperator();

            InitEndCallback?.Invoke(currentCharacter);
        }
示例#2
0
    public static async Task Init(InitCallback initCallback, params Func <Task>[] initTasks)
    {
        if (null != Instance)
        {
            throw new ApplicationException("SystemManager already exsited, can't run Init more than once!");
        }

        var go = new GameObject("Systems", typeof(SystemManager));

        DontDestroyOnLoad(go);

        SystemInitLog.Log("----------Initialize Game----------");
        for (int i = 0; i < initTasks.Length; ++i)
        {
            var    func    = initTasks[i];
            string sysName = GetName(func);
            initCallback(0, sysName, (float)i / initTasks.Length);
            SystemInitLog.Log(sysName);
            await func();

            Instance.AddSystem(func);
            initCallback(0, sysName, (float)(i + 1) / initTasks.Length);
        }
        SystemInitLog.Log("----------Initialize Finished----------");
    }
示例#3
0
 private void CallCallback()
 {
     if (this.m_callback != null)
     {
         this.m_callback();
         this.m_callback = null;
     }
 }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VuforiaInitializedCallback"/> class.
        /// </summary>
        /// <param name="onCallbackAction">Action to be called when the callback is triggered</param>
        public VuforiaInitializedCallback(Action <bool> onCallbackAction)
        {
            internalAction = onCallbackAction;

            this.callback = new InitCallback(OnInitializeCallback);

            taskCompletionSource = new TaskCompletionSource <bool>();
            callbackHandle       = GCHandle.Alloc(this.callback);
        }
示例#5
0
        /// <summary>
        /// Initializes the string table.
        /// </summary>
        public void Initialize(INetManager network, InitCallback callback = null)
        {
            Debug.Assert(!_initialized);

            _callback = callback;
            _network  = network;
            _network.RegisterNetMessage <MsgStringTableEntries>(MsgStringTableEntries.NAME, message =>
            {
                if (_network.IsServer) // Server does not receive entries from clients.
                {
                    return;
                }

                var msg = (MsgStringTableEntries)message;

                foreach (var entry in msg.Entries)
                {
                    var id  = entry.Id;
                    var str = string.IsNullOrEmpty(entry.String) ? null : entry.String;

                    if (str == null)
                    {
                        _strings.Remove(id);
                    }
                    else
                    {
                        if (TryFindStringId(str, out int oldId))
                        {
                            if (oldId == id)
                            {
                                continue;
                            }

                            _strings.Remove(oldId);
                            _strings.Add(id, str);
                        }
                        else
                        {
                            _strings.Add(id, str);
                        }
                    }
                }

                if (callback == null)
                {
                    return;
                }

                if (_network.IsClient && !_initialized)
                {
                    _callback?.Invoke();
                }
            });

            Reset();
        }
示例#6
0
        public void init(InitCallback cb_)
        {
            if (_systemInited)
            {
                cb_(true);
                return;
            }

            _initCallback = cb_;
            if (_webThread == null)
            {
                _webThread = new Thread(new ThreadStart(getTokenThread));
                _webThread.Start();
            }
        }
示例#7
0
        public void initialize(String SYSTEM_KEY, String SYSTEM_SECRET, InitCallback initCallback)
        {
            if (user != null)
            {
                user = null;
            }

            if (SYSTEM_KEY == null)
            {
                throw new ArgumentNullException(" The System Key must be a non-empty String");
            }

            if (SYSTEM_SECRET == null)
            {
                throw new ArgumentNullException(" The System Secret must be a non-empty String");
            }

            Util.setSystemKey(SYSTEM_KEY);
            Util.setSystemSecret(SYSTEM_SECRET);
            masterSecret = null;
            uri          = "https://platform.clearblade.com";
            messageUrl   = "platform.clearblade.com";
            logging      = false;
            callTimeOut  = 30000;

            user = new User(null);
            bool   initResult = user.authWithAnonUser(uri, callTimeOut);
            string resultData = "";

            if (initResult)
            {
                resultData = "";
            }
            else
            {
                resultData = "Unable to Auth!";
            }
            initCallback(initResult, resultData);
        }
示例#8
0
        private static void validateInitOptions(Dictionary <String, Object> initOptions, InitCallback initcallback)
        {
            initError = false;

            string email          = (string)initOptions["email"];
            string password       = (string)initOptions["password"];
            bool   shouldRegister = (bool)initOptions["registerUser"];

            if (email == null && password != null)
            {
                initError = true;
                initcallback(!initError, "Must provide both an email and password to authenticate. You only provided a password");
            }
            else if (email != null && password == null)
            {
                initError = true;
                initcallback(!initError, "Must provide both an email and password to authenticate. You only provided an email");
            }
            else if (shouldRegister && email == null)
            {
                initError = true;
                initcallback(!initError, "Cannot register anonymous user");
            }
        }
示例#9
0
        public void initialize(String SYSTEM_KEY, String SYSTEM_SECRET, InitCallback initCallback, Dictionary <string, object> initOptions)
        {
            if (SYSTEM_KEY == null)
            {
                throw new ArgumentNullException(" The System Key must be a non-empty String");
            }

            if (SYSTEM_SECRET == null)
            {
                throw new ArgumentNullException(" The System Secret must be a non-empty String");
            }

            validateInitOptions(initOptions, initCallback);

            Util.setSystemKey(SYSTEM_KEY);
            Util.setSystemSecret(SYSTEM_SECRET);

            string platformURL = (string)initOptions["platfromURL"];
            string messageURL  = (string)initOptions["messageURL"];
            bool   log         = (bool)initOptions["logging"];

            setLogging(log);
            int timeout = (int)initOptions["callTimeout"];

            if (platformURL != null)
            {
                uri = platformURL;
            }
            else
            {
                uri = "https://staging.clearblade.com";
            }

            if (messageURL != null)
            {
                messageUrl = messageURL;
            }
            else
            {
                messageUrl = "staging.clearblade.com";
            }

            if (timeout > 0)
            {
                setCallTimeOut(timeout);
            }
            else
            {
                setCallTimeOut(30000);
            }

            if (log)
            {
                logging = log;
            }
            else
            {
                logging = false;
            }

            //init registerUser
            bool registerUser = (bool)initOptions["registerUser"];


            //init untrusted
            bool allowUntrusted = (bool)initOptions["allowUntrusted"];

            setAllowUntrusted(allowUntrusted);

            string email    = (string)initOptions["email"];
            string password = (string)initOptions["password"];

            user = new User(email);

            if (!initError && email != null && !registerUser)
            {
                //no init error, an email was given, and don't register user
                //just auth with given user info
                bool   initResult = user.authWithCurrentUser(password, uri);
                string resultData = "";
                if (initResult)
                {
                    resultData = "";
                }
                else
                {
                    resultData = "Unable to Auth!";
                }
                initCallback(initResult, resultData);
            }
            else if (!initError && registerUser)
            {
                //no errors, and register new user
                //user.registerUser(password, initCallback);
            }
            else if (!initError && email == null)
            {
                //email is null, so try to auth as anon user
                user.authWithAnonUser(uri, callTimeOut);
            }
        }