Skip to content

Commit

Permalink
Refactor: Moved some more classes into fewer files
Browse files Browse the repository at this point in the history
  • Loading branch information
Martomate committed Dec 23, 2023
1 parent 0ae46d9 commit a340009
Show file tree
Hide file tree
Showing 65 changed files with 518 additions and 588 deletions.
7 changes: 2 additions & 5 deletions game/src/main/scala/hexacraft/game/GameScene.scala
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package hexacraft.game

import hexacraft.game.NetworkPacket.{GetState, GetWorldInfo}
import hexacraft.game.inventory.{InventoryBox, Toolbar}
import hexacraft.gui.*
import hexacraft.gui.comp.{Component, GUITransformation}
import hexacraft.infra.fs.BlockTextureLoader
import hexacraft.infra.gpu.OpenGL
import hexacraft.infra.window.*
import hexacraft.renderer.*
import hexacraft.util.{ResourceWrapper, TickableTimer, Tracker}
import hexacraft.world.{Camera, CameraProjection, CylinderSize, World, WorldInfo, WorldProvider, WorldSettings}
import hexacraft.world.block.{Block, BlockSpecRegistry, BlockState, HexBox}
import hexacraft.world.{Camera, CameraProjection, CylinderSize, HexBox, Player, Ray, RayTracer, World, WorldInfo, WorldProvider, WorldSettings}
import hexacraft.world.block.{Block, BlockSpecRegistry, BlockState}
import hexacraft.world.coord.{BlockCoords, BlockRelWorld, CoordUtils, CylCoords, NeighborOffsets}
import hexacraft.world.entity.{ControlledPlayerEntity, EntityBaseData, EntityModel, EntityModelLoader}
import hexacraft.world.player.Player
import hexacraft.world.ray.{Ray, RayTracer}
import hexacraft.world.render.WorldRenderer

import com.martomate.nbt.Nbt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package hexacraft.game.inventory
package hexacraft.game

import hexacraft.game
import hexacraft.game.GuiBlockRenderer
import hexacraft.gui.{Event, LocationInfo, RenderContext}
import hexacraft.gui.comp.{Component, GUITransformation}
import hexacraft.infra.window.{KeyAction, KeyboardKey, MouseAction}
import hexacraft.util.Tracker
import hexacraft.world.Inventory
import hexacraft.world.block.{Block, BlockSpecRegistry}
import hexacraft.world.player.Inventory

import org.joml.{Matrix4f, Vector4f}

object InventoryBox {
Expand Down
3 changes: 1 addition & 2 deletions game/src/main/scala/hexacraft/game/PlayerInputHandler.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hexacraft.game

import hexacraft.world.player.Player

import hexacraft.world.Player
import org.joml.Vector2fc

class PlayerInputHandler(keyboard: GameKeyboard, player: Player):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package hexacraft.game

import hexacraft.physics.{Density, DragCoefficient, FluidDynamics, Viscosity}
import hexacraft.world.{BlocksInWorld, CollisionDetector}
import hexacraft.world.block.HexBox
import hexacraft.world.player.Player
import hexacraft.world.{BlocksInWorld, CollisionDetector, HexBox, Player}

import org.joml.Vector3d

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package hexacraft.game.inventory
package hexacraft.game

import hexacraft.game.GuiBlockRenderer
import hexacraft.gui.{LocationInfo, RenderContext}
import hexacraft.gui.comp.{Component, GUITransformation, SubComponents}
import hexacraft.world.Inventory
import hexacraft.world.block.BlockSpecRegistry
import hexacraft.world.player.Inventory

import org.joml.{Matrix4f, Vector4f}

class Toolbar(location: LocationInfo, private var inventory: Inventory)(specs: BlockSpecRegistry)
Expand Down
2 changes: 1 addition & 1 deletion game/src/main/scala/hexacraft/gui/LocationInfo.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hexacraft.gui

import org.joml.{Vector2fc, Vector2ic}
import org.joml.Vector2ic

/** x, y, w, h are position and size. The entire screen corresponds to `(-a, -1, 2 * a, 2)` where
* `a` is `window.aspectRatio`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package hexacraft.world.block
package hexacraft.world

import hexacraft.math.geometry.{ConvexHull, OrthogonalProjection}
import hexacraft.math.MathUtils
import hexacraft.world.CylinderSize
import hexacraft.math.geometry.{ConvexHull, OrthogonalProjection}
import hexacraft.world.coord.{BlockCoords, BlockRelWorld, CoordUtils, CylCoords}

import org.joml.Vector3dc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hexacraft.world.player
package hexacraft.world

import hexacraft.world.block.Block

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package hexacraft.world.player
package hexacraft.world

import hexacraft.world.block.{Block, HexBox}
import hexacraft.world.block.Block
import hexacraft.world.coord.CylCoords

import com.martomate.nbt.Nbt
import hexacraft.world.coord.CylCoords
import org.joml.Vector3d

class Player(var inventory: Inventory) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package hexacraft.world.loader
package hexacraft.world

import hexacraft.world.{CameraView, CylinderSize}
import hexacraft.world.coord.CylCoords

import org.joml.{Vector3d, Vector4d}

case class PosAndDir(var pos: CylCoords, dir: Vector3d = new Vector3d()) {
Expand Down
1 change: 0 additions & 1 deletion game/src/main/scala/hexacraft/world/World.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import hexacraft.world.block.{BlockRepository, BlockState}
import hexacraft.world.chunk.*
import hexacraft.world.coord.*
import hexacraft.world.entity.{Entity, EntityModelLoader, EntityRegistry, PlayerFactory, SheepFactory}
import hexacraft.world.loader.{ChunkLoader, PosAndDir}

import scala.collection.mutable

Expand Down
1 change: 1 addition & 0 deletions game/src/main/scala/hexacraft/world/block/BlockState.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hexacraft.world.block

import hexacraft.world.coord.CylCoords
import hexacraft.world.HexBox

object BlockState {
val Air: BlockState = new BlockState(Block.Air)
Expand Down
1 change: 1 addition & 0 deletions game/src/main/scala/hexacraft/world/block/blocks.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hexacraft.world.block

import hexacraft.physics.Viscosity
import hexacraft.world.HexBox

object Block {
private val maxBlocks = 256
Expand Down
1 change: 0 additions & 1 deletion game/src/main/scala/hexacraft/world/camera.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package hexacraft.world

import hexacraft.math.MathUtils
import hexacraft.world.coord.{BlockCoords, BlockRelWorld, CoordUtils, CylCoords}

import org.joml.{Matrix4f, Vector3d, Vector3f, Vector3fc}

class Camera(val proj: CameraProjection)(using worldSize: CylinderSize) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package hexacraft.world

import hexacraft.math.MathUtils
import hexacraft.world.block.HexBox
import hexacraft.world.coord.{BlockCoords, BlockRelWorld, CoordUtils, CylCoords, Offset, SkewCylCoords}

import org.joml.Vector3d

class MovingBox(val bounds: HexBox, val pos: CylCoords, val velocity: CylCoords.Offset)
Expand Down
4 changes: 2 additions & 2 deletions game/src/main/scala/hexacraft/world/entity/ai.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hexacraft.world.entity

import hexacraft.world.{BlocksInWorld, CylinderSize}
import hexacraft.world.block.{Block, HexBox}
import hexacraft.world.{BlocksInWorld, CylinderSize, HexBox}
import hexacraft.world.block.Block
import hexacraft.world.coord.{BlockRelWorld, CoordUtils, CylCoords}

import com.martomate.nbt.Nbt
Expand Down
3 changes: 1 addition & 2 deletions game/src/main/scala/hexacraft/world/entity/base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package hexacraft.world.entity

import hexacraft.util.Result
import hexacraft.util.Result.{Err, Ok}
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize}
import hexacraft.world.block.HexBox
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize, HexBox}

import com.martomate.nbt.Nbt
import hexacraft.world.coord.CylCoords
Expand Down
2 changes: 1 addition & 1 deletion game/src/main/scala/hexacraft/world/entity/models.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hexacraft.world.entity

import hexacraft.renderer.TextureSingle
import hexacraft.world.block.HexBox
import hexacraft.world.coord.CylCoords
import hexacraft.world.HexBox

import org.joml.{Matrix4f, Vector3f}

Expand Down
4 changes: 2 additions & 2 deletions game/src/main/scala/hexacraft/world/entity/physics.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hexacraft.world.entity

import hexacraft.physics.Density
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize}
import hexacraft.world.block.{Block, HexBox}
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize, HexBox}
import hexacraft.world.block.Block
import hexacraft.world.coord.{BlockCoords, CylCoords}

import org.joml.Vector3d
Expand Down
3 changes: 1 addition & 2 deletions game/src/main/scala/hexacraft/world/entity/player.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package hexacraft.world.entity

import hexacraft.renderer.TextureSingle
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize}
import hexacraft.world.block.HexBox
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize, HexBox}

import com.martomate.nbt.Nbt
import hexacraft.world.coord.{BlockCoords, CylCoords}
Expand Down
3 changes: 1 addition & 2 deletions game/src/main/scala/hexacraft/world/entity/sheep.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package hexacraft.world.entity

import hexacraft.renderer.TextureSingle
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize}
import hexacraft.world.block.HexBox
import hexacraft.world.{BlocksInWorld, CollisionDetector, CylinderSize, HexBox}

import com.martomate.nbt.Nbt
import hexacraft.world.coord.{BlockCoords, CylCoords}
Expand Down
Loading

0 comments on commit a340009

Please sign in to comment.