Removed lots of unused code
This commit is contained in:
parent
55ea5e6c55
commit
fe1f97f248
|
|
@ -308,10 +308,6 @@ public class DisplayLighting
|
|||
(float)(lighting.y * 16 - Camera.camera.y - 0.5));
|
||||
}
|
||||
|
||||
else {
|
||||
System.out.println("CAMERA IS NULL");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void clearLighting()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import projectzombie.Main;
|
|||
import projectzombie.entity.player.EntityPlayer;
|
||||
import projectzombie.model.Model;
|
||||
import projectzombie.util.math.ColorRange;
|
||||
import projectzombie.world.chunk.Chunk;
|
||||
import projectzombie.world.chunk.ChunkEventHandler;
|
||||
|
||||
public class DisplayRender
|
||||
|
|
@ -42,7 +43,7 @@ public class DisplayRender
|
|||
Camera.camera = camera;
|
||||
|
||||
// Create the projection matrix
|
||||
Matrix4 projection = Matrix4.projection((double)w / (double)h, 45, 0.1, 1000);
|
||||
Matrix4 projection = Matrix4.projection((double)w / (double)h, 45, 0.1, Chunk.RENDER_DISTANCE*16+32);
|
||||
projection = Matrix4.multiply(camera.getMatrix(), projection);
|
||||
|
||||
Matrix4 rotated = Matrix4.rotate(-camera.angle, 0, 1, 0);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ public class DisplayRenderUI
|
|||
|
||||
public static Matrix4 camera, projection;
|
||||
|
||||
private static float calculateGreen(double a) {
|
||||
return (float)(-2 * a * (a - 1) + 0.25 * a * a);
|
||||
}
|
||||
|
||||
public static void renderGameGui()
|
||||
{
|
||||
{
|
||||
|
|
@ -85,12 +89,12 @@ public class DisplayRenderUI
|
|||
model_health_f.render();
|
||||
|
||||
double temperature = MathHelpers.smoothStep(Main.player.getTemperature());
|
||||
double hydration = MathHelpers.squared(1 - Main.player.getHydration());
|
||||
double hydration = MathHelpers.smoothStep(1 - Main.player.getHydration());
|
||||
|
||||
GL33.glUniform2f(Main.window.glsl_tex_cut, 0, 0);
|
||||
|
||||
GL33.glUniform4f(Main.window.glsl_color,
|
||||
(float)temperature, (float)temperature * 0.25f, 1 - (float)temperature, 1);
|
||||
(float)temperature, calculateGreen(temperature), 1 - (float)temperature, 1);
|
||||
|
||||
matrix = Matrix4.translate(-(9 * 0.75) / 8, -9.5 + (1.5 * 17) / 16, 0);
|
||||
|
||||
|
|
@ -98,7 +102,7 @@ public class DisplayRenderUI
|
|||
model_temperature.render();
|
||||
|
||||
GL33.glUniform4f(Main.window.glsl_color,
|
||||
(float)hydration, (float)hydration * 0.25f, 1 - (float)hydration, 1);
|
||||
(float)hydration * 0.75f, calculateGreen(hydration), 1 - (float)hydration, 1);
|
||||
|
||||
matrix = Matrix4.translate((1 * 0.75) / 8, -9.5 + (1.5 * 17) / 16, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,10 @@ public abstract class Entity implements IBdfClassManager
|
|||
public Chunk chunk;
|
||||
private TileState tile_front;
|
||||
private TileState tile_back;
|
||||
public boolean crossUnWalkable = true;
|
||||
public boolean goThroughSolid = true;
|
||||
protected static final Random rand = new Random();
|
||||
public boolean emitsLight = false;
|
||||
public int stepOnTileCooldown = 0;
|
||||
private boolean dead = false;
|
||||
protected boolean gravity = true;
|
||||
private boolean isDead = false;
|
||||
protected boolean hasGravity = true;
|
||||
|
||||
private Vec3d pos;
|
||||
private Vec3d velocity;
|
||||
|
|
@ -43,7 +40,7 @@ public abstract class Entity implements IBdfClassManager
|
|||
public abstract IModel getModel();
|
||||
|
||||
public boolean isDead() {
|
||||
return dead;
|
||||
return isDead;
|
||||
}
|
||||
|
||||
public Vec3d getPos() {
|
||||
|
|
@ -142,11 +139,8 @@ public abstract class Entity implements IBdfClassManager
|
|||
velocity = new Vec3d(e.get(1));
|
||||
hitbox = e.get(2).getDouble();
|
||||
isSolid = e.get(3).getBoolean();
|
||||
crossUnWalkable = e.get(4).getBoolean();
|
||||
goThroughSolid = e.get(5).getBoolean();
|
||||
emitsLight = e.get(6).getBoolean();
|
||||
stepOnTileCooldown = e.get(7).getInteger();
|
||||
gravity = e.get(8).getBoolean();
|
||||
hasGravity = e.get(8).getBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -165,18 +159,12 @@ public abstract class Entity implements IBdfClassManager
|
|||
BdfObject velocity_bdf = new BdfObject();
|
||||
velocity.BdfClassSave(velocity_bdf);
|
||||
|
||||
BdfArray e = new BdfArray();
|
||||
nl.set("e", BdfObject.withArray(e));
|
||||
|
||||
e.add(pos_bdf);
|
||||
e.add(velocity_bdf);
|
||||
e.add(BdfObject.withDouble(hitbox));
|
||||
e.add(BdfObject.withBoolean(isSolid));
|
||||
e.add(BdfObject.withBoolean(crossUnWalkable));
|
||||
e.add(BdfObject.withBoolean(goThroughSolid));
|
||||
e.add(BdfObject.withBoolean(emitsLight));
|
||||
e.add(BdfObject.withInteger(stepOnTileCooldown));
|
||||
e.add(BdfObject.withBoolean(gravity));
|
||||
nl.set("pos", pos_bdf);
|
||||
nl.set("velocity", velocity_bdf);
|
||||
nl.set("hitbox", BdfObject.withDouble(hitbox));
|
||||
nl.set("isSolid", BdfObject.withBoolean(isSolid));
|
||||
nl.set("emitsLight", BdfObject.withBoolean(emitsLight));
|
||||
nl.set("hasGravity", BdfObject.withBoolean(hasGravity));
|
||||
}
|
||||
|
||||
public void tick(Chunk chunk, Layer layer)
|
||||
|
|
@ -189,10 +177,6 @@ public abstract class Entity implements IBdfClassManager
|
|||
tile_back = chunk.getBackTile(tpos);
|
||||
tile_front = chunk.getFrontTile(tpos);
|
||||
|
||||
if(stepOnTileCooldown > 0) {
|
||||
stepOnTileCooldown -= 1;
|
||||
}
|
||||
|
||||
Vec3d new_pos = pos.add(velocity);
|
||||
|
||||
if(isSolid) {
|
||||
|
|
@ -221,7 +205,7 @@ public abstract class Entity implements IBdfClassManager
|
|||
pos.y = 0;
|
||||
}
|
||||
|
||||
if(gravity) {
|
||||
if(hasGravity) {
|
||||
velocity.y -= MathHelpers.FallSpeed;
|
||||
}
|
||||
|
||||
|
|
@ -232,11 +216,11 @@ public abstract class Entity implements IBdfClassManager
|
|||
|
||||
protected void moveAwayFromSolidEntities(Layer layer)
|
||||
{
|
||||
if(!goThroughSolid)
|
||||
if(isSolid)
|
||||
{
|
||||
for(Entity e : layer.getNearbyEntities(pos.xz(), hitbox))
|
||||
{
|
||||
if(e.isSolid && !e.goThroughSolid && e != this)
|
||||
if(e.isSolid && e != this)
|
||||
{
|
||||
double distance = pos.distance(e.pos);
|
||||
double angle = MathHelpers.atan2(e.pos.z - pos.z, e.pos.x - pos.x);
|
||||
|
|
@ -255,7 +239,7 @@ public abstract class Entity implements IBdfClassManager
|
|||
|
||||
public void kill() {
|
||||
chunk.killEntity(this);
|
||||
dead = true;
|
||||
isDead = true;
|
||||
}
|
||||
|
||||
public void activateTile()
|
||||
|
|
@ -270,9 +254,6 @@ public abstract class Entity implements IBdfClassManager
|
|||
}
|
||||
|
||||
public void activateSteppedOnTile()
|
||||
{
|
||||
// Has the cooldown expired
|
||||
if(stepOnTileCooldown == 0)
|
||||
{
|
||||
// Get the tile position and the layer
|
||||
Layer layer = Main.world.getLayer();
|
||||
|
|
@ -281,10 +262,6 @@ public abstract class Entity implements IBdfClassManager
|
|||
// Activate both tiles
|
||||
tile_front.tile.onWalkedOn(chunk, layer, tpos, this, tile_front);
|
||||
tile_back.tile.onWalkedOn(chunk, layer, tpos, this, tile_back);
|
||||
|
||||
// Reset the cooldown
|
||||
stepOnTileCooldown = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean moveIsLegal(Vec2d pos)
|
||||
|
|
@ -295,7 +272,7 @@ public abstract class Entity implements IBdfClassManager
|
|||
tile_front = chunk.getFrontTile(t_pos);
|
||||
|
||||
// Is this entity solid
|
||||
if(!goThroughSolid || !crossUnWalkable)
|
||||
if(isSolid)
|
||||
{
|
||||
// Check the tile the player is standing on
|
||||
Vec2i tpos = new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0);
|
||||
|
|
@ -304,13 +281,8 @@ public abstract class Entity implements IBdfClassManager
|
|||
// Get the tile
|
||||
Tile t = tile_back.tile;
|
||||
|
||||
// Send false if the tile isn't walkable
|
||||
if((!t.tileWalkable) && (!crossUnWalkable)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the tiles hitbox if the tile is solid
|
||||
if((t.tileSolid) && (!goThroughSolid))
|
||||
if(t.tileSolid)
|
||||
{
|
||||
// Is the entity in the tiles hitbox
|
||||
if(pos.squareDistance(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)) < t.tileHitbox)
|
||||
|
|
@ -325,13 +297,8 @@ public abstract class Entity implements IBdfClassManager
|
|||
// Get the front tile
|
||||
Tile t = tile_front.tile;
|
||||
|
||||
// Send false if the tile isn't walkable
|
||||
if((!t.tileWalkable) && (!crossUnWalkable)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the tiles hitbox if the tile is solid
|
||||
if((t.tileSolid) && (!goThroughSolid))
|
||||
if(t.tileSolid)
|
||||
{
|
||||
// Is the entity in the tiles hitbox
|
||||
if(pos.squareDistance(new Vec2d(tpos.x + 0.5, tpos.y + 0.5)) < t.tileHitbox)
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
|||
spawn_frequency = nl.get("spawn_frq").getInteger();
|
||||
|
||||
this.isSolid = true;
|
||||
this.goThroughSolid = false;
|
||||
this.crossUnWalkable = false;
|
||||
this.hitbox = 2;
|
||||
|
||||
long seed = nl.get("seed").getLong();
|
||||
|
|
@ -84,8 +82,6 @@ public class EntityBoss extends Entity implements IBossBar, EntityKillWithPartic
|
|||
super(pos, velocity);
|
||||
|
||||
this.isSolid = true;
|
||||
this.goThroughSolid = false;
|
||||
this.crossUnWalkable = false;
|
||||
this.hitbox = 2;
|
||||
|
||||
long seed = rand.nextLong();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class EntityBullet extends EntityParticle
|
|||
this.parent = parent;
|
||||
this.damage = damage;
|
||||
this.time = despawn_time;
|
||||
this.gravity = false;
|
||||
this.hasGravity = false;
|
||||
|
||||
// Play the gun sound
|
||||
Sounds.GUN.play(pos, 2);
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ public class EntityTnt extends Entity implements EntityHoldsEntities
|
|||
Vec2d v = MathHelpers.moveTowards2(0.05, Math.toRadians(angle));
|
||||
velocity = velocity.add(new Vec3d(v.x, v.y, 0.01));
|
||||
this.explode_radius = explode_radius;
|
||||
this.crossUnWalkable = true;
|
||||
this.goThroughSolid = false;
|
||||
this.explode_damage = explode_damage;
|
||||
this.smoke_particles = new ParticleSpark[100];
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
|||
private Vec3d walk_to;
|
||||
private int walk_scan_cooldown = 0;
|
||||
private boolean can_see_player = false;
|
||||
protected boolean crossUnwalkable = false;
|
||||
private int walking_for = 0;
|
||||
|
||||
public EntityZombie(BdfObject bdf) {
|
||||
|
|
@ -44,8 +45,6 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
|||
// Set some settings
|
||||
hitbox = 0.5;
|
||||
isSolid = true;
|
||||
goThroughSolid = false;
|
||||
crossUnWalkable = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -99,8 +98,6 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
|||
// Set some settings
|
||||
hitbox = 0.5;
|
||||
isSolid = true;
|
||||
goThroughSolid = false;
|
||||
crossUnWalkable = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -122,7 +119,7 @@ public class EntityZombie extends Entity implements EntityAlive, EntityKillWithP
|
|||
(walk_to != null && getPos().toInt().equal(walk_to.toInt()) &&
|
||||
player_distance > 2) || walk_scan_cooldown < 1 || walking_for > 200)
|
||||
{
|
||||
AStar astar = new AStar(getPos().xz().toInt(), 16, new AStarSearcher(layer, crossUnWalkable));
|
||||
AStar astar = new AStar(getPos().xz().toInt(), 16, new AStarSearcher(layer));
|
||||
Vec2i path[] = astar.getPath(Main.player.getPos().xz().toInt());
|
||||
|
||||
walk_scan_cooldown = 100;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class EntityZombieArmored extends EntityZombie
|
|||
this.health = this.health_max;
|
||||
this.gun_level = 3;
|
||||
|
||||
this.crossUnWalkable = true;
|
||||
this.crossUnwalkable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ParticleBreak extends EntityParticle implements IModel
|
|||
protected ParticleBreak(Vec3d pos, Vec3d velocity, IModel model, int count, double velocity_up_multiplier) {
|
||||
super(pos, new Vec3d(0, 0, 0));
|
||||
|
||||
this.gravity = false;
|
||||
this.hasGravity = false;
|
||||
|
||||
double model_height = model.getHeight();
|
||||
TextureRef3D[] textures = model.getTextures();
|
||||
|
|
|
|||
|
|
@ -94,15 +94,13 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
|||
}
|
||||
|
||||
public EntityPlayer() {
|
||||
super(new Vec3d(0, 0, 0), new Vec3d(0, 0, 0));
|
||||
super(new Vec3d(Math.pow(2, 30), 0, -Math.pow(2, 30)), new Vec3d(0, 0, 0));
|
||||
|
||||
this.angle = 45;
|
||||
|
||||
// Set some settings
|
||||
hitbox = 0.5;
|
||||
isSolid = true;
|
||||
goThroughSolid = false;
|
||||
crossUnWalkable = false;
|
||||
emitsLight = true;
|
||||
|
||||
// Create the inventory
|
||||
|
|
@ -190,7 +188,7 @@ public class EntityPlayer extends Entity implements EntityAlive, EntityInventory
|
|||
chunk.getLightLevel(getPos().xz().toInt()) * 0.6) - temperature;
|
||||
|
||||
temperature += temp_diff / 1000;
|
||||
hydration -= Math.sqrt(Math.abs(temperature - 0.5)) / 5000;
|
||||
hydration -= MathHelpers.smoothStep(Math.abs(temperature - 0.4) + 0.1) / 1000;
|
||||
|
||||
if(temperature < 0.3) {
|
||||
health -= 0.3 - temperature;
|
||||
|
|
|
|||
Loading…
Reference in New Issue