public void OnEnable() { if (_profile == null) { Debug.LogError("Please drag a CubizerProfile into Inspector."); } _context = new CubizerContext(); _context.profile = _profile; _context.behaviour = this; _context.materialFactory = _materialFactory; _lives = AddComponent(new LiveManagerComponent()); _chunkManager = AddComponent(new ChunkManagerComponent()); _biomeManager = AddComponent(new BiomeManagerComponent()); _playerComponent = AddComponent(new PlayerComponent()); _timeComponent = AddComponent(new TimeComponent()); _dbComponent = AddComponent(new DbComponent()); _serverComponent = AddComponent(new ServerComponent()); _clientComponent = AddComponent(new ClientComponent()); _lives.Init(_context, _profile.lives); _chunkManager.Init(_context, _profile.chunk); _chunkManager.callbacks.OnLoadChunkBefore += this.OnLoadChunkDataBefore; _chunkManager.callbacks.OnLoadChunkAfter += this.OnLoadChunkDataAfter; _chunkManager.callbacks.OnDestroyChunk += this.OnDestroyChunkData; _chunkManager.callbacks.OnAddBlockBefore += this.OnAddBlockBefore; _chunkManager.callbacks.OnAddBlockAfter += this.OnAddBlockAfter; _chunkManager.callbacks.OnRemoveBlockBefore += this.OnRemoveBlockBefore; _chunkManager.callbacks.OnRemoveBlockAfter += this.OnRemoveBlockAfter; _biomeManager.Init(_context, _profile.biome); _playerComponent.Init(_context, _profile.players); _timeComponent.Init(_context, _profile.time); _dbComponent.Init(_context, _profile.database); _serverComponent.Init(_context, _profile.network); _clientComponent.Init(_context, _profile.network); this.EnableComponents(); StartCoroutine("UpdateComponentsWithCoroutine"); }
public virtual void Init(CubizerContext _context, T _model) { model = _model; context = _context; }