Skip to content

Commit

Permalink
Playtesting created levels
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinSc committed Sep 20, 2016
1 parent 8e16d91 commit 40594b9
Show file tree
Hide file tree
Showing 26 changed files with 242 additions and 45 deletions.
3 changes: 2 additions & 1 deletion core/assets/prefabs/editorRenderingEntity.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"lookAt": "0,0,0",
"up": "0,1,0"
},
"RendersUIComponent": {}
"RendersUIComponent": {},
"RenderingEditorComponent": {}
}
13 changes: 10 additions & 3 deletions core/assets/prefabs/levels/emptyLevel.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"LevelComponent": {
"blockCoordinates": {
},
"locatedObjects": {
},
"additionalObjects": []
"locatedObjects": [
],
"additionalObjects": [],
"minX": -100,
"maxX": 100,
"minY": -100
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
}
}
6 changes: 3 additions & 3 deletions core/assets/prefabs/levels/level-sample1.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"0,-2,0": "stone",
"-1,-1,0": "exitPortal"
},
"locatedObjects": [
"-4.5,-1,0.5|playerSpawn"
],
"minX": -10,
"maxX": 6,
"minY": -7
},
"PlayerSpawnComponent": {
"location": "-4.5,-1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
4 changes: 1 addition & 3 deletions core/assets/prefabs/levels/level-sample10.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
"1,-1,0": "exitPortal"
},
"locatedObjects": [
"-4.5,-1,0.5|playerSpawn",
"-3,-2,0|stoneFront",
"0,-2,-1|stoneBack"
],
"minX": -10,
"maxX": 6,
"minY": -7
},
"PlayerSpawnComponent": {
"location": "-4.5,-1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
4 changes: 1 addition & 3 deletions core/assets/prefabs/levels/level-sample2.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"7,1,0": "exitPortal"
},
"locatedObjects": [
"-4.5,1,0.5|playerSpawn",
"-0.5,3,0.5|star",
"0.5,3.5,0.5|star",
"1.5,3,0.5|star",
Expand All @@ -22,9 +23,6 @@
"maxX": 14,
"minY": -5
},
"PlayerSpawnComponent": {
"location": "-4.5,1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
6 changes: 3 additions & 3 deletions core/assets/prefabs/levels/level-sample3.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"8,0,0": "stone",
"7,1,0": "exitPortal"
},
"locatedObjects": [
"-4.5,1,0.5|playerSpawn"
],
"minX": -10,
"maxX": 14,
"minY": -5
},
"PlayerSpawnComponent": {
"location": "-4.5,1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
4 changes: 1 addition & 3 deletions core/assets/prefabs/levels/level-sample4.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"7,0,0": "exitPortal"
},
"locatedObjects": [
"-4.5,1,0.5|playerSpawn",
"5,1,0.5|bug"
],
"additionalObjects": [
Expand All @@ -23,9 +24,6 @@
"maxX": 14,
"minY": -5
},
"PlayerSpawnComponent": {
"location": "-4.5,1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
6 changes: 2 additions & 4 deletions core/assets/prefabs/levels/level-sample5.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"11,1,0": "exitPortal"
},
"locatedObjects": [
"-4.5,1,0.5|playerSpawn",
"5,2,0.5|bugWithGun"
],
"additionalObjects": [
Expand All @@ -28,10 +29,7 @@
"minX": -10,
"maxX": 16,
"minY": -5
},
"PlayerSpawnComponent": {
"location": "-4.5,1,0.5"
},
}
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
4 changes: 1 addition & 3 deletions core/assets/prefabs/levels/level-sample6.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"9,-1,0": "exitPortal"
},
"locatedObjects": [
"-4.5,-1,0.5|playerSpawn",
"-3,-1,0|cycleDoor",
{
"prefabName": "stonePlatform",
Expand Down Expand Up @@ -43,9 +44,6 @@
"maxX": 15,
"minY": -7
},
"PlayerSpawnComponent": {
"location": "-4.5,-1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
4 changes: 1 addition & 3 deletions core/assets/prefabs/levels/level-sample7.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"-2,2,0": "stone"
},
"locatedObjects": [
"-8.5,-1,0.5|playerSpawn",
{
"prefabName": "pressurePlate",
"location": "-8,-2,0",
Expand Down Expand Up @@ -73,9 +74,6 @@
"maxX": 6,
"minY": -7
},
"PlayerSpawnComponent": {
"location": "-8.5,-1,0.5"
},
"CameraBoundsComponent": {
"min": "-10,0",
"max": "10,10"
Expand Down
4 changes: 1 addition & 3 deletions core/assets/prefabs/levels/level-sample8.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"7,7,0": "stone"
},
"locatedObjects": [
"0.5,1,0.5|playerSpawn",
{
"prefabName": "pressurePlate",
"location": "3,0,0",
Expand Down Expand Up @@ -95,9 +96,6 @@
"maxX": 14,
"minY": -5
},
"PlayerSpawnComponent": {
"location": "0.5,1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
4 changes: 1 addition & 3 deletions core/assets/prefabs/levels/level-sample9.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"5,4,0": "stone"
},
"locatedObjects": [
"0.5,1,0.5|playerSpawn",
{
"prefabName": "lever",
"location": "3,1,0",
Expand Down Expand Up @@ -54,9 +55,6 @@
"maxX": 14,
"minY": -5
},
"PlayerSpawnComponent": {
"location": "0.5,1,0.5"
},
"CameraBoundsComponent": {
"min": "0,0",
"max": "10,10"
Expand Down
15 changes: 15 additions & 0 deletions core/assets/prefabs/objects/playerSpawn.prefab
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": {}
}
9 changes: 9 additions & 0 deletions core/src/main/java/jgd/platformer/editor/EditorState.java
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 core/src/main/java/jgd/platformer/editor/EditorStateSystem.java
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 core/src/main/java/jgd/platformer/editor/RequestTestingLevel.java
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;
}
}
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();
}
}
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 {
}
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 {
}
Loading

0 comments on commit 40594b9

Please sign in to comment.