public EntityPathFinder(PathFinderDEP parent)
 {
     ChunkPathVals = new Dictionary <Vec2i, float[, ]>();
     Parent        = parent;
     if (parent == null)
     {
         Debug.Log("Parent is null??");
     }
 }
Example #2
0
    /// <summary>
    /// Starts the main part of the game.
    /// Checks if a game exists to load, and if so loads it.
    /// If not, we generate a game <see cref="GameManager.GenerateGame(int)"/>
    /// If we generate a game, at current we set the players location
    /// </summary>
    void Start()
    {
        Debug.BeginDeepProfile("game_start");
        if (GameToLoad == null || GameToLoad == "none")
        {
            Stopwatch s = new Stopwatch();
            s.Start();
            //UnityEngine.Profiling.CustomSampler gen = UnityEngine.Profiling.CustomSampler.Create("GenSampler");
            int seed = 0;
            Debug.Log("No game to load, generating with seed " + seed);
            GenerateGame(seed);
            PathFinder = new PathFinderDEP(WorldManager.World);
            PathFinder.SetPlayerPosition(PlayerManager.Player.TilePos);

            System.GC.Collect();
            s.Stop();
            Debug.Log("Generation took total time: " + s.ElapsedMilliseconds / 1000f);
            DebugGUI.SetData("genTime", s.ElapsedMilliseconds / 1000f);
        }
        else
        {
            UnityEngine.Profiling.CustomSampler load = UnityEngine.Profiling.CustomSampler.Create("LoadSampler");
            load.Begin();
            GameLoadSave gls   = LoadSave.Load();
            World        world = new World();
            world.LoadWorld(gls);
            EntityManager.Load(gls);
            WorldManager.SetWorld(world);
            Player player = new Player();
            TestSettle = WorldManager.World.GetSettlement(0);
            Vec2i set = TestSettle.Centre;
            //player.SetPosition(new Vector3(set.x * World.ChunkSize, 0, set.z * World.ChunkSize));
            player.MoveEntity(new Vector3(World.WorldSize / 2 * World.ChunkSize, 0, World.WorldSize / 2 * World.ChunkSize));
            PlayerManager.SetPlayer(player);

            load.End();
        }
        Debug.EndDeepProfile("game_start");



        RNG = new GenerationRandom(System.DateTime.Now.Millisecond);
    }