-
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.
- Loading branch information
Showing
26 changed files
with
242 additions
and
45 deletions.
There are no files selected for viewing
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
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
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
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
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,15 @@ | ||
{ | ||
"ModelRenderInEditorComponent": { | ||
}, | ||
"ModelColoredCuboidComponent": { | ||
"translate": "-0.5,0,-0.5", | ||
"color": "127,127,127" | ||
}, | ||
"ObjectInEditorComponent": { | ||
"displayName": "Player spawn", | ||
"renderSize": "1,1,1", | ||
"renderTranslate": "0,0,0", | ||
"placementTranslate": "0.5,0,0.5" | ||
}, | ||
"PlayerSpawnComponent": {} | ||
} |
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,9 @@ | ||
package jgd.platformer.editor; | ||
|
||
import com.gempukku.secsy.entity.io.EntityData; | ||
|
||
public interface EditorState { | ||
EntityData getLevelToTest(); | ||
|
||
void consumeLevelToTest(); | ||
} |
27 changes: 27 additions & 0 deletions
27
core/src/main/java/jgd/platformer/editor/EditorStateSystem.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,27 @@ | ||
package jgd.platformer.editor; | ||
|
||
import com.gempukku.secsy.context.annotation.RegisterSystem; | ||
import com.gempukku.secsy.entity.EntityRef; | ||
import com.gempukku.secsy.entity.dispatch.ReceiveEvent; | ||
import com.gempukku.secsy.entity.io.EntityData; | ||
|
||
@RegisterSystem( | ||
profiles = {"gameScreen", "editor"}, shared = EditorState.class) | ||
public class EditorStateSystem implements EditorState { | ||
private EntityData levelToTest; | ||
|
||
@ReceiveEvent | ||
public void levelTestRequested(RequestTestingLevel event, EntityRef entityRef) { | ||
levelToTest = event.getLevelToTest(); | ||
} | ||
|
||
@Override | ||
public void consumeLevelToTest() { | ||
levelToTest = null; | ||
} | ||
|
||
@Override | ||
public EntityData getLevelToTest() { | ||
return levelToTest; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
core/src/main/java/jgd/platformer/editor/RequestTestingLevel.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,16 @@ | ||
package jgd.platformer.editor; | ||
|
||
import com.gempukku.secsy.entity.event.Event; | ||
import com.gempukku.secsy.entity.io.EntityData; | ||
|
||
public class RequestTestingLevel extends Event { | ||
private EntityData levelToTest; | ||
|
||
public RequestTestingLevel(EntityData levelToTest) { | ||
this.levelToTest = levelToTest; | ||
} | ||
|
||
public EntityData getLevelToTest() { | ||
return levelToTest; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
core/src/main/java/jgd/platformer/editor/rendering/ModelEditorRenderer.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,76 @@ | ||
package jgd.platformer.editor.rendering; | ||
|
||
import com.badlogic.gdx.graphics.g3d.ModelBatch; | ||
import com.badlogic.gdx.graphics.g3d.ModelInstance; | ||
import com.badlogic.gdx.math.Vector3; | ||
import com.gempukku.gaming.asset.prefab.PrefabManager; | ||
import com.gempukku.gaming.asset.texture.TextureAtlasProvider; | ||
import com.gempukku.gaming.rendering.event.RenderEnvironment; | ||
import com.gempukku.gaming.rendering.shape.ShapeProvider; | ||
import com.gempukku.secsy.context.annotation.Inject; | ||
import com.gempukku.secsy.context.annotation.RegisterSystem; | ||
import com.gempukku.secsy.context.system.LifeCycleSystem; | ||
import com.gempukku.secsy.entity.EntityManager; | ||
import com.gempukku.secsy.entity.EntityRef; | ||
import com.gempukku.secsy.entity.dispatch.ReceiveEvent; | ||
import com.gempukku.secsy.entity.index.EntityIndex; | ||
import com.gempukku.secsy.entity.index.EntityIndexManager; | ||
import jgd.platformer.gameplay.component.Location3DComponent; | ||
import jgd.platformer.gameplay.rendering.model.GetModelInstance; | ||
import jgd.platformer.gameplay.rendering.model.ModelRotateComponent; | ||
import jgd.platformer.gameplay.rendering.model.ModelScaleComponent; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
@RegisterSystem(profiles = "gameScreen") | ||
public class ModelEditorRenderer implements LifeCycleSystem { | ||
@Inject | ||
private ShapeProvider shapeProvider; | ||
@Inject | ||
private TextureAtlasProvider textureAtlasProvider; | ||
@Inject | ||
private EntityIndexManager entityIndexManager; | ||
@Inject | ||
private PrefabManager prefabManager; | ||
@Inject | ||
private EntityManager entityManager; | ||
|
||
private ModelBatch modelBatch = new ModelBatch(); | ||
|
||
private EntityIndex modelsIndex; | ||
|
||
@Override | ||
public void initialize() { | ||
modelsIndex = entityIndexManager.addIndexOnComponents(ModelRenderInEditorComponent.class, Location3DComponent.class); | ||
} | ||
|
||
@ReceiveEvent(priority = -1) | ||
public void renderModels(RenderEnvironment event, EntityRef renderingEntity, RenderingEditorComponent renderingEditor) { | ||
List<ModelInstance> models = new LinkedList<>(); | ||
for (EntityRef entityRef : modelsIndex.getEntities()) { | ||
Vector3 locationVec = entityRef.getComponent(Location3DComponent.class).getLocation(); | ||
float rotationY = 0; | ||
ModelRotateComponent rotation = entityRef.getComponent(ModelRotateComponent.class); | ||
if (rotation != null) { | ||
rotationY = rotation.getRotateY(); | ||
} | ||
Vector3 scaleVec = new Vector3(1, 1, 1); | ||
ModelScaleComponent scale = entityRef.getComponent(ModelScaleComponent.class); | ||
if (scale != null) { | ||
scaleVec.set(scale.getScale()); | ||
} | ||
|
||
GetModelInstance getModelInstance = new GetModelInstance(locationVec, rotationY, scaleVec); | ||
entityRef.send(getModelInstance); | ||
|
||
models.addAll(getModelInstance.getInstances()); | ||
} | ||
|
||
event.getRenderPipeline().getCurrentBuffer().begin(); | ||
modelBatch.begin(event.getCamera()); | ||
modelBatch.render(models, event.getEnvironment()); | ||
modelBatch.end(); | ||
event.getRenderPipeline().getCurrentBuffer().end(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/jgd/platformer/editor/rendering/ModelRenderInEditorComponent.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,6 @@ | ||
package jgd.platformer.editor.rendering; | ||
|
||
import com.gempukku.secsy.entity.Component; | ||
|
||
public interface ModelRenderInEditorComponent extends Component { | ||
} |
6 changes: 6 additions & 0 deletions
6
core/src/main/java/jgd/platformer/editor/rendering/RenderingEditorComponent.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,6 @@ | ||
package jgd.platformer.editor.rendering; | ||
|
||
import com.gempukku.secsy.entity.Component; | ||
|
||
public interface RenderingEditorComponent extends Component { | ||
} |
Oops, something went wrong.