Implement gas block draw type in BlockDefinitions, also allow press function keys in text input widget (Thanks FabTheZen).

This commit is contained in:
UnknownShadow200 2015-12-30 21:42:20 +11:00
parent 1887b2f389
commit 0102471e91
8 changed files with 24 additions and 20 deletions

View File

@ -38,11 +38,12 @@ namespace ClassicalSharp {
if( info.IsSprite[block] ) {
minBB = Vector3.Zero; maxBB = Vector3.One;
}
if( info.IsAir[block] ) return;
index = 0;
// isometric coords size: cosY * -scale - sinY * scale
// we need to divide by (2 * cosY), as the calling function expects size to be in pixels.
scale = size / (2 * cosY);
scale = size / (2 * cosY);
// screen to isometric coords (cos(-x) = cos(x), sin(-x) = -sin(x))
pos.X = x; pos.Y = y; pos.Z = 0;
pos = Utils.RotateY( Utils.RotateX( pos, cosX, -sinX ), cosY, -sinY );

View File

@ -270,7 +270,7 @@ namespace ClassicalSharp {
} else {
textInput.HandlesKeyDown( key );
}
return true;
return key < Key.F1 || key > Key.F35;
}
if( key == game.Mapping( KeyBinding.OpenChat ) ) {

View File

@ -9,6 +9,8 @@ namespace ClassicalSharp {
bool[] hidden = new bool[BlocksCount * BlocksCount * TileSide.Sides];
public bool[] CanStretch = new bool[BlocksCount * TileSide.Sides];
public bool[] IsAir = new bool[BlocksCount];
internal void CheckOpaque() {
for( int tile = 1; tile < BlocksCount; tile++ ) {
@ -20,6 +22,7 @@ namespace ClassicalSharp {
}
internal void SetupCullingCache() {
IsAir[0] = true;
CheckOpaque();
for( int i = 0; i < CanStretch.Length; i++ )
CanStretch[i] = true;

View File

@ -172,6 +172,7 @@ namespace ClassicalSharp {
BlocksLight[id] = true;
FullBright[id] = false;
CullWithNeighbours[id] = true;
IsAir[id] = false;
Name[id] = "Invalid";
FogColour[id] = default( FastColour );

View File

@ -441,7 +441,8 @@ namespace ClassicalSharp {
}
internal bool CanPick( byte block ) {
if( block == 0 ) return false;
if( BlockInfo.CollideType[block] == BlockCollideType.WalkThrough )
return false;
if( !BlockInfo.IsLiquid[block] ) return true;
return !LiquidsBreakable ? false :

View File

@ -48,7 +48,7 @@ namespace ClassicalSharp {
int chunkIndex = (yy + 1) * extChunkSize2 + (zz + 1) * extChunkSize + (0 + 1);
for( int x = x1, xx = 0; x < xMax; x++, xx++ ) {
tile = chunk[chunkIndex];
if( tile != 0 )
if( !info.IsAir[tile] )
RenderTile( chunkIndex, xx, yy, zz, x, y, z );
chunkIndex++;
}
@ -59,12 +59,8 @@ namespace ClassicalSharp {
unsafe bool ReadChunkData( int x1, int y1, int z1 ) {
bool allAir = true, allSolid = true;
fixed( byte* chunkPtr = chunk, mapPtr = map.mapData ) {
int* chunkIntPtr = (int*)chunkPtr;
for( int i = 0; i < extChunkSize3 / sizeof( int ); i++ ) {
*chunkIntPtr++ = 0;
}
fixed( byte* chunkPtr = chunk, mapPtr = map.mapData ) {
MemUtils.memset( (IntPtr)chunkPtr, 0, 0, extChunkSize3 );
for( int yy = -1; yy < 17; yy++ ) {
int y = yy + y1;
@ -75,8 +71,8 @@ namespace ClassicalSharp {
if( z < 0 ) continue;
if( z > maxZ ) break;
int index = ( y * length + z ) * width + ( x1 - 1 - 1 );
int chunkIndex = ( yy + 1 ) * extChunkSize2 + ( zz + 1 ) * extChunkSize + ( -1 + 1 ) - 1;
int index = (y * length + z) * width + (x1 - 1 - 1);
int chunkIndex = (yy + 1) * extChunkSize2 + (zz + 1) * extChunkSize + (-1 + 1) - 1;
for( int xx = -1; xx < 17; xx++ ) {
int x = xx + x1;
@ -160,10 +156,9 @@ namespace ClassicalSharp {
DrawTopFace( topCount );
}
void Stretch( int x1, int y1, int z1 ) {
for( int i = 0; i < counts.Length; i++ ) {
counts[i] = 1;
}
unsafe void Stretch( int x1, int y1, int z1 ) {
fixed( byte* ptr = counts )
MemUtils.memset( (IntPtr)ptr, 1, 0, chunkSize3 * TileSide.Sides );
int xMax = Math.Min( width, x1 + chunkSize );
int yMax = Math.Min( height, y1 + chunkSize );
@ -187,7 +182,7 @@ namespace ClassicalSharp {
for( int x = x1, xx = 0; x < xMax; x++, xx++ ) {
chunkIndex++;
byte tile = chunk[chunkIndex];
if( tile == 0 ) continue;
if( info.IsAir[tile] ) continue;
int countIndex = ((yy << 8) + (zz << 4) + xx) * TileSide.Sides;
// Sprites only use one face to indicate stretching count, so we can take a shortcut here.

View File

@ -42,7 +42,7 @@ namespace ClassicalSharp.Model {
}
public void CalcState( byte block ) {
if( block == 0 ) {
if( game.BlockInfo.IsAir[block] ) {
bright = false;
minBB = Vector3.Zero;
maxBB = Vector3.One;
@ -71,7 +71,7 @@ namespace ClassicalSharp.Model {
}
CalcState( block );
if( block == 0 )
if( game.BlockInfo.IsAir[block] )
return;
lastTexId = -1;
atlas = game.TerrainAtlas1D;

View File

@ -460,6 +460,9 @@ namespace ClassicalSharp {
info.CullWithNeighbours[block] = false;
} else if( blockDraw == 3 ) {
info.IsTranslucent[block] = true;
} else if( blockDraw == 4 ) {
info.IsTransparent[block] = true;
info.IsAir[block] = true;
}
if( info.IsOpaque[block] )
info.IsOpaque[block] = blockDraw == 0;