public BasicRoadsPathEditor(IUserInterfaceManager uiManager) : base(uiManager)
        {
            // Register console commands
            try
            {
                RoadPathEditorCommands.RegisterCommands();
            }
            catch (Exception ex)
            {
                Debug.LogError(string.Format("Error Registering Travelmap Console commands: {0}", ex.Message));
            }

            roadsTexturing = (BasicRoadsTexturing)DaggerfallUnity.Instance.TerrainTexturing;
            pathsData[BasicRoadsTexturing.roads]  = roadsTexturing.GetPathData(BasicRoadsTexturing.roads);
            pathsData[BasicRoadsTexturing.tracks] = roadsTexturing.GetPathData(BasicRoadsTexturing.tracks);

            if (waterEditing)
            {
                showPaths[BasicRoadsTexturing.rivers]  = true;
                showPaths[BasicRoadsTexturing.streams] = true;
                pathsData[BasicRoadsTexturing.rivers]  = roadsTexturing.GetPathData(BasicRoadsTexturing.rivers);
                pathsData[BasicRoadsTexturing.streams] = roadsTexturing.GetPathData(BasicRoadsTexturing.streams);
                ReadEditedPathData(BasicRoadsTexturing.rivers, RiverDataFilename);
                ReadEditedPathData(BasicRoadsTexturing.streams, StreamDataFilename);
            }
            else
            {
                ReadEditedPathData(BasicRoadsTexturing.roads, RoadDataFilename);
                ReadEditedPathData(BasicRoadsTexturing.tracks, TrackDataFilename);
            }
        }
Example #2
0
        private void MessageReceiver(string message, object data, DFModMessageCallback callBack)
        {
            try {
                Vector2Int mpCoords;
                byte       point;
                switch (message)
                {
                case GET_PATH_DATA:
                    callBack?.Invoke(GET_PATH_DATA, roadTexturing.GetPathData((int)data));
                    break;

                case GET_ROAD_POINT:
                    mpCoords = (Vector2Int)data;
                    point    = roadTexturing.GetPathDataPoint(BasicRoadsTexturing.roads, mpCoords.x, mpCoords.y);
                    callBack?.Invoke(GET_ROAD_POINT, point);
                    break;

                case GET_TRACK_POINT:
                    mpCoords = (Vector2Int)data;
                    point    = roadTexturing.GetPathDataPoint(BasicRoadsTexturing.tracks, mpCoords.x, mpCoords.y);
                    callBack?.Invoke(GET_TRACK_POINT, point);
                    break;

                case GET_PATHS_POINT:
                    mpCoords = (Vector2Int)data;
                    byte roadPt  = roadTexturing.GetPathDataPoint(BasicRoadsTexturing.roads, mpCoords.x, mpCoords.y);
                    byte trackPt = roadTexturing.GetPathDataPoint(BasicRoadsTexturing.tracks, mpCoords.x, mpCoords.y);
                    point = (byte)(roadPt | trackPt);
                    callBack?.Invoke(GET_PATHS_POINT, point);
                    break;

                case SCHEDULE_ROADS_JOB:
                    // Get the parameters
                    object[]           paramArray   = (object[])data;
                    MapPixelData       mapData      = (MapPixelData)paramArray[0];
                    NativeArray <byte> tileData     = (NativeArray <byte>)paramArray[1];
                    JobHandle          dependencies = (JobHandle)paramArray[2];

                    // Instantiate PaintRoadsJob, schedule, then return job handle
                    JobHandle paintRoadsHandle = roadTexturing.SchedulePaintRoadsJob(ref mapData, ref tileData, dependencies);
                    callBack?.Invoke(SCHEDULE_ROADS_JOB, paintRoadsHandle);
                    break;

                default:
                    Debug.LogErrorFormat("{0}: unknown message received ({1}).", this, message);
                    break;
                }
            }
            catch
            {
                Debug.LogErrorFormat("{0}: error handling message ({1}).", this, message);
                callBack?.Invoke("error", "Data passed is invalid for " + message);
            }
        }
Example #3
0
        private void MessageReceiver(string message, object data, DFModMessageCallback callBack)
        {
            switch (message)
            {
            case GET_PATH_DATA:
                callBack?.Invoke(GET_PATH_DATA, roadTexturing.GetPathData((int)data));
                break;

            default:
                Debug.LogErrorFormat("{0}: unknown message received ({1}).", this, message);
                break;
            }
        }