コード例 #1
0
ファイル: Mapgen.cs プロジェクト: littlebeast/Outpost
 public patternOrChunk(OutpostLibrary.Structure pat)
 {
     pattern = pat;
     chunk = null;
 }
コード例 #2
0
ファイル: LuaBridge.cs プロジェクト: littlebeast/Outpost
        public void buildChunk(OutpostLibrary.IntVector3 location, Chunk chunk)
        {
            Func<Chunk, OutpostLibrary.IntVector3, LuaResult> doBuild = game["buildChunk"] as Func<Chunk, OutpostLibrary.IntVector3, LuaResult>;

            try
            {
                doBuild(chunk, location);
            }
            catch (LuaRuntimeException e)
            {
                Logger.Log(e.ToString());
                LuaExceptionData d = LuaExceptionData.GetData(e);
                Logger.Log(d.GetStackTrace(0, false));

            }
        }
コード例 #3
0
ファイル: Mapgen.cs プロジェクト: littlebeast/Outpost
 public patternOrChunk(Chunk oct)
 {
     chunk = oct;
     pattern = OutpostLibrary.Structure.field;
 }
コード例 #4
0
ファイル: MainGame.cs プロジェクト: littlebeast/Outpost
        /// <summary>
        /// Loads a chunk specified by filename.
        /// Assumes that the file exists and the chunk is generated.
        /// If there is ANY doubt about this (i.e. if the chunk is part of the main map), use loadChunk(IntVector) instead.
        /// </summary>
        /// <param name="filename">The file that the chunk is described in.</param>
        /// <returns>An Octree representation of the chunk.</returns>
        Chunk loadChunk(string filename)
        {
            mapV1 mapmaker = content.Load<mapV1>(filename);
            Chunk building = new Chunk(4, filename, graphics);

            //Actual chunk loading code goes here.

            building.endFill();
            return building;
        }
コード例 #5
0
ファイル: MainGame.cs プロジェクト: littlebeast/Outpost
        /// <summary>
        /// NOT FULLY IMPLEMENTED
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        public patternOrChunk getPatternOrChunk(IntVector3 position)
        {
            patternOrChunk toMake;


            //map first
            if ((position >= mapOffset) && position < mapOffset + new IntVector3(mapSize))
            {
                Chunk possible = map.get(position - mapOffset);
                if (possible != null)
                {
                    toMake = new patternOrChunk(possible);
                    if (mapGenHelper != null)
                    {
                        mapGenHelper[position] = toMake;
                    }
                    return toMake;
                }
            }

            //then helper
            //because if you do helper first, then ones generated during a run don't get acknowledged
            if (mapGenHelper != null)
            {
                if (mapGenHelper.ContainsKey(position))
                {
                    return mapGenHelper[position];
                }
            }

            //then, check for a file
            String filename = position.ToString();
            mapV1 mapmaker;
            try
            {
                //for some reason this is slow as f**k
                //probably because hard drives are slow
                //so it's commented for now
                //I wonder if it would be better if it was actually loading things?
                //mapmaker = content.Load<mapV1>(filename);
            }
            catch (ContentLoadException)
            {
                //if no file, then generate the pattern
                //mapmaker = Mapgen.generatePatterns(this, position);
            }
            //beyond here lies TEMP SHIT CODE

            //if (mapmaker.layers[0] == "ungenerated")
            {
                toMake = new patternOrChunk(OutpostLibrary.Structure.field);
                if (mapGenHelper != null)
                {
                    mapGenHelper[position] = toMake;
                }
                return toMake;
            }
            Chunk building = new Chunk(position, graphics);

            //chunk loading from file goes here

            building.endFill();
            toMake = new patternOrChunk(building);
            if (mapGenHelper != null)
            {
                mapGenHelper[position] = toMake;
            }
            return toMake;
        }
コード例 #6
0
ファイル: MainGame.cs プロジェクト: littlebeast/Outpost
        /// <summary>
        /// NOT FULLY IMPLEMENTED
        /// Loads a chunk specified by position in the world map.
        /// Will generate the chunk if it does not already exist.
        /// </summary>
        /// <param name="position">The position to load from.</param>
        /// <returns>An Octree representation of the chunk.</returns>
        Chunk loadChunk(IntVector3 position)
        {
            LoadingScreen.ChangeMessage("Loading chunk " + position.ToString());
            String filename = position.ToString();
            mapV1 mapmaker;
            try
            {
                //mapmaker = content.Load<mapV1>(filename);
            }
            catch (ContentLoadException)
            {
                //mapmaker = Mapgen.generatePatterns(this, position);
            }
            Chunk building = new Chunk(position, graphics);
            //if (mapmaker.layers[0] == "ungenerated")
            {

                lua.buildChunk(position, building);
            }
            //else
            {
                //Chunk loading from file code goes here.
            }
            return building;
        }
コード例 #7
0
ファイル: MainGame.cs プロジェクト: littlebeast/Outpost
 void recenterMap()
 {
     IntVector3 prevCenter = mapOffset + new IntVector3(mapCenter);
     IntVector3 difference = prevCenter - player.chunk;
     Chunk[, ,] newMap = new Chunk[mapSize, mapSize, mapSize];
     for (int x = 0; x < mapSize; x++)
     {
         for (int y = 0; y < mapSize; y++)
         {
             for (int z = 0; z < mapSize; z++)
             {
                 IntVector3 oldCoordinates = new IntVector3(x, y, z);
                 IntVector3 newCoordinates = oldCoordinates + difference;
                 if (newCoordinates >= new IntVector3(0) && newCoordinates < new IntVector3(mapSize))
                 {
                     newMap.set(newCoordinates, map.get(oldCoordinates));
                 }
                 else
                 {
                     Chunk unload = map.get(oldCoordinates);
                     if (unload != null)
                     {
                         unload.Dispose();
                     }
                 }
             }
         }
     }
     mapOffset -= difference;
     map = newMap;
     fillMapThreaded();
 }