Example #1
0
        public void CellUnloaded(Int3 batchId, Int3 cellId, int level)
        {
            AbsoluteEntityCell cell = new AbsoluteEntityCell(batchId.ToDto(), cellId.ToDto(), level);

            if (visibleCells.Contains(cell))
            {
                visibleCells.Remove(cell);
                removed.Add(cell);
                MarkCellsReadyForSync(0);
            }
        }
Example #2
0
        private IEnumerator WaitAndAddCell(Int3 batchId, Int3 cellId, int level)
        {
            yield return(new WaitForSeconds(0.5f));

            AbsoluteEntityCell cell = new AbsoluteEntityCell(batchId.ToDto(), cellId.ToDto(), level);

            if (!visibleCells.Contains(cell))
            {
                visibleCells.Add(cell);
                added.Add(cell);
            }
        }
Example #3
0
        public Optional <BuilderMetadata> From(object baseGhost)
        {
            BuilderMetadata builderMetadata = null;

            switch (baseGhost)
            {
            case BaseAddCorridorGhost corridorGhost:
            {
                int     rotation      = corridorGhost.rotation;
                Vector3 position      = corridorGhost.GetComponentInParent <ConstructableBase>().transform.position;
                bool    hasTargetBase = corridorGhost.targetBase != null;
                Int3    targetCell    = hasTargetBase ? corridorGhost.targetBase.WorldToGrid(position): default;
                builderMetadata = new CorridorBuilderMetadata(position.ToDto(), rotation, hasTargetBase, targetCell.ToDto());
                break;
            }

            case BaseAddMapRoomGhost mapRoomGhost:
            {
                Base.CellType cellType       = mapRoomGhost.cellType;
                int           connectionMask = mapRoomGhost.connectionMask;
                builderMetadata = new MapRoomBuilderMetadata((byte)cellType, connectionMask);
                break;
            }

            case BaseAddModuleGhost module:
            {
                Int3 cell      = module.anchoredFace !.Value.cell;
                int  direction = (int)module.anchoredFace.Value.direction;

                builderMetadata = new BaseModuleBuilderMetadata(cell.ToDto(), direction);
                break;
            }

            case BaseAddFaceGhost faceGhost:
            {
                Base.Face anchoredFace = faceGhost.anchoredFace !.Value;
                builderMetadata = new AnchoredFaceBuilderMetadata(anchoredFace.cell.ToDto(), (int)anchoredFace.direction, (int)faceGhost.faceType);
                break;
            }
            }

            return(Optional.OfNullable(builderMetadata));
        }
        public Optional <RotationMetadata> From(object baseGhost)
        {
            RotationMetadata rotationMetadata = null;

            if (baseGhost is BaseAddCorridorGhost)
            {
                BaseAddCorridorGhost corridorGhost = baseGhost as BaseAddCorridorGhost;
                int rotation = (int)corridorGhost.ReflectionGet("rotation");
                rotationMetadata = new CorridorRotationMetadata(rotation);
            }
            else if (baseGhost is BaseAddMapRoomGhost)
            {
                BaseAddMapRoomGhost mapRoomGhost = baseGhost as BaseAddMapRoomGhost;
                Base.CellType       cellType     = (Base.CellType)mapRoomGhost.ReflectionGet("cellType");
                int connectionMask = (int)mapRoomGhost.ReflectionGet("connectionMask");
                rotationMetadata = new MapRoomRotationMetadata((byte)cellType, connectionMask);
            }
            else if (baseGhost is BaseAddModuleGhost)
            {
                BaseAddModuleGhost module = baseGhost as BaseAddModuleGhost;

                Int3 cell      = module.anchoredFace.Value.cell;
                int  direction = (int)module.anchoredFace.Value.direction;

                rotationMetadata = new BaseModuleRotationMetadata(cell.ToDto(), direction);
            }
            else if (baseGhost is BaseAddFaceGhost)
            {
                BaseAddFaceGhost faceGhost = baseGhost as BaseAddFaceGhost;

                if (faceGhost.anchoredFace.HasValue)
                {
                    Base.Face anchoredFace = faceGhost.anchoredFace.Value;

                    rotationMetadata = new AnchoredFaceRotationMetadata(anchoredFace.cell.ToDto(), (int)anchoredFace.direction, (int)faceGhost.faceType);
                }
            }

            return(Optional.OfNullable(rotationMetadata));
        }
Example #5
0
 public AnchoredFaceRotationMetadata(Int3 cell, int facedirection, int facetype) : base(typeof(BaseAddFaceGhost))
 {
     Cell      = cell.ToDto();
     Direction = facedirection;
     FaceType  = facetype;
 }
 public BaseModuleRotationMetadata(Int3 cell, int direction) : base(typeof(BaseAddModuleGhost))
 {
     Cell      = cell.ToDto();
     Direction = direction;
 }