mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Implement gas block draw type in BlockDefinitions, also allow press function keys in text input widget (Thanks FabTheZen).
This commit is contained in:
parent
1887b2f389
commit
0102471e91
@ -38,11 +38,12 @@ namespace ClassicalSharp {
|
|||||||
if( info.IsSprite[block] ) {
|
if( info.IsSprite[block] ) {
|
||||||
minBB = Vector3.Zero; maxBB = Vector3.One;
|
minBB = Vector3.Zero; maxBB = Vector3.One;
|
||||||
}
|
}
|
||||||
|
if( info.IsAir[block] ) return;
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
// isometric coords size: cosY * -scale - sinY * scale
|
// isometric coords size: cosY * -scale - sinY * scale
|
||||||
// we need to divide by (2 * cosY), as the calling function expects size to be in pixels.
|
// 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))
|
// screen to isometric coords (cos(-x) = cos(x), sin(-x) = -sin(x))
|
||||||
pos.X = x; pos.Y = y; pos.Z = 0;
|
pos.X = x; pos.Y = y; pos.Z = 0;
|
||||||
pos = Utils.RotateY( Utils.RotateX( pos, cosX, -sinX ), cosY, -sinY );
|
pos = Utils.RotateY( Utils.RotateX( pos, cosX, -sinX ), cosY, -sinY );
|
||||||
|
@ -270,7 +270,7 @@ namespace ClassicalSharp {
|
|||||||
} else {
|
} else {
|
||||||
textInput.HandlesKeyDown( key );
|
textInput.HandlesKeyDown( key );
|
||||||
}
|
}
|
||||||
return true;
|
return key < Key.F1 || key > Key.F35;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( key == game.Mapping( KeyBinding.OpenChat ) ) {
|
if( key == game.Mapping( KeyBinding.OpenChat ) ) {
|
||||||
|
@ -9,6 +9,8 @@ namespace ClassicalSharp {
|
|||||||
bool[] hidden = new bool[BlocksCount * BlocksCount * TileSide.Sides];
|
bool[] hidden = new bool[BlocksCount * BlocksCount * TileSide.Sides];
|
||||||
|
|
||||||
public bool[] CanStretch = new bool[BlocksCount * TileSide.Sides];
|
public bool[] CanStretch = new bool[BlocksCount * TileSide.Sides];
|
||||||
|
|
||||||
|
public bool[] IsAir = new bool[BlocksCount];
|
||||||
|
|
||||||
internal void CheckOpaque() {
|
internal void CheckOpaque() {
|
||||||
for( int tile = 1; tile < BlocksCount; tile++ ) {
|
for( int tile = 1; tile < BlocksCount; tile++ ) {
|
||||||
@ -20,6 +22,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void SetupCullingCache() {
|
internal void SetupCullingCache() {
|
||||||
|
IsAir[0] = true;
|
||||||
CheckOpaque();
|
CheckOpaque();
|
||||||
for( int i = 0; i < CanStretch.Length; i++ )
|
for( int i = 0; i < CanStretch.Length; i++ )
|
||||||
CanStretch[i] = true;
|
CanStretch[i] = true;
|
||||||
|
@ -172,6 +172,7 @@ namespace ClassicalSharp {
|
|||||||
BlocksLight[id] = true;
|
BlocksLight[id] = true;
|
||||||
FullBright[id] = false;
|
FullBright[id] = false;
|
||||||
CullWithNeighbours[id] = true;
|
CullWithNeighbours[id] = true;
|
||||||
|
IsAir[id] = false;
|
||||||
|
|
||||||
Name[id] = "Invalid";
|
Name[id] = "Invalid";
|
||||||
FogColour[id] = default( FastColour );
|
FogColour[id] = default( FastColour );
|
||||||
|
@ -441,7 +441,8 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal bool CanPick( byte block ) {
|
internal bool CanPick( byte block ) {
|
||||||
if( block == 0 ) return false;
|
if( BlockInfo.CollideType[block] == BlockCollideType.WalkThrough )
|
||||||
|
return false;
|
||||||
if( !BlockInfo.IsLiquid[block] ) return true;
|
if( !BlockInfo.IsLiquid[block] ) return true;
|
||||||
|
|
||||||
return !LiquidsBreakable ? false :
|
return !LiquidsBreakable ? false :
|
||||||
|
@ -48,7 +48,7 @@ namespace ClassicalSharp {
|
|||||||
int chunkIndex = (yy + 1) * extChunkSize2 + (zz + 1) * extChunkSize + (0 + 1);
|
int chunkIndex = (yy + 1) * extChunkSize2 + (zz + 1) * extChunkSize + (0 + 1);
|
||||||
for( int x = x1, xx = 0; x < xMax; x++, xx++ ) {
|
for( int x = x1, xx = 0; x < xMax; x++, xx++ ) {
|
||||||
tile = chunk[chunkIndex];
|
tile = chunk[chunkIndex];
|
||||||
if( tile != 0 )
|
if( !info.IsAir[tile] )
|
||||||
RenderTile( chunkIndex, xx, yy, zz, x, y, z );
|
RenderTile( chunkIndex, xx, yy, zz, x, y, z );
|
||||||
chunkIndex++;
|
chunkIndex++;
|
||||||
}
|
}
|
||||||
@ -59,12 +59,8 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
unsafe bool ReadChunkData( int x1, int y1, int z1 ) {
|
unsafe bool ReadChunkData( int x1, int y1, int z1 ) {
|
||||||
bool allAir = true, allSolid = true;
|
bool allAir = true, allSolid = true;
|
||||||
fixed( byte* chunkPtr = chunk, mapPtr = map.mapData ) {
|
fixed( byte* chunkPtr = chunk, mapPtr = map.mapData ) {
|
||||||
|
MemUtils.memset( (IntPtr)chunkPtr, 0, 0, extChunkSize3 );
|
||||||
int* chunkIntPtr = (int*)chunkPtr;
|
|
||||||
for( int i = 0; i < extChunkSize3 / sizeof( int ); i++ ) {
|
|
||||||
*chunkIntPtr++ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int yy = -1; yy < 17; yy++ ) {
|
for( int yy = -1; yy < 17; yy++ ) {
|
||||||
int y = yy + y1;
|
int y = yy + y1;
|
||||||
@ -75,8 +71,8 @@ namespace ClassicalSharp {
|
|||||||
if( z < 0 ) continue;
|
if( z < 0 ) continue;
|
||||||
if( z > maxZ ) break;
|
if( z > maxZ ) break;
|
||||||
|
|
||||||
int index = ( y * length + z ) * width + ( x1 - 1 - 1 );
|
int index = (y * length + z) * width + (x1 - 1 - 1);
|
||||||
int chunkIndex = ( yy + 1 ) * extChunkSize2 + ( zz + 1 ) * extChunkSize + ( -1 + 1 ) - 1;
|
int chunkIndex = (yy + 1) * extChunkSize2 + (zz + 1) * extChunkSize + (-1 + 1) - 1;
|
||||||
|
|
||||||
for( int xx = -1; xx < 17; xx++ ) {
|
for( int xx = -1; xx < 17; xx++ ) {
|
||||||
int x = xx + x1;
|
int x = xx + x1;
|
||||||
@ -160,10 +156,9 @@ namespace ClassicalSharp {
|
|||||||
DrawTopFace( topCount );
|
DrawTopFace( topCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stretch( int x1, int y1, int z1 ) {
|
unsafe void Stretch( int x1, int y1, int z1 ) {
|
||||||
for( int i = 0; i < counts.Length; i++ ) {
|
fixed( byte* ptr = counts )
|
||||||
counts[i] = 1;
|
MemUtils.memset( (IntPtr)ptr, 1, 0, chunkSize3 * TileSide.Sides );
|
||||||
}
|
|
||||||
|
|
||||||
int xMax = Math.Min( width, x1 + chunkSize );
|
int xMax = Math.Min( width, x1 + chunkSize );
|
||||||
int yMax = Math.Min( height, y1 + chunkSize );
|
int yMax = Math.Min( height, y1 + chunkSize );
|
||||||
@ -187,7 +182,7 @@ namespace ClassicalSharp {
|
|||||||
for( int x = x1, xx = 0; x < xMax; x++, xx++ ) {
|
for( int x = x1, xx = 0; x < xMax; x++, xx++ ) {
|
||||||
chunkIndex++;
|
chunkIndex++;
|
||||||
byte tile = chunk[chunkIndex];
|
byte tile = chunk[chunkIndex];
|
||||||
if( tile == 0 ) continue;
|
if( info.IsAir[tile] ) continue;
|
||||||
int countIndex = ((yy << 8) + (zz << 4) + xx) * TileSide.Sides;
|
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.
|
// Sprites only use one face to indicate stretching count, so we can take a shortcut here.
|
||||||
|
@ -42,7 +42,7 @@ namespace ClassicalSharp.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void CalcState( byte block ) {
|
public void CalcState( byte block ) {
|
||||||
if( block == 0 ) {
|
if( game.BlockInfo.IsAir[block] ) {
|
||||||
bright = false;
|
bright = false;
|
||||||
minBB = Vector3.Zero;
|
minBB = Vector3.Zero;
|
||||||
maxBB = Vector3.One;
|
maxBB = Vector3.One;
|
||||||
@ -71,7 +71,7 @@ namespace ClassicalSharp.Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CalcState( block );
|
CalcState( block );
|
||||||
if( block == 0 )
|
if( game.BlockInfo.IsAir[block] )
|
||||||
return;
|
return;
|
||||||
lastTexId = -1;
|
lastTexId = -1;
|
||||||
atlas = game.TerrainAtlas1D;
|
atlas = game.TerrainAtlas1D;
|
||||||
|
@ -460,6 +460,9 @@ namespace ClassicalSharp {
|
|||||||
info.CullWithNeighbours[block] = false;
|
info.CullWithNeighbours[block] = false;
|
||||||
} else if( blockDraw == 3 ) {
|
} else if( blockDraw == 3 ) {
|
||||||
info.IsTranslucent[block] = true;
|
info.IsTranslucent[block] = true;
|
||||||
|
} else if( blockDraw == 4 ) {
|
||||||
|
info.IsTransparent[block] = true;
|
||||||
|
info.IsAir[block] = true;
|
||||||
}
|
}
|
||||||
if( info.IsOpaque[block] )
|
if( info.IsOpaque[block] )
|
||||||
info.IsOpaque[block] = blockDraw == 0;
|
info.IsOpaque[block] = blockDraw == 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user