feat: Multiplayer #2
41
.gitignore
vendored
41
.gitignore
vendored
@@ -1,42 +1 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
.kotlin
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
.idea/FuzzierSettings.xml
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
logs
|
||||
|
||||
14
.idea/FuzzierSettings.xml
generated
Normal file
14
.idea/FuzzierSettings.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="com.mituuz.fuzzier.FuzzierSettings">
|
||||
<option name="modules">
|
||||
<map>
|
||||
<entry key="common" value="$PROJECT_DIR$" />
|
||||
<entry key="game" value="$PROJECT_DIR$" />
|
||||
<entry key="game (1)" value="$PROJECT_DIR$" />
|
||||
<entry key="server" value="$PROJECT_DIR$" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="recentlySearchedFiles" value="rO0ABXNyABxqYXZheC5zd2luZy5EZWZhdWx0TGlzdE1vZGVsBgfGCGLvV2ICAAFMAAhkZWxlZ2F0ZXQAEkxqYXZhL3V0aWwvVmVjdG9yO3hyAB1qYXZheC5zd2luZy5BYnN0cmFjdExpc3RNb2RlbFrW+oYSs63tAgABTAAMbGlzdGVuZXJMaXN0dAAlTGphdmF4L3N3aW5nL2V2ZW50L0V2ZW50TGlzdGVuZXJMaXN0O3hwc3IAI2phdmF4LnN3aW5nLmV2ZW50LkV2ZW50TGlzdGVuZXJMaXN0kUjMLXPfDt4DAAB4cHB4c3IAEGphdmEudXRpbC5WZWN0b3LZl31bgDuvAQMAA0kAEWNhcGFjaXR5SW5jcmVtZW50SQAMZWxlbWVudENvdW50WwALZWxlbWVudERhdGF0ABNbTGphdmEvbGFuZy9PYmplY3Q7eHAAAAAAAAAAB3VyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAApzcgBIY29tLm1pdHV1ei5mdXp6aWVyLmVudGl0aWVzLkZ1enp5TWF0Y2hDb250YWluZXIkU2VyaWFsaXplZE1hdGNoQ29udGFpbmVy2S8sP5uny74CAARMAAhmaWxlUGF0aHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wACGZpbGVuYW1lcQB+AA1MAA5tb2R1bGVCYXNlUGF0aHEAfgANTAAFc2NvcmV0ADxMY29tL21pdHV1ei9mdXp6aWVyL2VudGl0aWVzL0Z1enp5TWF0Y2hDb250YWluZXIkRnV6enlTY29yZTt4cHQARC9nYW1lL3NyYy9tYWluL2phdmEvY3ovanppdG5pay9jbGllbnQvdXRpbHMvZXZlbnRzL0V2ZW50TWFuYWdlci5qYXZhdAARRXZlbnRNYW5hZ2VyLmphdmF0ABYvaG9tZS9rdWJhL0NvZGluZy9nYW1lc3IAOmNvbS5taXR1dXouZnV6emllci5lbnRpdGllcy5GdXp6eU1hdGNoQ29udGFpbmVyJEZ1enp5U2NvcmUvP9P07ROG2QIABUkADWZpbGVuYW1lU2NvcmVJAA9tdWx0aU1hdGNoU2NvcmVJABBwYXJ0aWFsUGF0aFNjb3JlSQALc3RyZWFrU2NvcmVMABNoaWdobGlnaHRDaGFyYWN0ZXJzdAAPTGphdmEvdXRpbC9TZXQ7eHAAAAAMAAAAAAAAAAoAAAAHc3IAEWphdmEudXRpbC5IYXNoU2V0ukSFlZa4tzQDAAB4cHcMAAAAED9AAAAAAAAMc3IAEWphdmEubGFuZy5JbnRlZ2VyEuKgpPeBhzgCAAFJAAV2YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAAABzcQB+ABgAAAABc3EAfgAYAAAAAnNxAH4AGAAAAANzcQB+ABgAAAAEc3EAfgAYAAAABXNxAH4AGAAAAAZzcQB+ABgAAAAHc3EAfgAYAAAACHNxAH4AGAAAAAlzcQB+ABgAAAAKc3EAfgAYAAAAC3hzcQB+AAx0AEQvZ2FtZS9zcmMvbWFpbi9qYXZhL2N6L2p6aXRuaWsvY2xpZW50L3NvY2tldC9Tb2NrZXRFdmVudE1hbmFnZXIuamF2YXQAF1NvY2tldEV2ZW50TWFuYWdlci5qYXZhdAAWL2hvbWUva3ViYS9Db2RpbmcvZ2FtZXNxAH4AEwAAABEAAAAAAAAAAAAAAApzcQB+ABZ3DAAAACA/QAAAAAAAEXEAfgAacQB+ABtxAH4AHHEAfgAdcQB+AB5xAH4AH3EAfgAgcQB+ACFxAH4AInEAfgAjcQB+ACRxAH4AJXNxAH4AGAAAAAxzcQB+ABgAAAANc3EAfgAYAAAADnNxAH4AGAAAAA9zcQB+ABgAAAAQeHNxAH4ADHQADS9nYW1lL3BvbS54bWx0AAdwb20ueG1sdAAWL2hvbWUva3ViYS9Db2RpbmcvZ2FtZXNxAH4AEwAAAAAAAAAAAAAAAAAAAAxzcQB+ABZ3DAAAAAE/QAAAAAAAAHhzcQB+AAx0AEkvZ2FtZS9zcmMvbWFpbi9qYXZhL2N6L2p6aXRuaWsvY2xpZW50L2Fubm90YXRpb25zL1NvY2tldEV2ZW50SGFuZGxlci5qYXZhdAAXU29ja2V0RXZlbnRIYW5kbGVyLmphdmF0ABYvaG9tZS9rdWJhL0NvZGluZy9nYW1lc3EAfgATAAAAEgAAAAAAAAAKAAAAEHNxAH4AFncMAAAAID9AAAAAAAAScQB+ABpxAH4AG3EAfgAccQB+AB1xAH4AHnEAfgAfcQB+ACBxAH4AIXEAfgAicQB+ACNxAH4AJHEAfgAlcQB+ACxxAH4ALXEAfgAucQB+AC9xAH4AMHNxAH4AGAAAABF4c3EAfgAMdAA/L2dhbWUvc3JjL21haW4vamF2YS9jei9qeml0bmlrL2NsaWVudC9nYW1lL3NldHVwL0dhbWVTZXR1cC5qYXZhdAAOR2FtZVNldHVwLmphdmF0ABYvaG9tZS9rdWJhL0NvZGluZy9nYW1lc3EAfgATAAAADAAAAAAAAAAAAAAABHNxAH4AFncMAAAAED9AAAAAAAAMc3EAfgAYAAAAAHNxAH4AGAAAAAFzcQB+ABgAAAACc3EAfgAYAAAAA3NxAH4AGAAAAARzcQB+ABgAAAAFc3EAfgAYAAAABnNxAH4AGAAAAAdzcQB+ABgAAAAIc3EAfgAYAAAACXNxAH4AGAAAAApzcQB+ABgAAAALeHNxAH4ADHQASS9nYW1lL3NyYy9tYWluL2phdmEvY3ovanppdG5pay9jbGllbnQvZ2FtZS9tb2JzL3Rhc2tzL3V0aWxzL0FTdGFyQWxnLmphdmF0AA1BU3RhckFsZy5qYXZhdAAWL2hvbWUva3ViYS9Db2RpbmcvZ2FtZXNxAH4AEwAAAAgAAAAAAAAACgAAAARzcQB+ABZ3DAAAABA/QAAAAAAACHEAfgBEcQB+AEVxAH4ARnEAfgBHcQB+AEhxAH4ASXEAfgBKcQB+AEt4c3EAfgAMdAA4L2dhbWUvc3JjL21haW4vamF2YS9jei9qeml0bmlrL2NsaWVudC91aS91dGlscy9HcmlkLmphdmF0AAlHcmlkLmphdmF0ABYvaG9tZS9rdWJhL0NvZGluZy9nYW1lc3EAfgATAAAACQAAAAAAAAAAAAAABnNxAH4AFncMAAAAED9AAAAAAAAJcQB+AERxAH4ARXEAfgBGcQB+AEdxAH4ASHEAfgBJcQB+AEpxAH4AS3EAfgBMeHBwcHg=" />
|
||||
</component>
|
||||
</project>
|
||||
40
.idea/compiler.xml
generated
Normal file
40
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
</profile>
|
||||
<profile name="Annotation profile for common" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.42/lombok-1.18.42.jar" />
|
||||
</processorPath>
|
||||
<module name="common" />
|
||||
</profile>
|
||||
<profile name="Annotation profile for server" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.42/lombok-1.18.42.jar" />
|
||||
</processorPath>
|
||||
<module name="server" />
|
||||
</profile>
|
||||
<profile name="Annotation profile for game-parent" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<processorPath useClasspath="false">
|
||||
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.38/lombok-1.18.38.jar" />
|
||||
</processorPath>
|
||||
<module name="game (1)" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/encodings.xml
generated
6
.idea/encodings.xml
generated
@@ -1,6 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/common/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/game/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/game/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/server/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/server/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
|
||||
25
.idea/jarRepositories.xml
generated
Normal file
25
.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="be.0110.repo-releases" />
|
||||
<option name="name" value="0110.be repository" />
|
||||
<option name="url" value="https://mvn.0110.be/releases" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
16
.idea/misc.xml
generated
16
.idea/misc.xml
generated
@@ -1,17 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="3">
|
||||
<item index="0" class="java.lang.String" itemvalue="cz.jzitnik.annotations.EventHandler" />
|
||||
<item index="1" class="java.lang.String" itemvalue="cz.jzitnik.annotations.ui.KeyboardPressHandler" />
|
||||
<item index="2" class="java.lang.String" itemvalue="cz.jzitnik.annotations.ui.MouseHandler" />
|
||||
</list>
|
||||
<writeAnnotations>
|
||||
<writeAnnotation name="cz.jzitnik.annotations.injectors.InjectConfig" />
|
||||
<writeAnnotation name="cz.jzitnik.annotations.injectors.InjectDependency" />
|
||||
<writeAnnotation name="cz.jzitnik.annotations.injectors.InjectState" />
|
||||
</writeAnnotations>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
@@ -20,7 +8,5 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="openjdk-25" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="openjdk-25" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
39
common/.gitignore
vendored
Normal file
39
common/.gitignore
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
.kotlin
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
3
common/.idea/.gitignore
generated
vendored
Normal file
3
common/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
7
common/.idea/encodings.xml
generated
Normal file
7
common/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
14
common/.idea/misc.xml
generated
Normal file
14
common/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="openjdk-25" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
6
common/.idea/vcs.xml
generated
Normal file
6
common/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
63
common/pom.xml
Normal file
63
common/pom.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cz.jzitnik</groupId>
|
||||
<artifactId>game-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.42</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<source>25</source>
|
||||
<target>25</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>tools.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>tools.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.42</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
5
common/src/main/java/cz/jzitnik/common/Config.java
Normal file
5
common/src/main/java/cz/jzitnik/common/Config.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package cz.jzitnik.common;
|
||||
|
||||
public class Config {
|
||||
public static final int WORLD_PASSWORD_LENGTH = 5;
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package cz.jzitnik.game.utils;
|
||||
package cz.jzitnik.common.models.coordinates;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.game.GameRoomPart;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@ToString
|
||||
@Getter
|
||||
public class RoomCords implements Cloneable {
|
||||
public class RoomCords implements Cloneable, Serializable {
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
@@ -29,8 +29,12 @@ public class RoomCords implements Cloneable {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void updateCordsWithColliders(List<GameRoomPart> colliders, int x, int y, GameRoomPart playerCollider) {
|
||||
var normalizedPlayerCollider = new GameRoomPart(
|
||||
public void updateCords(RoomCords roomCords) {
|
||||
updateCords(roomCords.getX(), roomCords.getY());
|
||||
}
|
||||
|
||||
public void updateCordsWithColliders(List<RoomPart> colliders, int x, int y, RoomPart playerCollider) {
|
||||
var normalizedPlayerCollider = new RoomPart(
|
||||
new RoomCords(playerCollider.getStart().getX() + x, playerCollider.getStart().getY() + y),
|
||||
new RoomCords(playerCollider.getEnd().getX() + x, playerCollider.getEnd().getY() + y)
|
||||
);
|
||||
@@ -1,20 +1,20 @@
|
||||
package cz.jzitnik.game;
|
||||
package cz.jzitnik.common.models.coordinates;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.game.utils.RoomCords;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class GameRoomPart {
|
||||
public class RoomPart implements Serializable {
|
||||
private RoomCords start;
|
||||
private RoomCords end;
|
||||
|
||||
@JsonCreator
|
||||
public GameRoomPart(
|
||||
public RoomPart(
|
||||
@JsonProperty("start") RoomCords start,
|
||||
@JsonProperty("end") RoomCords end
|
||||
) {
|
||||
@@ -32,7 +32,7 @@ public class GameRoomPart {
|
||||
/**
|
||||
* Checks if this GameRoomPart overlaps with another.
|
||||
*/
|
||||
public boolean isOverlapping(GameRoomPart other) {
|
||||
public boolean isOverlapping(RoomPart other) {
|
||||
return start.getX() <= other.getEnd().getX() &&
|
||||
end.getX() >= other.getStart().getX() &&
|
||||
start.getY() <= other.getEnd().getY() &&
|
||||
@@ -0,0 +1,27 @@
|
||||
package cz.jzitnik.common.models.player;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.common.models.coordinates.RoomPart;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Getter
|
||||
public final class PlayerCreation implements Serializable {
|
||||
@Setter
|
||||
private int id;
|
||||
private final RoomCords playerCords;
|
||||
private final RoomPart collider;
|
||||
|
||||
@JsonCreator
|
||||
public PlayerCreation(
|
||||
@JsonProperty("playerCords") RoomCords playerCords,
|
||||
@JsonProperty("collider") RoomPart collider
|
||||
) {
|
||||
this.playerCords = playerCords;
|
||||
this.collider = collider;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.common.socket;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface SocketMessage extends Serializable {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.common.socket.messages;
|
||||
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public class Test implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.common.socket.messages.game.connection;
|
||||
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record ConnectToAGame(String gamePass) implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cz.jzitnik.common.socket.messages.game.connection;
|
||||
|
||||
import cz.jzitnik.common.models.player.PlayerCreation;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record ConnectToAGameResponse(ResponseType responseType, PlayerCreation playerCreation, List<PlayerCreation> existingPlayers) implements SocketMessage {
|
||||
private enum ResponseType {
|
||||
GAME_DOES_NOT_EXIST,
|
||||
SUCCESS
|
||||
}
|
||||
|
||||
public ConnectToAGameResponse() {
|
||||
this(ResponseType.GAME_DOES_NOT_EXIST, null, null);
|
||||
}
|
||||
|
||||
public ConnectToAGameResponse(PlayerCreation playerCreation, List<PlayerCreation> existingPlayers) {
|
||||
this(ResponseType.SUCCESS, playerCreation, existingPlayers);
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
return responseType == ResponseType.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.common.socket.messages.game.creation;
|
||||
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public class CreateGame implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cz.jzitnik.common.socket.messages.game.creation;
|
||||
|
||||
import cz.jzitnik.common.models.player.PlayerCreation;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class CreateGameResponse implements SocketMessage {
|
||||
private final String gamePassword;
|
||||
private final PlayerCreation ownerPlayer;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cz.jzitnik.common.socket.messages.items;
|
||||
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record ItemTookFromChest(
|
||||
String roomId, // For faster lookup i guess
|
||||
int id
|
||||
) implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cz.jzitnik.common.socket.messages.player;
|
||||
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record PlayerArrivalChange(int id, RoomCords playerCords, PlayerRotation playerRotation,
|
||||
boolean arrived, boolean rerender) implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.common.socket.messages.player;
|
||||
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record PlayerDisconnected(int playerId) implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cz.jzitnik.common.socket.messages.player;
|
||||
|
||||
import cz.jzitnik.common.models.player.PlayerCreation;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record PlayerJoined(PlayerCreation playerCreation) implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cz.jzitnik.common.socket.messages.player;
|
||||
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record PlayerMove(RoomCords newCords, PlayerRotation playerRotation) implements SocketMessage {
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.common.socket.messages.player;
|
||||
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class PlayerMovedInUrRoom implements SocketMessage {
|
||||
private int playerId;
|
||||
private RoomCords cords;
|
||||
private PlayerRotation playerRotation;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package cz.jzitnik.common.socket.messages.player;
|
||||
|
||||
public enum PlayerRotation {
|
||||
FRONT, BACK, LEFT, RIGHT
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cz.jzitnik.common.socket.messages.room;
|
||||
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record MovePlayerRoom(String newRoomId, RoomCords oldCords, RoomCords newCords) implements SocketMessage {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cz.jzitnik.common.socket.messages.room;
|
||||
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
import cz.jzitnik.common.socket.messages.player.PlayerRotation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record MovePlayerRoomResponse(Set<Registry> players) implements SocketMessage {
|
||||
public record Registry(int id, RoomCords cords, PlayerRotation playerRotation) implements Serializable {}
|
||||
|
||||
public Optional<Registry> getById(int id) {
|
||||
return players.stream().filter(registry -> registry.id == id).findFirst();
|
||||
}
|
||||
|
||||
public Set<Integer> getIds() {
|
||||
return players.stream().map(Registry::id).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
42
game/.gitignore
vendored
Normal file
42
game/.gitignore
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
.kotlin
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
.idea/FuzzierSettings.xml
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
logs
|
||||
3
game/.idea/.gitignore
generated
vendored
Normal file
3
game/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
13
game/.idea/encodings.xml
generated
Normal file
13
game/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/common/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/game/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/game/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/server/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/server/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
12
game/.idea/misc.xml
generated
Normal file
12
game/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-25" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
6
game/.idea/vcs.xml
generated
Normal file
6
game/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
190
game/pom.xml
Normal file
190
game/pom.xml
Normal file
@@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>cz.jzitnik</groupId>
|
||||
<artifactId>game-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>game</artifactId>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.38</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
<source>25</source>
|
||||
<target>25</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>cz.jzitnik.client.Main</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<mainClass>cz.jzitnik.client.Main</mainClass>
|
||||
<classpathScope>compile</classpathScope>
|
||||
<skip>false</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>be.0110.repo-releases</id>
|
||||
<name>0110.be repository</name>
|
||||
<url>https://mvn.0110.be/releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cz.jzitnik</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.42</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.10.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>33.5.0-jre</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>tools.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>tools.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>6.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>6.0.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.17</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.5.25</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.trilarion</groupId>
|
||||
<artifactId>java-vorbis-support</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.lanterna</groupId>
|
||||
<artifactId>lanterna</artifactId>
|
||||
<version>3.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv-platform</artifactId>
|
||||
<version>1.5.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>ffmpeg-platform</artifactId>
|
||||
<version>7.1.1-1.5.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>be.tarsos.dsp</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>be.tarsos.dsp</groupId>
|
||||
<artifactId>jvm</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.tyrus.bundles</groupId>
|
||||
<artifactId>tyrus-standalone-client</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,18 +1,18 @@
|
||||
package cz.jzitnik;
|
||||
package cz.jzitnik.client;
|
||||
|
||||
import com.googlecode.lanterna.input.KeyStroke;
|
||||
import com.googlecode.lanterna.screen.TerminalScreen;
|
||||
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
|
||||
import com.googlecode.lanterna.terminal.MouseCaptureMode;
|
||||
import cz.jzitnik.annotations.Dependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.KeyboardPressEvent;
|
||||
import cz.jzitnik.events.MouseAction;
|
||||
import cz.jzitnik.events.TerminalResizeEvent;
|
||||
import cz.jzitnik.states.RunningState;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.Dependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.KeyboardPressEvent;
|
||||
import cz.jzitnik.client.events.MouseAction;
|
||||
import cz.jzitnik.client.events.TerminalResizeEvent;
|
||||
import cz.jzitnik.client.states.RunningState;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -31,8 +31,7 @@ public class Cli implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
eventManager.start(); // Start event manager thread
|
||||
|
||||
// Start event manager thread
|
||||
try (TerminalScreen terminal = new DefaultTerminalFactory()
|
||||
.setMouseCaptureMode(MouseCaptureMode.CLICK_RELEASE_DRAG_MOVE)
|
||||
.createScreen()) {
|
||||
49
game/src/main/java/cz/jzitnik/client/Game.java
Normal file
49
game/src/main/java/cz/jzitnik/client/Game.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package cz.jzitnik.client;
|
||||
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.game.setup.GameSetup;
|
||||
import cz.jzitnik.client.socket.Client;
|
||||
import cz.jzitnik.client.socket.SocketEventManager;
|
||||
import cz.jzitnik.client.utils.DependencyManager;
|
||||
import cz.jzitnik.client.utils.GlobalIOHandlerRepository;
|
||||
import cz.jzitnik.client.utils.ScheduledTaskManager;
|
||||
import cz.jzitnik.client.utils.ThreadManager;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import jakarta.websocket.DeploymentException;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Game {
|
||||
private final DependencyManager dependencyManager = new DependencyManager(new Reflections("cz.jzitnik.client"));
|
||||
|
||||
@InjectDependency
|
||||
private GameSetup gameSetup;
|
||||
@InjectDependency
|
||||
private EventManager eventManager;
|
||||
@InjectDependency
|
||||
private SocketEventManager socketEventManager;
|
||||
@InjectDependency
|
||||
private Cli cli;
|
||||
@InjectDependency
|
||||
private ThreadManager threadManager;
|
||||
@InjectDependency
|
||||
private ScheduledTaskManager scheduledTaskManager;
|
||||
@InjectDependency
|
||||
private GlobalIOHandlerRepository globalIOHandlerRepository;
|
||||
|
||||
public void start() throws IOException {
|
||||
dependencyManager.inject(this);
|
||||
|
||||
eventManager.start();
|
||||
socketEventManager.start();
|
||||
|
||||
threadManager.startAll();
|
||||
scheduledTaskManager.startAll();
|
||||
globalIOHandlerRepository.setup();
|
||||
|
||||
gameSetup.setup();
|
||||
|
||||
cli.run();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik;
|
||||
package cz.jzitnik.client;
|
||||
|
||||
// events/handlers/MouseMoveEventHandler.java
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations;
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations;
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,6 +1,6 @@
|
||||
package cz.jzitnik.annotations;
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations;
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations;
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -0,0 +1,14 @@
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface SocketEventHandler {
|
||||
Class<? extends SocketMessage> value();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations;
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations;
|
||||
package cz.jzitnik.client.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.injectors;
|
||||
package cz.jzitnik.client.annotations.injectors;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.injectors;
|
||||
package cz.jzitnik.client.annotations.injectors;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.injectors;
|
||||
package cz.jzitnik.client.annotations.injectors;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.ui;
|
||||
package cz.jzitnik.client.annotations.ui;
|
||||
|
||||
import com.googlecode.lanterna.input.KeyType;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.ui;
|
||||
package cz.jzitnik.client.annotations.ui;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.ui;
|
||||
package cz.jzitnik.client.annotations.ui;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.ui;
|
||||
package cz.jzitnik.client.annotations.ui;
|
||||
|
||||
public enum MouseHandlerType {
|
||||
CLICK,
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.ui;
|
||||
package cz.jzitnik.client.annotations.ui;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.annotations.ui;
|
||||
package cz.jzitnik.client.annotations.ui;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -1,9 +1,8 @@
|
||||
package cz.jzitnik.config;
|
||||
package cz.jzitnik.client.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.annotations.Config;
|
||||
import lombok.Getter;
|
||||
import cz.jzitnik.client.annotations.Config;
|
||||
|
||||
@Config("core_logic.yaml")
|
||||
public record CoreLogic(int itemDropDisappearMinutes) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package cz.jzitnik.config;
|
||||
package cz.jzitnik.client.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.annotations.Config;
|
||||
import cz.jzitnik.client.annotations.Config;
|
||||
|
||||
@Config("debugging.yaml")
|
||||
public record Debugging(boolean renderColliders, boolean renderPlayerCollider, boolean showPlayerCordsLogs) {
|
||||
@@ -1,8 +1,8 @@
|
||||
package cz.jzitnik.config;
|
||||
package cz.jzitnik.client.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.annotations.Config;
|
||||
import cz.jzitnik.client.annotations.Config;
|
||||
|
||||
@Config("microphone.yaml")
|
||||
public record MicrophoneConfig(float volumeThreshold) {
|
||||
@@ -1,9 +1,9 @@
|
||||
package cz.jzitnik.config;
|
||||
package cz.jzitnik.client.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.annotations.Config;
|
||||
import cz.jzitnik.events.handlers.PlayerMoveEventHandler;
|
||||
import cz.jzitnik.client.annotations.Config;
|
||||
import cz.jzitnik.client.events.handlers.PlayerMoveEventHandler;
|
||||
|
||||
@Config("player.yaml")
|
||||
public record PlayerConfig(
|
||||
@@ -1,9 +1,8 @@
|
||||
package cz.jzitnik.config;
|
||||
package cz.jzitnik.client.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import cz.jzitnik.annotations.Config;
|
||||
import lombok.Getter;
|
||||
import cz.jzitnik.client.annotations.Config;
|
||||
|
||||
@Config("threads.yaml")
|
||||
public record ThreadPoolConfig(int eventThreadCount, int taskThreadCount) {
|
||||
@@ -0,0 +1,7 @@
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.client.game.objects.DroppedItem;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
public record DroppedItemRerender(DroppedItem droppedItem) implements Event {
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
/** Custom event without any handler **/
|
||||
public class ExitEvent implements Event {
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
public class FullRedrawEvent implements Event {
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
public class InventoryRerender implements Event {
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import com.googlecode.lanterna.input.KeyStroke;
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import com.googlecode.lanterna.input.MouseActionType;
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
public class MouseAction extends com.googlecode.lanterna.input.MouseAction implements Event {
|
||||
public MouseAction(MouseActionType actionType, int button, TerminalPosition position) {
|
||||
@@ -1,6 +1,6 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import com.googlecode.lanterna.input.KeyStroke;
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
public class RenderStats implements Event {
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import com.googlecode.lanterna.TerminalSize;
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public record RerenderScreen(ScreenPart[] parts) implements Event {
|
||||
public RerenderScreen(ScreenPart part) {
|
||||
this(new ScreenPart[]{part});
|
||||
@@ -0,0 +1,7 @@
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.client.events.handlers.FullRoomDrawHandler;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
public record RoomChangeEvent(FullRoomDrawHandler.DoorPosition door) implements Event {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import cz.jzitnik.common.socket.SocketMessage;
|
||||
|
||||
public record SendSocketMessageEvent(SocketMessage message) implements Event {
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cz.jzitnik.events;
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import com.googlecode.lanterna.TerminalSize;
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package cz.jzitnik.client.events;
|
||||
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
|
||||
public class TerminalTooSmallEvent implements Event {
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TextColor;
|
||||
import com.googlecode.lanterna.graphics.TextGraphics;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.game.Constants;
|
||||
import cz.jzitnik.states.RenderState;
|
||||
import cz.jzitnik.states.ScreenBuffer;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.ui.pixels.AlphaPixel;
|
||||
import cz.jzitnik.ui.pixels.ColoredPixel;
|
||||
import cz.jzitnik.ui.pixels.Empty;
|
||||
import cz.jzitnik.ui.pixels.Pixel;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.RerenderScreen;
|
||||
import cz.jzitnik.client.game.Constants;
|
||||
import cz.jzitnik.client.states.RenderState;
|
||||
import cz.jzitnik.client.states.ScreenBuffer;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.ui.pixels.AlphaPixel;
|
||||
import cz.jzitnik.client.ui.pixels.ColoredPixel;
|
||||
import cz.jzitnik.client.ui.pixels.Empty;
|
||||
import cz.jzitnik.client.ui.pixels.Pixel;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -1,24 +1,24 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import com.googlecode.lanterna.TerminalSize;
|
||||
import com.googlecode.lanterna.TextColor;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.game.dialog.Dialog;
|
||||
import cz.jzitnik.game.dialog.OnEnd;
|
||||
import cz.jzitnik.states.DialogState;
|
||||
import cz.jzitnik.states.ScreenBuffer;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.ui.pixels.AlphaPixel;
|
||||
import cz.jzitnik.ui.pixels.ColoredPixel;
|
||||
import cz.jzitnik.ui.pixels.Empty;
|
||||
import cz.jzitnik.utils.DependencyManager;
|
||||
import cz.jzitnik.utils.TextRenderer;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.RerenderScreen;
|
||||
import cz.jzitnik.client.game.dialog.Dialog;
|
||||
import cz.jzitnik.client.game.dialog.OnEnd;
|
||||
import cz.jzitnik.client.states.DialogState;
|
||||
import cz.jzitnik.client.states.ScreenBuffer;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.ui.pixels.AlphaPixel;
|
||||
import cz.jzitnik.client.ui.pixels.ColoredPixel;
|
||||
import cz.jzitnik.client.ui.pixels.Empty;
|
||||
import cz.jzitnik.client.utils.DependencyManager;
|
||||
import cz.jzitnik.client.utils.TextRenderer;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -105,7 +105,7 @@ public class DialogEventHandler extends AbstractEventHandler<Dialog> {
|
||||
OnEnd.AskQuestion.Answer[] answers
|
||||
)) {
|
||||
for (OnEnd.AskQuestion.Answer answer : answers) {
|
||||
answersBuf.add(textRenderer.renderText(answer.answer(), size.getColumns() - PADDING * 2, BUTTON_HEIGHT, Color.BLACK, FONT_SIZE));
|
||||
answersBuf.add(textRenderer.renderText(answer.answer(), size.getColumns() - PADDING * 2, BUTTON_HEIGHT, Color.BLACK, FONT_SIZE, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.events.DroppedItemRerender;
|
||||
import cz.jzitnik.events.RerenderPart;
|
||||
import cz.jzitnik.game.utils.RoomCords;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.events.DroppedItemRerender;
|
||||
import cz.jzitnik.client.events.RerenderPart;
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.ExitEvent;
|
||||
import cz.jzitnik.states.RunningState;
|
||||
import cz.jzitnik.utils.ScheduledTaskManager;
|
||||
import cz.jzitnik.utils.ThreadManager;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.roomtasks.RoomTaskScheduler;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.ExitEvent;
|
||||
import cz.jzitnik.client.states.RunningState;
|
||||
import cz.jzitnik.client.utils.ScheduledTaskManager;
|
||||
import cz.jzitnik.client.utils.ThreadManager;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.roomtasks.RoomTaskScheduler;
|
||||
|
||||
@EventHandler(ExitEvent.class)
|
||||
public class ExitEventHandler extends AbstractEventHandler<ExitEvent> {
|
||||
@@ -1,14 +1,14 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.screen.Screen;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.FullRedrawEvent;
|
||||
import cz.jzitnik.events.FullRoomDraw;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.FullRedrawEvent;
|
||||
import cz.jzitnik.client.events.FullRoomDraw;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import com.googlecode.lanterna.TerminalSize;
|
||||
import com.googlecode.lanterna.screen.TerminalScreen;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.config.Debugging;
|
||||
import cz.jzitnik.events.FullRoomDraw;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.events.TerminalTooSmallEvent;
|
||||
import cz.jzitnik.game.GameRoom;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.game.Player;
|
||||
import cz.jzitnik.game.ResourceManager;
|
||||
import cz.jzitnik.states.RenderState;
|
||||
import cz.jzitnik.states.ScreenBuffer;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.utils.GlobalIOHandlerRepository;
|
||||
import cz.jzitnik.utils.RerenderUtils;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.utils.roomtasks.RoomTaskScheduler;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.config.Debugging;
|
||||
import cz.jzitnik.client.events.FullRoomDraw;
|
||||
import cz.jzitnik.client.events.RerenderScreen;
|
||||
import cz.jzitnik.client.events.TerminalTooSmallEvent;
|
||||
import cz.jzitnik.client.game.GameRoom;
|
||||
import cz.jzitnik.client.game.GameState;
|
||||
import cz.jzitnik.client.game.Player;
|
||||
import cz.jzitnik.client.game.ResourceManager;
|
||||
import cz.jzitnik.client.states.RenderState;
|
||||
import cz.jzitnik.client.states.ScreenBuffer;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.utils.GlobalIOHandlerRepository;
|
||||
import cz.jzitnik.client.utils.RerenderUtils;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import cz.jzitnik.client.utils.roomtasks.RoomTaskScheduler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -75,7 +75,7 @@ public class FullRoomDrawHandler extends AbstractEventHandler<FullRoomDraw> {
|
||||
int startX = start.getX();
|
||||
int startY = start.getY();
|
||||
|
||||
RerenderUtils.rerenderPart(0, width - 1, 0, height - 1, startX, startY, currentRoom, room, player, playerTexture, screenBuffer, resourceManager, debugging);
|
||||
RerenderUtils.rerenderPart(0, width - 1, 0, height - 1, startX, startY, currentRoom, room, player, screenBuffer, resourceManager, debugging, gameState.getOtherPlayers());
|
||||
if (event.isFullRerender()) {
|
||||
globalIOHandlerRepository.renderAll();
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.events.InventoryRerender;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.ui.Inventory;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.events.InventoryRerender;
|
||||
import cz.jzitnik.client.events.RerenderScreen;
|
||||
import cz.jzitnik.client.ui.Inventory;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
|
||||
@EventHandler(InventoryRerender.class)
|
||||
public class InventoryRerenderHandler extends AbstractEventHandler<InventoryRerender> {
|
||||
@@ -1,12 +1,12 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.*;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.utils.GlobalIOHandlerRepository;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.KeyboardPressEvent;
|
||||
import cz.jzitnik.client.game.GameState;
|
||||
import cz.jzitnik.client.utils.GlobalIOHandlerRepository;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
|
||||
@EventHandler(KeyboardPressEvent.class)
|
||||
public class KeyboardPressEventHandler extends AbstractEventHandler<KeyboardPressEvent> {
|
||||
@@ -1,19 +1,19 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.config.PlayerConfig;
|
||||
import cz.jzitnik.events.MouseAction;
|
||||
import cz.jzitnik.events.MouseMoveEvent;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.game.utils.Selectable;
|
||||
import cz.jzitnik.states.RenderState;
|
||||
import cz.jzitnik.utils.DependencyManager;
|
||||
import cz.jzitnik.utils.UIRoomClickHandlerRepository;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.config.PlayerConfig;
|
||||
import cz.jzitnik.client.events.MouseAction;
|
||||
import cz.jzitnik.client.events.MouseMoveEvent;
|
||||
import cz.jzitnik.client.game.GameState;
|
||||
import cz.jzitnik.client.game.utils.Selectable;
|
||||
import cz.jzitnik.client.states.RenderState;
|
||||
import cz.jzitnik.client.utils.DependencyManager;
|
||||
import cz.jzitnik.client.utils.UIRoomClickHandlerRepository;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
@@ -1,27 +1,27 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import com.googlecode.lanterna.input.MouseActionType;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.config.Debugging;
|
||||
import cz.jzitnik.config.PlayerConfig;
|
||||
import cz.jzitnik.events.MouseAction;
|
||||
import cz.jzitnik.events.MouseMoveEvent;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.game.GameRoom;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.game.Player;
|
||||
import cz.jzitnik.game.ResourceManager;
|
||||
import cz.jzitnik.game.utils.RoomCords;
|
||||
import cz.jzitnik.game.utils.Selectable;
|
||||
import cz.jzitnik.states.ScreenBuffer;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.utils.RerenderUtils;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.config.Debugging;
|
||||
import cz.jzitnik.client.config.PlayerConfig;
|
||||
import cz.jzitnik.client.events.MouseAction;
|
||||
import cz.jzitnik.client.events.MouseMoveEvent;
|
||||
import cz.jzitnik.client.events.RerenderScreen;
|
||||
import cz.jzitnik.client.game.GameRoom;
|
||||
import cz.jzitnik.client.game.GameState;
|
||||
import cz.jzitnik.client.game.Player;
|
||||
import cz.jzitnik.client.game.ResourceManager;
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.client.game.utils.Selectable;
|
||||
import cz.jzitnik.client.states.ScreenBuffer;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.utils.RerenderUtils;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -177,10 +177,10 @@ public class MouseMoveEventHandler extends AbstractEventHandler<MouseMoveEvent>
|
||||
currentRoom,
|
||||
room,
|
||||
player,
|
||||
playerTexture,
|
||||
screenBuffer,
|
||||
resourceManager,
|
||||
debugging
|
||||
debugging,
|
||||
gameState.getOtherPlayers()
|
||||
);
|
||||
|
||||
parts.add(new RerenderScreen.ScreenPart(
|
||||
@@ -1,31 +1,27 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import com.googlecode.lanterna.input.KeyStroke;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.config.Debugging;
|
||||
import cz.jzitnik.config.PlayerConfig;
|
||||
import cz.jzitnik.events.MouseMoveEvent;
|
||||
import cz.jzitnik.events.PlayerMoveEvent;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.events.RoomChangeEvent;
|
||||
import cz.jzitnik.game.GameRoom;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.game.Player;
|
||||
import cz.jzitnik.game.ResourceManager;
|
||||
import cz.jzitnik.game.utils.RoomCords;
|
||||
import cz.jzitnik.states.RenderState;
|
||||
import cz.jzitnik.states.ScreenBuffer;
|
||||
import cz.jzitnik.states.PlayerMovementState;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.ui.Stats;
|
||||
import cz.jzitnik.utils.RerenderUtils;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.Event;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.config.Debugging;
|
||||
import cz.jzitnik.client.config.PlayerConfig;
|
||||
import cz.jzitnik.client.events.*;
|
||||
import cz.jzitnik.client.game.*;
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.client.states.RenderState;
|
||||
import cz.jzitnik.client.states.ScreenBuffer;
|
||||
import cz.jzitnik.client.states.PlayerMovementState;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.ui.Stats;
|
||||
import cz.jzitnik.client.utils.RerenderUtils;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.Event;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import cz.jzitnik.common.socket.messages.player.PlayerMove;
|
||||
import cz.jzitnik.common.socket.messages.player.PlayerRotation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -79,46 +75,46 @@ public class PlayerMoveEventHandler extends AbstractEventHandler<PlayerMoveEvent
|
||||
case 'w' -> {
|
||||
if (originalPlayerY <= 10) {
|
||||
if (originalPlayerX >= 80 && originalPlayerX <= 105) {
|
||||
player.setPlayerRotation(Player.PlayerRotation.BACK);
|
||||
player.setPlayerRotation(PlayerRotation.BACK);
|
||||
eventManager.emitEvent(new RoomChangeEvent(FullRoomDrawHandler.DoorPosition.TOP));
|
||||
}
|
||||
return;
|
||||
}
|
||||
playerCords.updateCordsWithColliders(currentRoom.getColliders(), player.getPlayerCords().getX(), playerCords.getY() - moveStep, player.getCollider());
|
||||
player.setPlayerRotation(Player.PlayerRotation.BACK);
|
||||
player.setPlayerRotation(PlayerRotation.BACK);
|
||||
}
|
||||
case 'a' -> {
|
||||
if (originalPlayerX <= 30) {
|
||||
if (originalPlayerY >= 35 && originalPlayerY <= 65) {
|
||||
player.setPlayerRotation(Player.PlayerRotation.LEFT);
|
||||
player.setPlayerRotation(PlayerRotation.LEFT);
|
||||
eventManager.emitEvent(new RoomChangeEvent(FullRoomDrawHandler.DoorPosition.LEFT));
|
||||
}
|
||||
return;
|
||||
}
|
||||
playerCords.updateCordsWithColliders(currentRoom.getColliders(), player.getPlayerCords().getX() - moveStep, playerCords.getY(), player.getCollider());
|
||||
player.setPlayerRotation(Player.PlayerRotation.LEFT);
|
||||
player.setPlayerRotation(PlayerRotation.LEFT);
|
||||
}
|
||||
case 's' -> {
|
||||
if (originalPlayerY >= 110) {
|
||||
if (originalPlayerX >= 75 && originalPlayerX <= 105) {
|
||||
player.setPlayerRotation(Player.PlayerRotation.FRONT);
|
||||
player.setPlayerRotation(PlayerRotation.FRONT);
|
||||
eventManager.emitEvent(new RoomChangeEvent(FullRoomDrawHandler.DoorPosition.BOTTOM));
|
||||
}
|
||||
return;
|
||||
}
|
||||
playerCords.updateCordsWithColliders(currentRoom.getColliders(), player.getPlayerCords().getX(), playerCords.getY() + moveStep, player.getCollider());
|
||||
player.setPlayerRotation(Player.PlayerRotation.FRONT);
|
||||
player.setPlayerRotation(PlayerRotation.FRONT);
|
||||
}
|
||||
case 'd' -> {
|
||||
if (originalPlayerX >= 155) {
|
||||
if (originalPlayerY >= 40 && originalPlayerY <= 60) {
|
||||
player.setPlayerRotation(Player.PlayerRotation.RIGHT);
|
||||
player.setPlayerRotation(PlayerRotation.RIGHT);
|
||||
eventManager.emitEvent(new RoomChangeEvent(FullRoomDrawHandler.DoorPosition.RIGHT));
|
||||
}
|
||||
return;
|
||||
}
|
||||
playerCords.updateCordsWithColliders(currentRoom.getColliders(), player.getPlayerCords().getX() + moveStep, playerCords.getY(), player.getCollider());
|
||||
player.setPlayerRotation(Player.PlayerRotation.RIGHT);
|
||||
player.setPlayerRotation(PlayerRotation.RIGHT);
|
||||
}
|
||||
}
|
||||
playerMovementState.setLastMovement(System.currentTimeMillis());
|
||||
@@ -143,9 +139,10 @@ public class PlayerMoveEventHandler extends AbstractEventHandler<PlayerMoveEvent
|
||||
int startX = start.getX();
|
||||
int startY = start.getY();
|
||||
|
||||
RerenderUtils.rerenderPart(forStartX, forEndX, forStartY, forEndY, startX, startY, currentRoom, room, player, playerTexture, screenBuffer, resourceManager, debugging);
|
||||
RerenderUtils.rerenderPart(forStartX, forEndX, forStartY, forEndY, startX, startY, currentRoom, room, player, screenBuffer, resourceManager, debugging, gameState.getOtherPlayers());
|
||||
|
||||
eventManager.emitEvent(new Event[]{
|
||||
new SendSocketMessageEvent(new PlayerMove(playerCords, player.getPlayerRotation())),
|
||||
new MouseMoveEvent(null),
|
||||
new RerenderScreen(
|
||||
new RerenderScreen.ScreenPart[]{
|
||||
@@ -1,13 +1,13 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.events.RenderStats;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.ui.Stats;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.events.RenderStats;
|
||||
import cz.jzitnik.client.events.RerenderScreen;
|
||||
import cz.jzitnik.client.ui.Stats;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
|
||||
@EventHandler(RenderStats.class)
|
||||
public class RenderStatsHandler extends AbstractEventHandler<RenderStats> {
|
||||
@@ -1,22 +1,22 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalPosition;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.config.Debugging;
|
||||
import cz.jzitnik.events.RerenderPart;
|
||||
import cz.jzitnik.events.RerenderScreen;
|
||||
import cz.jzitnik.game.GameRoom;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.game.ResourceManager;
|
||||
import cz.jzitnik.game.utils.RoomCords;
|
||||
import cz.jzitnik.states.ScreenBuffer;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.utils.RerenderUtils;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectConfig;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.config.Debugging;
|
||||
import cz.jzitnik.client.events.RerenderPart;
|
||||
import cz.jzitnik.client.events.RerenderScreen;
|
||||
import cz.jzitnik.client.game.GameRoom;
|
||||
import cz.jzitnik.client.game.GameState;
|
||||
import cz.jzitnik.client.game.ResourceManager;
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.client.states.ScreenBuffer;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.utils.RerenderUtils;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@@ -62,10 +62,10 @@ public class RerenderPartHandler extends AbstractEventHandler<RerenderPart> {
|
||||
currentRoom,
|
||||
room,
|
||||
gameState.getPlayer(),
|
||||
gameState.getPlayer().getTexture(resourceManager),
|
||||
screenBuffer,
|
||||
resourceManager,
|
||||
debugging
|
||||
debugging,
|
||||
gameState.getOtherPlayers()
|
||||
);
|
||||
|
||||
eventManager.emitEvent(
|
||||
@@ -1,16 +1,17 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.FullRoomDraw;
|
||||
import cz.jzitnik.events.RoomChangeEvent;
|
||||
import cz.jzitnik.game.GameRoom;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.game.utils.RoomCords;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.utils.roomtasks.RoomTaskScheduler;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.RoomChangeEvent;
|
||||
import cz.jzitnik.client.events.SendSocketMessageEvent;
|
||||
import cz.jzitnik.client.game.GameRoom;
|
||||
import cz.jzitnik.client.game.GameState;
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import cz.jzitnik.client.utils.roomtasks.RoomTaskScheduler;
|
||||
import cz.jzitnik.common.socket.messages.room.MovePlayerRoom;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -31,6 +32,7 @@ public class RoomChangeEventHandler extends AbstractEventHandler<RoomChangeEvent
|
||||
@Override
|
||||
public void handle(RoomChangeEvent event) {
|
||||
RoomCords playerCords = gameState.getPlayer().getPlayerCords();
|
||||
RoomCords oldCords = playerCords.clone();
|
||||
GameRoom currentRoom = gameState.getCurrentRoom();
|
||||
GameRoom newRoom = switch (event.door()) {
|
||||
case LEFT -> currentRoom.getLeft();
|
||||
@@ -50,10 +52,9 @@ public class RoomChangeEventHandler extends AbstractEventHandler<RoomChangeEvent
|
||||
case BOTTOM -> playerCords.updateCords(playerCords.getX(), 10);
|
||||
}
|
||||
|
||||
eventManager.emitEvent(new SendSocketMessageEvent(new MovePlayerRoom(newRoom.getId(), oldCords, playerCords)));
|
||||
|
||||
gameState.setCurrentRoom(newRoom);
|
||||
scheduler.schedule(() -> {
|
||||
roomTaskScheduler.setupNewSchedulers(newRoom);
|
||||
}, 200, TimeUnit.MILLISECONDS);
|
||||
eventManager.emitEvent(new FullRoomDraw());
|
||||
scheduler.schedule(() -> roomTaskScheduler.setupNewSchedulers(newRoom), 200, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.events.SendSocketMessageEvent;
|
||||
import cz.jzitnik.client.socket.Client;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@EventHandler(SendSocketMessageEvent.class)
|
||||
public class SendSocketMessageEventHandler extends AbstractEventHandler<SendSocketMessageEvent> {
|
||||
@InjectDependency
|
||||
private Client client;
|
||||
|
||||
@Override
|
||||
public void handle(SendSocketMessageEvent event) {
|
||||
try {
|
||||
client.send(event.message());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.TerminalSize;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.FullRoomDraw;
|
||||
import cz.jzitnik.events.TerminalResizeEvent;
|
||||
import cz.jzitnik.game.GameState;
|
||||
import cz.jzitnik.states.ScreenBuffer;
|
||||
import cz.jzitnik.ui.pixels.AlphaPixel;
|
||||
import cz.jzitnik.ui.pixels.Empty;
|
||||
import cz.jzitnik.ui.pixels.Pixel;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.utils.events.EventManager;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectDependency;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.FullRoomDraw;
|
||||
import cz.jzitnik.client.events.TerminalResizeEvent;
|
||||
import cz.jzitnik.client.game.GameState;
|
||||
import cz.jzitnik.client.states.ScreenBuffer;
|
||||
import cz.jzitnik.client.ui.pixels.AlphaPixel;
|
||||
import cz.jzitnik.client.ui.pixels.Empty;
|
||||
import cz.jzitnik.client.ui.pixels.Pixel;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.utils.events.EventManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@@ -1,15 +1,15 @@
|
||||
package cz.jzitnik.events.handlers;
|
||||
package cz.jzitnik.client.events.handlers;
|
||||
|
||||
import com.googlecode.lanterna.SGR;
|
||||
import com.googlecode.lanterna.TerminalSize;
|
||||
import com.googlecode.lanterna.TextColor;
|
||||
import com.googlecode.lanterna.screen.Screen;
|
||||
import com.googlecode.lanterna.screen.TerminalScreen;
|
||||
import cz.jzitnik.annotations.EventHandler;
|
||||
import cz.jzitnik.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.events.TerminalTooSmallEvent;
|
||||
import cz.jzitnik.states.TerminalState;
|
||||
import cz.jzitnik.utils.events.AbstractEventHandler;
|
||||
import cz.jzitnik.client.annotations.EventHandler;
|
||||
import cz.jzitnik.client.annotations.injectors.InjectState;
|
||||
import cz.jzitnik.client.events.TerminalTooSmallEvent;
|
||||
import cz.jzitnik.client.states.TerminalState;
|
||||
import cz.jzitnik.client.utils.events.AbstractEventHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
@@ -1,4 +1,4 @@
|
||||
package cz.jzitnik.game;
|
||||
package cz.jzitnik.client.game;
|
||||
|
||||
import com.googlecode.lanterna.TextColor;
|
||||
|
||||
10
game/src/main/java/cz/jzitnik/client/game/GamePlayer.java
Normal file
10
game/src/main/java/cz/jzitnik/client/game/GamePlayer.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package cz.jzitnik.client.game;
|
||||
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public interface GamePlayer {
|
||||
RoomCords getPlayerCords();
|
||||
BufferedImage getTexture(ResourceManager resourceManager);
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package cz.jzitnik.game;
|
||||
package cz.jzitnik.client.game;
|
||||
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import cz.jzitnik.game.mobs.Mob;
|
||||
import cz.jzitnik.game.objects.DroppedItem;
|
||||
import cz.jzitnik.game.objects.GameObject;
|
||||
import cz.jzitnik.ui.pixels.Empty;
|
||||
import cz.jzitnik.ui.pixels.Pixel;
|
||||
import cz.jzitnik.client.game.mobs.Mob;
|
||||
import cz.jzitnik.client.game.objects.DroppedItem;
|
||||
import cz.jzitnik.client.game.objects.GameObject;
|
||||
import cz.jzitnik.client.ui.pixels.Empty;
|
||||
import cz.jzitnik.client.ui.pixels.Pixel;
|
||||
import cz.jzitnik.common.models.coordinates.RoomPart;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,7 +32,7 @@ public class GameRoom {
|
||||
@JsonIgnore
|
||||
private final Set<DroppedItem> droppedItems = new HashSet<>();
|
||||
@JsonIgnore
|
||||
private final List<GameRoomPart> colliders = new ArrayList<>();
|
||||
private final List<RoomPart> colliders = new ArrayList<>();
|
||||
|
||||
private GameRoom left;
|
||||
private GameRoom right;
|
||||
@@ -42,7 +43,7 @@ public class GameRoom {
|
||||
public GameRoom(
|
||||
@JsonProperty("id") String id,
|
||||
@JsonProperty("objects") List<GameObject> objects,
|
||||
@JsonProperty("colliders") List<GameRoomPart> colliders,
|
||||
@JsonProperty("colliders") List<RoomPart> colliders,
|
||||
@JsonProperty("mobs") List<Mob> mobs,
|
||||
@JsonProperty("texture") ResourceManager.Resource texture
|
||||
) {
|
||||
54
game/src/main/java/cz/jzitnik/client/game/GameState.java
Normal file
54
game/src/main/java/cz/jzitnik/client/game/GameState.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package cz.jzitnik.client.game;
|
||||
|
||||
import cz.jzitnik.client.annotations.State;
|
||||
import cz.jzitnik.client.game.objects.Interactable;
|
||||
import cz.jzitnik.client.screens.Screen;
|
||||
import cz.jzitnik.client.utils.DependencyManager;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@State
|
||||
public class GameState {
|
||||
private final DependencyManager dependencyManager; // Maybe transient in the future
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private GameRoom currentRoom;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private List<GameRoom> allRooms;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Player player;
|
||||
|
||||
private final List<OtherPlayer> otherPlayers = new ArrayList<>();
|
||||
|
||||
public List<OtherPlayer> getOtherPlayers() {
|
||||
return otherPlayers.stream().filter(OtherPlayer::isVisible).toList();
|
||||
}
|
||||
|
||||
public List<OtherPlayer> getAllOtherPlayers() {
|
||||
return otherPlayers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Interactable interacting;
|
||||
|
||||
@Getter
|
||||
private Screen screen;
|
||||
|
||||
public void setScreen(Screen screen) {
|
||||
if (screen != null) {
|
||||
dependencyManager.inject(screen);
|
||||
}
|
||||
this.screen = screen;
|
||||
}
|
||||
}
|
||||
41
game/src/main/java/cz/jzitnik/client/game/OtherPlayer.java
Normal file
41
game/src/main/java/cz/jzitnik/client/game/OtherPlayer.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package cz.jzitnik.client.game;
|
||||
|
||||
import cz.jzitnik.client.game.mobs.HittableMob;
|
||||
import cz.jzitnik.common.models.coordinates.RoomCords;
|
||||
import cz.jzitnik.common.models.player.PlayerCreation;
|
||||
import cz.jzitnik.common.socket.messages.player.PlayerRotation;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@Getter
|
||||
public class OtherPlayer implements GamePlayer {
|
||||
private final int id;
|
||||
private boolean hitAnimationOn = false;
|
||||
private final RoomCords playerCords;
|
||||
@Setter
|
||||
private PlayerRotation playerRotation = PlayerRotation.FRONT;
|
||||
@Setter
|
||||
private boolean visible;
|
||||
|
||||
public OtherPlayer(PlayerCreation playerCreation) {
|
||||
this.id = playerCreation.getId();
|
||||
this.playerCords = playerCreation.getPlayerCords();
|
||||
}
|
||||
|
||||
public BufferedImage getTexture(ResourceManager resourceManager) {
|
||||
BufferedImage resource = resourceManager.getResource(switch (playerRotation) {
|
||||
case FRONT -> ResourceManager.Resource.PLAYER_FRONT;
|
||||
case BACK -> ResourceManager.Resource.PLAYER_BACK;
|
||||
case LEFT -> ResourceManager.Resource.PLAYER_LEFT;
|
||||
case RIGHT -> ResourceManager.Resource.PLAYER_RIGHT;
|
||||
});
|
||||
|
||||
if (hitAnimationOn) {
|
||||
return HittableMob.applyRedFactor(resource);
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user