mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
Compare commits
1 Commits
test-cvec-
...
lwjgl3-mig
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f30e7fd45b |
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -4,4 +4,3 @@
|
|||||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
*.opus filter=lfs diff=lfs merge=lfs -text
|
*.opus filter=lfs diff=lfs merge=lfs -text
|
||||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
|
||||||
|
|||||||
23
.idea/inspectionProfiles/Project_Default.xml
generated
23
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,23 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="ArrayEquality" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
<inspection_tool class="ConstantConditionIf" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="CsvValidation" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="ExplicitThis" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="KotlinDoubleNegation" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
<inspection_tool class="NullChecksToSafeCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RedundantCompanionReference" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RedundantExplicitType" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RedundantGetter" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RedundantSetter" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RedundantUnitExpression" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RedundantUnitReturnType" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RemoveCurlyBracesFromTemplate" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RemoveEmptyPrimaryConstructor" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RemoveEmptySecondaryConstructorBody" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RemoveRedundantBackticks" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RemoveRedundantQualifierName" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
<inspection_tool class="RemoveSingleExpressionStringTemplate" enabled="false" level="WARNING" enabled_by_default="false" />
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
||||||
2
.idea/markdown-navigator/profiles_settings.xml
generated
2
.idea/markdown-navigator/profiles_settings.xml
generated
@@ -1,3 +1,3 @@
|
|||||||
<component name="MarkdownNavigator.ProfileManager">
|
<component name="MarkdownNavigator.ProfileManager">
|
||||||
<settings default="" pdf-export="" plain-text-search-scope="Project Files" />
|
<settings default="" pdf-export="" />
|
||||||
</component>
|
</component>
|
||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -38,7 +38,7 @@
|
|||||||
<property name="caretWidth" class="java.lang.Integer" />
|
<property name="caretWidth" class="java.lang.Integer" />
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="false" project-jdk-name="13-incubate" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,5 @@
|
|||||||
"id";"classname"
|
"id";"classname"
|
||||||
"8448";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper"
|
"8448";"net.torvald.terrarum.modulebasegame.items.PickaxeCopper"
|
||||||
"8449";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron"
|
"8449";"net.torvald.terrarum.modulebasegame.items.PickaxeIron"
|
||||||
"8450";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel"
|
"8450";"net.torvald.terrarum.modulebasegame.items.PickaxeSteel"
|
||||||
"8466";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire"
|
"8466";"net.torvald.terrarum.modulebasegame.items.WirePieceSignalWire"
|
||||||
"8467";"net.torvald.terrarum.modulebasegame.gameitems.TikiTorchTester"
|
|
||||||
|
|||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
import net.torvald.terrarum.itemproperties.Material
|
||||||
import org.jetbrains.annotations.NotNull
|
import org.jetbrains.annotations.NotNull
|
||||||
import org.jetbrains.annotations.Nullable
|
import org.jetbrains.annotations.Nullable
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.itemproperties.Calculate
|
import net.torvald.terrarum.itemproperties.Calculate
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
import net.torvald.terrarum.itemproperties.Material
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
// following two are NOT UNUSED!
|
// following two are NOT UNUSED!
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
# complete file name is: SPRITESHEET + bodypart name + EXTENSION
|
|
||||||
SPRITESHEET=mods/basegame/sprites/test_furry/furbud_
|
|
||||||
EXTENSION=.tga
|
|
||||||
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
|
|
||||||
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
|
|
||||||
CONFIG=SIZE 48,56;ORIGINX 29
|
|
||||||
|
|
||||||
# note to self: don't implement skeleton hierarchy: there's too many exceptions
|
|
||||||
# besides, you have "ALL" key.
|
|
||||||
|
|
||||||
! a skeleton also defines what body parts (images) be used.
|
|
||||||
! you can also write multiline text using reverse solidus; this is a feature of .properties
|
|
||||||
! skeleton joints are ordered: foremost-drawn object comes first, which means lowermost object IN THIS LIST
|
|
||||||
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
|
||||||
! first reversed then being iterated.
|
|
||||||
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
|
|
||||||
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
|
|
||||||
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
|
||||||
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
|
||||||
HAIR 0,32;HEAD 0,32;\
|
|
||||||
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
|
||||||
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
|
||||||
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
|
||||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
|
||||||
TAIL_0 0,13;TAIL_1 0,13
|
|
||||||
|
|
||||||
# skeleton_stand is used for testing purpose
|
|
||||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
|
||||||
ANIM_RUN_1=TAIL_0 0,-999;LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0
|
|
||||||
ANIM_RUN_2=TAIL_1 0,-999;ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1
|
|
||||||
ANIM_RUN_3=TAIL_1 0,-999;LEG_REST_RIGHT -1,0;FOOT_RIGHT -1,0;LEG_REST_LEFT 1,1;FOOT_LEFT 1,1
|
|
||||||
ANIM_RUN_4=TAIL_0 0,-999;ALL 0,1;LEG_REST_RIGHT 0,1;FOOT_RIGHT 0,1;LEG_REST_LEFT 0,-1;FOOT_LEFT 0,-1
|
|
||||||
|
|
||||||
|
|
||||||
ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND
|
|
||||||
ANIM_IDLE_1=TAIL_1 0,-999
|
|
||||||
ANIM_IDLE_2=TAIL_1 0,-999;\
|
|
||||||
UPPER_TORSO 0,-1;HEAD 0,-1;HAIR 0,-1;HELD_ITEM 0,-1;\
|
|
||||||
ARM_REST_LEFT 0,-1;ARM_REST_RIGHT 0,-1;HAND_REST_LEFT 0,-1;HAND_REST_RIGHT 0,-1;\
|
|
||||||
HAIR_FORE 0,-1;HEADGEAR 0,-1
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
# complete file name is: SPRITESHEET + bodypart name + EXTENSION
|
|
||||||
SPRITESHEET=mods/basegame/sprites/test_furry/furbudglow_
|
|
||||||
EXTENSION=.tga
|
|
||||||
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
|
|
||||||
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
|
|
||||||
CONFIG=SIZE 48,56;ORIGINX 29
|
|
||||||
|
|
||||||
# note to self: don't implement skeleton hierarchy: there's too many exceptions
|
|
||||||
# besides, you have "ALL" key.
|
|
||||||
|
|
||||||
! a skeleton also defines what body parts (images) be used.
|
|
||||||
! you can also write multiline text using reverse solidus; this is a feature of .properties
|
|
||||||
! skeleton joints are ordered: foremost-drawn object comes first, which means lowermost object IN THIS LIST
|
|
||||||
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
|
||||||
! first reversed then being iterated.
|
|
||||||
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
|
|
||||||
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
|
|
||||||
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
|
||||||
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
|
||||||
HAIR 0,32;HEAD 0,32;\
|
|
||||||
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
|
||||||
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
|
||||||
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
|
||||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
|
||||||
TAIL_0 0,13;TAIL_1 0,13
|
|
||||||
|
|
||||||
# skeleton_stand is used for testing purpose
|
|
||||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
|
||||||
ANIM_RUN_1=TAIL_0 0,-999;LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0
|
|
||||||
ANIM_RUN_2=TAIL_1 0,-999;ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1
|
|
||||||
ANIM_RUN_3=TAIL_1 0,-999;LEG_REST_RIGHT -1,0;FOOT_RIGHT -1,0;LEG_REST_LEFT 1,1;FOOT_LEFT 1,1
|
|
||||||
ANIM_RUN_4=TAIL_0 0,-999;ALL 0,1;LEG_REST_RIGHT 0,1;FOOT_RIGHT 0,1;LEG_REST_LEFT 0,-1;FOOT_LEFT 0,-1
|
|
||||||
|
|
||||||
|
|
||||||
ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND
|
|
||||||
ANIM_IDLE_1=TAIL_1 0,-999
|
|
||||||
ANIM_IDLE_2=TAIL_1 0,-999;\
|
|
||||||
UPPER_TORSO 0,-1;HEAD 0,-1;HAIR 0,-1;HELD_ITEM 0,-1;\
|
|
||||||
ARM_REST_LEFT 0,-1;ARM_REST_RIGHT 0,-1;HAND_REST_LEFT 0,-1;HAND_REST_RIGHT 0,-1;\
|
|
||||||
HAIR_FORE 0,-1;HEADGEAR 0,-1
|
|
||||||
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.
@@ -2,7 +2,6 @@
|
|||||||
SPRITESHEET=mods/basegame/sprites/sprite_assembler_test_assets/test_
|
SPRITESHEET=mods/basegame/sprites/sprite_assembler_test_assets/test_
|
||||||
EXTENSION=.tga
|
EXTENSION=.tga
|
||||||
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
|
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
|
||||||
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
|
|
||||||
CONFIG=SIZE 48,56;ORIGINX 29
|
CONFIG=SIZE 48,56;ORIGINX 29
|
||||||
|
|
||||||
# note to self: don't implement skeleton hierarchy: there's too many exceptions
|
# note to self: don't implement skeleton hierarchy: there's too many exceptions
|
||||||
@@ -14,15 +13,14 @@ CONFIG=SIZE 48,56;ORIGINX 29
|
|||||||
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
||||||
! first reversed then being iterated.
|
! first reversed then being iterated.
|
||||||
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
|
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
|
||||||
# TODO right now accessory points are explicitly defined. Should they be injected in run-time? In that case, certain names (e.g. headgear, held_item) will act as an anchor.
|
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
|
||||||
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
||||||
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
||||||
HAIR 0,32;HEAD 0,32;\
|
HAIR 0,32;HEAD 0,32;\
|
||||||
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
||||||
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
||||||
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
||||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12
|
||||||
TAIL0 0,13
|
|
||||||
|
|
||||||
# skeleton_stand is used for testing purpose
|
# skeleton_stand is used for testing purpose
|
||||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ uniform vec4 colourFilter = vec4(1, 1, 1, 1); // used by WALL to darken it
|
|||||||
|
|
||||||
uniform ivec2 cameraTranslation = ivec2(0, 0);
|
uniform ivec2 cameraTranslation = ivec2(0, 0);
|
||||||
|
|
||||||
uniform float drawBreakage = 1f; // set it to 0f to not draw breakage; non-zero value to draw it
|
|
||||||
|
|
||||||
|
|
||||||
ivec2 getTileXY(int tileNumber) {
|
ivec2 getTileXY(int tileNumber) {
|
||||||
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
|
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
|
||||||
@@ -110,13 +108,7 @@ void main() {
|
|||||||
|
|
||||||
vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend);
|
vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend);
|
||||||
|
|
||||||
vec4 finalBreakage;
|
vec4 finalBreakage = texture2D(tilesAtlas, finalUVCoordForBreakage);
|
||||||
if (drawBreakage == 0f) {
|
|
||||||
finalBreakage = vec4(0f);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
finalBreakage = texture2D(tilesAtlas, finalUVCoordForBreakage);
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 finalColor = vec4(mix(finalTile.rgb, finalBreakage.rgb, finalBreakage.a), finalTile.a);
|
vec4 finalColor = vec4(mix(finalTile.rgb, finalBreakage.rgb, finalBreakage.a), finalTile.a);
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,8 @@ task gamedebug(type: JavaExec) {
|
|||||||
classpath sourceSets.main.runtimeClasspath
|
classpath sourceSets.main.runtimeClasspath
|
||||||
main = 'net.torvald.terrarum.AppLoader'
|
main = 'net.torvald.terrarum.AppLoader'
|
||||||
group = "Application"
|
group = "Application"
|
||||||
description = "Launches the game with the debug key."
|
description = "Launches the game with debuy key."
|
||||||
args = ["isdev=true"]
|
args = ["isdev=true"]
|
||||||
jvmArgs = ["-ea"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task spriteassembler(type: JavaExec) {
|
task spriteassembler(type: JavaExec) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/javadoc/lwjgl3-javadoc.zip
LFS
BIN
lib/javadoc/lwjgl3-javadoc.zip
LFS
Binary file not shown.
Binary file not shown.
@@ -11,17 +11,12 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
interface HasAssembledSprite {
|
interface HasAssembledSprite {
|
||||||
|
|
||||||
/** ADL path for main sprite. Necessary. */
|
|
||||||
var animDescPath: String
|
var animDescPath: String
|
||||||
/** ADL path for glow sprite. Optional. */
|
|
||||||
var animDescPathGlow: String?
|
|
||||||
|
|
||||||
// FIXME sometimes the animmation is invisible (row and nFrames mismatch -- row is changed to 1 but it's drawing 3rd frame?)
|
// FIXME sometimes the animmation is invisible (row and nFrames mismatch -- row is changed to 1 but it's drawing 3rd frame?)
|
||||||
|
|
||||||
fun reassembleSprite(sprite: SpriteAnimation, spriteGlow: SpriteAnimation? = null) {
|
fun reassembleSprite(sprite: SpriteAnimation) {
|
||||||
_rebuild(ADProperties(Gdx.files.internal(animDescPath).read()), sprite)
|
_rebuild(ADProperties(Gdx.files.internal(animDescPath).read()), sprite)
|
||||||
if (spriteGlow != null)
|
|
||||||
_rebuild(ADProperties(Gdx.files.internal(animDescPathGlow).read()), spriteGlow)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*fun rebuild(animDescPath: String, spriteAnimation: SpriteAnimation) {
|
/*fun rebuild(animDescPath: String, spriteAnimation: SpriteAnimation) {
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ class SpriteAssemblerApp(val gdxWindow: SpriteAssemblerPreview) : JFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
panelCode.font = Font(Font.MONOSPACED, Font.PLAIN, 12)
|
panelCode.font = Font(Font.MONOSPACED, Font.PLAIN, 12)
|
||||||
panelCode.text = "Enter your descriptor code here…"
|
|
||||||
|
|
||||||
panelAnimationsList.model = DefaultListModel()
|
panelAnimationsList.model = DefaultListModel()
|
||||||
panelBodypartsList.model = DefaultListModel()
|
panelBodypartsList.model = DefaultListModel()
|
||||||
@@ -279,7 +278,7 @@ class SpriteAssemblerPreview: Game() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gdxClearAndSetBlend(bgCol)
|
gdxClearAndSetBlend(.62f,.79f,1f,1f)
|
||||||
|
|
||||||
|
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package net.torvald.terrarum;
|
package net.torvald.terrarum;
|
||||||
|
|
||||||
import com.badlogic.gdx.ApplicationListener;
|
import com.badlogic.gdx.ApplicationListener;
|
||||||
import com.badlogic.gdx.Files;
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
import com.badlogic.gdx.audio.AudioDevice;
|
import com.badlogic.gdx.audio.AudioDevice;
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||||
import com.badlogic.gdx.controllers.Controllers;
|
import com.badlogic.gdx.controllers.Controllers;
|
||||||
import com.badlogic.gdx.graphics.*;
|
import com.badlogic.gdx.graphics.*;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
@@ -38,7 +37,6 @@ import net.torvald.util.ArrayListMap;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import static net.torvald.terrarum.TerrarumKt.gdxClearAndSetBlend;
|
import static net.torvald.terrarum.TerrarumKt.gdxClearAndSetBlend;
|
||||||
@@ -87,9 +85,11 @@ public class AppLoader implements ApplicationListener {
|
|||||||
* @param appConfig LWJGL(2) Application Configuration
|
* @param appConfig LWJGL(2) Application Configuration
|
||||||
* @param injectScreen GDX Screen you want to run
|
* @param injectScreen GDX Screen you want to run
|
||||||
*/
|
*/
|
||||||
public AppLoader(LwjglApplicationConfiguration appConfig, Screen injectScreen) {
|
public AppLoader(Lwjgl3ApplicationConfiguration appConfig, Screen injectScreen, int width, int height) {
|
||||||
AppLoader.injectScreen = injectScreen;
|
AppLoader.injectScreen = injectScreen;
|
||||||
AppLoader.appConfig = appConfig;
|
AppLoader.appConfig = appConfig;
|
||||||
|
setWindowWidth = width;
|
||||||
|
setWindowHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,7 +97,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
*
|
*
|
||||||
* @param appConfig LWJGL(2) Application Configuration
|
* @param appConfig LWJGL(2) Application Configuration
|
||||||
*/
|
*/
|
||||||
public AppLoader(LwjglApplicationConfiguration appConfig) {
|
public AppLoader(Lwjgl3ApplicationConfiguration appConfig) {
|
||||||
AppLoader.appConfig = appConfig;
|
AppLoader.appConfig = appConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,13 +176,13 @@ public class AppLoader implements ApplicationListener {
|
|||||||
private static boolean resizeRequested = false;
|
private static boolean resizeRequested = false;
|
||||||
private static Point2i resizeReqSize;
|
private static Point2i resizeReqSize;
|
||||||
|
|
||||||
public static LwjglApplicationConfiguration appConfig;
|
public static Lwjgl3ApplicationConfiguration appConfig;
|
||||||
public static GameFontBase fontGame;
|
public static GameFontBase fontGame;
|
||||||
public static TinyAlphNum fontSmallNumbers;
|
public static TinyAlphNum fontSmallNumbers;
|
||||||
|
|
||||||
/** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */
|
/** A gamepad. Multiple gamepads may controll this single virtualised gamepad. */
|
||||||
public static TerrarumController gamepad = null;
|
public static TerrarumController gamepad = null;
|
||||||
public static float gamepadDeadzone = 0.3f;
|
public static float gamepadDeadzone = 0.2f;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,6 +198,9 @@ public class AppLoader implements ApplicationListener {
|
|||||||
public static final int minimumW = 1080;
|
public static final int minimumW = 1080;
|
||||||
public static final int minimumH = 720;
|
public static final int minimumH = 720;
|
||||||
|
|
||||||
|
public static int setWindowWidth;
|
||||||
|
public static int setWindowHeight;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// load configs
|
// load configs
|
||||||
getDefaultDirectory();
|
getDefaultDirectory();
|
||||||
@@ -206,34 +209,37 @@ public class AppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
|
|
||||||
try { processor = GetCpuName.getModelName(); }
|
try { processor = GetCpuName.getModelName(); }
|
||||||
catch (IOException e1) { processor = "Unknown CPU"; }
|
catch (IOException e1) { processor = "Unknown"; }
|
||||||
try { processorVendor = GetCpuName.getCPUID(); }
|
try { processorVendor = GetCpuName.getCPUID(); }
|
||||||
catch (IOException e2) { processorVendor = "Unknown CPU"; }
|
catch (IOException e2) { processorVendor = "Unknown"; }
|
||||||
|
|
||||||
|
|
||||||
ShaderProgram.pedantic = false;
|
ShaderProgram.pedantic = false;
|
||||||
|
|
||||||
LwjglApplicationConfiguration appConfig = new LwjglApplicationConfiguration();
|
Lwjgl3ApplicationConfiguration appConfig = new Lwjgl3ApplicationConfiguration();
|
||||||
appConfig.useGL30 = true; // utilising some GL trickeries, need this to be TRUE
|
appConfig.useOpenGL3(true, 3, 0);// utilising some GL trickeries, need this to be TRUE
|
||||||
appConfig.vSyncEnabled = getConfigBoolean("usevsync");
|
appConfig.setResizable(false);
|
||||||
appConfig.resizable = false;//true;
|
appConfig.useVsync(getConfigBoolean("usevsync"));
|
||||||
//appConfig.width = 1110; // photographic ratio (1.5:1)
|
//setWindowWidth = 1110; // photographic ratio (1.5:1)
|
||||||
//appConfig.height = 740; // photographic ratio (1.5:1)
|
//setWindowHeight = 740; // photographic ratio (1.5:1)
|
||||||
appConfig.width = getConfigInt("screenwidth");
|
setWindowWidth = getConfigInt("screenwidth");
|
||||||
appConfig.height = getConfigInt("screenheight");
|
setWindowHeight = getConfigInt("screenheight");
|
||||||
appConfig.backgroundFPS = getConfigInt("displayfps");
|
appConfig.setWindowedMode(setWindowWidth, setWindowHeight);
|
||||||
appConfig.foregroundFPS = getConfigInt("displayfps");
|
appConfig.setIdleFPS(getConfigInt("displayfps"));
|
||||||
appConfig.title = GAME_NAME;
|
appConfig.setTitle(GAME_NAME);
|
||||||
appConfig.forceExit = false;
|
//appConfig.forceExit = false;
|
||||||
|
if (IS_DEVELOPMENT_BUILD) {
|
||||||
|
appConfig.enableGLDebugOutput(true, System.err);
|
||||||
|
}
|
||||||
|
|
||||||
// load app icon
|
// load app icon
|
||||||
int[] appIconSizes = new int[]{256,128,64,32,16};
|
appConfig.setWindowIcon(
|
||||||
for (int size : appIconSizes) {
|
"assets/appicon256.png",
|
||||||
String name = "assets/appicon" + size + ".png";
|
"assets/appicon128.png",
|
||||||
if (new File("./" + name).exists()) {
|
"assets/appicon64.png",
|
||||||
appConfig.addIcon(name, Files.FileType.Internal);
|
"assets/appicon32.png",
|
||||||
}
|
"assets/appicon16.png"
|
||||||
}
|
);
|
||||||
|
|
||||||
if (args.length == 1 && args[0].equals("isdev=true")) {
|
if (args.length == 1 && args[0].equals("isdev=true")) {
|
||||||
IS_DEVELOPMENT_BUILD = true;
|
IS_DEVELOPMENT_BUILD = true;
|
||||||
@@ -241,7 +247,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
//KeyToggler.INSTANCE.forceSet(Input.Keys.F11, true);
|
//KeyToggler.INSTANCE.forceSet(Input.Keys.F11, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
new LwjglApplication(new AppLoader(appConfig), appConfig);
|
new Lwjgl3Application(new AppLoader(appConfig), appConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -285,20 +291,18 @@ public class AppLoader implements ApplicationListener {
|
|||||||
private FrameBuffer renderFBO;
|
private FrameBuffer renderFBO;
|
||||||
|
|
||||||
public static CommonResourcePool resourcePool;
|
public static CommonResourcePool resourcePool;
|
||||||
public static HashSet<File> tempFilePool = new HashSet();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
resourcePool = CommonResourcePool.INSTANCE;
|
resourcePool = CommonResourcePool.INSTANCE;
|
||||||
|
|
||||||
newTempFile("wenquanyi.tga"); // temp file required by the font
|
|
||||||
|
|
||||||
|
|
||||||
// set basis of draw
|
// set basis of draw
|
||||||
logoBatch = new SpriteBatch();
|
logoBatch = new SpriteBatch();
|
||||||
camera = new OrthographicCamera(((float) appConfig.width), ((float) appConfig.height));
|
|
||||||
|
|
||||||
initViewPort(appConfig.width, appConfig.height);
|
camera = new OrthographicCamera(((float) setWindowWidth), ((float) setWindowHeight));
|
||||||
|
|
||||||
|
initViewPort(setWindowWidth, setWindowHeight);
|
||||||
|
|
||||||
// logo here :p
|
// logo here :p
|
||||||
logo = new TextureRegion(new Texture(Gdx.files.internal("assets/graphics/logo_placeholder.tga")));
|
logo = new TextureRegion(new Texture(Gdx.files.internal("assets/graphics/logo_placeholder.tga")));
|
||||||
@@ -316,7 +320,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
VertexAttribute.ColorUnpacked(),
|
VertexAttribute.ColorUnpacked(),
|
||||||
VertexAttribute.TexCoords(0)
|
VertexAttribute.TexCoords(0)
|
||||||
);
|
);
|
||||||
updateFullscreenQuad(appConfig.width, appConfig.height);
|
updateFullscreenQuad(setWindowWidth, setWindowHeight);
|
||||||
|
|
||||||
|
|
||||||
// set up renderer info variables
|
// set up renderer info variables
|
||||||
@@ -380,6 +384,13 @@ public class AppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @link http://bilgin.esme.org/BitsAndBytes/KalmanFilterforDummies
|
||||||
|
*/
|
||||||
|
private void updateKalmanRenderDelta() {
|
||||||
|
// moved to LwjglGraphics
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
Gdx.gl.glDisable(GL20.GL_DITHER);
|
Gdx.gl.glDisable(GL20.GL_DITHER);
|
||||||
@@ -412,8 +423,8 @@ public class AppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
|
|
||||||
setCameraPosition(0f, 0f);
|
setCameraPosition(0f, 0f);
|
||||||
logoBatch.draw(logo, (appConfig.width - logo.getRegionWidth()) / 2f,
|
logoBatch.draw(logo, (setWindowWidth - logo.getRegionWidth()) / 2f,
|
||||||
(appConfig.height - logo.getRegionHeight()) / 2f
|
(setWindowHeight - logo.getRegionHeight()) / 2f
|
||||||
);
|
);
|
||||||
logoBatch.end();
|
logoBatch.end();
|
||||||
|
|
||||||
@@ -451,7 +462,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
screenshotRequested = false;
|
screenshotRequested = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Pixmap p = ScreenUtils.getFrameBufferPixmap(0, 0, appConfig.width, appConfig.height);
|
Pixmap p = ScreenUtils.getFrameBufferPixmap(0, 0, setWindowWidth, setWindowHeight);
|
||||||
PixmapIO2.writeTGA(Gdx.files.absolute(defaultDir + "/Screenshot.tga"), p, true);
|
PixmapIO2.writeTGA(Gdx.files.absolute(defaultDir + "/Screenshot.tga"), p, true);
|
||||||
p.dispose();
|
p.dispose();
|
||||||
}
|
}
|
||||||
@@ -494,8 +505,8 @@ public class AppLoader implements ApplicationListener {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
appConfig.width = screenW;
|
setWindowWidth = screenW;
|
||||||
appConfig.height = screenH;
|
setWindowHeight = screenH;
|
||||||
|
|
||||||
updateFullscreenQuad(screenW, screenH);
|
updateFullscreenQuad(screenW, screenH);
|
||||||
|
|
||||||
@@ -541,7 +552,8 @@ public class AppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
ModMgr.INSTANCE.disposeMods();
|
ModMgr.INSTANCE.disposeMods();
|
||||||
|
|
||||||
deleteTempfiles();
|
// delete temp files
|
||||||
|
new File("./tmp_wenquanyi.tga").delete(); // FIXME this is pretty much ad-hoc
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -618,7 +630,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
|
|
||||||
private void setCameraPosition(float newX, float newY) {
|
private void setCameraPosition(float newX, float newY) {
|
||||||
camera.position.set((-newX + appConfig.width / 2), (-newY + appConfig.height / 2), 0f);
|
camera.position.set((-newX + setWindowWidth / 2), (-newY + setWindowHeight / 2), 0f);
|
||||||
camera.update();
|
camera.update();
|
||||||
logoBatch.setProjectionMatrix(camera.combined);
|
logoBatch.setProjectionMatrix(camera.combined);
|
||||||
}
|
}
|
||||||
@@ -684,7 +696,6 @@ public class AppLoader implements ApplicationListener {
|
|||||||
System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem));
|
System.out.println(String.format("os.name = %s (with identifier %s)", OSName, operationSystem));
|
||||||
System.out.println(String.format("os.version = %s", OSVersion));
|
System.out.println(String.format("os.version = %s", OSVersion));
|
||||||
System.out.println(String.format("default directory: %s", defaultDir));
|
System.out.println(String.format("default directory: %s", defaultDir));
|
||||||
System.out.println(String.format("java version = %s", System.getProperty("java.version")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createDirs() {
|
private static void createDirs() {
|
||||||
@@ -698,17 +709,6 @@ public class AppLoader implements ApplicationListener {
|
|||||||
//dirs.forEach { if (!it.exists()) it.mkdirs() }
|
//dirs.forEach { if (!it.exists()) it.mkdirs() }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File newTempFile(String filename) {
|
|
||||||
File tempfile = new File("./tmp_" + filename);
|
|
||||||
tempFilePool.add(tempfile);
|
|
||||||
return tempfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void deleteTempfiles() {
|
|
||||||
for (File file : tempFilePool) {
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CONFIG //
|
// CONFIG //
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,9 @@ class GdxColorMap {
|
|||||||
height = pixmap.height
|
height = pixmap.height
|
||||||
is2D = pixmap.height > 1
|
is2D = pixmap.height > 1
|
||||||
|
|
||||||
dataRaw = kotlin.IntArray(pixmap.width * pixmap.height) {
|
data = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||||
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
||||||
}
|
}
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
|
||||||
|
|
||||||
pixmap.dispose()
|
pixmap.dispose()
|
||||||
}
|
}
|
||||||
@@ -32,46 +31,39 @@ class GdxColorMap {
|
|||||||
height = pixmap.height
|
height = pixmap.height
|
||||||
is2D = pixmap.height > 1
|
is2D = pixmap.height > 1
|
||||||
|
|
||||||
dataRaw = kotlin.IntArray(pixmap.width * pixmap.height) {
|
data = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||||
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
||||||
}
|
}
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
|
||||||
|
|
||||||
if (disposePixmap) pixmap.dispose()
|
if (disposePixmap) pixmap.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(color: Color) {
|
constructor(color: Color) {
|
||||||
dataRaw = intArrayOf(color.toIntBits())
|
data = intArrayOf(color.toIntBits())
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
|
||||||
width = 1
|
width = 1
|
||||||
height = 1
|
height = 1
|
||||||
is2D = false
|
is2D = false
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(gradStart: Color, gradEnd: Color) {
|
constructor(gradStart: Color, gradEnd: Color) {
|
||||||
dataRaw = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
data = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
||||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
|
||||||
width = 1
|
width = 1
|
||||||
height = 2
|
height = 2
|
||||||
is2D = true
|
is2D = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private val dataRaw: IntArray
|
private val data: IntArray
|
||||||
private val dataGdxColor: Array<Color>
|
|
||||||
//private val dataCvec: Array<Cvec>
|
|
||||||
val width: Int
|
val width: Int
|
||||||
val height: Int
|
val height: Int
|
||||||
val is2D: Boolean
|
val is2D: Boolean
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun get(x: Int, y: Int): Color = dataGdxColor[y * width + x]
|
fun get(x: Int, y: Int): Color = Color(data[y * width + x])
|
||||||
operator fun get(x: Int): Color = if (is2D) throw OperationNotSupportedException("This is 2D color map") else dataGdxColor[x]
|
operator fun get(x: Int): Color = if (is2D) throw OperationNotSupportedException("This is 2D color map") else Color(data[x])
|
||||||
|
|
||||||
fun getRaw(x: Int, y: Int): RGBA8888 = dataRaw[y * width + x]
|
fun getRaw(x: Int, y: Int): RGBA8888 = data[y * width + x]
|
||||||
fun getRaw(x: Int): RGBA8888 = if (is2D) throw OperationNotSupportedException("This is 2D color map") else dataRaw[x]
|
fun getRaw(x: Int): RGBA8888 = if (is2D) throw OperationNotSupportedException("This is 2D color map") else data[x]
|
||||||
|
|
||||||
//fun getAsCvec(x: Int, y: Int): Cvec = dataCvec[y * width + x]
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
|||||||
import net.torvald.terrarum.realestate.LandUtil
|
import net.torvald.terrarum.realestate.LandUtil
|
||||||
import net.torvald.terrarum.ui.ConsoleWindow
|
import net.torvald.terrarum.ui.ConsoleWindow
|
||||||
import net.torvald.util.SortedArrayList
|
import net.torvald.util.SortedArrayList
|
||||||
|
import java.util.*
|
||||||
import java.util.concurrent.locks.Lock
|
import java.util.concurrent.locks.Lock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,9 +127,6 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Wire version of terrainChanged() event
|
* Wire version of terrainChanged() event
|
||||||
*
|
|
||||||
* @param old previous settings of conduits in bit set format.
|
|
||||||
* @param new current settings of conduits in bit set format.
|
|
||||||
*/
|
*/
|
||||||
open fun queueWireChangedEvent(old: Int, new: Int, position: Long) {
|
open fun queueWireChangedEvent(old: Int, new: Int, position: Long) {
|
||||||
val (x, y) = LandUtil.resolveBlockAddr(world, position)
|
val (x, y) = LandUtil.resolveBlockAddr(world, position)
|
||||||
@@ -145,11 +143,11 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
if (actorContainerActive.size == 0 && actorContainerInactive.size == 0)
|
if (actorContainerActive.size == 0 && actorContainerInactive.size == 0)
|
||||||
throw IllegalArgumentException("Actor with ID $ID does not exist.")
|
throw IllegalArgumentException("Actor with ID $ID does not exist.")
|
||||||
|
|
||||||
var actor = actorContainerActive.searchFor(ID) { it.referenceID!! }
|
var index = actorContainerActive.binarySearch(ID)
|
||||||
if (actor == null) {
|
if (index < 0) {
|
||||||
actor = actorContainerInactive.searchFor(ID) { it.referenceID!! }
|
index = actorContainerInactive.binarySearch(ID)
|
||||||
|
|
||||||
if (actor == null) {
|
if (index < 0) {
|
||||||
/*JOptionPane.showMessageDialog(
|
/*JOptionPane.showMessageDialog(
|
||||||
null,
|
null,
|
||||||
"Actor with ID $ID does not exist.",
|
"Actor with ID $ID does not exist.",
|
||||||
@@ -158,14 +156,36 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
throw IllegalArgumentException("Actor with ID $ID does not exist.")
|
throw IllegalArgumentException("Actor with ID $ID does not exist.")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return actor
|
return actorContainerInactive[index]
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return actor
|
return actorContainerActive[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
//fun SortedArrayList<*>.binarySearch(actor: Actor) = this.toArrayList().binarySearch(actor.referenceID!!)
|
fun ArrayList<*>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID!!)
|
||||||
//fun SortedArrayList<*>.binarySearch(ID: Int) = this.toArrayList().binarySearch(ID)
|
|
||||||
|
fun ArrayList<*>.binarySearch(ID: Int): Int {
|
||||||
|
// code from collections/Collections.kt
|
||||||
|
var low = 0
|
||||||
|
var high = this.size - 1
|
||||||
|
|
||||||
|
while (low <= high) {
|
||||||
|
val mid = (low + high).ushr(1) // safe from overflows
|
||||||
|
|
||||||
|
val midVal = get(mid)!!
|
||||||
|
|
||||||
|
if (ID > midVal.hashCode())
|
||||||
|
low = mid + 1
|
||||||
|
else if (ID < midVal.hashCode())
|
||||||
|
high = mid - 1
|
||||||
|
else
|
||||||
|
return mid // key found
|
||||||
|
}
|
||||||
|
return -(low + 1) // key not found
|
||||||
|
}
|
||||||
|
|
||||||
|
fun SortedArrayList<*>.binarySearch(actor: Actor) = this.toArrayList().binarySearch(actor.referenceID!!)
|
||||||
|
fun SortedArrayList<*>.binarySearch(ID: Int) = this.toArrayList().binarySearch(ID)
|
||||||
|
|
||||||
open fun removeActor(ID: Int) = removeActor(getActorByID(ID))
|
open fun removeActor(ID: Int) = removeActor(getActorByID(ID))
|
||||||
/**
|
/**
|
||||||
@@ -179,9 +199,9 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
open fun removeActor(actor: Actor?) {
|
open fun removeActor(actor: Actor?) {
|
||||||
if (actor == null) return
|
if (actor == null) return
|
||||||
|
|
||||||
val indexToDelete = actorContainerActive.searchFor(actor.referenceID!!) { it.referenceID!! }
|
val indexToDelete = actorContainerActive.binarySearch(actor.referenceID!!)
|
||||||
if (indexToDelete != null) {
|
if (indexToDelete >= 0) {
|
||||||
actorContainerActive.remove(indexToDelete)
|
actorContainerActive.removeAt(indexToDelete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,13 +223,13 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
|||||||
if (actorContainerActive.size == 0)
|
if (actorContainerActive.size == 0)
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
actorContainerActive.searchFor(ID) { it.referenceID!! } != null
|
actorContainerActive.binarySearch(ID) >= 0
|
||||||
|
|
||||||
fun isInactive(ID: Int): Boolean =
|
fun isInactive(ID: Int): Boolean =
|
||||||
if (actorContainerInactive.size == 0)
|
if (actorContainerInactive.size == 0)
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
actorContainerInactive.searchFor(ID) { it.referenceID!! } != null
|
actorContainerInactive.binarySearch(ID) >= 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* actorContainerActive extensions
|
* actorContainerActive extensions
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
import net.torvald.terrarum.AppLoader.*
|
import net.torvald.terrarum.AppLoader.*
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.utils.CSVFetcher
|
import net.torvald.terrarum.utils.CSVFetcher
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
|||||||
import com.badlogic.gdx.math.Matrix4
|
import com.badlogic.gdx.math.Matrix4
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
import net.torvald.terrarum.ui.BasicDebugInfoWindow
|
import net.torvald.terrarum.ui.BasicDebugInfoWindow
|
||||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must be called by the App Loader
|
* Must be called by the App Loader
|
||||||
@@ -38,8 +37,6 @@ object PostProcessor {
|
|||||||
|
|
||||||
private val debugUI = BasicDebugInfoWindow()
|
private val debugUI = BasicDebugInfoWindow()
|
||||||
|
|
||||||
private var functionRowHelper = Texture(Gdx.files.internal("assets/graphics/function_row_help.png"))
|
|
||||||
|
|
||||||
fun dispose() {
|
fun dispose() {
|
||||||
batch.dispose()
|
batch.dispose()
|
||||||
shapeRenderer.dispose()
|
shapeRenderer.dispose()
|
||||||
@@ -64,7 +61,7 @@ object PostProcessor {
|
|||||||
batch.projectionMatrix = camera.combined
|
batch.projectionMatrix = camera.combined
|
||||||
|
|
||||||
shapeRenderer = ShapeRenderer()
|
shapeRenderer = ShapeRenderer()
|
||||||
Gdx.gl20.glViewport(0, 0, AppLoader.appConfig.width, AppLoader.appConfig.height)
|
Gdx.gl20.glViewport(0, 0, AppLoader.setWindowWidth, AppLoader.setWindowHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -81,25 +78,6 @@ object PostProcessor {
|
|||||||
drawSafeArea()
|
drawSafeArea()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyToggler.isOn(Input.Keys.F1)) {
|
|
||||||
batch.color = Color.WHITE
|
|
||||||
batch.inUse {
|
|
||||||
it.draw(functionRowHelper,
|
|
||||||
(AppLoader.screenW - functionRowHelper.width) / 2f,
|
|
||||||
functionRowHelper.height.toFloat(),
|
|
||||||
functionRowHelper.width.toFloat(),
|
|
||||||
functionRowHelper.height * -1f
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (KeyToggler.isOn(Input.Keys.F10)) {
|
|
||||||
batch.color = Color.WHITE
|
|
||||||
batch.inUse {
|
|
||||||
AppLoader.fontSmallNumbers.draw(it, "Wire draw bits: ${BlocksDrawer.drawWires.toString(2)}", 2f, 2f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (KeyToggler.isOn(Input.Keys.F3)) {
|
if (KeyToggler.isOn(Input.Keys.F3)) {
|
||||||
if (!debugUI.isOpened && !debugUI.isOpening) debugUI.setAsOpen()
|
if (!debugUI.isOpened && !debugUI.isOpening) debugUI.setAsOpen()
|
||||||
batch.inUse { debugUI.renderUI(batch, camera) }
|
batch.inUse { debugUI.renderUI(batch, camera) }
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
|||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
|
import net.torvald.util.CircularArray
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.AppLoader.*
|
import net.torvald.terrarum.AppLoader.*
|
||||||
import net.torvald.terrarum.gameactors.Actor
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
@@ -22,7 +23,6 @@ import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
|||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import net.torvald.util.CircularArray
|
|
||||||
import org.lwjgl.BufferUtils
|
import org.lwjgl.BufferUtils
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
@@ -196,6 +196,7 @@ object Terrarum : Screen {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
println("$NAME version ${AppLoader.getVERSION_STRING()}")
|
println("$NAME version ${AppLoader.getVERSION_STRING()}")
|
||||||
|
println("Java Runtime version ${System.getProperty("java.version")}")
|
||||||
println("LibGDX version ${com.badlogic.gdx.Version.VERSION}")
|
println("LibGDX version ${com.badlogic.gdx.Version.VERSION}")
|
||||||
|
|
||||||
|
|
||||||
@@ -612,10 +613,6 @@ fun blendNormal(batch: SpriteBatch) {
|
|||||||
// - https://www.andersriggelsen.dk/glblendfunc.php
|
// - https://www.andersriggelsen.dk/glblendfunc.php
|
||||||
}
|
}
|
||||||
|
|
||||||
fun gdxClearAndSetBlend(color: Color) {
|
|
||||||
gdxClearAndSetBlend(color.r, color.g, color.b, color.a)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun gdxClearAndSetBlend(r: Float, g: Float, b: Float, a: Float) {
|
fun gdxClearAndSetBlend(r: Float, g: Float, b: Float, a: Float) {
|
||||||
Gdx.gl.glClearColor(r,g,b,a)
|
Gdx.gl.glClearColor(r,g,b,a)
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false) {
|
cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false, forceAssignRefID = Terrarum.PLAYER_REF_ID) {
|
||||||
init {
|
init {
|
||||||
setHitboxDimension(2, 2, 0, 0)
|
setHitboxDimension(2, 2, 0, 0)
|
||||||
hitbox.setPosition(
|
hitbox.setPosition(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Camera
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Camera
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.torvald.terrarum.blockproperties
|
package net.torvald.terrarum.blockproperties
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.AppLoader.printmsg
|
import net.torvald.terrarum.AppLoader.printmsg
|
||||||
import net.torvald.terrarum.gameworld.FluidType
|
import net.torvald.terrarum.gameworld.FluidType
|
||||||
@@ -7,7 +8,6 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
import net.torvald.terrarum.gameworld.MapLayer
|
import net.torvald.terrarum.gameworld.MapLayer
|
||||||
import net.torvald.terrarum.gameworld.PairedMapLayer
|
import net.torvald.terrarum.gameworld.PairedMapLayer
|
||||||
import net.torvald.terrarum.utils.CSVFetcher
|
import net.torvald.terrarum.utils.CSVFetcher
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||||
import org.apache.commons.csv.CSVRecord
|
import org.apache.commons.csv.CSVRecord
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -110,7 +110,7 @@ object BlockCodex {
|
|||||||
prop.shadeColG = floatVal(record, "shdg") / LightmapRenderer.MUL_FLOAT
|
prop.shadeColG = floatVal(record, "shdg") / LightmapRenderer.MUL_FLOAT
|
||||||
prop.shadeColB = floatVal(record, "shdb") / LightmapRenderer.MUL_FLOAT
|
prop.shadeColB = floatVal(record, "shdb") / LightmapRenderer.MUL_FLOAT
|
||||||
prop.shadeColA = floatVal(record, "shduv") / LightmapRenderer.MUL_FLOAT
|
prop.shadeColA = floatVal(record, "shduv") / LightmapRenderer.MUL_FLOAT
|
||||||
prop.opacity = Cvec(prop.shadeColR, prop.shadeColG, prop.shadeColB, prop.shadeColA)
|
prop.opacity = Color(prop.shadeColR, prop.shadeColG, prop.shadeColB, prop.shadeColA)
|
||||||
|
|
||||||
prop.strength = intVal(record, "str")
|
prop.strength = intVal(record, "str")
|
||||||
prop.density = intVal(record, "dsty")
|
prop.density = intVal(record, "dsty")
|
||||||
@@ -119,7 +119,7 @@ object BlockCodex {
|
|||||||
prop.lumColG = floatVal(record, "lumg") / LightmapRenderer.MUL_FLOAT
|
prop.lumColG = floatVal(record, "lumg") / LightmapRenderer.MUL_FLOAT
|
||||||
prop.lumColB = floatVal(record, "lumb") / LightmapRenderer.MUL_FLOAT
|
prop.lumColB = floatVal(record, "lumb") / LightmapRenderer.MUL_FLOAT
|
||||||
prop.lumColA = floatVal(record, "lumuv") / LightmapRenderer.MUL_FLOAT
|
prop.lumColA = floatVal(record, "lumuv") / LightmapRenderer.MUL_FLOAT
|
||||||
prop.internalLumCol = Cvec(prop.lumColR, prop.lumColG, prop.lumColB, prop.lumColA)
|
prop.internalLumCol = Color(prop.lumColR, prop.lumColG, prop.lumColB, prop.lumColA)
|
||||||
|
|
||||||
prop.friction = intVal(record, "fr")
|
prop.friction = intVal(record, "fr")
|
||||||
prop.viscosity = intVal(record, "vscs")
|
prop.viscosity = intVal(record, "vscs")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.terrarum.blockproperties
|
package net.torvald.terrarum.blockproperties
|
||||||
|
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-16.
|
* Created by minjaesong on 2016-02-16.
|
||||||
@@ -17,7 +17,7 @@ class BlockProp {
|
|||||||
var shadeColB = 0f
|
var shadeColB = 0f
|
||||||
var shadeColA = 0f
|
var shadeColA = 0f
|
||||||
|
|
||||||
var opacity: Cvec = Cvec()
|
lateinit var opacity: Color
|
||||||
|
|
||||||
var strength: Int = 0
|
var strength: Int = 0
|
||||||
var density: Int = 0
|
var density: Int = 0
|
||||||
@@ -36,12 +36,12 @@ class BlockProp {
|
|||||||
var lumColG = 0f
|
var lumColG = 0f
|
||||||
var lumColB = 0f
|
var lumColB = 0f
|
||||||
var lumColA = 0f
|
var lumColA = 0f
|
||||||
var internalLumCol: Cvec = Cvec()
|
lateinit var internalLumCol: Color
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param luminosity
|
* @param luminosity
|
||||||
*/
|
*/
|
||||||
inline val luminosity: Cvec
|
inline val luminosity: Color
|
||||||
get() = BlockPropUtil.getDynamicLumFunc(internalLumCol, dynamicLuminosityFunction)
|
get() = BlockPropUtil.getDynamicLumFunc(internalLumCol, dynamicLuminosityFunction)
|
||||||
|
|
||||||
var drop: Int = 0
|
var drop: Int = 0
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package net.torvald.terrarum.blockproperties
|
package net.torvald.terrarum.blockproperties
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.Second
|
import net.torvald.terrarum.Second
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +37,7 @@ object BlockPropUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTorchFlicker(baseLum: Cvec): Cvec {
|
private fun getTorchFlicker(baseLum: Color): Color {
|
||||||
val funcY = FastMath.interpolateCatmullRom(0.0f, flickerFuncX / flickerFuncDomain,
|
val funcY = FastMath.interpolateCatmullRom(0.0f, flickerFuncX / flickerFuncDomain,
|
||||||
flickerP0, flickerP1, flickerP2, flickerP3
|
flickerP0, flickerP1, flickerP2, flickerP3
|
||||||
)
|
)
|
||||||
@@ -45,13 +45,13 @@ object BlockPropUtil {
|
|||||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSlowBreath(baseLum: Cvec): Cvec {
|
private fun getSlowBreath(baseLum: Color): Color {
|
||||||
val funcY = FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
|
val funcY = FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
|
||||||
|
|
||||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPulsate(baseLum: Cvec): Cvec {
|
private fun getPulsate(baseLum: Color): Color {
|
||||||
val funcY = FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
|
val funcY = FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
|
||||||
|
|
||||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||||
@@ -91,11 +91,11 @@ object BlockPropUtil {
|
|||||||
|
|
||||||
private fun linearInterpolation1D(a: Float, b: Float, x: Float) = a * (1 - x) + b * x
|
private fun linearInterpolation1D(a: Float, b: Float, x: Float) = a * (1 - x) + b * x
|
||||||
|
|
||||||
fun getDynamicLumFunc(baseLum: Cvec, type: Int): Cvec {
|
fun getDynamicLumFunc(baseLum: Color, type: Int): Color {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
1 -> getTorchFlicker(baseLum)
|
1 -> getTorchFlicker(baseLum)
|
||||||
2 -> (Terrarum.ingame!!.world).globalLight * LightmapRenderer.DIV_FLOAT // current global light
|
2 -> (Terrarum.ingame!!.world).globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT) // current global light
|
||||||
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2) * LightmapRenderer.DIV_FLOAT // daylight at noon
|
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2).cpy().mul(LightmapRenderer.DIV_FLOAT) // daylight at noon
|
||||||
4 -> getSlowBreath(baseLum)
|
4 -> getSlowBreath(baseLum)
|
||||||
5 -> getPulsate(baseLum)
|
5 -> getPulsate(baseLum)
|
||||||
else -> baseLum
|
else -> baseLum
|
||||||
|
|||||||
@@ -6,52 +6,21 @@ package net.torvald.terrarum.blockproperties
|
|||||||
object Wire {
|
object Wire {
|
||||||
|
|
||||||
/* A mapping for World's conduitTypes bits */
|
/* A mapping for World's conduitTypes bits */
|
||||||
/* Must be aligned with the sprite sheet */
|
|
||||||
const val BIT_NONE = 0
|
const val BIT_NONE = 0
|
||||||
const val BIT_SIGNAL_RED = 1
|
const val BIT_SIGNAL_RED = 1
|
||||||
const val BIT_UTILITY_PROTOTYPE = 2 // logic gates/PCLs/Diodes/Caps/etc.
|
const val BIT_UTILITY_PROTOTYPE = 2
|
||||||
const val BIT_POWER_LOW = 4
|
const val BIT_POWER_LOW = 4
|
||||||
const val BIT_POWER_HIGHT = 8
|
const val BIT_POWER_HIGHT = 8
|
||||||
const val BIT_THICKNET = 16 // the actual datagramme should be represented by another means than the ConduitFills
|
const val BIT_ETHERNET = 16
|
||||||
const val BIT_PARALLEL_8B = 32 // uses bit-to-mantissa encoding
|
|
||||||
const val BIT_PARALLEL_16B = 64 // uses bit-to-mantissa encoding. 16 bit half duplex OR 8 bit full duplex
|
|
||||||
|
|
||||||
/* A mapping for World's WiringNode.fills[] index */
|
/* A mapping for World's conduitFills[] index */
|
||||||
/*const val FILL_ID_SIGNAL_RED = 0
|
const val FILL_ID_SIGNAL_RED = 0
|
||||||
const val FILL_ID_UTILITY_PROTOTYPE = 1
|
const val FILL_ID_UTILITY_PROTOTYPE = 1
|
||||||
|
|
||||||
fun bitToConduitFillID(bit: Int) = when(bit) {
|
fun bitToConduitFillID(bit: Int) = when(bit) {
|
||||||
BIT_SIGNAL_RED -> FILL_ID_SIGNAL_RED
|
BIT_SIGNAL_RED -> FILL_ID_SIGNAL_RED
|
||||||
BIT_UTILITY_PROTOTYPE -> FILL_ID_UTILITY_PROTOTYPE
|
BIT_UTILITY_PROTOTYPE -> FILL_ID_UTILITY_PROTOTYPE
|
||||||
else -> null
|
else -> null
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encodes a byte to Float's mantissa. Normal value range is 1.0..1.99609375. When decoding, the sign and exponent bits
|
|
||||||
* must be ignored. (e.g. the encoded float might have not-one-point-something value after "bitwise" add/subtraction.
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
* exponent ,------- mantissa ------,
|
|
||||||
* s eeeeeeee bbbbbbbb cccccccc xxxxxxx
|
|
||||||
* s: sign (ignored)
|
|
||||||
* e: binary32 exponent (non-zero and non-255)
|
|
||||||
* b: upper octet
|
|
||||||
* c: lower octet (zero for Byte representation)
|
|
||||||
* x: not used, all zero
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* MSB of the byte is also the highest bit in the mantissa. Therefore ```0x80``` will be encoded as ```1.5```
|
|
||||||
*/
|
|
||||||
fun Byte.toFloatMantissa(): Float = Float.fromBits(0x3F800000 or (this.toInt().and(0xFF) shl 15))
|
|
||||||
fun Short.toFloatMantissa(): Float = Float.fromBits(0x3F800000 or (this.toInt().and(0xFFFF) shl 7))
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function does the reversal calculation.
|
|
||||||
*
|
|
||||||
* @see net.torvald.terrarum.blockproperties.Wire.toFloatMantissa
|
|
||||||
*/
|
|
||||||
fun Float.fromMantissaToByte(): Byte = this.toRawBits().ushr(15).and(0xFF).toByte()
|
|
||||||
fun Float.fromMantissaToShort(): Short = this.toRawBits().ushr(7).and(0xFFFF).toShort()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ object CommandDict {
|
|||||||
"kill" to KillActor,
|
"kill" to KillActor,
|
||||||
"money" to MoneyDisp,
|
"money" to MoneyDisp,
|
||||||
"screenshot" to TakeScreenshot,
|
"screenshot" to TakeScreenshot,
|
||||||
"resize" to ResizeScreen,
|
//"resize" to ResizeScreen,
|
||||||
|
|
||||||
// Test codes
|
// Test codes
|
||||||
"bulletintest" to SetBulletin,
|
"bulletintest" to SetBulletin,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
package net.torvald.terrarum.console
|
package net.torvald.terrarum.console
|
||||||
|
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
|
||||||
object ResizeScreen: ConsoleCommand {
|
object ResizeScreen: ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 3) {
|
if (args.size == 3) {
|
||||||
AppLoader.resizeScreen(args[1].toInt(), args[2].toInt())
|
Terrarum.resize(args[1].toInt(), args[2].toInt())
|
||||||
}
|
}
|
||||||
else if (args.size == 2) {
|
else if (args.size == 2) {
|
||||||
when (args[1]) {
|
when (args[1]) {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package net.torvald.terrarum.console
|
package net.torvald.terrarum.console
|
||||||
|
|
||||||
import net.torvald.terrarum.Terrarum
|
import com.badlogic.gdx.graphics.Color
|
||||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
|
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-17.
|
* Created by minjaesong on 2016-02-17.
|
||||||
@@ -13,12 +14,11 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
|||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 5) {
|
if (args.size == 5) {
|
||||||
try {
|
try {
|
||||||
val GL = Cvec(
|
val r = args[1].toFloat()
|
||||||
args[1].toFloat(),
|
val g = args[2].toFloat()
|
||||||
args[2].toFloat(),
|
val b = args[3].toFloat()
|
||||||
args[3].toFloat(),
|
val a = args[4].toFloat()
|
||||||
args[4].toFloat()
|
val GL = Color(r, g, b, a)
|
||||||
)
|
|
||||||
|
|
||||||
WeatherMixer.globalLightOverridden = true
|
WeatherMixer.globalLightOverridden = true
|
||||||
(Terrarum.ingame!!.world).globalLight = GL
|
(Terrarum.ingame!!.world).globalLight = GL
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex.ACTORID_MIN
|
import net.torvald.terrarum.itemproperties.ItemCodex.ACTORID_MIN
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
|
|||||||
* Valid RefID is equal to or greater than 16777216.
|
* Valid RefID is equal to or greater than 16777216.
|
||||||
* @return Reference ID. (16777216-0x7FFF_FFFF)
|
* @return Reference ID. (16777216-0x7FFF_FFFF)
|
||||||
*/
|
*/
|
||||||
open var referenceID: ActorID = Terrarum.generateUniqueReferenceID(renderOrder) // once this was nullable without initialiser. If you're going to revert to that, add the reason why this should be nullable.
|
open var referenceID: ActorID? = null
|
||||||
var actorValue = ActorValue(this) // FIXME cyclic reference on GSON
|
var actorValue = ActorValue(this) // FIXME cyclic reference on GSON
|
||||||
@Volatile var flagDespawn = false
|
@Volatile var flagDespawn = false
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-19.
|
* Created by minjaesong on 2016-02-19.
|
||||||
@@ -26,7 +26,7 @@ interface Luminous {
|
|||||||
actorValue[AVKey.LUMA] = value.a * LightmapRenderer.MUL_FLOAT
|
actorValue[AVKey.LUMA] = value.a * LightmapRenderer.MUL_FLOAT
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
var color: Cvec
|
var color: Color
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arguments:
|
* Arguments:
|
||||||
|
|||||||
@@ -6,12 +6,16 @@ import com.badlogic.gdx.InputAdapter
|
|||||||
import com.badlogic.gdx.controllers.Controllers
|
import com.badlogic.gdx.controllers.Controllers
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.controller.TerrarumController
|
import net.torvald.terrarum.controller.TerrarumController
|
||||||
import net.torvald.terrarum.floorInt
|
import net.torvald.terrarum.floorInt
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||||
|
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,16 +57,22 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
||||||
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
|
||||||
if (ingame.canPlayerControl) {
|
if (ingame.canPlayerControl) {
|
||||||
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) ||
|
||||||
if (ingame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary"))) {
|
||||||
|
|
||||||
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) {
|
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
|
||||||
ingame.worldPrimaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
if (player == null) return
|
||||||
}
|
|
||||||
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary"))) {
|
val itemOnGrip = player.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||||
ingame.worldSecondaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
|
||||||
|
itemOnGrip?.let {
|
||||||
|
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) {
|
||||||
|
player.consumePrimary(ItemCodex[it]!!)
|
||||||
|
}
|
||||||
|
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary"))) {
|
||||||
|
player.consumeSecondary(ItemCodex[it]!!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,6 +192,21 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
|
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
||||||
|
if (ingame.canPlayerControl) {
|
||||||
|
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
||||||
|
if (ingame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
|
||||||
|
|
||||||
|
if (button == AppLoader.getConfigInt("mouseprimary")) {
|
||||||
|
ingame.worldPrimaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
||||||
|
}
|
||||||
|
if (button == AppLoader.getConfigInt("mousesecondary")) {
|
||||||
|
ingame.worldSecondaryClickStart(AppLoader.UPDATE_RATE.toFloat())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ingame.uiContainer.forEach { it.touchDown(screenX, screenY, pointer, button) }
|
ingame.uiContainer.forEach { it.touchDown(screenX, screenY, pointer, button) }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
package net.torvald.terrarum.gameworld
|
package net.torvald.terrarum.gameworld
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import net.torvald.util.SortedArrayList
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
@@ -9,8 +11,7 @@ import net.torvald.terrarum.blockproperties.Fluid
|
|||||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldSimulator
|
import net.torvald.terrarum.modulebasegame.gameworld.WorldSimulator
|
||||||
import net.torvald.terrarum.realestate.LandUtil
|
import net.torvald.terrarum.realestate.LandUtil
|
||||||
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
import net.torvald.terrarum.toInt
|
||||||
import net.torvald.util.SortedArrayList
|
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
import kotlin.math.sign
|
import kotlin.math.sign
|
||||||
@@ -73,24 +74,23 @@ open class GameWorld {
|
|||||||
val fluidTypes: HashMap<BlockAddress, FluidType>
|
val fluidTypes: HashMap<BlockAddress, FluidType>
|
||||||
@TEMzPayload("FlFL", TEMzPayload.INT48_FLOAT_PAIR)
|
@TEMzPayload("FlFL", TEMzPayload.INT48_FLOAT_PAIR)
|
||||||
val fluidFills: HashMap<BlockAddress, Float>
|
val fluidFills: HashMap<BlockAddress, Float>
|
||||||
|
@TEMzPayload("CtYP", TEMzPayload.INT48_INT_PAIR)
|
||||||
|
val conduitTypes: HashMap<BlockAddress, Int> // 1 bit = 1 conduit (pipe/wire) type
|
||||||
|
@TEMzPayload("CfL", TEMzPayload.INT48_FLOAT_PAIR)
|
||||||
|
val conduitFills: Array<HashMap<BlockAddress, Float>>
|
||||||
|
val conduitFills0: HashMap<BlockAddress, Float> // size of liquid packet on the block
|
||||||
|
get() = conduitFills[0]
|
||||||
|
val conduitFills1: HashMap<BlockAddress, Float> // size of gas packet on the block
|
||||||
|
get() = conduitFills[1]
|
||||||
|
|
||||||
/**
|
private val wiringNodes = SortedArrayList<WiringNode>()
|
||||||
* Single block can have multiple conduits, different types of conduits are stored separately.
|
|
||||||
*/
|
|
||||||
@TEMzPayload("WiNt", TEMzPayload.EXTERNAL_JSON)
|
|
||||||
private val wirings: HashMap<BlockAddress, SortedArrayList<WiringNode>>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used by the renderer. When wirings are updated, `wirings` and this properties must be synchronised.
|
|
||||||
*/
|
|
||||||
private val wiringBlocks: HashMap<BlockAddress, Int>
|
|
||||||
|
|
||||||
//public World physWorld = new World( new Vec2(0, -Terrarum.game.gravitationalAccel) );
|
//public World physWorld = new World( new Vec2(0, -Terrarum.game.gravitationalAccel) );
|
||||||
//physics
|
//physics
|
||||||
/** Meter per second squared. Currently only the downward gravity is supported. No reverse gravity :p */
|
/** Meter per second squared. Currently only the downward gravity is supported. No reverse gravity :p */
|
||||||
var gravitation: Vector2 = Vector2(0.0, 9.80665)
|
var gravitation: Vector2 = Vector2(0.0, 9.80665)
|
||||||
/** 0.0..1.0+ */
|
/** 0.0..1.0+ */
|
||||||
var globalLight = Cvec()
|
var globalLight = Color(0f,0f,0f,0f)
|
||||||
var averageTemperature = 288f // 15 deg celsius; simulates global warming
|
var averageTemperature = 288f // 15 deg celsius; simulates global warming
|
||||||
|
|
||||||
|
|
||||||
@@ -114,13 +114,13 @@ open class GameWorld {
|
|||||||
layerTerrainLowBits = PairedMapLayer(width, height)
|
layerTerrainLowBits = PairedMapLayer(width, height)
|
||||||
layerWallLowBits = PairedMapLayer(width, height)
|
layerWallLowBits = PairedMapLayer(width, height)
|
||||||
|
|
||||||
wallDamages = HashMap()
|
wallDamages = HashMap<BlockAddress, Float>()
|
||||||
terrainDamages = HashMap()
|
terrainDamages = HashMap<BlockAddress, Float>()
|
||||||
fluidTypes = HashMap()
|
fluidTypes = HashMap<BlockAddress, FluidType>()
|
||||||
fluidFills = HashMap()
|
fluidFills = HashMap<BlockAddress, Float>()
|
||||||
|
|
||||||
wiringBlocks = HashMap()
|
conduitTypes = HashMap<BlockAddress, Int>()
|
||||||
wirings = HashMap()
|
conduitFills = Array(16) { HashMap<BlockAddress, Float>() }
|
||||||
|
|
||||||
// temperature layer: 2x2 is one cell
|
// temperature layer: 2x2 is one cell
|
||||||
//layerThermal = MapLayerHalfFloat(width, height, averageTemperature)
|
//layerThermal = MapLayerHalfFloat(width, height, averageTemperature)
|
||||||
@@ -148,8 +148,8 @@ open class GameWorld {
|
|||||||
fluidTypes = layerData.fluidTypes
|
fluidTypes = layerData.fluidTypes
|
||||||
fluidFills = layerData.fluidFills
|
fluidFills = layerData.fluidFills
|
||||||
|
|
||||||
wiringBlocks = HashMap()
|
conduitTypes = HashMap<BlockAddress, Int>()
|
||||||
wirings = HashMap()
|
conduitFills = Array(16) { HashMap<BlockAddress, Float>() }
|
||||||
|
|
||||||
spawnX = layerData.spawnX
|
spawnX = layerData.spawnX
|
||||||
spawnY = layerData.spawnY
|
spawnY = layerData.spawnY
|
||||||
@@ -210,6 +210,10 @@ open class GameWorld {
|
|||||||
terrain * PairedMapLayer.RANGE + terrainDamage
|
terrain * PairedMapLayer.RANGE + terrainDamage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getWires(x: Int, y: Int): Int {
|
||||||
|
return conduitTypes.getOrDefault(LandUtil.getBlockAddr(this, x, y), 0)
|
||||||
|
}
|
||||||
|
|
||||||
fun getWallLowBits(x: Int, y: Int): Int? {
|
fun getWallLowBits(x: Int, y: Int): Int? {
|
||||||
val (x, y) = coerceXY(x, y)
|
val (x, y) = coerceXY(x, y)
|
||||||
return layerWallLowBits.getData(x, y)
|
return layerWallLowBits.getData(x, y)
|
||||||
@@ -226,11 +230,10 @@ open class GameWorld {
|
|||||||
* *
|
* *
|
||||||
* @param y
|
* @param y
|
||||||
* *
|
* *
|
||||||
* @param combinedTilenum Item id of the wall block. Less-than-4096-value is permitted.
|
* @param combinedTilenum (tilenum * 16) + damage
|
||||||
*/
|
*/
|
||||||
fun setTileWall(x: Int, y: Int, combinedTilenum: Int) {
|
fun setTileWall(x: Int, y: Int, combinedTilenum: Int) {
|
||||||
val (x, y) = coerceXY(x, y)
|
val (x, y) = coerceXY(x, y)
|
||||||
val combinedTilenum = combinedTilenum % GameWorld.TILES_SUPPORTED // does work without this, but to be safe...
|
|
||||||
setTileWall(x, y, (combinedTilenum / PairedMapLayer.RANGE).toByte(), combinedTilenum % PairedMapLayer.RANGE)
|
setTileWall(x, y, (combinedTilenum / PairedMapLayer.RANGE).toByte(), combinedTilenum % PairedMapLayer.RANGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +243,7 @@ open class GameWorld {
|
|||||||
* *
|
* *
|
||||||
* @param y
|
* @param y
|
||||||
* *
|
* *
|
||||||
* @param combinedTilenum Item id of the terrain block, <4096
|
* @param combinedTilenum (tilenum * 16) + damage
|
||||||
*/
|
*/
|
||||||
fun setTileTerrain(x: Int, y: Int, combinedTilenum: Int) {
|
fun setTileTerrain(x: Int, y: Int, combinedTilenum: Int) {
|
||||||
val (x, y) = coerceXY(x, y)
|
val (x, y) = coerceXY(x, y)
|
||||||
@@ -288,35 +291,25 @@ open class GameWorld {
|
|||||||
Terrarum.ingame?.queueWireChangedEvent(oldWire, tile.toUint(), LandUtil.getBlockAddr(this, x, y))
|
Terrarum.ingame?.queueWireChangedEvent(oldWire, tile.toUint(), LandUtil.getBlockAddr(this, x, y))
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
fun getWiringBlocks(x: Int, y: Int): Int {
|
/**
|
||||||
return wiringBlocks.getOrDefault(LandUtil.getBlockAddr(this, x, y), 0)
|
* Overrides entire bits with given value. DO NOT USE THIS if you don't know what this means, you'll want to use setWire().
|
||||||
}
|
* Besides, this function won't fire WireChangedEvent
|
||||||
|
*/
|
||||||
fun getAllConduitsFrom(x: Int, y: Int): SortedArrayList<WiringNode>? {
|
fun setWires(x: Int, y: Int, wireBits: Int) {
|
||||||
return wirings.get(LandUtil.getBlockAddr(this, x, y))
|
val (x, y) = coerceXY(x, y)
|
||||||
|
conduitTypes[LandUtil.getBlockAddr(this, x, y)] = wireBits
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param conduitTypeBit defined in net.torvald.terrarum.blockproperties.Wire, always power-of-two
|
* Sets single bit for given tile. YOU'LL WANT TO USE THIS instead of setWires()
|
||||||
|
* @param selectedWire wire-bit to modify, must be power of two
|
||||||
*/
|
*/
|
||||||
fun getConduitByTypeFrom(x: Int, y: Int, conduitTypeBit: Int): WiringNode? {
|
fun setWire(x: Int, y: Int, selectedWire: Int, bitToSet: Boolean) {
|
||||||
val conduits = getAllConduitsFrom(x, y)
|
val oldWireBits = getWires(x, y)
|
||||||
return conduits?.searchFor(conduitTypeBit) { it.typeBitMask }
|
val oldStatus = getWires(x, y) or selectedWire != 0
|
||||||
}
|
if (oldStatus != bitToSet) {
|
||||||
|
setWires(x, y, (oldWireBits and selectedWire.inv()) or (selectedWire * oldStatus.toInt()))
|
||||||
fun addNewConduitTo(x: Int, y: Int, node: WiringNode) {
|
Terrarum.ingame?.queueWireChangedEvent(selectedWire * oldStatus.toInt(), selectedWire * bitToSet.toInt(), LandUtil.getBlockAddr(this, x, y))
|
||||||
val blockAddr = LandUtil.getBlockAddr(this, x, y)
|
|
||||||
|
|
||||||
// check for existing type of conduit
|
|
||||||
// if there's no duplicate...
|
|
||||||
if (getWiringBlocks(x, y) and node.typeBitMask == 0) {
|
|
||||||
// store as-is
|
|
||||||
wirings.getOrPut(blockAddr) { SortedArrayList() }.add(node)
|
|
||||||
// synchronise wiringBlocks
|
|
||||||
wiringBlocks[blockAddr] = (wiringBlocks[blockAddr] ?: 0) or node.typeBitMask
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TODO("need overwriting policy for existing conduit node")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +321,7 @@ open class GameWorld {
|
|||||||
return getTileFromWall(x, y)
|
return getTileFromWall(x, y)
|
||||||
}
|
}
|
||||||
else if (mode == WIRE) {
|
else if (mode == WIRE) {
|
||||||
return getWiringBlocks(x, y)
|
return getWires(x, y)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw IllegalArgumentException("illegal mode input: " + mode.toString())
|
throw IllegalArgumentException("illegal mode input: " + mode.toString())
|
||||||
@@ -489,17 +482,12 @@ open class GameWorld {
|
|||||||
override fun toString() = "Fluid type: ${type.value}, amount: $amount"
|
override fun toString() = "Fluid type: ${type.value}, amount: $amount"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private data class WiringNode(
|
||||||
* Connection rules: connect to all nearby, except:
|
|
||||||
*
|
|
||||||
* If the wire allows 3- or 4-way connection, make such connection.
|
|
||||||
* If the wire does not allow them (e.g. wire bridge, thicknet), connect top-bottom and left-right nodes.
|
|
||||||
*/
|
|
||||||
data class WiringNode(
|
|
||||||
val position: BlockAddress,
|
val position: BlockAddress,
|
||||||
/** One defined in WireCodex, always power of two */
|
/** One defined in WireCodex, always power of two */
|
||||||
val typeBitMask: Int,
|
val typeBitMask: Int,
|
||||||
var fills: Float = 0f
|
var fills: Float = 0f,
|
||||||
|
var connectedNodes: ArrayList<WiringNode>
|
||||||
) : Comparable<WiringNode> {
|
) : Comparable<WiringNode> {
|
||||||
override fun compareTo(other: WiringNode): Int {
|
override fun compareTo(other: WiringNode): Int {
|
||||||
return (this.position - other.position).sign
|
return (this.position - other.position).sign
|
||||||
@@ -547,9 +535,6 @@ inline class FluidType(val value: Int) {
|
|||||||
*/
|
*/
|
||||||
annotation class TEMzPayload(val payloadName: String, val arg: Int) {
|
annotation class TEMzPayload(val payloadName: String, val arg: Int) {
|
||||||
companion object {
|
companion object {
|
||||||
const val EXTERNAL_JAVAPROPERTIES = -3
|
|
||||||
const val EXTERNAL_CSV = -2
|
|
||||||
const val EXTERNAL_JSON = -1
|
|
||||||
const val EIGHT_MSB = 0
|
const val EIGHT_MSB = 0
|
||||||
const val FOUR_LSB = 1
|
const val FOUR_LSB = 1
|
||||||
const val INT48_FLOAT_PAIR = 2
|
const val INT48_FLOAT_PAIR = 2
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package net.torvald.terrarum.gameitem
|
package net.torvald.terrarum.itemproperties
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.ItemValue
|
import net.torvald.terrarum.ItemValue
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_DYNAMIC
|
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_DYNAMIC
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||||
@@ -14,18 +12,15 @@ import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
|||||||
typealias ItemID = Int
|
typealias ItemID = Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances of the GameItem (e.g. net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper) are preferably referenced
|
|
||||||
* from the ```<module>/items/itemid.csv``` file only, and not from the actual game code.
|
|
||||||
*
|
|
||||||
* Created by minjaesong on 2016-01-16.
|
* Created by minjaesong on 2016-01-16.
|
||||||
*/
|
*/
|
||||||
abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneable {
|
abstract class GameItem : Comparable<GameItem>, Cloneable {
|
||||||
|
|
||||||
open var dynamicID: ItemID = originalID
|
abstract var dynamicID: ItemID
|
||||||
/**
|
/**
|
||||||
* if the ID is a Actor range, it's an actor contained in a pocket.
|
* if the ID is a Actor range, it's an actor contained in a pocket.
|
||||||
*/
|
*/
|
||||||
//abstract val originalID: ItemID // WUT?! using init does not work!!
|
abstract val originalID: ItemID // WUT?! using init does not work!!
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,7 +268,6 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
@JvmStatic val BLOCK = "block"
|
@JvmStatic val BLOCK = "block"
|
||||||
@JvmStatic val WALL = "wall"
|
@JvmStatic val WALL = "wall"
|
||||||
@JvmStatic val WIRE = "wire"
|
@JvmStatic val WIRE = "wire"
|
||||||
@JvmStatic val FIXTURE = "fixture"
|
|
||||||
@JvmStatic val MISC = "misc"
|
@JvmStatic val MISC = "misc"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +281,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
|||||||
|
|
||||||
|
|
||||||
fun generateUniqueDynamicID(inventory: ActorInventory): GameItem {
|
fun generateUniqueDynamicID(inventory: ActorInventory): GameItem {
|
||||||
dynamicID = Companion.generateUniqueDynamicID(inventory)
|
dynamicID = GameItem.generateUniqueDynamicID(inventory)
|
||||||
ItemCodex.registerNewDynamicItem(dynamicID, this)
|
ItemCodex.registerNewDynamicItem(dynamicID, this)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,6 @@ import net.torvald.terrarum.AppLoader
|
|||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blockproperties.Fluid
|
import net.torvald.terrarum.blockproperties.Fluid
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.CanBeAnItem
|
import net.torvald.terrarum.modulebasegame.gameactors.CanBeAnItem
|
||||||
@@ -176,7 +174,9 @@ object ItemCodex {
|
|||||||
|
|
||||||
|
|
||||||
// test water bucket
|
// test water bucket
|
||||||
itemCodex[9000] = object : GameItem(9000) {
|
itemCodex[9000] = object : GameItem() {
|
||||||
|
override var dynamicID: ItemID = 9000
|
||||||
|
override val originalID: ItemID = 9000
|
||||||
|
|
||||||
override val isUnique: Boolean = true
|
override val isUnique: Boolean = true
|
||||||
override val originalName: String = "Infinite Water Bucket"
|
override val originalName: String = "Infinite Water Bucket"
|
||||||
@@ -203,7 +203,9 @@ object ItemCodex {
|
|||||||
|
|
||||||
|
|
||||||
// test lava bucket
|
// test lava bucket
|
||||||
itemCodex[9001] = object : GameItem(9001) {
|
itemCodex[9001] = object : GameItem() {
|
||||||
|
override var dynamicID: ItemID = 9001
|
||||||
|
override val originalID: ItemID = 9001
|
||||||
|
|
||||||
override val isUnique: Boolean = true
|
override val isUnique: Boolean = true
|
||||||
override val originalName: String = "Infinite Lava Bucket"
|
override val originalName: String = "Infinite Lava Bucket"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.blockproperties.Block
|
|||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||||
@@ -27,7 +27,6 @@ import net.torvald.terrarum.serialise.toULittle48
|
|||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarum.ui.UINSMenu
|
import net.torvald.terrarum.ui.UINSMenu
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
@@ -138,7 +137,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
internal var showSelection = true
|
internal var showSelection = true
|
||||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {
|
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {
|
||||||
|
|
||||||
override var referenceID: ActorID = 1048575 // custom refID
|
override var referenceID: ActorID? = 1048575 // custom refID
|
||||||
override val hitbox = Hitbox(0.0, 0.0, 16.0, 16.0)
|
override val hitbox = Hitbox(0.0, 0.0, 16.0, 16.0)
|
||||||
|
|
||||||
|
|
||||||
@@ -178,7 +177,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
private var _testMarkerDrawCalls = 0L
|
private var _testMarkerDrawCalls = 0L
|
||||||
|
|
||||||
private fun generateNewBlockMarkerVisible(x: Int, y: Int) = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {
|
private fun generateNewBlockMarkerVisible(x: Int, y: Int) = object : ActorWithBody(Actor.RenderOrder.OVERLAY) {
|
||||||
override var referenceID: ActorID = blockPosToRefID(x, y) // custom refID
|
override var referenceID: ActorID? = blockPosToRefID(x, y) // custom refID
|
||||||
override val hitbox = Hitbox(x * 16.0, y * 16.0, 16.0, 16.0)
|
override val hitbox = Hitbox(x * 16.0, y * 16.0, 16.0, 16.0)
|
||||||
|
|
||||||
override fun drawBody(batch: SpriteBatch) {
|
override fun drawBody(batch: SpriteBatch) {
|
||||||
@@ -280,7 +279,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
gameWorld.time.setTimeOfToday(WorldTime.HOUR_SEC * 10)
|
gameWorld.time.setTimeOfToday(WorldTime.HOUR_SEC * 10)
|
||||||
gameWorld.globalLight = Cvec(.8f)
|
gameWorld.globalLight = Color(.8f,.8f,.8f,.8f)
|
||||||
|
|
||||||
essentialOverlays.add(blockPointingCursor)
|
essentialOverlays.add(blockPointingCursor)
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package net.torvald.terrarum.modulebasegame
|
package net.torvald.terrarum.modulebasegame
|
||||||
|
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.AppLoader.IS_DEVELOPMENT_BUILD
|
import net.torvald.terrarum.AppLoader.IS_DEVELOPMENT_BUILD
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import net.torvald.terrarum.ModMgr
|
|
||||||
import net.torvald.terrarum.ModuleEntryPoint
|
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.BlockBase
|
|
||||||
import net.torvald.terrarum.modulebasegame.imagefont.WatchFont
|
import net.torvald.terrarum.modulebasegame.imagefont.WatchFont
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
@@ -56,7 +54,9 @@ class EntryPoint : ModuleEntryPoint() {
|
|||||||
val blockProp = BlockCodex.getOrNull(i % ItemCodex.ITEM_WALLS.first)
|
val blockProp = BlockCodex.getOrNull(i % ItemCodex.ITEM_WALLS.first)
|
||||||
|
|
||||||
if (blockProp != null) {
|
if (blockProp != null) {
|
||||||
ItemCodex.itemCodex[i] = object : GameItem(i) {
|
ItemCodex.itemCodex[i] = object : GameItem() {
|
||||||
|
override val originalID = i
|
||||||
|
override var dynamicID = i
|
||||||
override val isUnique: Boolean = false
|
override val isUnique: Boolean = false
|
||||||
override var baseMass: Double = blockProp.density / 1000.0
|
override var baseMass: Double = blockProp.density / 1000.0
|
||||||
override var baseToolSize: Double? = null
|
override var baseToolSize: Double? = null
|
||||||
@@ -74,11 +74,48 @@ class EntryPoint : ModuleEntryPoint() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun startPrimaryUse(delta: Float): Boolean {
|
override fun startPrimaryUse(delta: Float): Boolean {
|
||||||
return BlockBase.blockStartPrimaryUse(this, i, delta)
|
val ingame = Terrarum.ingame!! as Ingame
|
||||||
}
|
|
||||||
|
|
||||||
override fun effectWhenEquipped(delta: Float) {
|
val mousePoint = Point2d(Terrarum.mouseTileX.toDouble(), Terrarum.mouseTileY.toDouble())
|
||||||
BlockBase.blockEffectWhenEquipped(delta)
|
|
||||||
|
// check for collision with actors (BLOCK only)
|
||||||
|
if (this.inventoryCategory == Category.BLOCK) {
|
||||||
|
var ret1 = true
|
||||||
|
ingame.actorContainerActive.forEach {
|
||||||
|
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||||
|
ret1 = false // return is not allowed here
|
||||||
|
}
|
||||||
|
if (!ret1) return ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// return false if the tile is already there
|
||||||
|
if (this.inventoryCategory == Category.BLOCK &&
|
||||||
|
this.dynamicID == ingame.world.getTileFromTerrain(Terrarum.mouseTileX, Terrarum.mouseTileY) ||
|
||||||
|
this.inventoryCategory == Category.WALL &&
|
||||||
|
this.dynamicID - ItemCodex.ITEM_WALLS.start == ingame.world.getTileFromWall(Terrarum.mouseTileX, Terrarum.mouseTileY) ||
|
||||||
|
this.inventoryCategory == Category.WIRE &&
|
||||||
|
1.shl(this.dynamicID - ItemCodex.ITEM_WIRES.start) and (ingame.world.getWires(Terrarum.mouseTileX, Terrarum.mouseTileY) ?: 0) != 0
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
|
||||||
|
// filter passed, do the job
|
||||||
|
// FIXME this is only useful for Player
|
||||||
|
if (i in ItemCodex.ITEM_TILES) {
|
||||||
|
ingame.world.setTileTerrain(
|
||||||
|
Terrarum.mouseTileX,
|
||||||
|
Terrarum.mouseTileY,
|
||||||
|
i
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ingame.world.setTileWall(
|
||||||
|
Terrarum.mouseTileX,
|
||||||
|
Terrarum.mouseTileY,
|
||||||
|
i
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import net.torvald.terrarum.gameactors.Actor
|
|||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.gamecontroller.IngameController
|
import net.torvald.terrarum.gamecontroller.IngameController
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.console.AVTracker
|
import net.torvald.terrarum.modulebasegame.console.AVTracker
|
||||||
import net.torvald.terrarum.modulebasegame.console.ActorsList
|
import net.torvald.terrarum.modulebasegame.console.ActorsList
|
||||||
@@ -394,9 +394,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
override fun worldPrimaryClickStart(delta: Float) {
|
override fun worldPrimaryClickStart(delta: Float) {
|
||||||
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
||||||
val consumptionSuccessful = ItemCodex[itemOnGrip]?.startPrimaryUse(delta) ?: false
|
ItemCodex[itemOnGrip]?.startPrimaryUse(delta)
|
||||||
if (consumptionSuccessful)
|
|
||||||
actorNowPlaying?.inventory?.consumeItem(ItemCodex[itemOnGrip]!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun worldPrimaryClickEnd(delta: Float) {
|
override fun worldPrimaryClickEnd(delta: Float) {
|
||||||
@@ -406,9 +404,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
override fun worldSecondaryClickStart(delta: Float) {
|
override fun worldSecondaryClickStart(delta: Float) {
|
||||||
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
val itemOnGrip = actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
||||||
val consumptionSuccessful = ItemCodex[itemOnGrip]?.startSecondaryUse(delta) ?: false
|
ItemCodex[itemOnGrip]?.startSecondaryUse(delta)
|
||||||
if (consumptionSuccessful)
|
|
||||||
actorNowPlaying?.inventory?.consumeItem(ItemCodex[itemOnGrip]!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun worldSecondaryClickEnd(delta: Float) {
|
override fun worldSecondaryClickEnd(delta: Float) {
|
||||||
@@ -751,8 +747,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
if (actor.referenceID == theRealGamer.referenceID || actor.referenceID == 0x51621D) // do not delete this magic
|
if (actor.referenceID == theRealGamer.referenceID || actor.referenceID == 0x51621D) // do not delete this magic
|
||||||
throw RuntimeException("Attempted to remove player.")
|
throw RuntimeException("Attempted to remove player.")
|
||||||
val indexToDelete = actorContainerActive.searchForIndex(actor.referenceID!!) { it.referenceID!! }
|
val indexToDelete = actorContainerActive.binarySearch(actor.referenceID!!)
|
||||||
if (indexToDelete != null) {
|
if (indexToDelete >= 0) {
|
||||||
printdbg(this, "Removing actor $actor")
|
printdbg(this, "Removing actor $actor")
|
||||||
printStackTrace()
|
printStackTrace()
|
||||||
|
|
||||||
@@ -787,28 +783,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ArrayList<*>.binarySearch(actor: Actor) = this.binarySearch(actor.referenceID!!)
|
|
||||||
|
|
||||||
private fun ArrayList<*>.binarySearch(ID: Int): Int {
|
|
||||||
// code from collections/Collections.kt
|
|
||||||
var low = 0
|
|
||||||
var high = this.size - 1
|
|
||||||
|
|
||||||
while (low <= high) {
|
|
||||||
val mid = (low + high).ushr(1) // safe from overflows
|
|
||||||
|
|
||||||
val midVal = get(mid)!!
|
|
||||||
|
|
||||||
if (ID > midVal.hashCode())
|
|
||||||
low = mid + 1
|
|
||||||
else if (ID < midVal.hashCode())
|
|
||||||
high = mid - 1
|
|
||||||
else
|
|
||||||
return mid // key found
|
|
||||||
}
|
|
||||||
return -(low + 1) // key not found
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for duplicates, append actor and sort the list
|
* Check for duplicates, append actor and sort the list
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ object IngameRenderer {
|
|||||||
LightmapRenderer.fireRecalculateEvent(actorsRenderBehind, actorsRenderFront, actorsRenderMidTop, actorsRenderMiddle, actorsRenderOverlay)
|
LightmapRenderer.fireRecalculateEvent(actorsRenderBehind, actorsRenderFront, actorsRenderMidTop, actorsRenderMiddle, actorsRenderOverlay)
|
||||||
|
|
||||||
prepLightmapRGBA()
|
prepLightmapRGBA()
|
||||||
BlocksDrawer.renderData()
|
BlocksDrawer.renderData(selectedWireBitToDraw)
|
||||||
drawToRGB(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
drawToRGB(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||||
drawToA(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
drawToA(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||||
drawOverlayActors(actorsRenderOverlay)
|
drawOverlayActors(actorsRenderOverlay)
|
||||||
@@ -214,6 +214,9 @@ object IngameRenderer {
|
|||||||
// works but some UI elements have wrong transparency -> should be fixed with Terrarum.gdxCleanAndSetBlend -- Torvald 2019-01-12
|
// works but some UI elements have wrong transparency -> should be fixed with Terrarum.gdxCleanAndSetBlend -- Torvald 2019-01-12
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|
||||||
|
|
||||||
|
selectedWireBitToDraw = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
import net.torvald.spriteanimation.HasAssembledSprite
|
import net.torvald.spriteanimation.HasAssembledSprite
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameactors.faction.Faction
|
import net.torvald.terrarum.gameactors.faction.Faction
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
import net.torvald.terrarum.itemproperties.Material
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||||
import net.torvald.terrarum.realestate.LandUtil
|
import net.torvald.terrarum.realestate.LandUtil
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -68,18 +68,18 @@ open class ActorHumanoid(
|
|||||||
if (houseDesignation != null) houseDesignation!!.clear()
|
if (houseDesignation != null) houseDesignation!!.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
override var color: Cvec
|
override var color: Color
|
||||||
get() = Cvec(
|
get() = Color(
|
||||||
(actorValue.getAsFloat(AVKey.LUMR) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
(actorValue.getAsFloat(AVKey.LUMR) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
||||||
(actorValue.getAsFloat(AVKey.LUMG) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
(actorValue.getAsFloat(AVKey.LUMG) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
||||||
(actorValue.getAsFloat(AVKey.LUMB) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
(actorValue.getAsFloat(AVKey.LUMB) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
||||||
(actorValue.getAsFloat(AVKey.LUMA) ?: 0f) / LightmapRenderer.MUL_FLOAT
|
(actorValue.getAsFloat(AVKey.LUMA) ?: 0f) / LightmapRenderer.MUL_FLOAT
|
||||||
)
|
)
|
||||||
set(value) {
|
set(value) {
|
||||||
actorValue[AVKey.LUMR] = value.vec.lane(0) * LightmapRenderer.MUL_FLOAT
|
actorValue[AVKey.LUMR] = value.r * LightmapRenderer.MUL_FLOAT
|
||||||
actorValue[AVKey.LUMG] = value.vec.lane(1) * LightmapRenderer.MUL_FLOAT
|
actorValue[AVKey.LUMG] = value.g * LightmapRenderer.MUL_FLOAT
|
||||||
actorValue[AVKey.LUMB] = value.vec.lane(2) * LightmapRenderer.MUL_FLOAT
|
actorValue[AVKey.LUMB] = value.b * LightmapRenderer.MUL_FLOAT
|
||||||
actorValue[AVKey.LUMA] = value.vec.lane(3) * LightmapRenderer.MUL_FLOAT
|
actorValue[AVKey.LUMA] = value.a * LightmapRenderer.MUL_FLOAT
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -154,7 +154,9 @@ open class ActorHumanoid(
|
|||||||
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.actorNowPlaying
|
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.actorNowPlaying
|
||||||
|
|
||||||
|
|
||||||
@Transient private val nullItem = object : GameItem(0) {
|
@Transient private val nullItem = object : GameItem() {
|
||||||
|
override var dynamicID: Int = 0
|
||||||
|
override val originalID = dynamicID
|
||||||
override val isUnique: Boolean = false
|
override val isUnique: Boolean = false
|
||||||
override var baseMass: Double = 0.0
|
override var baseMass: Double = 0.0
|
||||||
override var baseToolSize: Double? = null
|
override var baseToolSize: Double? = null
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameactors.Actor
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_DYNAMIC
|
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_DYNAMIC
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_WALLS
|
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_WALLS
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
import net.torvald.terrarum.lock
|
import net.torvald.terrarum.lock
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar
|
import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar
|
||||||
@@ -177,9 +177,7 @@ class ActorInventory(@Transient val actor: Pocketed, var maxCapacity: Int, var c
|
|||||||
false
|
false
|
||||||
|
|
||||||
|
|
||||||
fun consumeItem(item: GameItem) {
|
fun consumeItem(actor: Actor, item: GameItem) {
|
||||||
val actor = this.actor as Actor
|
|
||||||
|
|
||||||
if (item.stackable && !item.isDynamic) {
|
if (item.stackable && !item.isDynamic) {
|
||||||
remove(item, 1)
|
remove(item, 1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-31.
|
* Created by minjaesong on 2016-01-31.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ open class FixtureBase(val blockBox: BlockBox, val blockBoxProps: BlockBoxProps
|
|||||||
/**
|
/**
|
||||||
* Adds this instance of the fixture to the world
|
* Adds this instance of the fixture to the world
|
||||||
*
|
*
|
||||||
* @param posX tile-wise top-left position of the fixture
|
* @param posX top-left position of the fixture, tile-wise
|
||||||
* @param posY tile-wise top-left position of the fixture
|
* @param posY top-left position of the fixture, tile-wise
|
||||||
* @return true if successfully spawned, false if was not (e.g. occupied space)
|
|
||||||
*/
|
*/
|
||||||
open fun spawn(posX: Int, posY: Int): Boolean {
|
open fun spawn(posX: Int, posY: Int) {
|
||||||
// place filler blocks
|
// place filler blocks
|
||||||
// place the filler blocks where:
|
// place the filler blocks where:
|
||||||
// origin posX: centre-left if mouseX is on the right-half of the game window,
|
// origin posX: centre-left if mouseX is on the right-half of the game window,
|
||||||
@@ -53,9 +52,6 @@ open class FixtureBase(val blockBox: BlockBox, val blockBoxProps: BlockBoxProps
|
|||||||
this.isVisible = true
|
this.isVisible = true
|
||||||
this.hitbox.setFromWidthHeight(posX * TSIZE, posY * TSIZE, blockBox.width * TSIZE, blockBox.height * TSIZE)
|
this.hitbox.setFromWidthHeight(posX * TSIZE, posY * TSIZE, blockBox.width * TSIZE, blockBox.height * TSIZE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true // TODO for the tests' sake, just get fucking spawned
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import net.torvald.terrarum.ModMgr
|
import net.torvald.terrarum.ModMgr
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameactors.Hitbox
|
import net.torvald.terrarum.gameactors.Hitbox
|
||||||
import net.torvald.terrarum.gameactors.Luminous
|
import net.torvald.terrarum.gameactors.Luminous
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ internal class FixtureTikiTorch : FixtureBase(
|
|||||||
BlockBox(BlockBox.NO_COLLISION, 1, 2)
|
BlockBox(BlockBox.NO_COLLISION, 1, 2)
|
||||||
), Luminous {
|
), Luminous {
|
||||||
|
|
||||||
override var color: Cvec
|
override var color: Color
|
||||||
get() = BlockCodex[Block.TORCH].luminosity
|
get() = BlockCodex[Block.TORCH].luminosity
|
||||||
set(value) {
|
set(value) {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.gameactors.AIControlled
|
import net.torvald.terrarum.gameactors.AIControlled
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
import net.torvald.terrarum.itemproperties.Material
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||||
|
|
||||||
@@ -16,8 +16,8 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
|||||||
open class HumanoidNPC(
|
open class HumanoidNPC(
|
||||||
override val ai: ActorAI, // it's there for written-in-Kotlin, "hard-wired" AIs
|
override val ai: ActorAI, // it's there for written-in-Kotlin, "hard-wired" AIs
|
||||||
born: time_t,
|
born: time_t,
|
||||||
usePhysics: Boolean = true
|
usePhysics: Boolean = true,
|
||||||
//forceAssignRefID: Int? = null
|
forceAssignRefID: Int? = null
|
||||||
) : ActorHumanoid(born, usePhysics = usePhysics), AIControlled, CanBeAnItem {
|
) : ActorHumanoid(born, usePhysics = usePhysics), AIControlled, CanBeAnItem {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -29,7 +29,9 @@ open class HumanoidNPC(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we're having GameItem data so that this class could be somewhat universal
|
// we're having GameItem data so that this class could be somewhat universal
|
||||||
override var itemData: GameItem = object : GameItem(referenceID) {//GameItem(referenceID ?: forceAssignRefID!!) {
|
override var itemData: GameItem = object : GameItem() {
|
||||||
|
override var dynamicID = referenceID ?: forceAssignRefID!!
|
||||||
|
override val originalID = dynamicID
|
||||||
override val isUnique = true
|
override val isUnique = true
|
||||||
override var baseMass: Double
|
override var baseMass: Double
|
||||||
get() = actorValue.getAsDouble(AVKey.BASEMASS)!!
|
get() = actorValue.getAsDouble(AVKey.BASEMASS)!!
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
|||||||
* Created by minjaesong on 2015-12-31.
|
* Created by minjaesong on 2015-12-31.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class IngamePlayer(
|
class IngamePlayer(override var animDescPath: String, born: time_t) : ActorHumanoid(born), HasAssembledSprite {
|
||||||
override var animDescPath: String,
|
|
||||||
override var animDescPathGlow: String? = null,
|
|
||||||
born: time_t
|
|
||||||
) : ActorHumanoid(born), HasAssembledSprite {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ object PlayerBuilder {
|
|||||||
operator fun invoke(): Actor {
|
operator fun invoke(): Actor {
|
||||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||||
|
|
||||||
val p: Actor = IngamePlayer("lol", "lol_glow", world.time.TIME_T)
|
val p: Actor = IngamePlayer("lol", world.time.TIME_T)
|
||||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||||
|
|
||||||
// attach sprite
|
// attach sprite
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
object PlayerBuilderSigrid {
|
object PlayerBuilderSigrid {
|
||||||
|
|
||||||
operator fun invoke(): IngamePlayer {
|
operator fun invoke(): IngamePlayer {
|
||||||
val p = IngamePlayer("lol", "lol_glow", - 9223372036854775807L) // XD
|
val p = IngamePlayer("lol", - 9223372036854775807L) // XD
|
||||||
|
|
||||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||||
|
|
||||||
@@ -82,13 +82,10 @@ object PlayerBuilderSigrid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// item ids are defined in <module>/items/itemid.csv
|
|
||||||
|
|
||||||
inventory.add(8448) // copper pick
|
inventory.add(8448) // copper pick
|
||||||
inventory.add(8449) // iron pick
|
inventory.add(8449) // iron pick
|
||||||
inventory.add(8450) // steel pick
|
inventory.add(8450) // steel pick
|
||||||
inventory.add(8466, 9995) // wire piece
|
inventory.add(8466) // wire piece
|
||||||
inventory.add(8467, 9995) // test tiki torch
|
|
||||||
inventory.add(9000) // TEST water bucket
|
inventory.add(9000) // TEST water bucket
|
||||||
inventory.add(9001) // TEST lava bucket
|
inventory.add(9001) // TEST lava bucket
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,14 @@ import net.torvald.spriteanimation.SpriteAnimation
|
|||||||
import net.torvald.terrarum.ModMgr
|
import net.torvald.terrarum.ModMgr
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||||
|
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-02-10.
|
* Created by minjaesong on 2017-02-10.
|
||||||
*/
|
*/
|
||||||
object PlayerBuilderTestSubject1 {
|
object PlayerBuilderTestSubject1 {
|
||||||
operator fun invoke(): IngamePlayer {
|
operator fun invoke(): IngamePlayer {
|
||||||
val p: IngamePlayer = IngamePlayer(
|
val p: IngamePlayer = IngamePlayer(ModMgr.getPath("basegame", "sprites/test_sprite.properties"), -589141658L) // random value thrown
|
||||||
ModMgr.getPath("basegame", "sprites/furry_sprite.properties"),
|
|
||||||
ModMgr.getPath("basegame", "sprites/furry_sprite_glow.properties"),
|
|
||||||
-589141658L // random value thrown
|
|
||||||
)
|
|
||||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||||
|
|
||||||
|
|
||||||
@@ -29,8 +26,7 @@ object PlayerBuilderTestSubject1 {
|
|||||||
p.sprite!!.setRowsAndFrames(2, 4)*/
|
p.sprite!!.setRowsAndFrames(2, 4)*/
|
||||||
|
|
||||||
p.sprite = SpriteAnimation(p)
|
p.sprite = SpriteAnimation(p)
|
||||||
p.spriteGlow = SpriteAnimation(p)
|
p.reassembleSprite(p.sprite!!)
|
||||||
p.reassembleSprite(p.sprite!!, p.spriteGlow)
|
|
||||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||||
|
|
||||||
p.setPosition(3.0 * CreateTileAtlas.TILE_SIZE, 3.0 * CreateTileAtlas.TILE_SIZE)
|
p.setPosition(3.0 * CreateTileAtlas.TILE_SIZE, 3.0 * CreateTileAtlas.TILE_SIZE)
|
||||||
@@ -38,10 +34,10 @@ object PlayerBuilderTestSubject1 {
|
|||||||
|
|
||||||
PlayerBuilderSigrid.fillTestInventory(p.inventory)
|
PlayerBuilderSigrid.fillTestInventory(p.inventory)
|
||||||
|
|
||||||
//p.actorValue[AVKey.LUMR] = 0.84
|
p.actorValue[AVKey.LUMR] = 0.84
|
||||||
//p.actorValue[AVKey.LUMG] = 0.93
|
p.actorValue[AVKey.LUMG] = 0.93
|
||||||
//p.actorValue[AVKey.LUMB] = 1.37
|
p.actorValue[AVKey.LUMB] = 1.37
|
||||||
//p.actorValue[AVKey.LUMA] = 1.93
|
p.actorValue[AVKey.LUMA] = 1.93
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-15.
|
* Created by minjaesong on 2016-01-15.
|
||||||
@@ -78,4 +79,15 @@ interface Pocketed {
|
|||||||
fun hasItem(item: GameItem) = inventory.contains(item.dynamicID)
|
fun hasItem(item: GameItem) = inventory.contains(item.dynamicID)
|
||||||
fun hasItem(id: Int) = inventory.contains(id)
|
fun hasItem(id: Int) = inventory.contains(id)
|
||||||
|
|
||||||
|
|
||||||
|
fun consumePrimary(item: GameItem) {
|
||||||
|
if (item.startPrimaryUse(AppLoader.UPDATE_RATE.toFloat())) {
|
||||||
|
inventory.consumeItem(this as Actor, item) // consume on successful
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun consumeSecondary(item: GameItem) {
|
||||||
|
if (item.startSecondaryUse(AppLoader.UPDATE_RATE.toFloat()))
|
||||||
|
inventory.consumeItem(this as Actor, item) // consume on successful
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,6 @@ import net.torvald.terrarum.blockproperties.BlockCodex
|
|||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.gameactors.Hitbox
|
import net.torvald.terrarum.gameactors.Hitbox
|
||||||
import net.torvald.terrarum.gameactors.Luminous
|
import net.torvald.terrarum.gameactors.Luminous
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -32,8 +31,8 @@ open class ProjectileSimple(
|
|||||||
val speed: Int
|
val speed: Int
|
||||||
|
|
||||||
|
|
||||||
override var color: Cvec
|
override var color: Color
|
||||||
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Cvec)
|
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Color).cpy()
|
||||||
set(value) {
|
set(value) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -119,8 +118,8 @@ open class ProjectileSimple(
|
|||||||
val OFFSET_LUMINOSITY = 4
|
val OFFSET_LUMINOSITY = 4
|
||||||
val bulletDatabase = arrayOf(
|
val bulletDatabase = arrayOf(
|
||||||
// damage, display colour, no gravity, speed
|
// damage, display colour, no gravity, speed
|
||||||
arrayOf(7, Cvec(1f, .329f, .161f, 1f), true, 40, 32),
|
arrayOf(7, Color(0xFF5429_FF.toInt()), true, 40, 32),
|
||||||
arrayOf(8, Cvec(1f, .329f, .161f, 1f), true, 20, 0)
|
arrayOf(8, Color(0xFF5429_FF.toInt()), true, 20, 0)
|
||||||
// ...
|
// ...
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.gameactors.Hitbox
|
import net.torvald.terrarum.gameactors.Hitbox
|
||||||
import net.torvald.terrarum.gameactors.Luminous
|
import net.torvald.terrarum.gameactors.Luminous
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-04-26.
|
* Created by minjaesong on 2016-04-26.
|
||||||
@@ -20,7 +21,7 @@ class WeaponSwung(val itemID: Int) : ActorWBMovable(RenderOrder.MIDTOP), Luminou
|
|||||||
actorValue[AVKey.LUMINOSITY] = value
|
actorValue[AVKey.LUMINOSITY] = value
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
override var color: Cvec
|
override var color: Color
|
||||||
get() = throw UnsupportedOperationException()
|
get() = throw UnsupportedOperationException()
|
||||||
set(value) {
|
set(value) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameitems
|
|
||||||
|
|
||||||
import net.torvald.terrarum.Point2d
|
|
||||||
import net.torvald.terrarum.Point2i
|
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
|
||||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
|
||||||
import net.torvald.terrarum.realestate.LandUtil
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by minjaesong on 2019-05-02.
|
|
||||||
*/
|
|
||||||
object BlockBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param dontEncaseActors when set to true, blocks won't be placed where Actors are. You will want to set it false
|
|
||||||
* for wire items, otherwise you want it to be true.
|
|
||||||
*/
|
|
||||||
fun blockStartPrimaryUse(gameItem: GameItem, itemID: Int, delta: Float): Boolean {
|
|
||||||
val ingame = Terrarum.ingame!! as Ingame
|
|
||||||
val mousePoint = Point2d(Terrarum.mouseTileX.toDouble(), Terrarum.mouseTileY.toDouble())
|
|
||||||
val mouseTile = Point2i(Terrarum.mouseTileX, Terrarum.mouseTileY)
|
|
||||||
|
|
||||||
// check for collision with actors (BLOCK only)
|
|
||||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK) {
|
|
||||||
var ret1 = true
|
|
||||||
ingame.actorContainerActive.forEach {
|
|
||||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
|
||||||
ret1 = false // return is not allowed here
|
|
||||||
}
|
|
||||||
if (!ret1) return ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
// return false if the tile is already there
|
|
||||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK &&
|
|
||||||
gameItem.dynamicID == ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y) ||
|
|
||||||
gameItem.inventoryCategory == GameItem.Category.WALL &&
|
|
||||||
gameItem.dynamicID - ItemCodex.ITEM_WALLS.start == ingame.world.getTileFromWall(mouseTile.x, mouseTile.y)
|
|
||||||
)
|
|
||||||
return false
|
|
||||||
|
|
||||||
// filter passed, do the job
|
|
||||||
// FIXME this is only useful for Player
|
|
||||||
if (itemID in ItemCodex.ITEM_TILES) {
|
|
||||||
ingame.world.setTileTerrain(
|
|
||||||
mouseTile.x,
|
|
||||||
mouseTile.y,
|
|
||||||
itemID
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ingame.world.setTileWall(
|
|
||||||
mouseTile.x,
|
|
||||||
mouseTile.y,
|
|
||||||
itemID
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
fun blockEffectWhenEquipped(delta: Float) {
|
|
||||||
IngameRenderer.selectedWireBitToDraw = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fun wireStartPrimaryUse(gameItem: GameItem, wireTypeBit: Int, delta: Float): Boolean {
|
|
||||||
val ingame = Terrarum.ingame!! as Ingame
|
|
||||||
val mouseTile = Point2i(Terrarum.mouseTileX, Terrarum.mouseTileY)
|
|
||||||
|
|
||||||
// return false if the tile is already there
|
|
||||||
if (ingame.world.getWiringBlocks(mouseTile.x, mouseTile.y) and wireTypeBit != 0)
|
|
||||||
return false
|
|
||||||
|
|
||||||
// filter passed, do the job
|
|
||||||
// FIXME this is only useful for Player
|
|
||||||
ingame.world.addNewConduitTo(
|
|
||||||
mouseTile.x,
|
|
||||||
mouseTile.y,
|
|
||||||
GameWorld.WiringNode(
|
|
||||||
LandUtil.getBlockAddr(ingame.world, mouseTile.x, mouseTile.y),
|
|
||||||
wireTypeBit,
|
|
||||||
0f
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
fun wireEffectWhenEquipped(typebit: Int, delta: Float) {
|
|
||||||
IngameRenderer.selectedWireBitToDraw = typebit
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameitems
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
|
||||||
import net.torvald.terrarum.AppLoader
|
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by minjaesong on 2019-05-16.
|
|
||||||
*/
|
|
||||||
class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
|
|
||||||
|
|
||||||
override var dynamicID: ItemID = originalID
|
|
||||||
override val originalName = "Tiki Torch"
|
|
||||||
override var baseMass = 1.0
|
|
||||||
override var stackable = true
|
|
||||||
override var inventoryCategory = Category.FIXTURE
|
|
||||||
override val isUnique = false
|
|
||||||
override val isDynamic = false
|
|
||||||
override val material = Material()
|
|
||||||
override val itemImage: TextureRegion?
|
|
||||||
get() = AppLoader.resourcePool.getAsTextureRegion("itemplaceholder_48")
|
|
||||||
override var baseToolSize: Double? = baseMass
|
|
||||||
|
|
||||||
override fun startPrimaryUse(delta: Float): Boolean {
|
|
||||||
val torch = FixtureTikiTorch()
|
|
||||||
|
|
||||||
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
|
|
||||||
// return true when placed, false when cannot be placed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameitems
|
package net.torvald.terrarum.modulebasegame.items
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
@@ -7,13 +7,13 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
|
||||||
import net.torvald.terrarum.itemproperties.Calculate
|
import net.torvald.terrarum.itemproperties.Calculate
|
||||||
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
|
import net.torvald.terrarum.modulebasegame.items.PickaxeCore.BASE_MASS_AND_SIZE
|
||||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.TOOL_DURABILITY_BASE
|
import net.torvald.terrarum.modulebasegame.items.PickaxeCore.TOOL_DURABILITY_BASE
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@@ -74,8 +74,9 @@ object PickaxeCore {
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-07-17.
|
* Created by minjaesong on 2017-07-17.
|
||||||
*/
|
*/
|
||||||
class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
|
class PickaxeCopper(override val originalID: ItemID) : GameItem() {
|
||||||
|
|
||||||
|
override var dynamicID: ItemID = originalID
|
||||||
override val originalName = "PACKAGED_PICK"
|
override val originalName = "PACKAGED_PICK"
|
||||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||||
override var stackable = true
|
override var stackable = true
|
||||||
@@ -101,8 +102,9 @@ class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2019-03-10.
|
* Created by minjaesong on 2019-03-10.
|
||||||
*/
|
*/
|
||||||
class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
|
class PickaxeIron(override val originalID: ItemID) : GameItem() {
|
||||||
|
|
||||||
|
override var dynamicID: ItemID = originalID
|
||||||
override val originalName = "PACKAGED_PICK"
|
override val originalName = "PACKAGED_PICK"
|
||||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||||
override var stackable = true
|
override var stackable = true
|
||||||
@@ -128,8 +130,9 @@ class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2019-03-10.
|
* Created by minjaesong on 2019-03-10.
|
||||||
*/
|
*/
|
||||||
class PickaxeSteel(originalID: ItemID) : GameItem(originalID) {
|
class PickaxeSteel(override val originalID: ItemID) : GameItem() {
|
||||||
|
|
||||||
|
override var dynamicID: ItemID = originalID
|
||||||
override val originalName = "PACKAGED_PICK"
|
override val originalName = "PACKAGED_PICK"
|
||||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||||
override var stackable = true
|
override var stackable = true
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameitems
|
package net.torvald.terrarum.modulebasegame.items
|
||||||
|
|
||||||
import net.torvald.random.Fudge3
|
import net.torvald.random.Fudge3
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
@@ -25,6 +24,6 @@ object WeaponMeleeCore {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class WeaponMeleeBase(originalID: ItemID) : GameItem(originalID) {
|
abstract class WeaponMeleeBase : GameItem() {
|
||||||
abstract val velocityMod: Double
|
abstract val velocityMod: Double
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,18 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameitems
|
package net.torvald.terrarum.modulebasegame.items
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.blockproperties.Wire
|
import net.torvald.terrarum.blockproperties.Wire
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
import net.torvald.terrarum.itemproperties.Material
|
import net.torvald.terrarum.itemproperties.Material
|
||||||
|
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||||
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2019-03-10.
|
* Created by minjaesong on 2019-03-10.
|
||||||
*/
|
*/
|
||||||
class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
|
class WirePieceSignalWire(override val originalID: ItemID) : GameItem() {
|
||||||
|
|
||||||
override var dynamicID: ItemID = originalID
|
override var dynamicID: ItemID = originalID
|
||||||
override val originalName = "ITEM_WIRE"
|
override val originalName = "ITEM_WIRE"
|
||||||
@@ -22,7 +24,7 @@ class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
|
|||||||
override val isDynamic = false
|
override val isDynamic = false
|
||||||
override val material = Material()
|
override val material = Material()
|
||||||
override val itemImage: TextureRegion?
|
override val itemImage: TextureRegion?
|
||||||
get() = AppLoader.resourcePool.getAsTextureRegionPack("basegame.items16").get(1,9)
|
get() = (AppLoader.resourcePool["basegame.items16"] as TextureRegionPack).get(1,9)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
|
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
|
||||||
@@ -30,10 +32,11 @@ class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun startPrimaryUse(delta: Float): Boolean {
|
override fun startPrimaryUse(delta: Float): Boolean {
|
||||||
return BlockBase.wireStartPrimaryUse(this, Wire.BIT_SIGNAL_RED, delta)
|
return super.startPrimaryUse(delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun effectWhenEquipped(delta: Float) {
|
override fun effectWhenEquipped(delta: Float) {
|
||||||
BlockBase.wireEffectWhenEquipped(Wire.BIT_SIGNAL_RED, delta)
|
IngameRenderer.selectedWireBitToDraw = Wire.BIT_SIGNAL_RED
|
||||||
|
//println("wires!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.toInt
|
import net.torvald.terrarum.toInt
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import net.torvald.terrarum.GdxColorMap
|
import net.torvald.terrarum.GdxColorMap
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.ui.UIItem
|
import net.torvald.terrarum.ui.UIItem
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK
|
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
|||||||
import net.torvald.terrarum.modulebasegame.worldgenerator.WorldGenerator
|
import net.torvald.terrarum.modulebasegame.worldgenerator.WorldGenerator
|
||||||
import net.torvald.terrarum.utils.JsonFetcher
|
import net.torvald.terrarum.utils.JsonFetcher
|
||||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||||
import net.torvald.terrarum.worlddrawer.Cvec
|
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -52,8 +51,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
|
|
||||||
lateinit var mixedWeather: BaseModularWeather
|
lateinit var mixedWeather: BaseModularWeather
|
||||||
|
|
||||||
var globalLightNow = Cvec()
|
val globalLightNow = Color(0)
|
||||||
private set
|
|
||||||
|
|
||||||
// Weather indices
|
// Weather indices
|
||||||
const val WEATHER_GENERIC = "generic"
|
const val WEATHER_GENERIC = "generic"
|
||||||
@@ -135,7 +133,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
|
|
||||||
// calculate global light
|
// calculate global light
|
||||||
val globalLight = getGradientColour(skyboxColourMap, 2, timeNow)
|
val globalLight = getGradientColour(skyboxColourMap, 2, timeNow)
|
||||||
globalLightNow = Cvec(globalLight.r, globalLight.g, globalLight.b, globalLight.a)
|
globalLightNow.set(globalLight)
|
||||||
|
|
||||||
|
|
||||||
/* (copied from the shader source)
|
/* (copied from the shader source)
|
||||||
@@ -180,10 +178,8 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
/**
|
/**
|
||||||
* Get a GL of specific time
|
* Get a GL of specific time
|
||||||
*/
|
*/
|
||||||
fun getGlobalLightOfTime(timeInSec: Int): Cvec {
|
fun getGlobalLightOfTime(timeInSec: Int): Color =
|
||||||
val c = getGradientColour(currentWeather.skyboxGradColourMap, 2, timeInSec)
|
getGradientColour(currentWeather.skyboxGradColourMap, 2, timeInSec)
|
||||||
return Cvec(c.r, c.g, c.b, c.a)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getGradientColour(colorMap: GdxColorMap, row: Int, timeInSec: Int): Color {
|
fun getGradientColour(colorMap: GdxColorMap, row: Int, timeInSec: Int): Color {
|
||||||
val dataPointDistance = WorldTime.DAY_LENGTH / colorMap.width
|
val dataPointDistance = WorldTime.DAY_LENGTH / colorMap.width
|
||||||
|
|||||||
Binary file not shown.
@@ -5,7 +5,7 @@ import net.torvald.terrarum.AppLoader
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.gameactors.AVKey
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
import net.torvald.terrarum.gameactors.Actor
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
import net.torvald.terrarum.gameitem.GameItem
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.*
|
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.*
|
||||||
import net.torvald.terrarum.roundInt
|
import net.torvald.terrarum.roundInt
|
||||||
|
|||||||
BIN
src/net/torvald/terrarum/terrarum.zip
Normal file
BIN
src/net/torvald/terrarum/terrarum.zip
Normal file
Binary file not shown.
@@ -4,8 +4,8 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.InputAdapter
|
import com.badlogic.gdx.InputAdapter
|
||||||
import com.badlogic.gdx.ScreenAdapter
|
import com.badlogic.gdx.ScreenAdapter
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.Pixmap
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
@@ -15,22 +15,16 @@ import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
|||||||
import com.sudoplay.joise.Joise
|
import com.sudoplay.joise.Joise
|
||||||
import com.sudoplay.joise.module.ModuleBasisFunction
|
import com.sudoplay.joise.module.ModuleBasisFunction
|
||||||
import com.sudoplay.joise.module.ModuleFractal
|
import com.sudoplay.joise.module.ModuleFractal
|
||||||
import com.sudoplay.joise.module.ModuleScaleDomain
|
|
||||||
import com.sudoplay.joise.module.ModuleScaleOffset
|
import com.sudoplay.joise.module.ModuleScaleOffset
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.concurrent.BlockingThreadPool
|
import net.torvald.terrarum.concurrent.BlockingThreadPool
|
||||||
import net.torvald.terrarum.concurrent.RunnableFun
|
|
||||||
import net.torvald.terrarum.concurrent.ParallelUtils.sliceEvenly
|
import net.torvald.terrarum.concurrent.ParallelUtils.sliceEvenly
|
||||||
import net.torvald.terrarum.concurrent.ThreadParallel
|
|
||||||
import net.torvald.terrarum.inUse
|
import net.torvald.terrarum.inUse
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.roundInt
|
import net.torvald.terrarum.roundInt
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
import kotlin.system.measureNanoTime
|
|
||||||
import kotlin.system.measureTimeMillis
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2018-12-14.
|
* Created by minjaesong on 2018-12-14.
|
||||||
@@ -50,11 +44,11 @@ class NoiseGenerator : ScreenAdapter() {
|
|||||||
Gdx.input.inputProcessor = NoiseGeneratorController(this)
|
Gdx.input.inputProcessor = NoiseGeneratorController(this)
|
||||||
|
|
||||||
batch = SpriteBatch()
|
batch = SpriteBatch()
|
||||||
camera = OrthographicCamera(AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
camera = OrthographicCamera(AppLoader.setWindowWidth.toFloat(), AppLoader.setWindowHeight.toFloat())
|
||||||
|
|
||||||
camera.setToOrtho(true, AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
camera.setToOrtho(true, AppLoader.setWindowWidth.toFloat(), AppLoader.setWindowHeight.toFloat())
|
||||||
camera.update()
|
camera.update()
|
||||||
Gdx.gl20.glViewport(0, 0, AppLoader.appConfig.width, AppLoader.appConfig.height)
|
Gdx.gl20.glViewport(0, 0, AppLoader.setWindowWidth, AppLoader.setWindowHeight)
|
||||||
|
|
||||||
pixmap = Pixmap(IMAGE_SIZE, IMAGE_SIZE, Pixmap.Format.RGBA8888)
|
pixmap = Pixmap(IMAGE_SIZE, IMAGE_SIZE, Pixmap.Format.RGBA8888)
|
||||||
texture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
texture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
||||||
@@ -255,14 +249,10 @@ class NoiseGeneratorController(val host: NoiseGenerator) : InputAdapter() {
|
|||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
ShaderProgram.pedantic = false
|
ShaderProgram.pedantic = false
|
||||||
|
|
||||||
val appConfig = LwjglApplicationConfiguration()
|
val appConfig = Lwjgl3ApplicationConfiguration()
|
||||||
appConfig.vSyncEnabled = false
|
appConfig.useVsync(false)
|
||||||
appConfig.resizable = false//true;
|
appConfig.setResizable(false)
|
||||||
appConfig.width = 1024
|
appConfig.setWindowedMode(1024, 1024)
|
||||||
appConfig.height = 1024
|
|
||||||
appConfig.backgroundFPS = 9999
|
|
||||||
appConfig.foregroundFPS = 9999
|
|
||||||
appConfig.forceExit = false
|
|
||||||
|
|
||||||
LwjglApplication(AppLoader(appConfig, NoiseGenerator()), appConfig)
|
Lwjgl3Application(AppLoader(appConfig, NoiseGenerator(), 1024, 1024), appConfig)
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,8 @@ package net.torvald.terrarum.tests
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.InputAdapter
|
import com.badlogic.gdx.InputAdapter
|
||||||
import com.badlogic.gdx.ScreenAdapter
|
import com.badlogic.gdx.ScreenAdapter
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
@@ -67,13 +67,13 @@ class UITestPad1 : ScreenAdapter() {
|
|||||||
Yaml(treeStr)
|
Yaml(treeStr)
|
||||||
)
|
)
|
||||||
batch = SpriteBatch()
|
batch = SpriteBatch()
|
||||||
camera = OrthographicCamera(AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
camera = OrthographicCamera(AppLoader.setWindowWidth.toFloat(), AppLoader.setWindowHeight.toFloat())
|
||||||
|
|
||||||
camera.setToOrtho(true, AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
camera.setToOrtho(true, AppLoader.setWindowWidth.toFloat(), AppLoader.setWindowHeight.toFloat())
|
||||||
camera.update()
|
camera.update()
|
||||||
Gdx.gl20.glViewport(0, 0, AppLoader.appConfig.width, AppLoader.appConfig.height)
|
Gdx.gl20.glViewport(0, 0, AppLoader.setWindowWidth, AppLoader.setWindowHeight)
|
||||||
|
|
||||||
resize(AppLoader.appConfig.width, AppLoader.appConfig.height)
|
resize(AppLoader.setWindowWidth, AppLoader.setWindowHeight)
|
||||||
|
|
||||||
nsMenu.setPosition(0, 0)
|
nsMenu.setPosition(0, 0)
|
||||||
nsMenu.setAsAlwaysVisible()
|
nsMenu.setAsAlwaysVisible()
|
||||||
@@ -148,16 +148,8 @@ class UITestPad1Controller(val host: UITestPad1) : InputAdapter() {
|
|||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
ShaderProgram.pedantic = false
|
ShaderProgram.pedantic = false
|
||||||
|
|
||||||
val appConfig = LwjglApplicationConfiguration()
|
val appConfig = Lwjgl3ApplicationConfiguration()
|
||||||
appConfig.vSyncEnabled = false
|
appConfig.setWindowedMode(1110, 740)
|
||||||
appConfig.resizable = false//true;
|
|
||||||
//appConfig.width = 1072; // IMAX ratio
|
|
||||||
//appConfig.height = 742; // IMAX ratio
|
|
||||||
appConfig.width = 1110 // photographic ratio (1.5:1)
|
|
||||||
appConfig.height = 740 // photographic ratio (1.5:1)
|
|
||||||
appConfig.backgroundFPS = 9999
|
|
||||||
appConfig.foregroundFPS = 9999
|
|
||||||
appConfig.forceExit = false
|
|
||||||
|
|
||||||
LwjglApplication(AppLoader(appConfig, UITestPad1()), appConfig)
|
Lwjgl3Application(AppLoader(appConfig, UITestPad1(), 1110, 740), appConfig)
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user