Exemplo n.º 1
0
        private void Initialize()
        {
            _editableImageConstraint = new TycoonTileConstraint2i();
            _sampler = new DualImageSampler2i();

            _terrainGenerator = new TerrainGenerator2i <TerrainMesher2i>();
            _meshUpdater      = new TerrainMeshUpdater();
            _groupsSelector   = new GroupsByCameraVisibilitySelector();
            _imageProvider    = new EditableMatrixImage2i(InitialTexture, InitialTextureScale, _sampler, _editableImageConstraint);
        }
Exemplo n.º 2
0
        public SceneContext(
            IGroupSelector groupSelector,
            ITerrainGenerator2i terrainGenerator,
            IMeshUpdater meshUpdater,
            Vector3 cameraPosition,
            IReadOnlyList <Plane> cameraPlanes,
            IReadOnlyPooledList <Vector3> cameraFrustumCorners,
            Matrix4x4 cameraLocalToWorldMatrix,
            Matrix4x4 parentContainerWorldToLocalMatrix,
            IReadOnlySet <Vector2i> existingGroups,
            Vector2i cellInGroupCount,
            IImage2i image,
            Rect2i invalidatedArea_imageSpace,
            IImageSampler2i imageSampler,
            Func <GameObject> gameObjectFactory,
            ProfilerFactoryDelegate profilerFactory,
            LoggerFactoryDelegate loggerFactory)
        {
            GroupSelector                     = groupSelector;
            TerrainGenerator                  = terrainGenerator;
            MeshUpdater                       = meshUpdater;
            CameraPosition                    = cameraPosition;
            CameraPlanes                      = cameraPlanes;
            CameraFrustumCorners              = cameraFrustumCorners;
            CameraLocalToWorldMatrix          = cameraLocalToWorldMatrix;
            ParentContainerWorldToLocalMatrix = parentContainerWorldToLocalMatrix;
            ExistingGroups                    = existingGroups;
            CellInGroupCount                  = cellInGroupCount;
            Image             = image;
            ImageSampler      = imageSampler;
            GameObjectFactory = gameObjectFactory;
            ProfilerFactory   = profilerFactory;
            LoggerFactory     = loggerFactory;

            RangeZ      = image.RangeZ;
            GroupBounds = new Bounds(new Vector3(CellInGroupCount.x / 2.0f, CellInGroupCount.y / 2.0f, RangeZ.Center), new Vector3(CellInGroupCount.x, CellInGroupCount.y, RangeZ.Size));
            InvalidatedArea_worldSpace = ImageSampler
                                         .ImageToWorld(invalidatedArea_imageSpace)
                                         .RoundToContain();

            (Image as IInitializableImage)?.StartUsing();
        }
Exemplo n.º 3
0
        private void DisposeService()
        {
            (_imageProvider as IDisposable)?.Dispose();
            _imageProvider = null;

            (_editableImageConstraint as IDisposable)?.Dispose();
            _editableImageConstraint = null;

            (_sampler as IDisposable)?.Dispose();
            _sampler = null;

            (_terrainGenerator as IDisposable)?.Dispose();
            _terrainGenerator = null;

            (_meshUpdater as IDisposable)?.Dispose();
            _meshUpdater = null;

            (_groupsSelector as IDisposable)?.Dispose();
            _groupsSelector = null;
        }
Exemplo n.º 4
0
 void EnqueueUpdater(IMeshUpdater updater)
 {
     lock (mesh_builders_ready)
         mesh_builders_ready.Enqueue(updater);
     mesh_builders_ready_flag = true;
 }