Skip to content

Commit

Permalink
Document formatting applied based on editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
AristurtleDev committed Oct 8, 2023
1 parent 1ab476f commit 1dc2bd2
Show file tree
Hide file tree
Showing 21 changed files with 158 additions and 161 deletions.
39 changes: 18 additions & 21 deletions source/Infiniminer/Infiniminer.Client/Engines/BlockEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

namespace Infiniminer
{



[Serializable]
public struct VertexPositionTextureShade : IVertexType
{
Expand All @@ -44,10 +41,10 @@ public struct VertexPositionTextureShade : IVertexType
VertexDeclaration IVertexType.VertexDeclaration => VertexDeclaration;

public static readonly VertexElement[] VertexElements = new VertexElement[]
{
{
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(sizeof(float)*3,VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
new VertexElement(sizeof(float)*5,VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 1)
new VertexElement(sizeof(float)*5,VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 1)
};

public VertexPositionTextureShade(Vector3 position, Vector2 uv, double shade)
Expand Down Expand Up @@ -103,8 +100,8 @@ public IMTexture(Texture2D texture)
public class BlockEngine
{
BlockType[,,] blockList = null;
public BlockType[, ,] downloadList = null;
Dictionary<uint,bool>[,] faceMap = null;
public BlockType[,,] downloadList = null;
Dictionary<uint, bool>[,] faceMap = null;
BlockTexture[,] blockTextureMap = null;
IMTexture[] blockTextures = null;
Effect basicEffect;
Expand Down Expand Up @@ -149,16 +146,16 @@ public BlockEngine(InfiniminerGame gameInstance)
}

// Initialize the face lists.
faceMap = new Dictionary<uint,bool>[(byte)BlockTexture.MAXIMUM, NUMREGIONS];
faceMap = new Dictionary<uint, bool>[(byte)BlockTexture.MAXIMUM, NUMREGIONS];
for (BlockTexture blockTexture = BlockTexture.None; blockTexture < BlockTexture.MAXIMUM; blockTexture++)
for (int r=0; r<NUMREGIONS; r++)
for (int r = 0; r < NUMREGIONS; r++)
faceMap[(byte)blockTexture, r] = new Dictionary<uint, bool>();

// Initialize the texture map.
blockTextureMap = new BlockTexture[(byte)BlockType.MAXIMUM, 6];
for (BlockType blockType = BlockType.None; blockType < BlockType.MAXIMUM; blockType++)
for (BlockFaceDirection faceDir = BlockFaceDirection.XIncreasing; faceDir < BlockFaceDirection.MAXIMUM; faceDir++)
blockTextureMap[(byte)blockType,(byte)faceDir] = BlockInformation.GetTexture(blockType, faceDir);
blockTextureMap[(byte)blockType, (byte)faceDir] = BlockInformation.GetTexture(blockType, faceDir);

// Load the textures we'll use.
blockTextures = new IMTexture[(byte)BlockTexture.MAXIMUM];
Expand Down Expand Up @@ -227,7 +224,7 @@ public BlockEngine(InfiniminerGame gameInstance)
// Returns true if we are solid at this point.
public bool SolidAtPoint(Vector3 point)
{
return BlockAtPoint(point) != BlockType.None;
return BlockAtPoint(point) != BlockType.None;
}

public bool SolidAtPointForPlayer(Vector3 point)
Expand All @@ -253,14 +250,14 @@ public BlockType BlockAtPoint(Vector3 point)
ushort z = (ushort)point.Z;
if (x < 0 || y < 0 || z < 0 || x >= MAPSIZE || y >= MAPSIZE || z >= MAPSIZE)
return BlockType.None;
return blockList[x, y, z];
return blockList[x, y, z];
}

public bool RayCollision(Vector3 startPosition, Vector3 rayDirection, float distance, int searchGranularity, ref Vector3 hitPoint, ref Vector3 buildPoint)
{
Vector3 testPos = startPosition;
Vector3 buildPos = startPosition;
for (int i=0; i<searchGranularity; i++)
for (int i = 0; i < searchGranularity; i++)
{
testPos += rayDirection * distance / searchGranularity;
BlockType testBlock = BlockAtPoint(testPos);
Expand All @@ -279,7 +276,7 @@ public void Render(GraphicsDevice graphicsDevice, GameTime gameTime)
{
RegenerateDirtyVertexLists();

for (BlockTexture blockTexture = BlockTexture.None+1; blockTexture < BlockTexture.MAXIMUM; blockTexture++)
for (BlockTexture blockTexture = BlockTexture.None + 1; blockTexture < BlockTexture.MAXIMUM; blockTexture++)
for (uint r = 0; r < NUMREGIONS; r++)
{
// Figure out if we should be rendering translucently.
Expand Down Expand Up @@ -320,17 +317,17 @@ private void RenderVertexList(GraphicsDevice graphicsDevice, DynamicVertexBuffer
if (renderLava)
{
basicEffect.CurrentTechnique = basicEffect.Techniques["LavaBlock"];
basicEffect.Parameters["xTime"].SetValue(elapsedTime%5);
basicEffect.Parameters["xTime"].SetValue(elapsedTime % 5);
}
else
basicEffect.CurrentTechnique = basicEffect.Techniques["Block"];

basicEffect.Parameters["xWorld"].SetValue(Matrix.Identity);
basicEffect.Parameters["xView"].SetValue(gameInstance.propertyBag.playerCamera.ViewMatrix);
basicEffect.Parameters["xProjection"].SetValue(gameInstance.propertyBag.playerCamera.ProjectionMatrix);
basicEffect.Parameters["xTexture"].SetValue(blockTexture);
basicEffect.Parameters["xLODColor"].SetValue(lodColor.ToVector3());

foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Apply();
Expand All @@ -355,12 +352,12 @@ private void RenderVertexList(GraphicsDevice graphicsDevice, DynamicVertexBuffer
// [MG_PORT_NOTES] The cheatsheet says additive, may not be correct?
graphicsDevice.BlendState = BlendState.Additive;
}
}
}
}

private void RegenerateDirtyVertexLists()
{
for (BlockTexture blockTexture = BlockTexture.None+1; blockTexture < BlockTexture.MAXIMUM; blockTexture++)
for (BlockTexture blockTexture = BlockTexture.None + 1; blockTexture < BlockTexture.MAXIMUM; blockTexture++)
for (int r = 0; r < NUMREGIONS; r++)
if (vertexListDirty[(byte)blockTexture, r])
{
Expand Down Expand Up @@ -393,7 +390,7 @@ private DynamicVertexBuffer CreateVertexBufferFromFaceList(Dictionary<uint, bool
foreach (uint faceInfo in faceList.Keys)
{
BuildFaceVertices(ref vertexList, vertexPointer, faceInfo, texture == (int)BlockTexture.Spikes);
vertexPointer += 6;
vertexPointer += 6;
}
DynamicVertexBuffer vertexBuffer = new DynamicVertexBuffer(gameInstance.GraphicsDevice, typeof(VertexPositionTextureShade), vertexList.Length * VertexPositionTextureShade.SizeInBytes, BufferUsage.WriteOnly);
// [MG_PORT_NOTES] .ContentLost is not part of MonoGame. Need to find some other way to support this
Expand Down Expand Up @@ -572,7 +569,7 @@ private Vector3 GetRegionCenter(uint regionNumber)
y = regionNumber % REGIONRATIO;
regionNumber = (regionNumber - y) / REGIONRATIO;
z = regionNumber;
return new Vector3(x * REGIONSIZE + REGIONSIZE / 2, y * REGIONSIZE + REGIONSIZE / 2, z * REGIONSIZE + REGIONSIZE / 2);
return new Vector3(x * REGIONSIZE + REGIONSIZE / 2, y * REGIONSIZE + REGIONSIZE / 2, z * REGIONSIZE + REGIONSIZE / 2);
}

private void ShowQuad(ushort x, ushort y, ushort z, BlockFaceDirection faceDir, BlockType blockType)
Expand Down
18 changes: 9 additions & 9 deletions source/Infiniminer/Infiniminer.Client/Engines/InterfaceEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void RenderRadarBlip(SpriteBatch spriteBatch, Vector3 position, Color col
if (ping)
spriteBatch.Draw(texRadarPlayerPing, new Vector2(10 + 99 + relativePosition.X - texRadarPlayerPing.Width / 2, 30 + 99 + relativePosition.Z - texRadarPlayerPing.Height / 2), color);
}

// Render text.
if (text != "")
{
Expand Down Expand Up @@ -255,7 +255,7 @@ public void RenderConstructionGun(GraphicsDevice graphicsDevice, SpriteBatch spr
else if (_P.constructionGunAnimation > 0.001)
gunSprite = texToolBuildSmoke;
spriteBatch.Draw(gunSprite, new Rectangle(drawX, drawY, 120 * 3, 126 * 3), Color.White);
spriteBatch.Draw(blockIcons[blockType], new Rectangle(drawX+37*3, drawY+50*3, 117, 63), Color.White);
spriteBatch.Draw(blockIcons[blockType], new Rectangle(drawX + 37 * 3, drawY + 50 * 3, 117, 63), Color.White);
}

public void Render(GraphicsDevice graphicsDevice)
Expand All @@ -267,7 +267,7 @@ public void Render(GraphicsDevice graphicsDevice)

// Draw the UI.
spriteBatch.Begin(blendState: BlendState.AlphaBlend, sortMode: SpriteSortMode.Immediate);

// Draw the crosshair.
spriteBatch.Draw(texCrosshairs, new Rectangle(graphicsDevice.Viewport.Width / 2 - texCrosshairs.Width / 2,
graphicsDevice.Viewport.Height / 2 - texCrosshairs.Height / 2,
Expand Down Expand Up @@ -322,9 +322,9 @@ public void Render(GraphicsDevice graphicsDevice)
RenderMessageCenter(spriteBatch, "YOU CANNOT CHANGE YOUR CLASS BELOW THE SURFACE", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 90), Color.White, Color.Black);

// Draw the text-based information panel.
int textStart = (graphicsDevice.Viewport.Width - 1024)/2;
int textStart = (graphicsDevice.Viewport.Width - 1024) / 2;
spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, 20), Color.Black);
spriteBatch.DrawString(uiFont, "ORE: " + _P.playerOre + "/" + _P.playerOreMax, new Vector2(textStart+3, 2), Color.White);
spriteBatch.DrawString(uiFont, "ORE: " + _P.playerOre + "/" + _P.playerOreMax, new Vector2(textStart + 3, 2), Color.White);
spriteBatch.DrawString(uiFont, "LOOT: $" + _P.playerCash, new Vector2(textStart + 170, 2), Color.White);
spriteBatch.DrawString(uiFont, "WEIGHT: " + _P.playerWeight + "/" + _P.playerWeightMax, new Vector2(textStart + 340, 2), Color.White);
spriteBatch.DrawString(uiFont, "TEAM ORE: " + _P.teamOre, new Vector2(textStart + 515, 2), Color.White);
Expand All @@ -343,13 +343,13 @@ public void Render(GraphicsDevice graphicsDevice)
string gameOverMessage = "GAME OVER - " + teamName + " TEAM WINS!";
RenderMessageCenter(spriteBatch, gameOverMessage, new Vector2(graphicsDevice.Viewport.Width / 2, 150), teamColor, new Color(0, 0, 0, 0));
}

int drawY = 200;
foreach (Player p in _P.playerList.Values)
{
if (p.Team != PlayerTeam.Red)
continue;
RenderMessageCenter(spriteBatch, p.Handle + " ( $" + p.Score + " )", new Vector2(graphicsDevice.Viewport.Width/4, drawY), Defines.IM_RED, new Color(0, 0, 0, 0));
RenderMessageCenter(spriteBatch, p.Handle + " ( $" + p.Score + " )", new Vector2(graphicsDevice.Viewport.Width / 4, drawY), Defines.IM_RED, new Color(0, 0, 0, 0));
drawY += 35;
}
drawY = 200;
Expand Down Expand Up @@ -402,14 +402,14 @@ public void Render(GraphicsDevice graphicsDevice)
RenderMessageCenter(spriteBatch, "PRESS Y TO CONFIRM THAT YOU WANT TO QUIT.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 30), Color.White, Color.Black);
RenderMessageCenter(spriteBatch, "PRESS K TO COMMIT PIXELCIDE.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2 + 80), Color.White, Color.Black);
}

// Draw the current screen effect.
if (_P.screenEffect == ScreenEffect.Death)
{
Color drawColor = new Color(1 - (float)_P.screenEffectCounter * 0.5f, 0f, 0f);
spriteBatch.Draw(texBlank, new Rectangle(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height), drawColor);
if (_P.screenEffectCounter >= 2)
RenderMessageCenter(spriteBatch, "You have died. Click to respawn.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height/2), Color.White, Color.Black);
RenderMessageCenter(spriteBatch, "You have died. Click to respawn.", new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2), Color.White, Color.Black);
}
if (_P.screenEffect == ScreenEffect.Teleport || _P.screenEffect == ScreenEffect.Explosion)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void CreateExplosionDebris(Vector3 explosionPosition)
for (int i = 0; i < 50; i++)
{
Particle p = new Particle();
p.Color = new Color(90,60,40);
p.Color = new Color(90, 60, 40);
p.Size = (float)(randGen.NextDouble() * 0.4 + 0.05);
p.Position = explosionPosition;
p.Position.Y += (float)randGen.NextDouble() - 0.5f;
Expand All @@ -157,7 +157,7 @@ public void CreateBloodSplatter(Vector3 playerPosition, Color color)
{
Particle p = new Particle();
p.Color = color;
p.Size = (float)(randGen.NextDouble()*0.2 + 0.05);
p.Size = (float)(randGen.NextDouble() * 0.2 + 0.05);
p.Position = playerPosition;
p.Position.Y -= (float)randGen.NextDouble();
p.Velocity = new Vector3((float)randGen.NextDouble() * 5 - 2.5f, (float)randGen.NextDouble() * 4f, (float)randGen.NextDouble() * 5 - 2.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public SkyplaneEngine(InfiniminerGame gameInstance)
// Generate a noise texture.
randGen = new Random();
texNoise = new Texture2D(gameInstance.GraphicsDevice, 64, 64);
uint[] noiseData = new uint[64*64];
uint[] noiseData = new uint[64 * 64];
for (int i = 0; i < 64 * 64; i++)
if (randGen.Next(32) == 0)
noiseData[i] = Color.White.PackedValue;
Expand Down
30 changes: 15 additions & 15 deletions source/Infiniminer/Infiniminer.Client/InfiniminerGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public InfiniminerGame(string[] args)
public void JoinGame(IPEndPoint serverEndPoint)
{
// Clear out the map load progress indicator.
propertyBag.mapLoadProgress = new bool[64,64];
propertyBag.mapLoadProgress = new bool[64, 64];
for (int i = 0; i < 64; i++)
for (int j=0; j<64; j++)
propertyBag.mapLoadProgress[i,j] = false;
for (int j = 0; j < 64; j++)
propertyBag.mapLoadProgress[i, j] = false;

// Create our connect message.
NetBuffer connectBuffer = propertyBag.netClient.CreateBuffer();
Expand All @@ -72,7 +72,7 @@ public void JoinGame(IPEndPoint serverEndPoint)
public List<ServerInformation> EnumerateServers(float discoveryTime)
{
List<ServerInformation> serverList = new List<ServerInformation>();

// Discover local servers.
propertyBag.netClient.DiscoverLocalServers(5565);
NetBuffer msgBuffer = propertyBag.netClient.CreateBuffer();
Expand Down Expand Up @@ -173,18 +173,18 @@ public void UpdateNetwork(GameTime gameTime)
{
byte x = msgBuffer.ReadByte();
byte y = msgBuffer.ReadByte();
propertyBag.mapLoadProgress[x,y] = true;
for (byte dy=0; dy<16; dy++)
for (byte z=0; z<64; z++)
propertyBag.mapLoadProgress[x, y] = true;
for (byte dy = 0; dy < 16; dy++)
for (byte z = 0; z < 64; z++)
{
BlockType blockType = (BlockType)msgBuffer.ReadByte();
if (blockType != BlockType.None)
propertyBag.blockEngine.downloadList[x, y+dy, z] = blockType;
propertyBag.blockEngine.downloadList[x, y + dy, z] = blockType;
}
bool downloadComplete = true;
for (x=0; x<64; x++)
for (y=0; y<64; y+=16)
if (propertyBag.mapLoadProgress[x,y] == false)
for (x = 0; x < 64; x++)
for (y = 0; y < 64; y += 16)
if (propertyBag.mapLoadProgress[x, y] == false)
{
downloadComplete = false;
break;
Expand Down Expand Up @@ -259,15 +259,15 @@ public void UpdateNetwork(GameTime gameTime)
if (propertyBag.blockEngine.BlockAtPoint(new Vector3(x, y, z)) != BlockType.None)
propertyBag.blockEngine.RemoveBlock(x, y, z);
propertyBag.blockEngine.AddBlock(x, y, z, blockType);
CheckForStandingInLava();
CheckForStandingInLava();
}
}
break;

case InfiniminerMessage.TriggerExplosion:
{
Vector3 blockPos = msgBuffer.ReadVector3();

// Play the explosion sound.
propertyBag.PlaySound(InfiniminerSound.Explosion, blockPos);

Expand Down Expand Up @@ -460,7 +460,7 @@ protected override void Initialize()
if (dataFile.Data.ContainsKey("pretty"))
RenderPretty = bool.Parse(dataFile.Data["pretty"]);
if (dataFile.Data.ContainsKey("volume"))
volumeLevel = Math.Max(0,Math.Min(1,float.Parse(dataFile.Data["volume"], System.Globalization.CultureInfo.InvariantCulture)));
volumeLevel = Math.Max(0, Math.Min(1, float.Parse(dataFile.Data["volume"], System.Globalization.CultureInfo.InvariantCulture)));

graphicsDeviceManager.ApplyChanges();
base.Initialize();
Expand All @@ -474,7 +474,7 @@ protected override void Update(GameTime gameTime)
protected override void OnExiting(object sender, EventArgs args)
{
propertyBag.netClient.Shutdown("Client exiting.");

base.OnExiting(sender, args);
}

Expand Down
Loading

0 comments on commit 1dc2bd2

Please sign in to comment.