Exemplo n.º 1
0
        private static void ApplyRotationMetadata(GameObject ghostModel, RotationMetadata rotationMetadata)
        {
            BaseGhost component = ghostModel.GetComponent <BaseGhost>();

            if (component == null)
            {
                Log.Error("Was unable to apply rotation metadata - no BaseGhost found");
            }
            else if (component.GetType() != rotationMetadata.GhostType)
            {
                Log.Error("Was unable to apply rotation metadata - " + component.GetType() + " did not match " + rotationMetadata.GhostType);
            }
            else if (component is BaseAddCorridorGhost corridor)
            {
                Log.Info("Placing BaseAddCorridorGhost Rotation Metadata");

                CorridorRotationMetadata corridorRotationMetadata = (CorridorRotationMetadata)rotationMetadata;
                corridor.rotation = corridorRotationMetadata.Rotation;

                int corridorType = corridor.CalculateCorridorType();
                corridor.ghostBase.SetCorridor(Int3.zero, corridorType, corridor.isGlass);
                corridor.RebuildGhostGeometry();
            }
            else if (component is BaseAddMapRoomGhost mapRoom)
            {
                Log.Info("Placing MapRoomRotationMetadata Rotation Metadata");

                MapRoomRotationMetadata mapRoomRotationMetadata = (MapRoomRotationMetadata)rotationMetadata;
                mapRoom.cellType       = (Base.CellType)mapRoomRotationMetadata.CellType;
                mapRoom.connectionMask = mapRoomRotationMetadata.ConnectionMask;

                mapRoom.ghostBase.SetCell(Int3.zero, (Base.CellType)mapRoomRotationMetadata.CellType);
                mapRoom.RebuildGhostGeometry();
            }
            else if (component is BaseAddModuleGhost ghost)
            {
                BaseModuleRotationMetadata baseModuleRotationMetadata = (BaseModuleRotationMetadata)rotationMetadata;

                ghost.anchoredFace = new Base.Face(baseModuleRotationMetadata.Cell.ToUnity(), (Base.Direction)baseModuleRotationMetadata.Direction);
                ghost.RebuildGhostGeometry();
            }
            else if (component is BaseAddFaceGhost faceGhost)
            {
                AnchoredFaceRotationMetadata baseModuleRotationMetadata = (AnchoredFaceRotationMetadata)rotationMetadata;
                Log.Info("Applying BaseAddFaceGhost " + baseModuleRotationMetadata);

                Base.Face face = new(baseModuleRotationMetadata.Cell.ToUnity(), (Base.Direction)baseModuleRotationMetadata.Direction);
                faceGhost.anchoredFace = face;

                Base.FaceType faceType = (Base.FaceType)baseModuleRotationMetadata.FaceType;
                faceGhost.ghostBase.SetFace(face, faceType);

                faceGhost.RebuildGhostGeometry();
            }
        }
Exemplo n.º 2
0
        private static void ApplyRotationMetadata(GameObject ghostModel, RotationMetadata rotationMetadata)
        {
            BaseGhost component = ghostModel.GetComponent <BaseGhost>();

            if (component == null)
            {
                Log.Error("Was unable to apply rotation metadata - no BaseGhost found");
            }
            else if (component.GetType() != rotationMetadata.GhostType)
            {
                Log.Error("Was unable to apply rotation metadata - " + component.GetType() + " did not match " + rotationMetadata.GhostType);
            }
            else if (component is BaseAddCorridorGhost)
            {
                Log.Info("Placing BaseAddCorridorGhost Rotation Metadata");

                CorridorRotationMetadata corridorRotationMetadata = (rotationMetadata as CorridorRotationMetadata);
                BaseAddCorridorGhost     corridor = (component as BaseAddCorridorGhost);
                corridor.ReflectionSet("rotation", corridorRotationMetadata.Rotation);

                int  corridorType = (int)corridor.ReflectionCall("CalculateCorridorType");
                Base ghostBase    = (Base)corridor.ReflectionGet("ghostBase");
                ghostBase.SetCorridor(Int3.zero, corridorType, corridor.isGlass);
                corridor.ReflectionCall("RebuildGhostGeometry");
            }
            else if (component is BaseAddMapRoomGhost)
            {
                Log.Info("Placing MapRoomRotationMetadata Rotation Metadata");

                MapRoomRotationMetadata mapRoomRotationMetadata = (rotationMetadata as MapRoomRotationMetadata);
                BaseAddMapRoomGhost     mapRoom = (component as BaseAddMapRoomGhost);
                mapRoom.ReflectionSet("cellType", mapRoomRotationMetadata.CellType);
                mapRoom.ReflectionSet("connectionMask", mapRoomRotationMetadata.ConnectionMask);

                Base ghostBase = (Base)mapRoom.ReflectionGet("ghostBase");

                ghostBase.SetCell(Int3.zero, (Base.CellType)mapRoomRotationMetadata.CellType);
                mapRoom.ReflectionCall("RebuildGhostGeometry");
            }
            else if (component is BaseAddModuleGhost)
            {
                BaseModuleRotationMetadata baseModuleRotationMetadata = (rotationMetadata as BaseModuleRotationMetadata);
                BaseAddModuleGhost         module = (component as BaseAddModuleGhost);

                module.anchoredFace = new Base.Face(baseModuleRotationMetadata.Cell.Global(), (Base.Direction)baseModuleRotationMetadata.Direction);
                module.ReflectionCall("RebuildGhostGeometry");
            }
        }