mirror of
				https://github.com/simon987/Much-Assembly-Required.git
				synced 2025-11-04 10:06:54 +00:00 
			
		
		
		
	Added Fluid Tile
This commit is contained in:
		
							parent
							
								
									bbaa338469
								
							
						
					
					
						commit
						70eeb1442d
					
				@ -113,6 +113,7 @@ public class GameServer implements Runnable {
 | 
			
		||||
        gameRegistry.registerTile(TileWall.ID, TileWall.class);
 | 
			
		||||
        gameRegistry.registerTile(TileCopper.ID, TileCopper.class);
 | 
			
		||||
        gameRegistry.registerTile(TileIron.ID, TileIron.class);
 | 
			
		||||
        gameRegistry.registerTile(TileFluid.ID, TileFluid.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GameUniverse getGameUniverse() {
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
package net.simon987.server.game.objects;
 | 
			
		||||
 | 
			
		||||
import net.simon987.server.GameServer;
 | 
			
		||||
import net.simon987.server.game.world.Tile;
 | 
			
		||||
import net.simon987.server.game.world.World;
 | 
			
		||||
import net.simon987.server.io.JSONSerializable;
 | 
			
		||||
import net.simon987.server.io.MongoSerializable;
 | 
			
		||||
@ -102,10 +103,15 @@ public abstract class GameObject implements JSONSerializable, MongoSerializable
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //Check collision
 | 
			
		||||
            if (!world.isTileBlocked(newX, newY)) { //Check for collision
 | 
			
		||||
                //Tile is passable
 | 
			
		||||
                x = newX;
 | 
			
		||||
                y = newY;
 | 
			
		||||
            if (this.world.getGameObjectsBlockingAt(newX, newY).size() > 0) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Tile tile = world.getTileMap().getTileAt(newX, newY);
 | 
			
		||||
            if (tile.walk(this)) {
 | 
			
		||||
 | 
			
		||||
                this.setX(newX);
 | 
			
		||||
                this.setY(newY);
 | 
			
		||||
                return true;
 | 
			
		||||
            } else {
 | 
			
		||||
                return false;
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,30 @@
 | 
			
		||||
package net.simon987.server.game.world;
 | 
			
		||||
 | 
			
		||||
import net.simon987.server.game.item.Item;
 | 
			
		||||
import net.simon987.server.game.objects.GameObject;
 | 
			
		||||
 | 
			
		||||
public class TileFluid extends Tile {
 | 
			
		||||
 | 
			
		||||
    public static final int ID = 6;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getId() {
 | 
			
		||||
        return 6;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Item drill() {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean walk(GameObject object) {
 | 
			
		||||
        object.setDead(true);
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isBlocked() {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -30,6 +30,9 @@ public class WorldGenerator {
 | 
			
		||||
     */
 | 
			
		||||
    private int wallPlainRatio;
 | 
			
		||||
 | 
			
		||||
    private int fluidCenterPointMin;
 | 
			
		||||
    private int fluidCenterPointMax;
 | 
			
		||||
 | 
			
		||||
    private int minIronCount;
 | 
			
		||||
    private int maxIronCount;
 | 
			
		||||
    private int minCopperCount;
 | 
			
		||||
@ -52,6 +55,8 @@ public class WorldGenerator {
 | 
			
		||||
        maxIronCount = config.getInt("wg_maxIronCount");
 | 
			
		||||
        minCopperCount = config.getInt("wg_minCopperCount");
 | 
			
		||||
        maxCopperCount = config.getInt("wg_maxCopperCount");
 | 
			
		||||
        fluidCenterPointMin = config.getInt("wg_fluidCenterPointMin");
 | 
			
		||||
        fluidCenterPointMax = config.getInt("wg_fluidCenterPointMax");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -60,7 +65,6 @@ public class WorldGenerator {
 | 
			
		||||
    private static int distanceBetween(int x1, int y1, int x2, int y2) {
 | 
			
		||||
 | 
			
		||||
        return (int) Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private int getClosestCenterPointTile(int x, int y) {
 | 
			
		||||
@ -79,7 +83,6 @@ public class WorldGenerator {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        return closest;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@ -101,6 +104,7 @@ public class WorldGenerator {
 | 
			
		||||
        centerPointsMap = new HashMap<>(16);
 | 
			
		||||
 | 
			
		||||
        int centerPointCount = random.nextInt(centerPointCountMax - centerPointCountMin) + centerPointCountMin;
 | 
			
		||||
        int fluidCenterPointCount = random.nextInt((fluidCenterPointMax - fluidCenterPointMin) + fluidCenterPointMin);
 | 
			
		||||
 | 
			
		||||
        //Create center points
 | 
			
		||||
        for (int i = centerPointCount; i >= 0; i--) {
 | 
			
		||||
@ -109,6 +113,10 @@ public class WorldGenerator {
 | 
			
		||||
            centerPointsMap.put(new Point(random.nextInt(DEFAULT_WORLD_SIZE), random.nextInt(DEFAULT_WORLD_SIZE)), tile);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (int i = fluidCenterPointCount; i >= 0; i--) {
 | 
			
		||||
            centerPointsMap.put(new Point(random.nextInt(DEFAULT_WORLD_SIZE), random.nextInt(DEFAULT_WORLD_SIZE)), TileFluid.ID);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Fill unset tiles
 | 
			
		||||
        for (int y = 0; y < DEFAULT_WORLD_SIZE; y++) {
 | 
			
		||||
            for (int x = 0; x < DEFAULT_WORLD_SIZE; x++) {
 | 
			
		||||
@ -139,26 +147,25 @@ public class WorldGenerator {
 | 
			
		||||
                if (x == 0 || x == DEFAULT_WORLD_SIZE - 1) {
 | 
			
		||||
                    //Vertical (West & East) walls
 | 
			
		||||
                    if (y < 6 || y > 9) {
 | 
			
		||||
                        tile = 1;
 | 
			
		||||
                        tile = TileWall.ID;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        tile = 0;
 | 
			
		||||
                        tile = TilePlain.ID;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (y == 0 || y == DEFAULT_WORLD_SIZE - 1) {
 | 
			
		||||
                    // Horizontal (North & South) walls
 | 
			
		||||
                    if (x < 6 || x > 9) {
 | 
			
		||||
                        tile = 1;
 | 
			
		||||
                        tile = TileWall.ID;
 | 
			
		||||
                    } else {
 | 
			
		||||
                        tile = 0;
 | 
			
		||||
                        tile = TilePlain.ID;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                if (((x == 1 || x == DEFAULT_WORLD_SIZE - 2) && y > 0 && y < DEFAULT_WORLD_SIZE - 1) ||
 | 
			
		||||
                        ((y == 1 || y == DEFAULT_WORLD_SIZE - 2) && x > 0 && x < DEFAULT_WORLD_SIZE - 1)) {
 | 
			
		||||
                    //Inner border
 | 
			
		||||
                    tile = 0;
 | 
			
		||||
                    tile = TilePlain.ID;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                world.getTileMap().setTileAt(tile, x, y);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@ -192,5 +199,4 @@ public class WorldGenerator {
 | 
			
		||||
 | 
			
		||||
        return world;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -19,7 +19,7 @@ public class TerrainRequestHandler implements MessageHandler {
 | 
			
		||||
            try {
 | 
			
		||||
                world = GameServer.INSTANCE.getGameUniverse().getWorld(
 | 
			
		||||
                        Long.valueOf((long) json.get("x")).intValue(),
 | 
			
		||||
                        Long.valueOf((long) json.get("y")).intValue(), false,
 | 
			
		||||
                        Long.valueOf((long) json.get("y")).intValue(), true,
 | 
			
		||||
                        (String) json.get("dimension"));
 | 
			
		||||
            } catch (NullPointerException e) {
 | 
			
		||||
                LogManager.LOGGER.severe("FIXME: handle TerrainRequestHandler");
 | 
			
		||||
 | 
			
		||||
@ -37,6 +37,8 @@ wg_minIronCount=0
 | 
			
		||||
wg_maxIronCount=2
 | 
			
		||||
wg_minCopperCount=0
 | 
			
		||||
wg_maxCopperCount=2
 | 
			
		||||
wg_fluidCenterPointMin=0
 | 
			
		||||
wg_fluidCenterPointMax=2
 | 
			
		||||
#CPU
 | 
			
		||||
tick_length=1000
 | 
			
		||||
org_offset=512
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								Server/src/main/resources/static/js/mar.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								Server/src/main/resources/static/js/mar.js
									
									
									
									
										vendored
									
									
								
							@ -1593,7 +1593,7 @@ var FluidTile = (function (_super) {
 | 
			
		||||
        _this.baseTint = config.tile.fluid;
 | 
			
		||||
        _this.tint = _this.baseTint;
 | 
			
		||||
        _this.alpha = 0.6;
 | 
			
		||||
        _this.baseZ = -15;
 | 
			
		||||
        _this.baseZ = -10;
 | 
			
		||||
        _this.isoZ = _this.baseZ;
 | 
			
		||||
        _this.tileType = "fluid";
 | 
			
		||||
        return _this;
 | 
			
		||||
 | 
			
		||||
@ -565,7 +565,6 @@ class HarvesterNPC extends Cubot {
 | 
			
		||||
                this.tileY = json.y;
 | 
			
		||||
 | 
			
		||||
                this.walk();
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -192,7 +192,7 @@ class FluidTile extends Tile {
 | 
			
		||||
        this.baseTint = config.tile.fluid;
 | 
			
		||||
        this.tint = this.baseTint;
 | 
			
		||||
        this.alpha = 0.6;
 | 
			
		||||
        this.baseZ = -15;
 | 
			
		||||
        this.baseZ = -10;
 | 
			
		||||
        this.isoZ = this.baseZ;
 | 
			
		||||
 | 
			
		||||
        this.tileType = "fluid";
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user