Exemple #1
0
 public void CreateContextObserver(IContext Context)
 {
     if (UnityEngine.Application.isPlaying)
     {
         var Observer = new Entitas.VisualDebugging.Unity.ContextObserver(Context);
         DontDestroyOnLoad(Observer.gameObject);
     }
 }
 static void createContextObserver(Entitas.IContext context)
 {
     if (UnityEngine.Application.isPlaying)
     {
         var observer = new Entitas.VisualDebugging.Unity.ContextObserver(context);
         UnityEngine.Object.DontDestroyOnLoad(observer.gameObject);
     }
 }
        public static void Observe(IContext c)
        {
            if (!Application.isPlaying || !Application.isEditor)
            {
                return;
            }

            var observer = new ContextObserver(c);

            Object.DontDestroyOnLoad(observer.gameObject);
        }
        public static void SetupVisualDebugging(IContext context)
        {
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
            if (!UnityEngine.Application.isPlaying)
            {
                return;
            }

            var observer = new Entitas.VisualDebugging.Unity.ContextObserver(context);
            UnityEngine.Object.DontDestroyOnLoad(observer.gameObject);
            var behavior = observer.gameObject.GetComponent <ContextObserverBehaviour>();
#endif
        }
    public void StartClient()
    {
        if (Mode != Mode.Inactive)
        {
            throw new ApplicationException("Can't start client if already active.");
        }

        _backGameContext = new GameContext();
        _backGameContext.AddEntityIndex(new Entitas.PrimaryEntityIndex <GameEntity, ushort>(
                                            "Id",
                                            _backGameContext.GetGroup(GameMatcher.Id),
                                            (e, c) => ((IdComponent)c).Value));

        if (Application.isPlaying)
        {
            var observer = new Entitas.VisualDebugging.Unity.ContextObserver(_backGameContext);
            observer.gameObject.name = "backGame";
            DontDestroyOnLoad(observer.gameObject);
        }

        _client = new ClientNetworkSystem(_contexts.game, _backGameContext)
        {
            TickRate           = (ushort)TargetTickPerSecond,
            PanicStateCount    = PanicStateCount,
            PanicCleanupTarget = PanicCleanupTarget
        };


        var services = new Services
        {
            ClientSystem = _client,
            BackContext  = _backGameContext
        };

        _clientFeature     = new ClientFeature(_contexts, services);
        _clientViewFeature = new ClientViewFeature(_contexts, services);
        Mode = Mode.Client;
    }
 public void Init(ContextObserver contextObserver)
 {
     _contextObserver = contextObserver;
     Update();
 }