mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Read saved environment metadata from maps in singleplayer mode.
This commit is contained in:
parent
81906c75ed
commit
d95272f4a7
@ -39,6 +39,31 @@ namespace ClassicalSharp {
|
||||
string group = ReadString( reader );
|
||||
string key = ReadString( reader );
|
||||
string value = ReadString( reader );
|
||||
if( group == "CS_Client" ) {
|
||||
int valueInt = Int32.Parse( value );
|
||||
switch( key ) {
|
||||
case "SkyCol":
|
||||
game.Map.SetSkyColour( new FastColour( valueInt ) ); break;
|
||||
case "CloudsCol":
|
||||
game.Map.SetCloudsColour( new FastColour( valueInt ) ); break;
|
||||
case "FogCol":
|
||||
game.Map.SetFogColour( new FastColour( valueInt ) ); break;
|
||||
|
||||
case "ClickDist":
|
||||
game.LocalPlayer.ReachDistance = valueInt / 32f; break;
|
||||
case "SunLight":
|
||||
game.Map.SetSunlight( new FastColour( valueInt ) ); break;
|
||||
case "ShadowLight":
|
||||
game.Map.SetShadowlight( new FastColour( valueInt ) ); break;
|
||||
|
||||
case "Weather":
|
||||
game.Map.SetWeather( (Weather)valueInt ); break;
|
||||
case "SidesBlock":
|
||||
game.Map.SetSidesBlock( (Block)valueInt ); break;
|
||||
case "EdgeBlock":
|
||||
game.Map.SetEdgeBlock( (Block)valueInt ); break;
|
||||
}
|
||||
}
|
||||
Console.WriteLine( group + "," + key + "," + value );
|
||||
}
|
||||
byte[] blocks = new byte[width * height * length];
|
||||
@ -98,10 +123,10 @@ namespace ClassicalSharp {
|
||||
static void WriteMetadata( Stream stream, Game game ) {
|
||||
BinaryWriter writer = new BinaryWriter( stream );
|
||||
LocalPlayer p = game.LocalPlayer;
|
||||
Map map = game.Map;
|
||||
Map map = game.Map;
|
||||
|
||||
WriteMetadataEntry( writer, "SkyCol", map.SkyCol.ToArgb() );
|
||||
WriteMetadataEntry( writer, "CloudsCol", map.CloudsCol.ToArgb() );
|
||||
WriteMetadataEntry( writer, "CloudsCol", map.CloudsCol.ToArgb() );
|
||||
WriteMetadataEntry( writer, "FogCol", map.FogCol.ToArgb() );
|
||||
|
||||
WriteMetadataEntry( writer, "ClickDist", (int)( p.ReachDistance * 32 ) );
|
||||
|
@ -81,9 +81,8 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
static FastColour ParseWomColour( string value, FastColour defaultCol ) {
|
||||
int col;
|
||||
return Int32.TryParse( value, out col ) ?
|
||||
new FastColour( ( col & 0xFF0000 ) >> 16, ( col & 0xFF00 ) >> 8, col & 0xFF ) : defaultCol;
|
||||
int argb;
|
||||
return Int32.TryParse( value, out argb ) ? new FastColour( argb ) : defaultCol;
|
||||
}
|
||||
}
|
||||
}
|
@ -235,7 +235,6 @@ namespace ClassicalSharp {
|
||||
int adjViewDistSqr = ( game.ViewDistance + 14 ) * ( game.ViewDistance + 14 );
|
||||
chunksTarget += deltaTime < 0.034 ? 1 : -1; // build more chunks if 30 FPS or over, otherwise slowdown.
|
||||
Utils.Clamp( ref chunksTarget, 4, 12 );
|
||||
Console.WriteLine( (deltaTime * 1000) + ":" + chunksTarget );
|
||||
|
||||
for( int i = 0; i < chunks.Length; i++ ) {
|
||||
ChunkInfo info = chunks[i];
|
||||
|
@ -36,6 +36,13 @@ namespace ClassicalSharp {
|
||||
G = (byte)g;
|
||||
B = (byte)b;
|
||||
}
|
||||
|
||||
public FastColour( int argb ) {
|
||||
A = (byte)( argb >> 24 );
|
||||
R = (byte)( argb >> 16 );
|
||||
G = (byte)( argb >> 8 );
|
||||
B = (byte)argb;
|
||||
}
|
||||
|
||||
public FastColour( Color c ) {
|
||||
A = c.A;
|
||||
|
Loading…
x
Reference in New Issue
Block a user