コード例 #1
0
    public static bool DoSanityCheck(bool ignoreGraphCacheWarning)
    {
        Debug.Log("Running map sanity check");

        ClearLog();

        SpawnPoint[] spawnPoints            = GameObject.FindObjectsOfType <SpawnPoint>();
        SpawnPointNeighborManager neighbors = GameObject.FindObjectOfType <SpawnPointNeighborManager>();

        Camera[]         cameras          = GameObject.FindObjectsOfType <Camera>();
        PathfindingBox[] pathfindingBoxes = GameObject.FindObjectsOfType <PathfindingBox>();

        bool ok = true;

        for (int i = 0; i < requiredTypes.Length; i++)
        {
            if (GameObject.FindObjectOfType(requiredTypes[i]) == null)
            {
                Log("No " + requiredTypes[i] + " found in scene, you should place a " + prefabs[i] + " from the \"Prefabs/Map Elements/Must Haves\" folder!");
                ok = false;
            }
        }

        bool blueTeamSpawn = false;
        bool redTeamSpawn  = false;

        foreach (SpawnPoint spawnPoint in spawnPoints)
        {
            if (spawnPoint.defaultOwner == SpawnPoint.Team.Blue)
            {
                blueTeamSpawn = true;
            }
            else if (spawnPoint.defaultOwner == SpawnPoint.Team.Red)
            {
                redTeamSpawn = true;
            }
        }

        if (!blueTeamSpawn || !redTeamSpawn)
        {
            Log("Not all teams have spawn points. Make sure both teams is the default owner of at least one spawn point!");
            ok = false;
        }

        if (neighbors != null && neighbors.neighbors.Length == 0)
        {
            Log("There are no neighbors set up in the Neighbor Manager.");
            ok = false;
        }

        if (!ok)
        {
            Log("All these issues must be fixed before the map can be exported.");
            DisplayFatalLog();
            return(false);
        }



        // WARNINGS

        foreach (Camera camera in cameras)
        {
            if (camera.enabled && !CameraHasSupportedScript(camera))
            {
                Log("The camera " + camera.gameObject.name + " doesn't have a game script on it, and is likely unintetionally placed. Consider deleting it!");
            }
        }

        foreach (PathfindingBox box in pathfindingBoxes)
        {
            /*int cellNumber = Mathf.RoundToInt((box.transform.localScale.x/box.cellSize)*(box.transform.localScale.z/box.cellSize));
             * if(cellNumber > PathfindingBox.RECOMMENDED_MAX_CELLS) {
             *
             * }*/

            if (box.characterRadius < box.cellSize * 2)
            {
                Log("Character radius of PathfindingBox " + box.gameObject.name + " is less than double the cell size. You should increase the character radius to something larger than " + box.cellSize * 2 + "!");
            }
        }

        Camera minimapCamera = GameObject.FindObjectOfType <MinimapCamera>().GetComponent <Camera>();

        foreach (SpawnPoint spawn in spawnPoints)
        {
            Vector3 viewportPoint = minimapCamera.WorldToViewportPoint(spawn.transform.position);
            if (viewportPoint.x < 0 || viewportPoint.x > 11f || viewportPoint.y < 0 || viewportPoint.y > 1f)
            {
                Log("Spawnpoint " + spawn.gameObject.name + " is outside of the minimap camera, move the minimap or increase the minimap camera's field of view to solve this.");
            }
        }


        if (EditorSceneManager.GetSceneAt(0).name == "ExampleScene")
        {
            Log("You are working in the ExampleScene, you should save it as your own scene so it doesn't get accidentally overwritten if you update the Ravenfield Tools.");
        }

        if (RenderSettings.ambientMode != UnityEngine.Rendering.AmbientMode.Trilight)
        {
            Log("Environment Lighting Source is not set to Gradient, consider changing this (in Window -> Lighting -> Settings)!");
        }

        if (neighbors.neighbors.Length > spawnPoints.Length * RECOMMENDED_MAX_NEIGHBORS_PER_FLAG)
        {
            Log("You have a very large number of neighbor elements, consider simplifying the neighbor connections!");
        }

        if (UnityEditor.Lightmapping.bakedGI)
        {
            Log("Your scene is set up to use Baked Global Illumination. This is not required for Ravenfield, consider disabling it (in Window -> Lighting -> Settings)!");
        }
        if (UnityEditor.Lightmapping.realtimeGI)
        {
            Log("Your scene is set up to use Realtime Global Illumination. This is not required for Ravenfield, consider disabling it (in Window -> Lighting -> Settings)!");
        }

        if (!ignoreGraphCacheWarning && !CacheGenerator.GraphCacheSceneObjectExists() && (CacheGenerator.GetGraphCacheFile() == null || CacheGenerator.GetGraphCacheCoverPointFile() == null))
        {
            Log("You haven't generated a navmesh graph cache for your scene. You can generate one by running Ravenfield Tools -> Scan Pathfinding. This will significantly speed up load times!");
        }

        if (!string.IsNullOrEmpty(log))
        {
            DisplayWarningLog();
        }

        return(ok);
    }
コード例 #2
0
 void OnEnable()
 {
     this.neighborManager = (SpawnPointNeighborManager)this.target;
 }