mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 00:26:07 +09:00
more draft on Actor inventory (save <RefID/ItemID, amount>), successfully implemented 9-set hangul johab font, Hashtable -> HashMap
Former-commit-id: 4f51d33a166ca10ee49c471104ebe97aeee33fe7 Former-commit-id: 0066f44d522f3c9d96ad57b92d17a05dc920bffb
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -100,3 +100,12 @@
|
|||||||
|
|
||||||
Scale ^ 3 ^ (3/4)
|
Scale ^ 3 ^ (3/4)
|
||||||
= (ThisWgt / TargetWgt) ^ (3/4)
|
= (ThisWgt / TargetWgt) ^ (3/4)
|
||||||
|
|
||||||
|
|
||||||
|
== (De)serialisation ==
|
||||||
|
|
||||||
|
* Custom binary + GSON
|
||||||
|
|
||||||
|
* Custom binary: Game map
|
||||||
|
|
||||||
|
* GSON: Actors, game configurations
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 19 KiB |
@@ -61,9 +61,9 @@ public class HSVUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Color(
|
return new Color(
|
||||||
(int) ((R_prime + m) * 255)
|
(R_prime + m)
|
||||||
, (int) ((G_prime + m) * 255)
|
, (G_prime + m)
|
||||||
, (int) ((B_prime + m) * 255)
|
, (B_prime + m)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +72,9 @@ public class HSVUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HSV fromRGB(Color color) {
|
public static HSV fromRGB(Color color) {
|
||||||
float r = color.getRed() / 255f;
|
float r = color.r;
|
||||||
float g = color.getGreen() / 255f;
|
float g = color.g;
|
||||||
float b = color.getBlue() / 255f;
|
float b = color.b;
|
||||||
|
|
||||||
float rgbMin = FastMath.min(r, g, b);
|
float rgbMin = FastMath.min(r, g, b);
|
||||||
float rgbMax = FastMath.max(r, g, b);
|
float rgbMax = FastMath.max(r, g, b);
|
||||||
|
|||||||
@@ -10,5 +10,9 @@ public interface Actor {
|
|||||||
|
|
||||||
void update(GameContainer gc, int delta_t);
|
void update(GameContainer gc, int delta_t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid RefID is equal to or greater than 32768.
|
||||||
|
* @return Reference ID. (32768-0x7FFF_FFFF_FFFF_FFFF)
|
||||||
|
*/
|
||||||
long getRefID();
|
long getRefID();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.Torvald.Terrarum.Actors;
|
package com.Torvald.Terrarum.Actors;
|
||||||
|
|
||||||
import com.Torvald.Terrarum.GameItem.InventoryItem;
|
import com.Torvald.Terrarum.GameItem.InventoryItem;
|
||||||
|
import com.Torvald.Terrarum.GameItem.ItemCodex;
|
||||||
import com.sun.istack.internal.Nullable;
|
import com.sun.istack.internal.Nullable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-15.
|
* Created by minjaesong on 16-01-15.
|
||||||
@@ -14,10 +18,13 @@ public class ActorInventory {
|
|||||||
@Nullable private int capacityByWeight;
|
@Nullable private int capacityByWeight;
|
||||||
private int capacityMode;
|
private int capacityMode;
|
||||||
|
|
||||||
private LinkedList<InventoryItem> pocket;
|
/**
|
||||||
|
* <ReferenceID, Amounts>
|
||||||
|
*/
|
||||||
|
private HashMap<Long, Integer> itemList;
|
||||||
|
|
||||||
public final int CAPACITY_MODE_COUNT = 1;
|
public final transient int CAPACITY_MODE_COUNT = 1;
|
||||||
public final int CAPACITY_MODE_WEIGHT = 2;
|
public final transient int CAPACITY_MODE_WEIGHT = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct new inventory with specified capacity.
|
* Construct new inventory with specified capacity.
|
||||||
@@ -53,26 +60,28 @@ public class ActorInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get reference to the pocket
|
* Get reference to the itemList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LinkedList<InventoryItem> getPocket() {
|
public Map<Long, Integer> getItemList() {
|
||||||
return pocket;
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get clone of the pocket
|
* Get clone of the itemList
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LinkedList<InventoryItem> getCopyOfPocket() {
|
public Map getCopyOfItemList() {
|
||||||
return (LinkedList<InventoryItem>) (pocket.clone());
|
return (Map) (itemList.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getTotalWeight() {
|
public float getTotalWeight() {
|
||||||
float weight = 0;
|
float weight = 0;
|
||||||
|
|
||||||
for (InventoryItem item : pocket) {
|
for (Map.Entry<Long, Integer> item : itemList.entrySet()) {
|
||||||
weight += item.getWeight();
|
//weight += item.getWeight();
|
||||||
|
weight += ItemCodex.getItem(item.getKey()).getWeight()
|
||||||
|
* item.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return weight;
|
return weight;
|
||||||
@@ -81,19 +90,24 @@ public class ActorInventory {
|
|||||||
public float getTotalCount() {
|
public float getTotalCount() {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (InventoryItem item : pocket) {
|
for (Map.Entry<Long, Integer> item : itemList.entrySet()) {
|
||||||
count += 1;
|
//weight += item.getWeight();
|
||||||
|
count += item.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendToPocket(InventoryItem item) {
|
public void appendToPocket(InventoryItem item) {
|
||||||
pocket.add(item);
|
long key = item.getItemID();
|
||||||
|
if (itemList.containsKey(key))
|
||||||
|
itemList.put(key, itemList.get(key) + 1);
|
||||||
|
else
|
||||||
|
itemList.put(key, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the pocket contains too many items
|
* Check whether the itemList contains too many items
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isEncumbered() {
|
public boolean isEncumbered() {
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package com.Torvald.Terrarum.Actors;
|
package com.Torvald.Terrarum.Actors;
|
||||||
|
|
||||||
import com.Torvald.Terrarum.KVHashtable;
|
import com.Torvald.Terrarum.KVHashMap;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-03.
|
* Created by minjaesong on 16-01-03.
|
||||||
*/
|
*/
|
||||||
public class ActorValue extends KVHashtable {
|
public class ActorValue extends KVHashMap {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import com.jme3.math.FastMath;
|
|||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-13.
|
* Created by minjaesong on 16-01-13.
|
||||||
*/
|
*/
|
||||||
@@ -19,8 +21,7 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
|||||||
|
|
||||||
ActorInventory inventory;
|
ActorInventory inventory;
|
||||||
|
|
||||||
private @NotNull
|
private @NotNull float hitboxTranslateX; // relative to spritePosX
|
||||||
float hitboxTranslateX; // relative to spritePosX
|
|
||||||
private @NotNull float hitboxTranslateY; // relative to spritePosY
|
private @NotNull float hitboxTranslateY; // relative to spritePosY
|
||||||
private @NotNull int baseHitboxW;
|
private @NotNull int baseHitboxW;
|
||||||
private @NotNull int baseHitboxH;
|
private @NotNull int baseHitboxH;
|
||||||
@@ -34,13 +35,12 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
|||||||
* +3.0 is acceleration. You __accumulate__ acceleration to the velocity.
|
* +3.0 is acceleration. You __accumulate__ acceleration to the velocity.
|
||||||
*/
|
*/
|
||||||
private volatile @NotNull float veloX, veloY;
|
private volatile @NotNull float veloX, veloY;
|
||||||
private final float VELO_HARD_LIMIT = 10000;
|
private final transient float VELO_HARD_LIMIT = 10000;
|
||||||
|
|
||||||
boolean grounded = false;
|
boolean grounded = false;
|
||||||
|
|
||||||
@Nullable
|
@Nullable transient SpriteAnimation sprite;
|
||||||
SpriteAnimation sprite;
|
@Nullable transient SpriteAnimation spriteGlow;
|
||||||
@Nullable SpriteAnimation spriteGlow;
|
|
||||||
/** Default to 'false' */
|
/** Default to 'false' */
|
||||||
private boolean visible = false;
|
private boolean visible = false;
|
||||||
/** Default to 'true' */
|
/** Default to 'true' */
|
||||||
@@ -60,15 +60,15 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
|||||||
/**
|
/**
|
||||||
* Physical properties
|
* Physical properties
|
||||||
*/
|
*/
|
||||||
@NonZero private volatile float scale = 1;
|
@NonZero private volatile transient float scale = 1;
|
||||||
@NonZero private volatile float mass = 2f;
|
@NonZero private volatile transient float mass = 2f;
|
||||||
private final float MASS_LOWEST = 2f;
|
private final transient float MASS_LOWEST = 2f;
|
||||||
/** Valid range: [0, 1] */
|
/** Valid range: [0, 1] */
|
||||||
private float elasticity = 0;
|
private float elasticity = 0;
|
||||||
private final float ELASTICITY_MAX = 0.993f;
|
private final transient float ELASTICITY_MAX = 0.993f;
|
||||||
@NoNegative private float density = 1000;
|
@NoNegative private float density = 1000;
|
||||||
|
|
||||||
private static final int TSIZE = MapDrawer.TILE_SIZE;
|
private static final transient int TSIZE = MapDrawer.TILE_SIZE;
|
||||||
private static int AUTO_CLIMB_RATE = TSIZE / 8;
|
private static int AUTO_CLIMB_RATE = TSIZE / 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,53 +77,53 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
|||||||
* s^2 = 1/FPS = 1/60 if FPS is targeted to 60
|
* s^2 = 1/FPS = 1/60 if FPS is targeted to 60
|
||||||
* meter to pixel : 24/FPS
|
* meter to pixel : 24/FPS
|
||||||
*/
|
*/
|
||||||
private final float METER = 24f;
|
private final transient float METER = 24f;
|
||||||
/**
|
/**
|
||||||
* [m / s^2] * SI_TO_GAME_ACC -> [px / IFrame^2]
|
* [m / s^2] * SI_TO_GAME_ACC -> [px / IFrame^2]
|
||||||
*/
|
*/
|
||||||
private final float SI_TO_GAME_ACC = METER / FastMath.sqr(Terrarum.TARGET_FPS);
|
private final transient float SI_TO_GAME_ACC = METER / FastMath.sqr(Terrarum.TARGET_FPS);
|
||||||
/**
|
/**
|
||||||
* [m / s] * SI_TO_GAME_VEL -> [px / IFrame]
|
* [m / s] * SI_TO_GAME_VEL -> [px / IFrame]
|
||||||
*/
|
*/
|
||||||
private final float SI_TO_GAME_VEL = METER / Terrarum.TARGET_FPS;
|
private final transient float SI_TO_GAME_VEL = METER / Terrarum.TARGET_FPS;
|
||||||
|
|
||||||
private float gravitation;
|
private float gravitation;
|
||||||
private final float DRAG_COEFF = 1f;
|
private final transient float DRAG_COEFF = 1f;
|
||||||
|
|
||||||
private final int CONTACT_AREA_TOP = 0;
|
private final transient int CONTACT_AREA_TOP = 0;
|
||||||
private final int CONTACT_AREA_RIGHT = 1;
|
private final transient int CONTACT_AREA_RIGHT = 1;
|
||||||
private final int CONTACT_AREA_BOTTOM = 2;
|
private final transient int CONTACT_AREA_BOTTOM = 2;
|
||||||
private final int CONTACT_AREA_LEFT = 3;
|
private final transient int CONTACT_AREA_LEFT = 3;
|
||||||
|
|
||||||
private final int UD_COMPENSATOR_MAX = TSIZE;
|
private final transient int UD_COMPENSATOR_MAX = TSIZE;
|
||||||
private final int LR_COMPENSATOR_MAX = TSIZE;
|
private final transient int LR_COMPENSATOR_MAX = TSIZE;
|
||||||
private final int TILE_AUTOCLIMB_RATE = 4;
|
private final transient int TILE_AUTOCLIMB_RATE = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A constant to make falling faster so that the game is more playable
|
* A constant to make falling faster so that the game is more playable
|
||||||
*/
|
*/
|
||||||
private final float G_MUL_PLAYABLE_CONST = 1.4142f;
|
private final transient float G_MUL_PLAYABLE_CONST = 1.4142f;
|
||||||
|
|
||||||
long referenceID;
|
long referenceID;
|
||||||
|
|
||||||
private final int EVENT_MOVE_TOP = 0;
|
private final transient int EVENT_MOVE_TOP = 0;
|
||||||
private final int EVENT_MOVE_RIGHT = 1;
|
private final transient int EVENT_MOVE_RIGHT = 1;
|
||||||
private final int EVENT_MOVE_BOTTOM = 2;
|
private final transient int EVENT_MOVE_BOTTOM = 2;
|
||||||
private final int EVENT_MOVE_LEFT = 3;
|
private final transient int EVENT_MOVE_LEFT = 3;
|
||||||
private final int EVENT_MOVE_NONE = -1;
|
private final transient int EVENT_MOVE_NONE = -1;
|
||||||
|
|
||||||
int eventMoving = EVENT_MOVE_NONE; // cannot collide both X-axis and Y-axis, or else jump control breaks up.
|
int eventMoving = EVENT_MOVE_NONE; // cannot collide both X-axis and Y-axis, or else jump control breaks up.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* in milliseconds
|
* in milliseconds
|
||||||
*/
|
*/
|
||||||
public final int INVINCIBILITY_TIME = 500;
|
public final transient int INVINCIBILITY_TIME = 500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will ignore fluid resistance if (submerged height / actor height) <= this var
|
* Will ignore fluid resistance if (submerged height / actor height) <= this var
|
||||||
*/
|
*/
|
||||||
private final float FLUID_RESISTANCE_IGNORE_THRESHOLD_RATIO = 0.2f;
|
private final transient float FLUID_RESISTANCE_IGNORE_THRESHOLD_RATIO = 0.2f;
|
||||||
private final float FLUID_RESISTANCE_APPLY_FULL_RATIO = 0.5f;
|
private final transient float FLUID_RESISTANCE_APPLY_FULL_RATIO = 0.5f;
|
||||||
|
|
||||||
private GameMap map;
|
private GameMap map;
|
||||||
|
|
||||||
@@ -958,6 +958,10 @@ public class ActorWithBody implements Actor, Visible, Glowing {
|
|||||||
this.noSubjectToFluidResistance = noSubjectToFluidResistance;
|
this.noSubjectToFluidResistance = noSubjectToFluidResistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getElasticity() {
|
||||||
|
return elasticity;
|
||||||
|
}
|
||||||
|
|
||||||
public void setElasticity(float elasticity) {
|
public void setElasticity(float elasticity) {
|
||||||
if (elasticity < 0)
|
if (elasticity < 0)
|
||||||
throw new IllegalArgumentException("[ActorWithBody] " + elasticity + ": valid elasticity value is [0, 1].");
|
throw new IllegalArgumentException("[ActorWithBody] " + elasticity + ": valid elasticity value is [0, 1].");
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.Torvald.Terrarum.GameItem.InventoryItem;
|
|||||||
import com.Torvald.Terrarum.Terrarum;
|
import com.Torvald.Terrarum.Terrarum;
|
||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ public class NPCIntelligentBase extends ActorWithBody implements AIControlled, P
|
|||||||
Factionable, Landholder {
|
Factionable, Landholder {
|
||||||
|
|
||||||
private InventoryItem itemData; // keep it for extendibility, like Carriers in SC1
|
private InventoryItem itemData; // keep it for extendibility, like Carriers in SC1
|
||||||
private ActorAI ai;
|
private transient ActorAI ai;
|
||||||
private ActorInventory inventory;
|
private ActorInventory inventory;
|
||||||
|
|
||||||
private HashSet<Faction> factionSet = new HashSet<>();
|
private HashSet<Faction> factionSet = new HashSet<>();
|
||||||
@@ -51,35 +52,35 @@ public class NPCIntelligentBase extends ActorWithBody implements AIControlled, P
|
|||||||
public void attachItemData() {
|
public void attachItemData() {
|
||||||
itemData = new InventoryItem() {
|
itemData = new InventoryItem() {
|
||||||
@Override
|
@Override
|
||||||
public float getWeight() {
|
public long getItemID() {
|
||||||
return getMass();
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getWeight() {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set no effect */
|
|
||||||
@Override
|
@Override
|
||||||
public void effectWhileInPocket(GameContainer gc, int delta_t) {
|
public void effectWhileInPocket(GameContainer gc, int delta_t) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set no effect */
|
|
||||||
@Override
|
@Override
|
||||||
public void effectWhenPickedUp(GameContainer gc, int delta_t) {
|
public void effectWhenPickedUp(GameContainer gc, int delta_t) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set no effect */
|
|
||||||
@Override
|
@Override
|
||||||
public void primaryUse(GameContainer gc, int delta_t) {
|
public void primaryUse(GameContainer gc, int delta_t) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set no effect */
|
|
||||||
@Override
|
@Override
|
||||||
public void secondaryUse(GameContainer gc, int delta_t) {
|
public void secondaryUse(GameContainer gc, int delta_t) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set no effect */
|
|
||||||
@Override
|
@Override
|
||||||
public void effectWhenThrownAway(GameContainer gc, int delta_t) {
|
public void effectWhenThrownAway(GameContainer gc, int delta_t) {
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.lwjgl.input.Controller;
|
|||||||
import org.lwjgl.input.Controllers;
|
import org.lwjgl.input.Controllers;
|
||||||
import org.newdawn.slick.*;
|
import org.newdawn.slick.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,13 +25,13 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
|||||||
|
|
||||||
int jumpCounter = 0;
|
int jumpCounter = 0;
|
||||||
int walkPowerCounter = 0;
|
int walkPowerCounter = 0;
|
||||||
private final int MAX_JUMP_LENGTH = 17; // use 17; in internal frames
|
private final transient int MAX_JUMP_LENGTH = 17; // use 17; in internal frames
|
||||||
/**
|
/**
|
||||||
* experimental value.
|
* experimental value.
|
||||||
*/
|
*/
|
||||||
// private final float JUMP_ACCELERATION_MOD = ???f / 10000f; //quadratic mode
|
// private final transient float JUMP_ACCELERATION_MOD = ???f / 10000f; //quadratic mode
|
||||||
private final float JUMP_ACCELERATION_MOD = 170f / 10000f; //linear mode
|
private final transient float JUMP_ACCELERATION_MOD = 170f / 10000f; //linear mode
|
||||||
private final int WALK_FRAMES_TO_MAX_ACCEL = 6;
|
private final transient int WALK_FRAMES_TO_MAX_ACCEL = 6;
|
||||||
|
|
||||||
public float readonly_totalX = 0, readonly_totalY = 0;
|
public float readonly_totalX = 0, readonly_totalY = 0;
|
||||||
|
|
||||||
@@ -38,29 +39,29 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
|||||||
|
|
||||||
@NotNull int walkHeading;
|
@NotNull int walkHeading;
|
||||||
|
|
||||||
private final int LEFT = 1;
|
private final transient int LEFT = 1;
|
||||||
private final int RIGHT = 2;
|
private final transient int RIGHT = 2;
|
||||||
|
|
||||||
private int prevHMoveKey = -1;
|
private final transient int KEY_NULL = -1;
|
||||||
private int prevVMoveKey = -1;
|
private int prevHMoveKey = KEY_NULL;
|
||||||
private final int KEY_NULL = -1;
|
private int prevVMoveKey = KEY_NULL;
|
||||||
|
|
||||||
static final float ACCEL_MULT_IN_FLIGHT = 0.48f;
|
static final transient float ACCEL_MULT_IN_FLIGHT = 0.48f;
|
||||||
static final float WALK_STOP_ACCEL = 0.32f;
|
static final transient float WALK_STOP_ACCEL = 0.32f;
|
||||||
static final float WALK_ACCEL_BASE = 0.32f;
|
static final transient float WALK_ACCEL_BASE = 0.32f;
|
||||||
|
|
||||||
private boolean noClip = false;
|
private boolean noClip = false;
|
||||||
|
|
||||||
public static final long PLAYER_REF_ID = 0x51621D;
|
public static final long PLAYER_REF_ID = 0x51621D;
|
||||||
|
|
||||||
private final float AXIS_POSMAX = 1.0f;
|
private final transient float AXIS_POSMAX = 1.0f;
|
||||||
private final int GAMEPAD_JUMP = 5;
|
private final transient int GAMEPAD_JUMP = 5;
|
||||||
|
|
||||||
private final int TSIZE = MapDrawer.TILE_SIZE;
|
private final transient int TSIZE = MapDrawer.TILE_SIZE;
|
||||||
|
|
||||||
private HashSet<Faction> factionSet = new HashSet<>();
|
private HashSet<Faction> factionSet = new HashSet<>();
|
||||||
|
|
||||||
private final int BASE_DENSITY = 1020;
|
private final transient int BASE_DENSITY = 1020;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,13 +92,13 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
|||||||
|
|
||||||
if (noClip) { super.setGrounded(true); }
|
if (noClip) { super.setGrounded(true); }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePhysicalInfos() {
|
private void updatePhysicalInfos() {
|
||||||
super.setScale(actorValue.getAsFloat("scale"));
|
super.setScale(actorValue.getAsFloat("scale"));
|
||||||
super.setMass(actorValue.getAsFloat("basemass")
|
super.setMass(actorValue.getAsFloat("basemass")
|
||||||
* FastMath.pow(super.getScale(), 3));
|
* FastMath.pow(super.getScale(), 3));
|
||||||
|
if (super.getElasticity() != 0) super.setElasticity(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ package com.Torvald.Terrarum.ConsoleCommand;
|
|||||||
|
|
||||||
import com.Torvald.Terrarum.Terrarum;
|
import com.Torvald.Terrarum.Terrarum;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-15.
|
* Created by minjaesong on 16-01-15.
|
||||||
*/
|
*/
|
||||||
public class CommandDict {
|
public class CommandDict {
|
||||||
|
|
||||||
protected static Hashtable<String, ConsoleCommand> dict;
|
protected static HashMap<String, ConsoleCommand> dict;
|
||||||
|
|
||||||
public CommandDict() {
|
public CommandDict() {
|
||||||
dict = new Hashtable<>();
|
dict = new HashMap<>();
|
||||||
|
|
||||||
dict.put("echo", new Echo());
|
dict.put("echo", new Echo());
|
||||||
dict.put("setav", new SetAV());
|
dict.put("setav", new SetAV());
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.Torvald.Terrarum;
|
package com.Torvald.Terrarum;
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 15-12-30.
|
* Created by minjaesong on 15-12-30.
|
||||||
*/
|
*/
|
||||||
public class GameConfig extends KVHashtable{
|
public class GameConfig extends KVHashMap {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ import org.newdawn.slick.GameContainer;
|
|||||||
*/
|
*/
|
||||||
public interface InventoryItem {
|
public interface InventoryItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get internal ID of an Item.
|
||||||
|
* 0-4096: Tiles
|
||||||
|
* 4097-32767: Various items
|
||||||
|
* >=32768: Actor RefID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
long getItemID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Weight of the item
|
* Weight of the item
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
20
src/com/Torvald/Terrarum/GameItem/ItemCodex.java
Normal file
20
src/com/Torvald/Terrarum/GameItem/ItemCodex.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package com.Torvald.Terrarum.GameItem;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 16-03-11.
|
||||||
|
*/
|
||||||
|
public class ItemCodex {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <ItemID or RefID for Actor, TheItem>
|
||||||
|
* Will return corresponding Actor if ID >= 32768
|
||||||
|
*/
|
||||||
|
private static HashMap<Long, InventoryItem> itemCodex;
|
||||||
|
|
||||||
|
public static InventoryItem getItem(long code) {
|
||||||
|
return itemCodex.get(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ package com.Torvald.Terrarum.GameMap;
|
|||||||
import com.sun.istack.internal.NotNull;
|
import com.sun.istack.internal.NotNull;
|
||||||
import org.newdawn.slick.SlickException;
|
import org.newdawn.slick.SlickException;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
@@ -32,9 +33,9 @@ public class GameMap {
|
|||||||
public int spawnX;
|
public int spawnX;
|
||||||
public int spawnY;
|
public int spawnY;
|
||||||
|
|
||||||
public static final int WALL = 0;
|
public static transient final int WALL = 0;
|
||||||
public static final int TERRAIN = 1;
|
public static transient final int TERRAIN = 1;
|
||||||
public static final int WIRE = 2;
|
public static transient final int WIRE = 2;
|
||||||
|
|
||||||
//public World physWorld = new World( new Vec2(0, -TerrarumMain.game.gravitationalAccel) );
|
//public World physWorld = new World( new Vec2(0, -TerrarumMain.game.gravitationalAccel) );
|
||||||
//physics
|
//physics
|
||||||
@@ -42,7 +43,7 @@ public class GameMap {
|
|||||||
private char globalLight;
|
private char globalLight;
|
||||||
private WorldTime worldTime;
|
private WorldTime worldTime;
|
||||||
|
|
||||||
public static final int TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE;
|
public static transient final int TILES_SUPPORTED = MapLayer.RANGE * PairedMapLayer.RANGE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param width
|
* @param width
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.Torvald.Terrarum.GameMap;
|
package com.Torvald.Terrarum.GameMap;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -14,7 +15,7 @@ public class MapLayer implements Iterable<Byte> {
|
|||||||
public int width;
|
public int width;
|
||||||
public int height;
|
public int height;
|
||||||
|
|
||||||
public static final int RANGE = 256;
|
public static transient final int RANGE = 256;
|
||||||
|
|
||||||
public MapLayer(int width, int height) {
|
public MapLayer(int width, int height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.Torvald.Terrarum.GameMap;
|
|||||||
|
|
||||||
import com.Torvald.Point.Point2f;
|
import com.Torvald.Point.Point2f;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
public class MapPoint {
|
public class MapPoint {
|
||||||
private Point2f startPoint;
|
private Point2f startPoint;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.Torvald.Terrarum.GameMap;
|
package com.Torvald.Terrarum.GameMap;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -22,7 +23,7 @@ public class PairedMapLayer implements Iterable<Integer> {
|
|||||||
public int width;
|
public int width;
|
||||||
public int height;
|
public int height;
|
||||||
|
|
||||||
public static final int RANGE = 16;
|
public static transient final int RANGE = 16;
|
||||||
|
|
||||||
public PairedMapLayer(int width, int height) {
|
public PairedMapLayer(int width, int height) {
|
||||||
this.width = width / 2;
|
this.width = width / 2;
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
package com.Torvald.Terrarum.GameMap;
|
package com.Torvald.Terrarum.GameMap;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-24.
|
* Created by minjaesong on 16-01-24.
|
||||||
*/
|
*/
|
||||||
public class WorldTime {
|
public class WorldTime {
|
||||||
|
|
||||||
public int seconds = 0;
|
private int seconds = 0;
|
||||||
public int minutes = 0;
|
private int minutes = 0;
|
||||||
public int hours = 0;
|
private int hours = 0;
|
||||||
|
|
||||||
public int daysCount = 0; //NOT a calendar day
|
private int daysCount = 0; //NOT a calendar day
|
||||||
|
|
||||||
public int days = 1;
|
private int days = 1;
|
||||||
public int months = 1;
|
private int months = 1;
|
||||||
public int years = 1;
|
private int years = 1;
|
||||||
|
|
||||||
public int weeks = 1;
|
private int dayOfWeek = 0; //0: Mondag-The first day of weekday
|
||||||
public int dayOfWeek = 0; //0: Mondag-The first day of weekday
|
|
||||||
|
|
||||||
public static final int DAY_LENGTH = 79200; //must be the multiple of 3600
|
public static transient final int DAY_LENGTH = 79200; //must be the multiple of 3600
|
||||||
public int timeDelta = 1;
|
private int timeDelta = 1;
|
||||||
|
|
||||||
|
private static transient final int HOUR_SEC = 3600;
|
||||||
|
private static transient final int MINUTE_SEC = 60;
|
||||||
|
|
||||||
public final String[] DAYNAMES = { //daynames are taken from Nynorsk (å -> o)
|
public final String[] DAYNAMES = { //daynames are taken from Nynorsk (å -> o)
|
||||||
"Mondag"
|
"Mondag"
|
||||||
@@ -52,22 +56,7 @@ public class WorldTime {
|
|||||||
//time
|
//time
|
||||||
seconds += timeDelta;
|
seconds += timeDelta;
|
||||||
|
|
||||||
if (seconds >= 60){
|
kickVariables();
|
||||||
seconds = 0;
|
|
||||||
minutes++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minutes >= 60){
|
|
||||||
minutes = 0;
|
|
||||||
hours++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hours >= DAY_LENGTH/3600){
|
|
||||||
hours = 0;
|
|
||||||
days++;
|
|
||||||
daysCount++;
|
|
||||||
dayOfWeek++;
|
|
||||||
}
|
|
||||||
|
|
||||||
//calendar (the world calendar)
|
//calendar (the world calendar)
|
||||||
if (dayOfWeek == 7){
|
if (dayOfWeek == 7){
|
||||||
@@ -97,37 +86,31 @@ public class WorldTime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much time has passed today, in seconds.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public int elapsedSeconds(){
|
public int elapsedSeconds(){
|
||||||
return (3600 * hours + 60 * minutes + seconds) % DAY_LENGTH;
|
return (HOUR_SEC * hours + MINUTE_SEC * minutes + seconds) % DAY_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How much time has passed since the beginning, in seconds.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public long totalSeconds(){
|
public long totalSeconds(){
|
||||||
return (long)(DAY_LENGTH) * daysCount + 3600 * hours + 60 * minutes + seconds;
|
return (long)(DAY_LENGTH) * daysCount + HOUR_SEC * hours + MINUTE_SEC * minutes + seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLeapYear(){
|
public boolean isLeapYear(){
|
||||||
boolean ret = false;
|
return ((years % 4 == 0) && (years % 100 != 0)) || (years % 400 == 0);
|
||||||
|
|
||||||
if (years % 4 == 0){
|
|
||||||
ret = true;
|
|
||||||
|
|
||||||
if (years % 100 == 0){
|
|
||||||
ret = false;
|
|
||||||
|
|
||||||
if (years % 400 == 0){
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTime(int t){
|
public void setTime(int t){
|
||||||
days += t / DAY_LENGTH;
|
days += t / DAY_LENGTH;
|
||||||
hours = t / 3600;
|
hours = t / HOUR_SEC;
|
||||||
minutes = (t - 3600 * hours) / 60;
|
minutes = (t - HOUR_SEC * hours) / MINUTE_SEC;
|
||||||
seconds = t - minutes * 60;
|
seconds = t - minutes * MINUTE_SEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTime(int t){
|
public void addTime(int t){
|
||||||
@@ -141,4 +124,23 @@ public class WorldTime {
|
|||||||
public String getDayName(){
|
public String getDayName(){
|
||||||
return DAYNAMES[dayOfWeek];
|
return DAYNAMES[dayOfWeek];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void kickVariables() {
|
||||||
|
if (seconds >= 60){
|
||||||
|
seconds = 0;
|
||||||
|
minutes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minutes >= 60){
|
||||||
|
minutes = 0;
|
||||||
|
hours++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hours >= DAY_LENGTH/3600){
|
||||||
|
hours = 0;
|
||||||
|
days++;
|
||||||
|
daysCount++;
|
||||||
|
dayOfWeek++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
package com.Torvald.Terrarum;
|
package com.Torvald.Terrarum;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 15-12-30.
|
* Created by minjaesong on 15-12-30.
|
||||||
*/
|
*/
|
||||||
public class KVHashtable {
|
public class KVHashMap {
|
||||||
|
|
||||||
private Hashtable<String, Object> hashtable;
|
private HashMap<String, Object> hashMap;
|
||||||
|
|
||||||
public KVHashtable() {
|
public KVHashMap() {
|
||||||
hashtable = new Hashtable<>();
|
hashMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +24,7 @@ public class KVHashtable {
|
|||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
public void set(String key, Object value){
|
public void set(String key, Object value){
|
||||||
hashtable.put(key.toLowerCase(), value);
|
hashMap.put(key.toLowerCase(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,7 +34,7 @@ public class KVHashtable {
|
|||||||
* @return Object value
|
* @return Object value
|
||||||
*/
|
*/
|
||||||
public Object get(String key){
|
public Object get(String key){
|
||||||
return hashtable.get(key.toLowerCase());
|
return hashMap.get(key.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAsInt(String key) {
|
public int getAsInt(String key) {
|
||||||
@@ -55,11 +56,11 @@ public class KVHashtable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasKey(String key) {
|
public boolean hasKey(String key) {
|
||||||
return hashtable.containsKey(key);
|
return hashMap.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set getKeySet() {
|
public Set getKeySet() {
|
||||||
return hashtable.keySet();
|
return hashMap.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -100,3 +100,12 @@
|
|||||||
|
|
||||||
Scale ^ 3 ^ (3/4)
|
Scale ^ 3 ^ (3/4)
|
||||||
= (ThisWgt / TargetWgt) ^ (3/4)
|
= (ThisWgt / TargetWgt) ^ (3/4)
|
||||||
|
|
||||||
|
|
||||||
|
== (De)serialisation ==
|
||||||
|
|
||||||
|
* Custom binary + GSON
|
||||||
|
|
||||||
|
* Custom binary: Game map
|
||||||
|
|
||||||
|
* GSON: Actors, game configurations
|
||||||
Reference in New Issue
Block a user