-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.1.5, added SnapshotProducer, TimeCompound, AdvancedRectangl…
…e and cleaned up some mess in some file classes as well as in CollisionUtils2D
- Loading branch information
Showing
31 changed files
with
677 additions
and
292 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/de/kleesup/libraries/gamebase/shared/SnapshotProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package de.kleesup.libraries.gamebase.shared; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.InvocationTargetException; | ||
|
||
/** | ||
* An interface for classes which require the functionality to create objects from snapshots of the class. | ||
* Snapshots can be useful if you want to have an object which contains only the most necessary information of an object. | ||
* The snapshots can be used in several ways and also to load the full object. | ||
* NOTE: Classes implementing this interface are REQUIRED to have a constructor that accepts the created snapshot type | ||
* or else {@link SnapshotProducer#fromSnapshot(Class, Object)} will fail! | ||
* <br>Created on 24.02.2023</br> | ||
* @author KleeSup | ||
* @version 1.0 | ||
* @since 1.1.5 | ||
*/ | ||
public interface SnapshotProducer<T> { | ||
|
||
/** | ||
* Loads a full object from a given snapshot. | ||
* NOTE: All classes that implement {@link SnapshotProducer} need to have a default constructor accepting the snapshot received from {@link SnapshotProducer#toSnapshot()}! | ||
* @param clazz The class of the object to be loaded. | ||
* @param snapshot The snapshot to load the object from. | ||
* @return The loaded object which was created with the given snapshot. | ||
*/ | ||
static <S extends SnapshotProducer<?>> S fromSnapshot(Class<S> clazz, Object snapshot){ | ||
KleeUtil.paramRequireNonNull(clazz, "Class to construct instance for cannot be null!"); | ||
KleeUtil.paramRequireNonNull(snapshot, "Snapshot to build instance from cannot be null!"); | ||
try { | ||
Constructor<S> constructor = clazz.getConstructor(snapshot.getClass()); | ||
return constructor.newInstance(snapshot); | ||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { | ||
throw new RuntimeException("Unable to build "+clazz.getName()+ | ||
" instance from snapshot, as the class does not have a default constructor accepting the snapshot instance! [new MyClass(myClassSnapshot) not available]", e); | ||
} | ||
} | ||
|
||
/** | ||
* @return A created snapshot of this class containing minimal essential information to load this object. | ||
* The snapshot can be used to save this object into files or sent it via packets. | ||
*/ | ||
T toSnapshot(); | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/de/kleesup/libraries/gamebase/shared/TimeCompound.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package de.kleesup.libraries.gamebase.shared; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* A compound of a {@link TimeUnit} and a long-value that refers to the time. | ||
* <br>Created on 22.02.2023</br> | ||
* @author KleeSup | ||
* @version 1.0 | ||
* @since 1.1.5 | ||
*/ | ||
public class TimeCompound { | ||
|
||
private final TimeUnit unit; | ||
private final long value; | ||
public TimeCompound(TimeUnit unit, long value){ | ||
KleeUtil.paramRequireNonNull(unit, "TimeUnit cannot be null!"); | ||
this.unit = unit; | ||
this.value = value; | ||
} | ||
|
||
public long convert(TimeUnit otherUnit){ | ||
return otherUnit.convert(value, unit); | ||
} | ||
|
||
public TimeUnit getUnit() { | ||
return unit; | ||
} | ||
|
||
public long getValue() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/main/java/de/kleesup/libraries/gamebase/shared/entity/Controller.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/main/java/de/kleesup/libraries/gamebase/shared/entity/IEntity2D.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.kleesup.libraries.gamebase.shared.entity; | ||
|
||
import com.badlogic.gdx.utils.Disposable; | ||
import de.kleesup.libraries.gamebase.shared.Identifiable; | ||
import de.kleesup.libraries.gamebase.shared.math.gdx.AABB2D; | ||
import de.kleesup.libraries.gamebase.shared.world.IDynamicWorldObject2D; | ||
import de.kleesup.libraries.gamebase.shared.world.IGameWorld; | ||
import de.kleesup.libraries.gamebase.shared.world.IWorldHolder; | ||
|
||
/** | ||
* A simple base class for entity implementations. | ||
* <br>Created on 20.02.2023</br> | ||
* @author KleeSup | ||
* @version 1.0 | ||
* @since 1.1.5 | ||
*/ | ||
public interface IEntity2D<I, W extends IGameWorld> extends IDynamicWorldObject2D, Identifiable<I>, Disposable, IWorldHolder<W> { | ||
|
||
AABB2D getBoundingBox(); | ||
|
||
default void kill(){ | ||
dispose(); | ||
} | ||
default void remove(){ | ||
dispose(); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/de/kleesup/libraries/gamebase/shared/entity/IEntity3D.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.kleesup.libraries.gamebase.shared.entity; | ||
|
||
import com.badlogic.gdx.utils.Disposable; | ||
import de.kleesup.libraries.gamebase.shared.Identifiable; | ||
import de.kleesup.libraries.gamebase.shared.math.AABB3D; | ||
import de.kleesup.libraries.gamebase.shared.world.IDynamicWorldObject3D; | ||
import de.kleesup.libraries.gamebase.shared.world.IGameWorld; | ||
import de.kleesup.libraries.gamebase.shared.world.IWorldHolder; | ||
|
||
/** | ||
* A simple base class for entity implementations. | ||
* <br>Created on 28.02.2023</br> | ||
* @author KleeSup | ||
* @version 1.0 | ||
* @since 1.1.5 | ||
*/ | ||
public interface IEntity3D<I, W extends IGameWorld> extends IDynamicWorldObject3D, Identifiable<I>, Disposable, IWorldHolder<W> { | ||
|
||
AABB3D getBoundingBox(); | ||
|
||
default void kill(){ | ||
dispose(); | ||
} | ||
default void remove(){ | ||
dispose(); | ||
} | ||
|
||
} |
74 changes: 0 additions & 74 deletions
74
src/main/java/de/kleesup/libraries/gamebase/shared/entity/PlayerController.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.