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, direction);
            }

            return(Optional.OfNullable(rotationMetadata));
        }
Example #2
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));
        }
Example #3
0
        public static Optional <RotationMetadata> From(BaseGhost 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(cellType, connectionMask);
            }

            return(Optional <RotationMetadata> .OfNullable(rotationMetadata));
        }
Example #4
0
        public Optional <RotationMetadata> From(object baseGhost)
        {
            RotationMetadata rotationMetadata = null;

            if (baseGhost is BaseAddCorridorGhost)
            {
                BaseAddCorridorGhost corridorGhost = baseGhost as BaseAddCorridorGhost;
                int rotation = (int)corridorGhost.rotation;
                rotationMetadata = new CorridorRotationMetadata(rotation);
            }
            else if (baseGhost is BaseAddMapRoomGhost)
            {
                BaseAddMapRoomGhost mapRoomGhost = baseGhost as BaseAddMapRoomGhost;
                Base.CellType       cellType     = mapRoomGhost.cellType;
                int connectionMask = mapRoomGhost.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 MapRoomRotationMetadata(Base.CellType cellType, int connectionMask) : base(typeof(BaseAddMapRoomGhost))
 {
     CellType       = cellType;
     ConnectionMask = connectionMask;
 }