Move Editor to Artemis-based runtime:
* Epic artemis switch! * Update to 0.0.8-SNAPSHOT
This commit is contained in:
@@ -1 +1 @@
|
||||
version=0.0.7
|
||||
version=0.0.8-SNAPSHOT
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
+2
-2
@@ -14,7 +14,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'games.rednblack'
|
||||
version '0.0.7'
|
||||
version '0.0.8'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -84,7 +84,7 @@ dependencies {
|
||||
exclude group: 'com.badlogicgames.gdx', module: 'gdx-backend-lwjgl'
|
||||
}
|
||||
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
||||
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
implementation "net.onedaybeard.artemis:artemis-odb:$artemisVersion"
|
||||
|
||||
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
gdxVersion = 1.10.0
|
||||
lwjgl3Version = 3.2.3
|
||||
ashleyVersion = 1.7.4
|
||||
artemisVersion = 2.3.0
|
||||
spineVersion = 3.8.55.1
|
||||
visuiVersion = 1.5.0
|
||||
typingLabelVersion = 1.2.0
|
||||
|
||||
Submodule h2d-libgdx-spine-extension updated: 4442f02e78...f0b66533a8
Submodule h2d-libgdx-talos-extension updated: 99011034e7...82421191ed
+1
-1
Submodule hyperlap2d-common-api updated: 0f4343906a...4d2862b4c5
Submodule hyperlap2d-runtime-libgdx updated: ffcd8e49c2...d8879a0f6e
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'games.rednblack'
|
||||
version '0.0.7'
|
||||
version '0.0.8'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -12,8 +12,8 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
implementation "com.kotcrab.vis:vis-ui:$visuiVersion"
|
||||
implementation "net.onedaybeard.artemis:artemis-odb:$artemisVersion"
|
||||
|
||||
implementation 'net.mountainblade:modular:1.0'
|
||||
|
||||
|
||||
+8
-10
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.plugin.ninepatch;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||
@@ -56,8 +55,8 @@ public class MainPanelMediator extends Mediator<MainPanel> {
|
||||
convertImageToNinePatch();
|
||||
break;
|
||||
case MainPanel.SAVE_CLICKED:
|
||||
Entity entity = plugin.currEditingEntity;
|
||||
NinePatchComponent ninePatchComponent = ComponentRetriever.get(entity, NinePatchComponent.class);
|
||||
int entity = plugin.currEditingEntity;
|
||||
NinePatchComponent ninePatchComponent = ComponentRetriever.get(entity, NinePatchComponent.class, plugin.getAPI().getEngine());
|
||||
applyNewSplits(ninePatchComponent.textureRegionName, viewComponent.getSplits());
|
||||
viewComponent.hide();
|
||||
break;
|
||||
@@ -65,12 +64,12 @@ public class MainPanelMediator extends Mediator<MainPanel> {
|
||||
}
|
||||
|
||||
private void convertImageToNinePatch() {
|
||||
Entity entity = plugin.currEditingEntity;
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
int entity = plugin.currEditingEntity;
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, plugin.getAPI().getEngine());
|
||||
mainItemComponent.entityType = EntityFactory.NINE_PATCH;
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class, plugin.getAPI().getEngine());
|
||||
String regionName = textureRegionComponent.regionName;
|
||||
NinePatchComponent ninePatchComponent = plugin.getAPI().getEngine().createComponent(NinePatchComponent.class);
|
||||
NinePatchComponent ninePatchComponent = plugin.getAPI().getEngine().edit(entity).create(NinePatchComponent.class);
|
||||
ninePatchComponent.textureRegionName = regionName;
|
||||
TextureAtlas.AtlasRegion newRegion = (TextureAtlas.AtlasRegion) textureRegionComponent.region;
|
||||
int[] splits = {0, 0, 0, 0};
|
||||
@@ -78,7 +77,6 @@ public class MainPanelMediator extends Mediator<MainPanel> {
|
||||
newRegion.names = new String[] {"split", "pad"};
|
||||
newRegion.values = new int[][] {splits, pad};
|
||||
ninePatchComponent.ninePatch = new NinePatch(textureRegionComponent.region, 0, 0, 0, 0);
|
||||
entity.add(ninePatchComponent);
|
||||
|
||||
//remove original image
|
||||
File originalImg = new File(plugin.getAPI().getProjectPath() + "/assets/orig/images/"+regionName+".png");
|
||||
@@ -93,8 +91,8 @@ public class MainPanelMediator extends Mediator<MainPanel> {
|
||||
}
|
||||
|
||||
private void loadNinePatch() {
|
||||
Entity entity = plugin.currEditingEntity;
|
||||
NinePatchComponent ninePatchComponent = ComponentRetriever.get(entity, NinePatchComponent.class);
|
||||
int entity = plugin.currEditingEntity;
|
||||
NinePatchComponent ninePatchComponent = ComponentRetriever.get(entity, NinePatchComponent.class, plugin.getAPI().getEngine());
|
||||
loadRegion(ninePatchComponent.textureRegionName);
|
||||
viewComponent.show(plugin.getAPI().getUIStage());
|
||||
}
|
||||
|
||||
+4
-5
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.plugin.ninepatch;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
@@ -23,7 +22,7 @@ public class NinePatchPlugin extends H2DPluginAdapter {
|
||||
|
||||
private MainPanelMediator performancePanelMediator;
|
||||
|
||||
public Entity currEditingEntity;
|
||||
public int currEditingEntity;
|
||||
|
||||
public NinePatchPlugin() {
|
||||
super(CLASS_NAME);
|
||||
@@ -38,10 +37,10 @@ public class NinePatchPlugin extends H2DPluginAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDropDownOpen(Set<Entity> selectedEntities, Array<String> actionsSet) {
|
||||
public void onDropDownOpen(Set<Integer> selectedEntities, Array<String> actionsSet) {
|
||||
if(selectedEntities.size() == 1) {
|
||||
Entity entity = selectedEntities.stream().findFirst().get();
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
int entity = selectedEntities.stream().findFirst().get();
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, getAPI().getEngine());
|
||||
|
||||
if(mainItemComponent.entityType == EntityFactory.NINE_PATCH) {
|
||||
// it's our guy
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'games.rednblack'
|
||||
version '0.0.7'
|
||||
version '0.0.8'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -12,8 +12,8 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
implementation "com.kotcrab.vis:vis-ui:$visuiVersion"
|
||||
implementation "net.onedaybeard.artemis:artemis-odb:$artemisVersion"
|
||||
|
||||
implementation 'net.mountainblade:modular:1.0'
|
||||
|
||||
|
||||
+8
-5
@@ -1,6 +1,8 @@
|
||||
package games.rednblack.editor.plugin.performance;
|
||||
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import com.artemis.Aspect;
|
||||
import com.artemis.EntitySubscription;
|
||||
import com.artemis.utils.IntBag;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.profiling.GLProfiler;
|
||||
import com.kotcrab.vis.ui.widget.VisLabel;
|
||||
@@ -16,7 +18,7 @@ public class PerformancePanel extends UIDraggablePanel {
|
||||
|
||||
private VisLabel entitiesCount, memoryLabel, fpsLbl, glCalls, drawCalls, shaderSwitch, textureBind, vertexCount;
|
||||
|
||||
private Engine engine;
|
||||
private EntitySubscription entitySubscription;
|
||||
private final GLProfiler profiler;
|
||||
|
||||
public PerformancePanel() {
|
||||
@@ -87,7 +89,7 @@ public class PerformancePanel extends UIDraggablePanel {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
super.act(delta);
|
||||
entitiesCount.setText(engine.getEntities().size());
|
||||
entitiesCount.setText(entitySubscription.getEntities().size());
|
||||
fpsLbl.setText(Gdx.graphics.getFramesPerSecond());
|
||||
MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||
long usedMemory = memoryUsage.getUsed() / (1024 * 1024);
|
||||
@@ -109,7 +111,8 @@ public class PerformancePanel extends UIDraggablePanel {
|
||||
profiler.reset();
|
||||
}
|
||||
|
||||
public void setEngine(Engine engine) {
|
||||
this.engine = engine;
|
||||
public void setEngine(com.artemis.World engine) {
|
||||
entitySubscription = engine.getAspectSubscriptionManager()
|
||||
.get(Aspect.all());
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.plugin.performance;
|
||||
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
import org.puremvc.java.patterns.mediator.Mediator;
|
||||
@@ -33,7 +32,7 @@ public class PerformancePanelMediator extends Mediator<PerformancePanel> {
|
||||
switch (notification.getName()) {
|
||||
case MsgAPI.SCENE_LOADED:
|
||||
viewComponent.initView();
|
||||
Engine engine = performancePlugin.getAPI().getEngine();
|
||||
com.artemis.World engine = performancePlugin.getAPI().getEngine();
|
||||
viewComponent.setEngine(engine);
|
||||
break;
|
||||
case PerformancePlugin.PANEL_OPEN:
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'games.rednblack'
|
||||
version '0.0.7'
|
||||
version '0.0.8'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -12,8 +12,8 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
implementation "com.kotcrab.vis:vis-ui:$visuiVersion"
|
||||
implementation "net.onedaybeard.artemis:artemis-odb:$artemisVersion"
|
||||
|
||||
implementation 'net.mountainblade:modular:1.0'
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'games.rednblack'
|
||||
version '0.0.7'
|
||||
version '0.0.8'
|
||||
|
||||
ext {
|
||||
pack = ["assets/textures", "assets/pack/", "tiled"]
|
||||
@@ -16,8 +16,8 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
implementation "com.badlogicgames.ashley:ashley:$ashleyVersion"
|
||||
implementation "com.kotcrab.vis:vis-ui:$visuiVersion"
|
||||
implementation "net.onedaybeard.artemis:artemis-odb:$artemisVersion"
|
||||
|
||||
implementation "com.esotericsoftware.spine:spine-libgdx:$spineVersion"
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ package games.rednblack.editor.plugin.tiled;
|
||||
|
||||
import org.puremvc.java.interfaces.IFacade;
|
||||
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.kotcrab.vis.ui.widget.VisLabel;
|
||||
import com.kotcrab.vis.ui.widget.VisTable;
|
||||
@@ -60,7 +59,7 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
private SettingsTab settingsTab;
|
||||
private AutoGridTilesTab autoGridTilesTab;
|
||||
private VisTable mainTable;
|
||||
private Engine engine;
|
||||
private com.artemis.World engine;
|
||||
private ResourcesManager resourcesManager;
|
||||
|
||||
private boolean isAutoGridTabSelected;
|
||||
@@ -246,7 +245,7 @@ public class TiledPanel extends UIDraggablePanel {
|
||||
mainTable.add(new VisLabel("no scenes open")).right();
|
||||
}
|
||||
|
||||
public void setEngine(Engine engine) {
|
||||
public void setEngine(com.artemis.World engine) {
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -26,8 +26,6 @@ import games.rednblack.editor.renderer.data.TexturePackVO;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
import org.puremvc.java.patterns.mediator.Mediator;
|
||||
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
@@ -118,7 +116,7 @@ public class TiledPanelMediator extends Mediator<TiledPanel> {
|
||||
|
||||
targetGrid = initTarget(targetGrid, viewComponent.getDropTable(), false);
|
||||
targetAutoGrid = initTarget(targetAutoGrid, viewComponent.getAutoGridDropTable(), true);
|
||||
Engine engine = tiledPlugin.getAPI().getEngine();
|
||||
com.artemis.World engine = tiledPlugin.getAPI().getEngine();
|
||||
viewComponent.setEngine(engine);
|
||||
viewComponent.setFixedPosition();
|
||||
break;
|
||||
@@ -289,8 +287,8 @@ public class TiledPanelMediator extends Mediator<TiledPanel> {
|
||||
tiledPlugin.saveDataManager.save();
|
||||
break;
|
||||
case TiledPlugin.ACTION_SET_GRID_SIZE_FROM_ITEM:
|
||||
Entity observable = notification.getBody();
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(observable, DimensionsComponent.class);
|
||||
int observable = notification.getBody();
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(observable, DimensionsComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
tiledPlugin.dataToSave.setGrid(dimensionsComponent.width, dimensionsComponent.height);
|
||||
tiledPlugin.facade.sendNotification(TiledPlugin.GRID_CHANGED);
|
||||
break;
|
||||
|
||||
@@ -21,7 +21,6 @@ package games.rednblack.editor.plugin.tiled;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
@@ -156,7 +155,7 @@ public class TiledPlugin extends H2DPluginAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDropDownOpen(Set<Entity> selectedEntities, Array<String> actionsSet) {
|
||||
public void onDropDownOpen(Set<Integer> selectedEntities, Array<String> actionsSet) {
|
||||
if(selectedEntities.size() == 1) {
|
||||
actionsSet.add(ACTION_SET_GRID_SIZE_FROM_ITEM);
|
||||
}
|
||||
@@ -172,29 +171,29 @@ public class TiledPlugin extends H2DPluginAdapter {
|
||||
deleteTileTool = new DeleteTileTool(this);
|
||||
}
|
||||
|
||||
public Entity getPluginEntityWithParams(int row, int column) {
|
||||
for (Entity entity : pluginAPI.getProjectEntities()) {
|
||||
public int getPluginEntityWithParams(int row, int column) {
|
||||
for (int entity : pluginAPI.getProjectEntities()) {
|
||||
if(!isTile(entity)) continue;
|
||||
boolean isEntityVisible = pluginAPI.isEntityVisible(entity);
|
||||
if (!isEntityVisible || !isOnCurrentSelectedLayer(entity)) continue;
|
||||
|
||||
currentEntityMainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
currentEntityMainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, getAPI().getEngine());
|
||||
currentEntityCustomVariables = currentEntityMainItemComponent.customVariables;
|
||||
if (currentEntityCustomVariables.getIntegerVariable(ROW) == row
|
||||
&& currentEntityCustomVariables.getIntegerVariable(COLUMN) == column) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Entity getPluginEntityWithCoords(float x, float y) {
|
||||
for (Entity entity : pluginAPI.getProjectEntities()) {
|
||||
public int getPluginEntityWithCoords(float x, float y) {
|
||||
for (int entity : pluginAPI.getProjectEntities()) {
|
||||
if (!isTile(entity)) continue;
|
||||
boolean isEntityVisible = pluginAPI.isEntityVisible(entity);
|
||||
if (!isEntityVisible || !isOnCurrentSelectedLayer(entity)) continue;
|
||||
|
||||
currentEntityTransformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
currentEntityTransformComponent = ComponentRetriever.get(entity, TransformComponent.class, getAPI().getEngine());
|
||||
Rectangle tmp = new Rectangle(
|
||||
currentEntityTransformComponent.x,
|
||||
currentEntityTransformComponent.y,
|
||||
@@ -205,21 +204,21 @@ public class TiledPlugin extends H2DPluginAdapter {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public float getPixelToWorld() {
|
||||
return pluginAPI.getSceneLoader().getRm().getProjectVO().pixelToWorld;
|
||||
}
|
||||
|
||||
public boolean isTile(Entity entity) {
|
||||
if (entity == null)
|
||||
public boolean isTile(int entity) {
|
||||
if (entity == -1)
|
||||
return false;
|
||||
return ComponentRetriever.get(entity, MainItemComponent.class).tags.contains(TILE_TAG);
|
||||
return ComponentRetriever.get(entity, MainItemComponent.class, getAPI().getEngine()).tags.contains(TILE_TAG);
|
||||
}
|
||||
|
||||
public boolean isOnCurrentSelectedLayer(Entity entity) {
|
||||
ZIndexComponent entityZComponent = ComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
public boolean isOnCurrentSelectedLayer(int entity) {
|
||||
ZIndexComponent entityZComponent = ComponentRetriever.get(entity, ZIndexComponent.class, getAPI().getEngine());
|
||||
return entityZComponent.layerName.equals(pluginAPI.getCurrentSelectedLayerName());
|
||||
}
|
||||
|
||||
@@ -274,8 +273,8 @@ public class TiledPlugin extends H2DPluginAdapter {
|
||||
public void applySelectedTileGridOffset() {
|
||||
pluginAPI.getProjectEntities().forEach(entity -> {
|
||||
if (!(isTile(entity))) return;
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class, getAPI().getEngine());
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class, getAPI().getEngine());
|
||||
if (selectedTileVO.regionName.equals(textureRegionComponent.regionName)) {
|
||||
transformComponent.x -= selectedTileVO.gridOffset.x;
|
||||
transformComponent.y -= selectedTileVO.gridOffset.y;
|
||||
|
||||
+18
-20
@@ -1,7 +1,5 @@
|
||||
package games.rednblack.editor.plugin.tiled.manager;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
@@ -27,8 +25,8 @@ public class AutoGridTileManager {
|
||||
}
|
||||
|
||||
public void autoFill() {
|
||||
for (Entity entity : tiledPlugin.getAPI().getProjectEntities()) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
for (int entity : tiledPlugin.getAPI().getProjectEntities()) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
if (!mainItemComponent.tags.contains(TiledPlugin.AUTO_TILE_TAG)) {
|
||||
continue;
|
||||
}
|
||||
@@ -37,43 +35,43 @@ public class AutoGridTileManager {
|
||||
|
||||
int c = 0;
|
||||
int val = 0;
|
||||
Entity ul = tiledPlugin.getPluginEntityWithParams(row + 1, col - 1);
|
||||
if (ul != null) {
|
||||
int ul = tiledPlugin.getPluginEntityWithParams(row + 1, col - 1);
|
||||
if (ul != -1) {
|
||||
c++;
|
||||
val += UL;
|
||||
}
|
||||
Entity u = tiledPlugin.getPluginEntityWithParams(row + 1, col);
|
||||
if (u != null) {
|
||||
int u = tiledPlugin.getPluginEntityWithParams(row + 1, col);
|
||||
if (u != -1) {
|
||||
c++;
|
||||
val += U;
|
||||
}
|
||||
Entity ur = tiledPlugin.getPluginEntityWithParams(row + 1, col + 1);
|
||||
if (ur != null) {
|
||||
int ur = tiledPlugin.getPluginEntityWithParams(row + 1, col + 1);
|
||||
if (ur != -1) {
|
||||
c++;
|
||||
val += UR;
|
||||
}
|
||||
Entity r = tiledPlugin.getPluginEntityWithParams(row, col + 1);
|
||||
if (r != null) {
|
||||
int r = tiledPlugin.getPluginEntityWithParams(row, col + 1);
|
||||
if (r != -1) {
|
||||
c++;
|
||||
val += R;
|
||||
}
|
||||
Entity dr = tiledPlugin.getPluginEntityWithParams(row - 1, col + 1);
|
||||
if (dr != null) {
|
||||
int dr = tiledPlugin.getPluginEntityWithParams(row - 1, col + 1);
|
||||
if (dr != -1) {
|
||||
c++;
|
||||
val += DR;
|
||||
}
|
||||
Entity d = tiledPlugin.getPluginEntityWithParams(row - 1, col);
|
||||
if (d != null) {
|
||||
int d = tiledPlugin.getPluginEntityWithParams(row - 1, col);
|
||||
if (d != -1) {
|
||||
c++;
|
||||
val += D;
|
||||
}
|
||||
Entity dl = tiledPlugin.getPluginEntityWithParams(row - 1, col - 1);
|
||||
if (dl != null) {
|
||||
int dl = tiledPlugin.getPluginEntityWithParams(row - 1, col - 1);
|
||||
if (dl != -1) {
|
||||
c++;
|
||||
val += DL;
|
||||
}
|
||||
Entity l = tiledPlugin.getPluginEntityWithParams(row, col - 1);
|
||||
if (l != null) {
|
||||
int l = tiledPlugin.getPluginEntityWithParams(row, col - 1);
|
||||
if (l != -1) {
|
||||
c++;
|
||||
val += L;
|
||||
}
|
||||
|
||||
+10
-11
@@ -5,7 +5,6 @@ import java.util.Set;
|
||||
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
@@ -72,24 +71,24 @@ public class DeleteTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemMouseDown(Entity entity, float x, float y) {
|
||||
public boolean itemMouseDown(int entity, float x, float y) {
|
||||
deleteEntityWithCoordinate(x, y);
|
||||
tiledPlugin.facade.sendNotification(TiledPlugin.AUTO_FILL_TILES);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemMouseUp(Entity entity, float x, float y) {
|
||||
public void itemMouseUp(int entity, float x, float y) {
|
||||
tiledPlugin.facade.sendNotification(TiledPlugin.AUTO_FILL_TILES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemMouseDragged(Entity entity, float x, float y) {
|
||||
public void itemMouseDragged(int entity, float x, float y) {
|
||||
deleteEntityWithCoordinate(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemMouseDoubleClick(Entity entity, float x, float y) {
|
||||
public void itemMouseDoubleClick(int entity, float x, float y) {
|
||||
|
||||
}
|
||||
|
||||
@@ -104,12 +103,12 @@ public class DeleteTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyDown(Entity entity, int keycode) {
|
||||
public void keyDown(int entity, int keycode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyUp(Entity entity, int keycode) {
|
||||
public void keyUp(int entity, int keycode) {
|
||||
if(isHotswapped) {
|
||||
if(keycode == Input.Keys.SHIFT_LEFT || keycode == Input.Keys.SHIFT_RIGHT) {
|
||||
isHotswapped = false;
|
||||
@@ -118,8 +117,8 @@ public class DeleteTileTool implements Tool {
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entity> items = new HashSet<>();
|
||||
private void deleteEntity(Entity entity) {
|
||||
Set<Integer> items = new HashSet<>();
|
||||
private void deleteEntity(int entity) {
|
||||
if (tiledPlugin.isTile(entity) && tiledPlugin.isOnCurrentSelectedLayer(entity)) {
|
||||
items.clear();
|
||||
items.add(entity);
|
||||
@@ -129,8 +128,8 @@ public class DeleteTileTool implements Tool {
|
||||
}
|
||||
|
||||
private void deleteEntityWithCoordinate (float x, float y) {
|
||||
Entity entity = tiledPlugin.getPluginEntityWithCoords(x, y);
|
||||
if (entity != null) {
|
||||
int entity = tiledPlugin.getPluginEntityWithCoords(x, y);
|
||||
if (entity != -1) {
|
||||
deleteEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-12
@@ -2,7 +2,6 @@ package games.rednblack.editor.plugin.tiled.tools;
|
||||
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
@@ -91,9 +90,9 @@ public class DrawTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemMouseDown(Entity entity, float x, float y) {
|
||||
public boolean itemMouseDown(int entity, float x, float y) {
|
||||
initGridThings();
|
||||
if (entity == null)
|
||||
if (entity == -1)
|
||||
drawTile(x, y);
|
||||
else
|
||||
drawOnEntity(entity);
|
||||
@@ -101,23 +100,23 @@ public class DrawTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemMouseUp(Entity entity, float x, float y) {
|
||||
public void itemMouseUp(int entity, float x, float y) {
|
||||
tiledPlugin.facade.sendNotification(TiledPlugin.AUTO_FILL_TILES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemMouseDragged(Entity entity, float x, float y) {
|
||||
public void itemMouseDragged(int entity, float x, float y) {
|
||||
drawTile(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemMouseDoubleClick(Entity entity, float x, float y) {
|
||||
public void itemMouseDoubleClick(int entity, float x, float y) {
|
||||
if (!tiledPlugin.isOnCurrentSelectedLayer(entity)) return;
|
||||
if (entity != null && tiledPlugin.isTile(entity)) {
|
||||
if (entity != -1 && tiledPlugin.isTile(entity)) {
|
||||
//rotate
|
||||
TransformCommandBuilder commandBuilder = new TransformCommandBuilder();
|
||||
commandBuilder.begin(entity);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
commandBuilder.begin(entity, tiledPlugin.getAPI().getEngine());
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
if (transformComponent.scaleX > 0 && transformComponent.scaleY > 0) {
|
||||
commandBuilder.setScale(transformComponent.scaleX * -1f, transformComponent.scaleY);
|
||||
} else if (transformComponent.scaleX < 0 && transformComponent.scaleY > 0) {
|
||||
@@ -142,7 +141,7 @@ public class DrawTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyDown(Entity entity, int keycode) {
|
||||
public void keyDown(int entity, int keycode) {
|
||||
if(keycode == Input.Keys.SHIFT_LEFT || keycode == Input.Keys.SHIFT_RIGHT) {
|
||||
tiledPlugin.getAPI().toolHotSwap(tiledPlugin.deleteTileTool);
|
||||
tiledPlugin.deleteTileTool.setHotSwapped();
|
||||
@@ -150,7 +149,7 @@ public class DrawTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyUp(Entity entity, int keycode) {
|
||||
public void keyUp(int entity, int keycode) {
|
||||
|
||||
}
|
||||
|
||||
@@ -191,7 +190,7 @@ public class DrawTileTool implements Tool {
|
||||
currentDrawStrategy.drawTile(newX, newY, row, column);
|
||||
}
|
||||
|
||||
private void drawOnEntity(Entity entity) {
|
||||
private void drawOnEntity(int entity) {
|
||||
chooseDrawStrategy();
|
||||
currentDrawStrategy.updateTile(entity);
|
||||
}
|
||||
|
||||
+8
-10
@@ -1,7 +1,5 @@
|
||||
package games.rednblack.editor.plugin.tiled.tools.drawStrategy;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
import games.rednblack.editor.plugin.tiled.data.AutoTileVO;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
@@ -22,8 +20,8 @@ public class AutoTileDrawStrategy extends BasicDrawStrategy {
|
||||
|
||||
@Override
|
||||
public void drawTile(float x, float y, int row, int column) {
|
||||
Entity underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != null) {
|
||||
int underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != -1) {
|
||||
updateTile(underneathTile);
|
||||
return;
|
||||
}
|
||||
@@ -32,7 +30,7 @@ public class AutoTileDrawStrategy extends BasicDrawStrategy {
|
||||
temp.set(x, y);
|
||||
tileToDraw = selectTileToDraw();
|
||||
if (itemFactory.createSimpleImage(tileToDraw + TiledPlugin.AUTO_TILE_DRAW_SUFFIX, temp)) {
|
||||
Entity imageEntity = itemFactory.getCreatedEntity();
|
||||
int imageEntity = itemFactory.getCreatedEntity();
|
||||
postProcessEntity(imageEntity, x, y, row, column);
|
||||
}
|
||||
}
|
||||
@@ -64,10 +62,10 @@ public class AutoTileDrawStrategy extends BasicDrawStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(Entity entity) {
|
||||
public void updateTile(int entity) {
|
||||
if (!checkValidTile(entity)) return;
|
||||
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
if (tiledPlugin.getSelectedAutoTileName().equals(mainItemComponent.customVariables.getStringVariable(TiledPlugin.ORIG_AUTO_TILE))) {
|
||||
// we only allow an update when the auto-tiles is different
|
||||
// firstly, it does not make any sense to randomly reselect another alternative tile
|
||||
@@ -75,7 +73,7 @@ public class AutoTileDrawStrategy extends BasicDrawStrategy {
|
||||
return;
|
||||
}
|
||||
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
if (textureRegionComponent != null && textureRegionComponent.regionName != null) {
|
||||
// there is already other tile under this one
|
||||
String selectedAutoTileName = selectTileToDraw();
|
||||
@@ -94,10 +92,10 @@ public class AutoTileDrawStrategy extends BasicDrawStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessEntity(Entity entity, float x, float y, int row, int column) {
|
||||
protected void postProcessEntity(int entity, float x, float y, int row, int column) {
|
||||
super.postProcessEntity(entity, x, y, row, column);
|
||||
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
mainItemComponent.tags.add(TiledPlugin.AUTO_TILE_TAG);
|
||||
mainItemComponent.setCustomVars(TiledPlugin.REGION, tileToDraw);
|
||||
mainItemComponent.setCustomVars(TiledPlugin.ORIG_AUTO_TILE, tiledPlugin.getSelectedAutoTileName());
|
||||
|
||||
+5
-6
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.plugin.tiled.tools.drawStrategy;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
@@ -15,20 +14,20 @@ public abstract class BasicDrawStrategy implements IDrawStrategy {
|
||||
tiledPlugin = plugin;
|
||||
}
|
||||
|
||||
protected void postProcessEntity(Entity entity, float x, float y, int row, int column) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
protected void postProcessEntity(int entity, float x, float y, int row, int column) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
mainItemComponent.tags.add(TiledPlugin.TILE_TAG);
|
||||
|
||||
mainItemComponent.setCustomVars(TiledPlugin.ROW, Integer.toString(row));
|
||||
mainItemComponent.setCustomVars(TiledPlugin.COLUMN, Integer.toString(column));
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
transformComponent.x = x;
|
||||
transformComponent.y = y;
|
||||
}
|
||||
|
||||
protected boolean checkValidTile(Entity entity) {
|
||||
protected boolean checkValidTile(int entity) {
|
||||
return tiledPlugin.isOnCurrentSelectedLayer(entity) && tiledPlugin.isTile(entity)
|
||||
&& ComponentRetriever.get(entity, MainItemComponent.class).entityType == tiledPlugin.getSelectedTileType();
|
||||
&& ComponentRetriever.get(entity, MainItemComponent.class, tiledPlugin.getAPI().getEngine()).entityType == tiledPlugin.getSelectedTileType();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,8 +1,6 @@
|
||||
package games.rednblack.editor.plugin.tiled.tools.drawStrategy;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
public interface IDrawStrategy {
|
||||
void drawTile(float x, float y, int row, int column);
|
||||
void updateTile(Entity entity);
|
||||
void updateTile(int entity);
|
||||
}
|
||||
|
||||
+6
-8
@@ -1,7 +1,5 @@
|
||||
package games.rednblack.editor.plugin.tiled.tools.drawStrategy;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.components.TextureRegionComponent;
|
||||
@@ -18,8 +16,8 @@ public class ImageDrawStrategy extends BasicDrawStrategy {
|
||||
|
||||
@Override
|
||||
public void drawTile(float x, float y, int row, int column) {
|
||||
Entity underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != null) {
|
||||
int underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != -1) {
|
||||
updateTile(underneathTile);
|
||||
return;
|
||||
}
|
||||
@@ -27,16 +25,16 @@ public class ImageDrawStrategy extends BasicDrawStrategy {
|
||||
IFactory itemFactory = tiledPlugin.getAPI().getItemFactory();
|
||||
temp.set(x, y);
|
||||
if (itemFactory.createSimpleImage(tiledPlugin.getSelectedTileName(), temp)) {
|
||||
Entity imageEntity = itemFactory.getCreatedEntity();
|
||||
int imageEntity = itemFactory.getCreatedEntity();
|
||||
postProcessEntity(imageEntity, x, y, row, column);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(Entity entity) {
|
||||
public void updateTile(int entity) {
|
||||
if (!checkValidTile(entity)) return;
|
||||
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
if (textureRegionComponent != null && textureRegionComponent.regionName != null) {
|
||||
// there is already other tile under this one
|
||||
if (!textureRegionComponent.regionName.equals(tiledPlugin.getSelectedTileName())) {
|
||||
@@ -46,7 +44,7 @@ public class ImageDrawStrategy extends BasicDrawStrategy {
|
||||
replaceRegionCommandBuilder.setRegionName(region);
|
||||
replaceRegionCommandBuilder.execute(tiledPlugin.facade);
|
||||
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
mainItemComponent.tags.remove(TiledPlugin.AUTO_TILE_TAG);
|
||||
mainItemComponent.removeCustomVars(TiledPlugin.REGION);
|
||||
}
|
||||
|
||||
+5
-6
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.plugin.tiled.tools.drawStrategy;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.esotericsoftware.spine.Skeleton;
|
||||
import com.esotericsoftware.spine.SkeletonData;
|
||||
import com.esotericsoftware.spine.SkeletonJson;
|
||||
@@ -21,8 +20,8 @@ public class SpineDrawStrategy extends BasicDrawStrategy {
|
||||
|
||||
@Override
|
||||
public void drawTile(float x, float y, int row, int column) {
|
||||
Entity underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != null) {
|
||||
int underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != -1) {
|
||||
updateTile(underneathTile);
|
||||
return;
|
||||
}
|
||||
@@ -31,16 +30,16 @@ public class SpineDrawStrategy extends BasicDrawStrategy {
|
||||
temp.set(x, y);
|
||||
|
||||
if (itemFactory.createSpineAnimation(tiledPlugin.getSelectedTileName(), temp)) {
|
||||
Entity imageEntity = itemFactory.getCreatedEntity();
|
||||
int imageEntity = itemFactory.getCreatedEntity();
|
||||
postProcessEntity(imageEntity, x, y, row, column);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(Entity entity) {
|
||||
public void updateTile(int entity) {
|
||||
if (!checkValidTile(entity)) return;
|
||||
|
||||
SpineDataComponent spineDataComponent = ComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineDataComponent spineDataComponent = ComponentRetriever.get(entity, SpineDataComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
if (!spineDataComponent.animationName.equals(tiledPlugin.getSelectedTileName())) {
|
||||
replaceSpineCommandBuilder.begin(entity);
|
||||
String animName = tiledPlugin.getSelectedTileName();
|
||||
|
||||
+5
-6
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.plugin.tiled.tools.drawStrategy;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.plugin.tiled.TiledPlugin;
|
||||
@@ -18,8 +17,8 @@ public class SpriteDrawStrategy extends BasicDrawStrategy {
|
||||
|
||||
@Override
|
||||
public void drawTile(float x, float y, int row, int column) {
|
||||
Entity underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != null) {
|
||||
int underneathTile = tiledPlugin.getPluginEntityWithParams(row, column);
|
||||
if (underneathTile != -1) {
|
||||
updateTile(underneathTile);
|
||||
return;
|
||||
}
|
||||
@@ -28,16 +27,16 @@ public class SpriteDrawStrategy extends BasicDrawStrategy {
|
||||
temp.set(x, y);
|
||||
|
||||
if (itemFactory.createSpriteAnimation(tiledPlugin.getSelectedTileName(), temp)) {
|
||||
Entity imageEntity = itemFactory.getCreatedEntity();
|
||||
int imageEntity = itemFactory.getCreatedEntity();
|
||||
postProcessEntity(imageEntity, x, y, row, column);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(Entity entity) {
|
||||
public void updateTile(int entity) {
|
||||
if (!checkValidTile(entity)) return;
|
||||
|
||||
SpriteAnimationComponent spriteAnimationComponent = ComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationComponent spriteAnimationComponent = ComponentRetriever.get(entity, SpriteAnimationComponent.class, tiledPlugin.getAPI().getEngine());
|
||||
|
||||
if (!spriteAnimationComponent.animationName.equals(tiledPlugin.getSelectedTileName())) {
|
||||
Array<TextureAtlas.AtlasRegion> regions = getRegions(tiledPlugin.getSelectedTileName());
|
||||
|
||||
+10
-9
@@ -1,7 +1,7 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Component;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.artemis.Component;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
|
||||
@@ -13,20 +13,20 @@ public class AddComponentToItemCommand extends EntityModifyRevertibleCommand {
|
||||
private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.AddComponentToItemCommand";
|
||||
public static final String DONE = CLASS_NAME + "DONE";
|
||||
|
||||
private Entity entity;
|
||||
private Component component;
|
||||
private int entity;
|
||||
private Class<? extends Component> component;
|
||||
|
||||
private void collectData() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
entity = (Entity) payload[0];
|
||||
component = (Component) payload[1];
|
||||
entity = (int) payload[0];
|
||||
component = (Class<? extends Component>) payload[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
collectData();
|
||||
|
||||
entity.add(component);
|
||||
Sandbox.getInstance().getEngine().edit(entity).create(component);
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(DONE, entity);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
@@ -34,13 +34,14 @@ public class AddComponentToItemCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
entity.remove(component.getClass());
|
||||
Sandbox.getInstance().getEngine().edit(entity).remove(component);
|
||||
Sandbox.getInstance().getEngine().process();
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(DONE, entity);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object[] payload(Entity entity, Component component) {
|
||||
public static Object[] payload(int entity, Class<? extends Component> component) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = component;
|
||||
|
||||
@@ -20,7 +20,6 @@ package games.rednblack.editor.controller.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
@@ -39,18 +38,18 @@ public class AddSelectionCommand extends RevertibleCommand {
|
||||
public void doAction() {
|
||||
cancel();
|
||||
if(entityIds == null) {
|
||||
Set<Entity> items = getNotification().getBody();
|
||||
Set<Integer> items = getNotification().getBody();
|
||||
entityIds = EntityUtils.getEntityId(items);
|
||||
}
|
||||
|
||||
Set<Entity> items = EntityUtils.getByUniqueId(entityIds);
|
||||
Set<Integer> items = EntityUtils.getByUniqueId(entityIds);
|
||||
Sandbox.getInstance().getSelector().addSelections(items);
|
||||
facade.sendNotification(DONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Set<Entity> items = EntityUtils.getByUniqueId(entityIds);
|
||||
Set<Integer> items = EntityUtils.getByUniqueId(entityIds);
|
||||
Sandbox.getInstance().getSelector().releaseSelections(items);
|
||||
facade.sendNotification(DONE);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
@@ -43,11 +43,11 @@ public class AddToLibraryCommand extends RevertibleCommand {
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
|
||||
Entity item = ((Entity) payload[0]);
|
||||
int item = ((int) payload[0]);
|
||||
entityId = EntityUtils.getEntityId(item);
|
||||
createdLibraryItemName = (String) payload[1];
|
||||
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(item, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(item, MainItemComponent.class);
|
||||
|
||||
if(createdLibraryItemName.length() > 0) {
|
||||
ProjectManager projectManager = HyperLap2DFacade.getInstance().retrieveProxy(ProjectManager.NAME);
|
||||
@@ -58,7 +58,7 @@ public class AddToLibraryCommand extends RevertibleCommand {
|
||||
}
|
||||
|
||||
CompositeItemVO newVO = new CompositeItemVO();
|
||||
newVO.loadFromEntity(item);
|
||||
newVO.loadFromEntity(item, sandbox.getEngine());
|
||||
newVO.cleanIds();
|
||||
libraryItems.put(createdLibraryItemName, newVO);
|
||||
|
||||
@@ -86,14 +86,14 @@ public class AddToLibraryCommand extends RevertibleCommand {
|
||||
}
|
||||
facade.sendNotification(MsgAPI.LIBRARY_LIST_UPDATED);
|
||||
} else {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
mainItemComponent.libraryLink = prevName;
|
||||
facade.sendNotification(MsgAPI.ITEM_DATA_UPDATED);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object payloadUnLink(Entity entity) {
|
||||
public static Object payloadUnLink(int entity) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = "";
|
||||
@@ -101,7 +101,7 @@ public class AddToLibraryCommand extends RevertibleCommand {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public static Object payloadLink(Entity entity, String link) {
|
||||
public static Object payloadLink(int entity, String link) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = link;
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.SandboxCommand;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.command.TransformCommandBuilder;
|
||||
import games.rednblack.editor.view.ui.validator.FloatInputValidator;
|
||||
import games.rednblack.h2d.common.view.ui.dialog.MultipleInputDialog;
|
||||
@@ -17,14 +17,14 @@ public class ChangeOriginPointPosition extends SandboxCommand {
|
||||
public void execute(INotification notification) {
|
||||
super.execute(notification);
|
||||
|
||||
Entity entity = notification.getBody();
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
int entity = notification.getBody();
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
MultipleInputDialog dialog = new MultipleInputDialog("Origin Position", new String[]{"X : ", "Y : "}, false, new FloatInputValidator(), new MultipleInputDialogListener() {
|
||||
@Override
|
||||
public void finished(String[] input) {
|
||||
TransformCommandBuilder commandBuilder = new TransformCommandBuilder();
|
||||
commandBuilder.begin(entity);
|
||||
commandBuilder.begin(entity, sandbox.getEngine());
|
||||
commandBuilder.setOrigin(Float.parseFloat(input[0]), Float.parseFloat(input[1]));
|
||||
commandBuilder.execute(HyperLap2DFacade.getInstance());
|
||||
}
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import games.rednblack.editor.controller.commands.component.UpdatePolygonDataCom
|
||||
import games.rednblack.editor.renderer.components.PolygonComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.poly.PolygonUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.ui.followers.PolygonFollower;
|
||||
import games.rednblack.editor.view.ui.validator.FloatInputValidator;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -36,7 +37,7 @@ public class ChangePolygonVertexPositionCommand extends SandboxCommand {
|
||||
@Override
|
||||
public void finished(String[] input) {
|
||||
Vector2[] points = follower.getOriginalPoints().toArray(new Vector2[0]);
|
||||
PolygonComponent polygonComponent = ComponentRetriever.get(follower.getEntity(), PolygonComponent.class);
|
||||
PolygonComponent polygonComponent = SandboxComponentRetriever.get(follower.getEntity(), PolygonComponent.class);
|
||||
points[anchor].set(Float.parseFloat(input[0]), Float.parseFloat(input[1]));
|
||||
|
||||
// check if any of near lines intersect
|
||||
|
||||
+16
-18
@@ -18,9 +18,9 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
import games.rednblack.editor.renderer.components.ParentNodeComponent;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.components.ViewPortComponent;
|
||||
@@ -43,8 +43,8 @@ public class CompositeCameraChangeCommand extends RevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
cancel();
|
||||
Entity entity = getNotification().getBody();
|
||||
Entity oldEntity = sandbox.getCurrentViewingEntity();
|
||||
int entity = getNotification().getBody();
|
||||
int oldEntity = sandbox.getCurrentViewingEntity();
|
||||
|
||||
// check if entity is selected
|
||||
wasPrevSelected = sandbox.getSelector().isSelected(entity);
|
||||
@@ -52,21 +52,20 @@ public class CompositeCameraChangeCommand extends RevertibleCommand {
|
||||
if(enteringInto == null) enteringInto = EntityUtils.getEntityId(entity);
|
||||
if(previousViewEntityId == null) previousViewEntityId = EntityUtils.getEntityId(oldEntity);
|
||||
|
||||
ViewPortComponent viewPortComponent = ComponentRetriever.get(oldEntity, ViewPortComponent.class);
|
||||
ViewPortComponent viewPortComponent = SandboxComponentRetriever.get(oldEntity, ViewPortComponent.class);
|
||||
Viewport currViewport = viewPortComponent.viewPort;
|
||||
oldEntity.remove(ViewPortComponent.class);
|
||||
sandbox.getEngine().edit(oldEntity).remove(ViewPortComponent.class);
|
||||
|
||||
ViewPortComponent newViewPortComponent = sandbox.getEngine().createComponent(ViewPortComponent.class);
|
||||
ViewPortComponent newViewPortComponent = sandbox.getEngine().edit(entity).create(ViewPortComponent.class);
|
||||
newViewPortComponent.viewPort = currViewport;
|
||||
entity.add(newViewPortComponent);
|
||||
|
||||
sandbox.setCurrentViewingEntity(entity);
|
||||
|
||||
sandbox.getSelector().clearSelections();
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TransformComponent previousTransformComponent = ComponentRetriever.get(oldEntity, TransformComponent.class);
|
||||
ParentNodeComponent parentNodeComponent = ComponentRetriever.get(entity, ParentNodeComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
TransformComponent previousTransformComponent = SandboxComponentRetriever.get(oldEntity, TransformComponent.class);
|
||||
ParentNodeComponent parentNodeComponent = SandboxComponentRetriever.get(entity, ParentNodeComponent.class);
|
||||
if (parentNodeComponent == null || oldEntity != parentNodeComponent.parentEntity)
|
||||
previousTransformComponent.enableTransform();
|
||||
transformComponent.disableTransform();
|
||||
@@ -80,22 +79,21 @@ public class CompositeCameraChangeCommand extends RevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity oldEntity = EntityUtils.getByUniqueId(previousViewEntityId);
|
||||
Entity currEntity = sandbox.getCurrentViewingEntity();
|
||||
int oldEntity = EntityUtils.getByUniqueId(previousViewEntityId);
|
||||
int currEntity = sandbox.getCurrentViewingEntity();
|
||||
|
||||
ViewPortComponent viewPortComponent = ComponentRetriever.get(currEntity, ViewPortComponent.class);
|
||||
ViewPortComponent viewPortComponent = SandboxComponentRetriever.get(currEntity, ViewPortComponent.class);
|
||||
Viewport currViewport = viewPortComponent.viewPort;
|
||||
currEntity.remove(ViewPortComponent.class);
|
||||
sandbox.getEngine().edit(currEntity).remove(ViewPortComponent.class);
|
||||
|
||||
ViewPortComponent newViewPortComponent = sandbox.getEngine().createComponent(ViewPortComponent.class);
|
||||
ViewPortComponent newViewPortComponent = sandbox.getEngine().edit(oldEntity).create(ViewPortComponent.class);
|
||||
newViewPortComponent.viewPort = currViewport;
|
||||
oldEntity.add(newViewPortComponent);
|
||||
sandbox.setCurrentViewingEntity(oldEntity);
|
||||
|
||||
facade.sendNotification(DONE, previousViewEntityId);
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(currEntity, TransformComponent.class);
|
||||
TransformComponent previousTransformComponent = ComponentRetriever.get(oldEntity, TransformComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(currEntity, TransformComponent.class);
|
||||
TransformComponent previousTransformComponent = SandboxComponentRetriever.get(oldEntity, TransformComponent.class);
|
||||
previousTransformComponent.disableTransform();
|
||||
transformComponent.enableTransform();
|
||||
|
||||
|
||||
+7
-7
@@ -18,7 +18,6 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.LayerMapComponent;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.components.additional.ButtonComponent;
|
||||
@@ -26,6 +25,7 @@ import games.rednblack.editor.renderer.data.LayerItemVO;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -37,10 +37,10 @@ public class ConvertToButtonCommand extends ConvertToCompositeCommand {
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
Entity entity;
|
||||
int entity;
|
||||
|
||||
HashSet<Entity> entities = (HashSet<Entity>) sandbox.getSelector().getSelectedItems();
|
||||
Entity item = entities.iterator().next();
|
||||
HashSet<Integer> entities = (HashSet<Integer>) sandbox.getSelector().getSelectedItems();
|
||||
int item = entities.iterator().next();
|
||||
|
||||
if(entities.size() == 1 && EntityUtils.getType(item) == EntityFactory.COMPOSITE_TYPE) {
|
||||
entity = item;
|
||||
@@ -50,14 +50,14 @@ public class ConvertToButtonCommand extends ConvertToCompositeCommand {
|
||||
}
|
||||
|
||||
//create layers
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(entity, LayerMapComponent.class);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(entity, LayerMapComponent.class);
|
||||
layerMapComponent.addLayer(new LayerItemVO("normal"));
|
||||
layerMapComponent.addLayer(new LayerItemVO("pressed"));
|
||||
|
||||
// adding button logic
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
mainItemComponent.tags.add("button");
|
||||
entity.add(new ButtonComponent());
|
||||
sandbox.getEngine().edit(entity).create(ButtonComponent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+21
-19
@@ -18,8 +18,8 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.factory.ItemFactory;
|
||||
@@ -50,14 +50,14 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
// get entity list
|
||||
HashSet<Entity> entities = (HashSet<Entity>) sandbox.getSelector().getSelectedItems();
|
||||
HashSet<Integer> entities = (HashSet<Integer>) sandbox.getSelector().getSelectedItems();
|
||||
UILayerBoxMediator layerBoxMediator = facade.retrieveMediator(UILayerBoxMediator.NAME);
|
||||
|
||||
if(layersBackup == null) {
|
||||
// backup layer data
|
||||
layersBackup = new HashMap<>();
|
||||
for(Entity entity: entities) {
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
for(int entity: entities) {
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
int tmpId = EntityUtils.getEntityId(entity);
|
||||
layersBackup.put(tmpId, zIndexComponent.layerName);
|
||||
}
|
||||
@@ -67,9 +67,8 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand {
|
||||
Vector2 position = EntityUtils.getLeftBottomPoint(entities);
|
||||
|
||||
//create new entity
|
||||
Entity entity = ItemFactory.get().createCompositeItem(position);
|
||||
int entity = ItemFactory.get().createCompositeItem(position);
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
sandbox.getEngine().addEntity(entity);
|
||||
|
||||
// what was the parent component of entities
|
||||
parentEntityId = EntityUtils.getEntityId(sandbox.getCurrentViewingEntity());
|
||||
@@ -78,26 +77,28 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand {
|
||||
EntityUtils.changeParent(entities, entity);
|
||||
|
||||
//reposition children
|
||||
for(Entity childEntity: entities) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(childEntity, TransformComponent.class);
|
||||
for(int childEntity: entities) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(childEntity, TransformComponent.class);
|
||||
transformComponent.x -= position.x;
|
||||
transformComponent.y -=position.y;
|
||||
|
||||
// put it on default layer
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(childEntity, ZIndexComponent.class);
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(childEntity, ZIndexComponent.class);
|
||||
zIndexComponent.layerName = "Default";
|
||||
|
||||
}
|
||||
// recalculate composite size
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
Vector2 newSize = EntityUtils.getRightTopPoint(entities);
|
||||
dimensionsComponent.width = newSize.x;
|
||||
dimensionsComponent.height = newSize.y;
|
||||
dimensionsComponent.boundBox.set(0, 0, newSize.x, newSize.y);
|
||||
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
zIndexComponent.layerName = layerBoxMediator.getCurrentSelectedLayerName();
|
||||
|
||||
sandbox.getEngine().process();
|
||||
|
||||
//let everyone know
|
||||
HyperLap2DFacade.getInstance().sendNotification(DONE);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity);
|
||||
@@ -110,11 +111,11 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand {
|
||||
FollowersUIMediator followersUIMediator = HyperLap2DFacade.getInstance().retrieveMediator(FollowersUIMediator.NAME);
|
||||
|
||||
//get the entity
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
Entity oldParentEntity = EntityUtils.getByUniqueId(parentEntityId);
|
||||
if (entity == null || oldParentEntity == null)
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
int oldParentEntity = EntityUtils.getByUniqueId(parentEntityId);
|
||||
if (entity == -1 || oldParentEntity == -1)
|
||||
return;
|
||||
HashSet<Entity> children = EntityUtils.getChildren(entity);
|
||||
HashSet<Integer> children = EntityUtils.getChildren(entity);
|
||||
if (children == null)
|
||||
return;
|
||||
// what will be the position diff of children?
|
||||
@@ -124,19 +125,20 @@ public class ConvertToCompositeCommand extends EntityModifyRevertibleCommand {
|
||||
EntityUtils.changeParent(children, oldParentEntity);
|
||||
|
||||
//reposition children
|
||||
for(Entity tmpEntity: children) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(tmpEntity, TransformComponent.class);
|
||||
for(int tmpEntity: children) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(tmpEntity, TransformComponent.class);
|
||||
transformComponent.x+=positionDiff.x;
|
||||
transformComponent.y+=positionDiff.y;
|
||||
|
||||
// put layer data back
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
zIndexComponent.layerName = layersBackup.get(EntityUtils.getEntityId(tmpEntity));
|
||||
}
|
||||
|
||||
// remove composite
|
||||
followersUIMediator.removeFollower(entity);
|
||||
sandbox.getEngine().removeEntity(entity);
|
||||
sandbox.getEngine().delete(entity);
|
||||
sandbox.getEngine().process();
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(DONE);
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.NodeComponent;
|
||||
@@ -43,11 +43,11 @@ public class CreateItemCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
Entity entity = getNotification().getBody();
|
||||
int entity = getNotification().getBody();
|
||||
|
||||
if (serializedEntity != null) {
|
||||
EntityFactory factory = Sandbox.getInstance().sceneControl.sceneLoader.getEntityFactory();
|
||||
Entity parentEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
int parentEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
entity = EntityUtils.getEntityFromJson(serializedEntity, entityType, factory, parentEntity);
|
||||
serializedEntity = null;
|
||||
}
|
||||
@@ -55,29 +55,29 @@ public class CreateItemCommand extends EntityModifyRevertibleCommand {
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
entityType = EntityUtils.getType(entity);
|
||||
|
||||
sandbox.getEngine().addEntity(entity);
|
||||
|
||||
// z-index
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(Sandbox.getInstance().getCurrentViewingEntity(), NodeComponent.class);
|
||||
ZIndexComponent zindexComponent = ComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(Sandbox.getInstance().getCurrentViewingEntity(), NodeComponent.class);
|
||||
ZIndexComponent zindexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
zindexComponent.setZIndex(nodeComponent.children.size);
|
||||
|
||||
sandbox.getEngine().process();
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity);
|
||||
|
||||
Set<Entity> items = new HashSet<>();
|
||||
Set<Integer> items = new HashSet<>();
|
||||
items.add(entity);
|
||||
facade.sendNotification(MsgAPI.ACTION_SET_SELECTION, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
serializedEntity = EntityUtils.getJsonStringFromEntity(entity);
|
||||
|
||||
FollowersUIMediator followersUIMediator = HyperLap2DFacade.getInstance().retrieveMediator(FollowersUIMediator.NAME);
|
||||
followersUIMediator.removeFollower(entity);
|
||||
|
||||
sandbox.getEngine().removeEntity(entity);
|
||||
sandbox.getEngine().delete(entity);
|
||||
sandbox.getEngine().process();
|
||||
facade.sendNotification(MsgAPI.DELETE_ITEMS_COMMAND_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
|
||||
/**
|
||||
* Created by CyberJoe on 11/6/2015.
|
||||
@@ -41,14 +41,14 @@ public class CustomVariableModifyCommand extends EntityModifyRevertibleCommand {
|
||||
}
|
||||
|
||||
private void addVariable(String key, String value) {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
mainItemComponent.setCustomVars(key, value);
|
||||
}
|
||||
|
||||
private void removeVariable(String key) {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
value = mainItemComponent.customVariables.getStringVariable(key); //storing the backup
|
||||
mainItemComponent.removeCustomVars(key);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class CustomVariableModifyCommand extends EntityModifyRevertibleCommand {
|
||||
if(entityId == null) {
|
||||
// First time call, need to prepare the data and fetch payload
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity item = (Entity) payload[0];
|
||||
int item = (int) payload[0];
|
||||
entityId = EntityUtils.getEntityId(item);
|
||||
key = (String) payload[2];
|
||||
isAdding = false;
|
||||
@@ -68,7 +68,7 @@ public class CustomVariableModifyCommand extends EntityModifyRevertibleCommand {
|
||||
}
|
||||
}
|
||||
|
||||
public static Object addCustomVariable(Entity entity, String key, String value) {
|
||||
public static Object addCustomVariable(int entity, String key, String value) {
|
||||
Object[] payload = new Object[4];
|
||||
payload[0] = entity;
|
||||
payload[1] = true; // is adding type
|
||||
@@ -78,7 +78,7 @@ public class CustomVariableModifyCommand extends EntityModifyRevertibleCommand {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public static Object removeCustomVariable(Entity entity, String key) {
|
||||
public static Object removeCustomVariable(int entity, String key) {
|
||||
Object[] payload = new Object[3];
|
||||
payload[0] = entity;
|
||||
payload[1] = true;
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -51,9 +49,10 @@ public class CutItemsCommand extends EntityModifyRevertibleCommand {
|
||||
public void undoAction() {
|
||||
Json json = new Json();
|
||||
CompositeVO compositeVO = json.fromJson(CompositeVO.class, backup);
|
||||
Set<Entity> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
Set<Integer> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
|
||||
for (Entity entity : newEntitiesList) {
|
||||
sandbox.getEngine().process();
|
||||
for (int entity : newEntitiesList) {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -39,11 +38,11 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
private Array<Integer> entityIdsToDelete;
|
||||
|
||||
private void backup() {
|
||||
Set<Entity> entitySet = new HashSet<>();
|
||||
Set<Integer> entitySet = new HashSet<>();
|
||||
if(entityIdsToDelete == null) {
|
||||
entityIdsToDelete = new Array<>();
|
||||
entitySet = sandbox.getSelector().getSelectedItems();
|
||||
for(Entity entity: entitySet) {
|
||||
for(int entity: entitySet) {
|
||||
entityIdsToDelete.add(EntityUtils.getEntityId(entity));
|
||||
}
|
||||
} else {
|
||||
@@ -61,10 +60,11 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
FollowersUIMediator followersUIMediator = HyperLap2DFacade.getInstance().retrieveMediator(FollowersUIMediator.NAME);
|
||||
for (Integer entityId : entityIdsToDelete) {
|
||||
Entity item = EntityUtils.getByUniqueId(entityId);
|
||||
int item = EntityUtils.getByUniqueId(entityId);
|
||||
followersUIMediator.removeFollower(item);
|
||||
sandbox.getEngine().removeEntity(item);
|
||||
sandbox.getEngine().delete(item);
|
||||
}
|
||||
sandbox.getEngine().process();
|
||||
|
||||
sandbox.getSelector().getCurrentSelection().clear();
|
||||
|
||||
@@ -75,18 +75,19 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
public void undoAction() {
|
||||
Json json = new Json();
|
||||
CompositeVO compositeVO = json.fromJson(CompositeVO.class, backup);
|
||||
Set<Entity> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
Set<Integer> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
|
||||
for (Entity entity : newEntitiesList) {
|
||||
sandbox.getEngine().process();
|
||||
for (int entity : newEntitiesList) {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity);
|
||||
}
|
||||
|
||||
sandbox.getSelector().setSelections(newEntitiesList, true);
|
||||
}
|
||||
|
||||
public void setItemsToDelete(Set<Entity> entities) {
|
||||
public void setItemsToDelete(Set<Integer> entities) {
|
||||
entityIdsToDelete = new Array<>();
|
||||
for(Entity entity: entities) {
|
||||
for(int entity: entities) {
|
||||
entityIdsToDelete.add(EntityUtils.getEntityId(entity));
|
||||
}
|
||||
}
|
||||
|
||||
+5
-7
@@ -1,9 +1,9 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.LayerMapComponent;
|
||||
import games.rednblack.editor.renderer.data.LayerItemVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
/**
|
||||
@@ -24,10 +24,8 @@ public class DeleteLayerAtomCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
Entity viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
|
||||
|
||||
int viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
|
||||
if(layerMapComponent.getLayers().size() > 1) {
|
||||
layerMapComponent.deleteLayer(layerName);
|
||||
@@ -38,8 +36,8 @@ public class DeleteLayerAtomCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
int viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
|
||||
layerMapComponent.addLayer(layerIndex, layerItemVO);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.NodeComponent;
|
||||
import games.rednblack.editor.renderer.components.ZIndexComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -40,13 +40,13 @@ public class DeleteLayerCommand extends TransactiveCommand {
|
||||
facade.sendNotification(UNDONE, layerName);
|
||||
}
|
||||
|
||||
public Set<Entity> getItemsByLayerName(String layerName) {
|
||||
Set<Entity> result = new HashSet<>();
|
||||
Entity viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(viewingEntity, NodeComponent.class);
|
||||
public Set<Integer> getItemsByLayerName(String layerName) {
|
||||
Set<Integer> result = new HashSet<>();
|
||||
int viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(viewingEntity, NodeComponent.class);
|
||||
for(int i = 0; i < nodeComponent.children.size; i++) {
|
||||
Entity child = nodeComponent.children.get(i);
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(child, ZIndexComponent.class);
|
||||
int child = nodeComponent.children.get(i);
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(child, ZIndexComponent.class);
|
||||
if(zIndexComponent.layerName.equals(layerName)) {
|
||||
result.add(child);
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import games.rednblack.editor.controller.commands.component.UpdatePolygonDataCom
|
||||
import games.rednblack.editor.renderer.components.PolygonComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.poly.PolygonUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.ui.followers.PolygonFollower;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import org.puremvc.java.interfaces.INotification;
|
||||
@@ -31,7 +32,7 @@ public class DeletePolygonVertexCommand extends SandboxCommand {
|
||||
PolygonFollower follower = (PolygonFollower) payload[0];
|
||||
int anchor = (int) payload[1];
|
||||
|
||||
PolygonComponent polygonComponent = ComponentRetriever.get(follower.getEntity(), PolygonComponent.class);
|
||||
PolygonComponent polygonComponent = SandboxComponentRetriever.get(follower.getEntity(), PolygonComponent.class);
|
||||
if(polygonComponent == null || polygonComponent.vertices == null || polygonComponent.vertices.length == 0) return;
|
||||
if(follower.getOriginalPoints().size() <= 3) return;
|
||||
|
||||
|
||||
+11
-12
@@ -18,8 +18,6 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
@@ -29,6 +27,7 @@ import games.rednblack.editor.renderer.components.NodeComponent;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -50,10 +49,10 @@ public abstract class EntityModifyRevertibleCommand extends RevertibleCommand {
|
||||
|
||||
protected void postChange() {
|
||||
Integer parentId = EntityUtils.getEntityId(sandbox.getCurrentViewingEntity());
|
||||
Entity entity = EntityUtils.getByUniqueId(parentId);
|
||||
int entity = EntityUtils.getByUniqueId(parentId);
|
||||
|
||||
// Update item library data if it was in library
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
String link = mainItemComponent.libraryLink;
|
||||
|
||||
if(link != null && link.length() > 0) {
|
||||
@@ -61,23 +60,23 @@ public abstract class EntityModifyRevertibleCommand extends RevertibleCommand {
|
||||
HashMap<String, CompositeItemVO> libraryItems = projectManager.currentProjectInfoVO.libraryItems;
|
||||
if (libraryItems.containsKey(mainItemComponent.libraryLink)) {
|
||||
CompositeItemVO itemVO = new CompositeItemVO();
|
||||
itemVO.loadFromEntity(entity);
|
||||
itemVO.loadFromEntity(entity, sandbox.getEngine());
|
||||
itemVO.cleanIds();
|
||||
libraryItems.put(mainItemComponent.libraryLink, itemVO);
|
||||
}
|
||||
|
||||
Array<Entity> linkedEntities = EntityUtils.getByLibraryLink(link);
|
||||
for (Entity dependable : linkedEntities) {
|
||||
Array<Integer> linkedEntities = EntityUtils.getByLibraryLink(link);
|
||||
for (int dependable : linkedEntities) {
|
||||
if(dependable == entity) continue;
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(dependable, NodeComponent.class);
|
||||
for(Entity child: nodeComponent.children) {
|
||||
sandbox.getEngine().removeEntity(child);
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(dependable, NodeComponent.class);
|
||||
for(int child: nodeComponent.children) {
|
||||
sandbox.getEngine().delete(child);
|
||||
}
|
||||
nodeComponent.children.clear();
|
||||
sandbox.getEngine().process();
|
||||
|
||||
Engine engine = sandbox.getSceneControl().sceneLoader.getEngine();
|
||||
EntityFactory factory = sandbox.getSceneControl().sceneLoader.getEntityFactory();
|
||||
factory.initAllChildren(engine, dependable, libraryItems.get(link).composite);
|
||||
factory.initAllChildren(dependable, libraryItems.get(link).composite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,8 +1,8 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.DimensionsComponent;
|
||||
@@ -20,19 +20,19 @@ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand
|
||||
|
||||
private HashMap<Integer, Vector2> prevPosMap = new HashMap<>();
|
||||
private HashMap<Integer, PositionSize> parentPositionAndSizeMap = new HashMap<>();
|
||||
private Entity entity;
|
||||
private int entity;
|
||||
|
||||
private Vector2 prevLo;
|
||||
|
||||
private void doActionOnParent() {
|
||||
Array<Object[]> objects = getNotification().getBody();
|
||||
Object[] itemData = objects.get(0);
|
||||
Entity entity = (Entity) itemData[0];
|
||||
int entity = (int) itemData[0];
|
||||
Vector2 newPos = (Vector2) itemData[1];
|
||||
Vector2 newSize = (Vector2) itemData[2];
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
Vector2 prevLocation = new Vector2(transformComponent.x, transformComponent.y);
|
||||
Vector2 prevSize = new Vector2(dimensionsComponent.width, dimensionsComponent.height);
|
||||
PositionSize positionSize = new PositionSize(prevLocation, prevSize);
|
||||
@@ -56,8 +56,8 @@ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand
|
||||
Vector2 prevLocation = positionSize.position;
|
||||
Vector2 prevSize = positionSize.size;
|
||||
entity = EntityUtils.getByUniqueId(entityUniqueId);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
setState(transformComponent, prevLocation, dimensionsComponent, prevSize);
|
||||
// transformComponent.x = prevLocation.x;
|
||||
// transformComponent.y = prevLocation.y;
|
||||
@@ -77,9 +77,9 @@ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand
|
||||
Array<Object[]> payload = notification.getBody();
|
||||
for (int i = 1; i < payload.size; i++) {
|
||||
Object[] objectData = payload.get(i);
|
||||
Entity entity = (Entity) objectData[0];
|
||||
int entity = (int) objectData[0];
|
||||
Vector2 newPos = (Vector2) objectData[1];
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
Vector2 prevPos = new Vector2(transformComponent.x, transformComponent.y);
|
||||
prevPosMap.put(EntityUtils.getEntityId(entity), prevPos);
|
||||
// EntityUtils.setPosition(entity, newPos);
|
||||
@@ -95,8 +95,8 @@ public class ItemChildrenTransformCommand extends EntityModifyRevertibleCommand
|
||||
for (Map.Entry<Integer, Vector2> entry : prevPosMap.entrySet()) {
|
||||
Integer entityUniqueId = entry.getKey();
|
||||
Vector2 oldPosition = entry.getValue();
|
||||
Entity entity = EntityUtils.getByUniqueId(entityUniqueId);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityUniqueId);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
transformComponent.x = oldPosition.x;
|
||||
transformComponent.y = oldPosition.y;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.renderer.components.PolygonComponent;
|
||||
import games.rednblack.editor.renderer.components.TextureRegionComponent;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
import games.rednblack.editor.renderer.components.physics.PhysicsBodyComponent;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.DimensionsComponent;
|
||||
@@ -26,7 +22,7 @@ public class ItemTransformCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload.get(0);
|
||||
int entity = (int) payload.get(0);
|
||||
Object[] newData = (Object[]) payload.get(2);
|
||||
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
@@ -37,8 +33,8 @@ public class ItemTransformCommand extends EntityModifyRevertibleCommand {
|
||||
Float newRotation = (Float) newData[3];
|
||||
Vector2 newOrigin = (Vector2) newData[4];
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
|
||||
if(newPos != null) transformComponent.x = newPos.x;
|
||||
if(newPos != null) transformComponent.y = newPos.y;
|
||||
@@ -57,7 +53,7 @@ public class ItemTransformCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
Object[] prevData = (Object[]) payload.get(1);
|
||||
|
||||
Vector2 prevPos = (Vector2) prevData[0];
|
||||
@@ -66,8 +62,8 @@ public class ItemTransformCommand extends EntityModifyRevertibleCommand {
|
||||
Float prevRotation = (Float) prevData[3];
|
||||
Vector2 prevOrigin = (Vector2) prevData[4];
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
|
||||
transformComponent.x = prevPos.x;
|
||||
transformComponent.y = prevPos.y;
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
@@ -44,10 +44,10 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand {
|
||||
for(int i = 0; i < payload.size; i++) {
|
||||
Object[] itemData = payload.get(i);
|
||||
|
||||
Entity entity = (Entity) itemData[0];
|
||||
int entity = (int) itemData[0];
|
||||
Vector2 newLocation = (Vector2) itemData[1];
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
Vector2 prevLocation = new Vector2(transformComponent.x, transformComponent.y);
|
||||
if(itemData.length > 2) {
|
||||
@@ -69,9 +69,9 @@ public class ItemsMoveCommand extends EntityModifyRevertibleCommand {
|
||||
Integer entityUniqueId = entry.getKey();
|
||||
Vector2 prevLocation = entry.getValue();
|
||||
|
||||
Entity entity = EntityUtils.getByUniqueId(entityUniqueId);
|
||||
int entity = EntityUtils.getByUniqueId(entityUniqueId);
|
||||
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
transformComponent.x = prevLocation.x;
|
||||
transformComponent.y = prevLocation.y;
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.LayerMapComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
/**
|
||||
@@ -49,8 +49,8 @@ public class LayerSwapCommand extends EntityModifyRevertibleCommand {
|
||||
public void doAction() {
|
||||
backup();
|
||||
|
||||
Entity viewingEntity = EntityUtils.getByUniqueId(entityId);
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
int viewingEntity = EntityUtils.getByUniqueId(entityId);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
layerMapComponent.swap(sourceName, targetName);
|
||||
|
||||
facade.sendNotification(DONE);
|
||||
@@ -59,8 +59,8 @@ public class LayerSwapCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity viewingEntity = EntityUtils.getByUniqueId(entityId);
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
int viewingEntity = EntityUtils.getByUniqueId(entityId);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
layerMapComponent.swap(targetName, sourceName);
|
||||
|
||||
facade.sendNotification(DONE);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.LayerMapComponent;
|
||||
import games.rednblack.editor.renderer.data.LayerItemVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
/**
|
||||
@@ -21,8 +21,8 @@ public class NewLayerCommand extends EntityModifyRevertibleCommand {
|
||||
int index = (int) payload[0];
|
||||
layerName = (String) payload[1];
|
||||
|
||||
Entity viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
int viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
|
||||
LayerItemVO vo = new LayerItemVO(layerName);
|
||||
vo.isVisible = true;
|
||||
@@ -33,8 +33,8 @@ public class NewLayerCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
int viewingEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewingEntity, LayerMapComponent.class);
|
||||
|
||||
layerMapComponent.deleteLayer(layerName);
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
@@ -64,12 +64,13 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
Json json = new Json();
|
||||
CompositeVO compositeVO = json.fromJson(CompositeVO.class, (String) payload[1]);
|
||||
forceIdChange(compositeVO);
|
||||
Set<Entity> newEntitiesList = createEntitiesFromVO(compositeVO);
|
||||
for (Entity entity : newEntitiesList) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
Set<Integer> newEntitiesList = createEntitiesFromVO(compositeVO);
|
||||
sandbox.getEngine().process();
|
||||
for (int entity : newEntitiesList) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
transformComponent.x += diff.x;
|
||||
transformComponent.y += diff.y;
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
// UILayerBoxMediator layerBoxMediator = facade.retrieveMediator(UILayerBoxMediator.NAME);
|
||||
zIndexComponent.layerName = layerBoxMediator.getCurrentSelectedLayerName();
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.NEW_ITEM_ADDED, entity);
|
||||
@@ -82,9 +83,10 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
public void undoAction() {
|
||||
FollowersUIMediator followersUIMediator = HyperLap2DFacade.getInstance().retrieveMediator(FollowersUIMediator.NAME);
|
||||
for (Integer entityId : pastedEntityIds) {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
followersUIMediator.removeFollower(entity);
|
||||
sandbox.getEngine().removeEntity(entity);
|
||||
sandbox.getEngine().delete(entity);
|
||||
sandbox.getEngine().process();
|
||||
facade.sendNotification(MsgAPI.DELETE_ITEMS_COMMAND_DONE);
|
||||
}
|
||||
pastedEntityIds.clear();
|
||||
@@ -98,62 +100,52 @@ public class PasteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
}
|
||||
|
||||
|
||||
public static Set<Entity> createEntitiesFromVO(CompositeVO compositeVO) {
|
||||
Set<Entity> entities = new HashSet<>();
|
||||
public static Set<Integer> createEntitiesFromVO(CompositeVO compositeVO) {
|
||||
Set<Integer> entities = new HashSet<>();
|
||||
|
||||
EntityFactory factory = Sandbox.getInstance().sceneControl.sceneLoader.getEntityFactory();
|
||||
Entity parentEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
int parentEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
|
||||
for (int i = 0; i < compositeVO.sImages.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sImages.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sImages.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sImage9patchs.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sImage9patchs.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sImage9patchs.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sLabels.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sLabels.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sLabels.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sParticleEffects.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sParticleEffects.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sParticleEffects.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sTalosVFX.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sTalosVFX.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sTalosVFX.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sLights.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sLights.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sLights.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sSpineAnimations.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sSpineAnimations.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sSpineAnimations.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sSpriteAnimations.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sSpriteAnimations.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sSpriteAnimations.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sColorPrimitives.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sColorPrimitives.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sColorPrimitives.get(i));
|
||||
entities.add(child);
|
||||
}
|
||||
for (int i = 0; i < compositeVO.sComposites.size(); i++) {
|
||||
Entity child = factory.createEntity(parentEntity, compositeVO.sComposites.get(i));
|
||||
Sandbox.getInstance().getEngine().addEntity(child);
|
||||
int child = factory.createEntity(parentEntity, compositeVO.sComposites.get(i));
|
||||
entities.add(child);
|
||||
factory.initAllChildren(Sandbox.getInstance().getEngine(), child, compositeVO.sComposites.get(i).composite);
|
||||
factory.initAllChildren(child, compositeVO.sComposites.get(i).composite);
|
||||
}
|
||||
|
||||
return entities;
|
||||
|
||||
+2
-3
@@ -22,7 +22,6 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
@@ -40,7 +39,7 @@ public class ReleaseSelectionCommand extends RevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
cancel();
|
||||
Set<Entity> items = new HashSet<>(getNotification().<Collection<Entity>>getBody());
|
||||
Set<Integer> items = new HashSet<>(getNotification().<Collection<Integer>>getBody());
|
||||
Sandbox.getInstance().getSelector().releaseSelections(items);
|
||||
|
||||
entityIds = EntityUtils.getEntityId(items);
|
||||
@@ -50,7 +49,7 @@ public class ReleaseSelectionCommand extends RevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Set<Entity> items = EntityUtils.getByUniqueId(entityIds);
|
||||
Set<Integer> items = EntityUtils.getByUniqueId(entityIds);
|
||||
Sandbox.getInstance().getSelector().addSelections(items);
|
||||
|
||||
facade.sendNotification(DONE);
|
||||
|
||||
+17
-13
@@ -1,9 +1,10 @@
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Component;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.RemovableComponent;
|
||||
import com.artemis.Component;
|
||||
import games.rednblack.editor.renderer.components.RemovableObject;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.ComponentCloner;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
|
||||
@@ -15,23 +16,25 @@ public class RemoveComponentFromItemCommand extends EntityModifyRevertibleComman
|
||||
private static final String CLASS_NAME = "games.rednblack.editor.controller.commands.RemoveComponentFromItemCommand";
|
||||
public static final String DONE = CLASS_NAME + "DONE";
|
||||
|
||||
private Entity entity;
|
||||
private int entity;
|
||||
private Component component;
|
||||
private Class<? extends Component> componentClass;
|
||||
|
||||
private void collectData() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
entity = (Entity) payload[0];
|
||||
Class<? extends Component> componentClass = (Class<? extends Component>) payload[1];
|
||||
component = ComponentCloner.get(entity.getComponent(componentClass));
|
||||
entity = (int) payload[0];
|
||||
componentClass = (Class<? extends Component>) payload[1];
|
||||
component = ComponentCloner.get(SandboxComponentRetriever.get(entity, componentClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
collectData();
|
||||
if (component instanceof RemovableComponent) {
|
||||
((RemovableComponent) component).onRemove();
|
||||
if (component instanceof RemovableObject) {
|
||||
((RemovableObject) component).onRemove();
|
||||
}
|
||||
entity.remove(component.getClass());
|
||||
sandbox.getEngine().edit(entity).remove(component.getClass());
|
||||
sandbox.getEngine().process();
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(DONE, entity);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
@@ -39,15 +42,16 @@ public class RemoveComponentFromItemCommand extends EntityModifyRevertibleComman
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
if (entity.getComponent(component.getClass()) == null) {
|
||||
entity.add(component);
|
||||
if (SandboxComponentRetriever.get(entity, component.getClass()) == null) {
|
||||
Component newComponent = sandbox.getEngine().edit(entity).create(componentClass);
|
||||
ComponentCloner.set(newComponent, component);
|
||||
}
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(DONE, entity);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object[] payload(Entity entity, Class<? extends Component> componentClass) {
|
||||
public static Object[] payload(int entity, Class<? extends Component> componentClass) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = componentClass;
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.renderer.components.LayerMapComponent;
|
||||
import games.rednblack.editor.renderer.components.NodeComponent;
|
||||
import games.rednblack.editor.renderer.components.ZIndexComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
|
||||
/**
|
||||
@@ -57,9 +57,9 @@ public class RenameLayerCommand extends EntityModifyRevertibleCommand {
|
||||
}
|
||||
|
||||
private void renameLayer(String fromName, String toName) {
|
||||
Entity viewEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(viewEntity, NodeComponent.class);
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(viewEntity, LayerMapComponent.class);
|
||||
int viewEntity = Sandbox.getInstance().getCurrentViewingEntity();
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(viewEntity, NodeComponent.class);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(viewEntity, LayerMapComponent.class);
|
||||
|
||||
if (layerMapComponent.getLayer(toName) != null) {
|
||||
cancel();
|
||||
@@ -68,8 +68,8 @@ public class RenameLayerCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
layerMapComponent.rename(fromName, toName);
|
||||
|
||||
for(Entity childEntity: nodeComponent.children) {
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(childEntity, ZIndexComponent.class);
|
||||
for(int childEntity: nodeComponent.children) {
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(childEntity, ZIndexComponent.class);
|
||||
if(zIndexComponent.layerName.equals(fromName)) {
|
||||
zIndexComponent.layerName = toName;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.editor.renderer.components.NodeComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
@@ -42,10 +42,10 @@ public class SetSelectionCommand extends RevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
cancel();
|
||||
HashSet<Entity> previousSelection = new HashSet<>(Sandbox.getInstance().getSelector().getSelectedItems());
|
||||
HashSet<Integer> previousSelection = new HashSet<>(Sandbox.getInstance().getSelector().getSelectedItems());
|
||||
previousSelectionIds = EntityUtils.getEntityId(previousSelection);
|
||||
|
||||
Set<Entity> items = getNotification().getBody();
|
||||
Set<Integer> items = getNotification().getBody();
|
||||
|
||||
if(items == null) {
|
||||
// deselect all
|
||||
@@ -55,10 +55,10 @@ public class SetSelectionCommand extends RevertibleCommand {
|
||||
}
|
||||
|
||||
// check if items are in viewable element, if no - cancel
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(sandbox.getCurrentViewingEntity(), NodeComponent.class);
|
||||
for (Iterator<Entity> iterator = items.iterator(); iterator.hasNext();) {
|
||||
Entity item = iterator.next();
|
||||
if(!nodeComponent.children.contains(item, true)) {
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(sandbox.getCurrentViewingEntity(), NodeComponent.class);
|
||||
for (Iterator<Integer> iterator = items.iterator(); iterator.hasNext();) {
|
||||
int item = iterator.next();
|
||||
if(!nodeComponent.children.contains(item, false)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -18,9 +18,9 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.badlogic.ashley.core.Component;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.artemis.Component;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
@@ -39,13 +39,13 @@ public class UpdateEntityComponentsCommand extends EntityModifyRevertibleCommand
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
Array<Component> components = (Array<Component>) payload[1];
|
||||
|
||||
for(int i = 0; i < components.size; i++) {
|
||||
//backup the original component
|
||||
Component originalComponent = ComponentRetriever.get(entity, components.get(i).getClass());
|
||||
Component originalComponent = SandboxComponentRetriever.get(entity, components.get(i).getClass());
|
||||
backupComponents.add(ComponentCloner.get(originalComponent));
|
||||
|
||||
//now modify the entity component from provided data
|
||||
@@ -59,9 +59,9 @@ public class UpdateEntityComponentsCommand extends EntityModifyRevertibleCommand
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
for(int i = 0; i < backupComponents.size; i++) {
|
||||
Component entityComponent = ComponentRetriever.get(entity, backupComponents.get(i).getClass());
|
||||
Component entityComponent = SandboxComponentRetriever.get(entity, backupComponents.get(i).getClass());
|
||||
ComponentCloner.set(entityComponent, backupComponents.get(i));
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
@@ -10,6 +9,7 @@ import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.data.ProjectInfoVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
@@ -22,15 +22,15 @@ public class ReplaceRegionCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
String regionName = (String) payload[1];
|
||||
TextureRegion region = (TextureRegion) payload[2];
|
||||
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
backupRegionName = textureRegionComponent.regionName;
|
||||
backupRegion = textureRegionComponent.region;
|
||||
@@ -50,11 +50,11 @@ public class ReplaceRegionCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
textureRegionComponent.regionName = backupRegionName;
|
||||
textureRegionComponent.region = backupRegion;
|
||||
|
||||
+11
-11
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.esotericsoftware.spine.*;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
@@ -9,6 +8,7 @@ import games.rednblack.editor.renderer.components.SpineDataComponent;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.h2d.extention.spine.SpineObjectComponent;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ReplaceSpineCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
String animName = (String) payload[1];
|
||||
SkeletonJson skeletonJson = (SkeletonJson) payload[2];
|
||||
Skeleton skeleton = (Skeleton) payload[3];
|
||||
@@ -30,10 +30,10 @@ public class ReplaceSpineCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
SpineDataComponent spineDataComponent = ComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = ComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
SpineDataComponent spineDataComponent = SandboxComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = SandboxComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
backupAnimName = spineDataComponent.animationName;
|
||||
backupSkeletonJson = spineObjectComponent.skeletonJson;
|
||||
@@ -63,12 +63,12 @@ public class ReplaceSpineCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
SpineDataComponent spineDataComponent = ComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = ComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
SpineDataComponent spineDataComponent = SandboxComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = SandboxComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
spineDataComponent.animationName = backupAnimName;
|
||||
spineObjectComponent.skeletonJson = backupSkeletonJson;
|
||||
|
||||
+13
-13
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.graphics.g2d.Animation;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -15,6 +14,7 @@ import games.rednblack.editor.renderer.data.FrameRange;
|
||||
import games.rednblack.editor.renderer.data.ProjectInfoVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
@@ -27,17 +27,17 @@ public class ReplaceSpriteAnimationCommand extends EntityModifyRevertibleCommand
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
String animName = (String) payload[1];
|
||||
Array<TextureAtlas.AtlasRegion> regions = (Array<TextureAtlas.AtlasRegion>) payload[2];
|
||||
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
SpriteAnimationComponent spriteAnimationComponent = ComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = ComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = SandboxComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
backupAnimName = spriteAnimationComponent.animationName;
|
||||
backupAnimRegions = spriteAnimationStateComponent.allRegions;
|
||||
@@ -67,13 +67,13 @@ public class ReplaceSpriteAnimationCommand extends EntityModifyRevertibleCommand
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
SpriteAnimationComponent spriteAnimationComponent = ComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = ComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = SandboxComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent size = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
|
||||
spriteAnimationComponent.animationName = backupAnimName;
|
||||
spriteAnimationComponent.frameRangeMap.clear();
|
||||
|
||||
+9
-9
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.CompositeTransformComponent;
|
||||
@@ -8,6 +7,7 @@ import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.data.CompositeItemVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class UpdateCompositeDataCommand extends EntityModifyRevertibleCommand {
|
||||
@@ -17,14 +17,14 @@ public class UpdateCompositeDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
CompositeItemVO vo = (CompositeItemVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new CompositeItemVO();
|
||||
backup.loadFromEntity(entity);
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
|
||||
CompositeTransformComponent transformComponent = ComponentRetriever.get(entity, CompositeTransformComponent.class);
|
||||
CompositeTransformComponent transformComponent = SandboxComponentRetriever.get(entity, CompositeTransformComponent.class);
|
||||
transformComponent.automaticResize = vo.automaticResize;
|
||||
transformComponent.scissorsEnabled = vo.scissorsEnabled;
|
||||
transformComponent.renderToFBO = vo.renderToFBO;
|
||||
@@ -32,16 +32,16 @@ public class UpdateCompositeDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
|
||||
if (!transformComponent.renderToFBO) {
|
||||
String tag = ComponentRetriever.get(entity, MainItemComponent.class).itemIdentifier;
|
||||
String tag = SandboxComponentRetriever.get(entity, MainItemComponent.class).itemIdentifier;
|
||||
sandbox.getSceneControl().sceneLoader.getFrameBufferManager().dispose(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
CompositeTransformComponent transformComponent = ComponentRetriever.get(entity, CompositeTransformComponent.class);
|
||||
CompositeTransformComponent transformComponent = SandboxComponentRetriever.get(entity, CompositeTransformComponent.class);
|
||||
transformComponent.automaticResize = backup.automaticResize;
|
||||
transformComponent.scissorsEnabled = backup.scissorsEnabled;
|
||||
transformComponent.renderToFBO = backup.renderToFBO;
|
||||
@@ -49,12 +49,12 @@ public class UpdateCompositeDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
|
||||
if (!transformComponent.renderToFBO) {
|
||||
String tag = ComponentRetriever.get(entity, MainItemComponent.class).itemIdentifier;
|
||||
String tag = SandboxComponentRetriever.get(entity, MainItemComponent.class).itemIdentifier;
|
||||
sandbox.getSceneControl().sceneLoader.getFrameBufferManager().dispose(tag);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, CompositeItemVO vo) {
|
||||
public static Object payload(int entity, CompositeItemVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+9
-11
@@ -1,15 +1,13 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.DimensionsComponent;
|
||||
import games.rednblack.editor.renderer.components.PolygonComponent;
|
||||
import games.rednblack.editor.renderer.components.TextureRegionComponent;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.data.SimpleImageVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class UpdateImageItemDataCommand extends EntityModifyRevertibleCommand {
|
||||
@@ -20,11 +18,11 @@ public class UpdateImageItemDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
SimpleImageVO vo = (SimpleImageVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
|
||||
backup = new SimpleImageVO();
|
||||
backup.loadFromComponent(textureRegionComponent);
|
||||
@@ -39,8 +37,8 @@ public class UpdateImageItemDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
|
||||
textureRegionComponent.isRepeat = backup.isRepeat;
|
||||
textureRegionComponent.isPolygon = backup.isPolygon;
|
||||
@@ -50,9 +48,9 @@ public class UpdateImageItemDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
private void updateEntity(Entity entity) {
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
private void updateEntity(int entity) {
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
|
||||
if (!textureRegionComponent.isPolygon) {
|
||||
dimensionsComponent.polygon = null;
|
||||
@@ -61,7 +59,7 @@ public class UpdateImageItemDataCommand extends EntityModifyRevertibleCommand {
|
||||
textureRegionComponent.scheduleRefresh();
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, SimpleImageVO vo) {
|
||||
public static Object payload(int entity, SimpleImageVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+5
-5
@@ -18,8 +18,8 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.label.LabelComponent;
|
||||
@@ -48,10 +48,10 @@ public class UpdateLabelDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
LabelComponent labelComponent = ComponentRetriever.get(entity, LabelComponent.class);
|
||||
LabelComponent labelComponent = SandboxComponentRetriever.get(entity, LabelComponent.class);
|
||||
|
||||
this.prevFontName = labelComponent.fontName;
|
||||
this.prevFontSize = labelComponent.fontSize;
|
||||
@@ -85,8 +85,8 @@ public class UpdateLabelDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
final Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
final LabelComponent labelComponent = ComponentRetriever.get(entity, LabelComponent.class);
|
||||
final int entity = EntityUtils.getByUniqueId(entityId);
|
||||
final LabelComponent labelComponent = SandboxComponentRetriever.get(entity, LabelComponent.class);
|
||||
|
||||
labelComponent.fontName = prevFontName;
|
||||
labelComponent.fontSize = prevFontSize;
|
||||
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
import games.rednblack.editor.renderer.data.LightBodyDataVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class UpdateLightBodyDataCommand extends EntityModifyRevertibleCommand {
|
||||
@@ -17,11 +17,11 @@ public class UpdateLightBodyDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
LightBodyDataVO vo = (LightBodyDataVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
LightBodyComponent lightComponent = ComponentRetriever.get(entity, LightBodyComponent.class);
|
||||
LightBodyComponent lightComponent = SandboxComponentRetriever.get(entity, LightBodyComponent.class);
|
||||
|
||||
backup = new LightBodyDataVO();
|
||||
backup.loadFromComponent(lightComponent);
|
||||
@@ -47,8 +47,8 @@ public class UpdateLightBodyDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
LightBodyComponent lightComponent = ComponentRetriever.get(entity, LightBodyComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
LightBodyComponent lightComponent = SandboxComponentRetriever.get(entity, LightBodyComponent.class);
|
||||
|
||||
lightComponent.rayDirection = backup.rayDirection;
|
||||
lightComponent.distance = backup.distance;
|
||||
@@ -69,7 +69,7 @@ public class UpdateLightBodyDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, LightBodyDataVO vo) {
|
||||
public static Object payload(int entity, LightBodyDataVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+7
-7
@@ -18,13 +18,13 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.light.LightObjectComponent;
|
||||
import games.rednblack.editor.renderer.data.LightVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class UpdateLightDataCommand extends EntityModifyRevertibleCommand {
|
||||
@@ -35,14 +35,14 @@ public class UpdateLightDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
LightVO vo = (LightVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new LightVO();
|
||||
backup.loadFromEntity(entity);
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
|
||||
LightObjectComponent lightObjectComponent = ComponentRetriever.get(entity, LightObjectComponent.class);
|
||||
LightObjectComponent lightObjectComponent = SandboxComponentRetriever.get(entity, LightObjectComponent.class);
|
||||
|
||||
lightObjectComponent.rays = vo.rays;
|
||||
lightObjectComponent.isStatic = vo.isStatic;
|
||||
@@ -61,8 +61,8 @@ public class UpdateLightDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
LightObjectComponent lightObjectComponent = ComponentRetriever.get(entity, LightObjectComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
LightObjectComponent lightObjectComponent = SandboxComponentRetriever.get(entity, LightObjectComponent.class);
|
||||
|
||||
lightObjectComponent.rays = backup.rays;
|
||||
lightObjectComponent.isStatic = backup.isStatic;
|
||||
@@ -79,7 +79,7 @@ public class UpdateLightDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, LightVO vo) {
|
||||
public static Object payload(int entity, LightVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+7
-7
@@ -1,12 +1,12 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.particle.ParticleComponent;
|
||||
import games.rednblack.editor.renderer.data.ParticleEffectVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class UpdateParticleDataCommand extends EntityModifyRevertibleCommand {
|
||||
@@ -17,14 +17,14 @@ public class UpdateParticleDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
ParticleEffectVO vo = (ParticleEffectVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new ParticleEffectVO();
|
||||
backup.loadFromEntity(entity);
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
|
||||
ParticleComponent particleComponent = ComponentRetriever.get(entity, ParticleComponent.class);
|
||||
ParticleComponent particleComponent = SandboxComponentRetriever.get(entity, ParticleComponent.class);
|
||||
particleComponent.transform = vo.transform;
|
||||
|
||||
particleComponent.particleEffect.setPosition(0, 0);
|
||||
@@ -34,15 +34,15 @@ public class UpdateParticleDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
ParticleComponent particleComponent = ComponentRetriever.get(entity, ParticleComponent.class);
|
||||
ParticleComponent particleComponent = SandboxComponentRetriever.get(entity, ParticleComponent.class);
|
||||
particleComponent.transform = backup.transform;
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, ParticleEffectVO vo) {
|
||||
public static Object payload(int entity, ParticleEffectVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.physics.PhysicsBodyComponent;
|
||||
import games.rednblack.editor.renderer.data.PhysicsBodyDataVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand {
|
||||
@@ -17,11 +17,11 @@ public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
PhysicsBodyDataVO vo = (PhysicsBodyDataVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
PhysicsBodyComponent physicsComponent = ComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
PhysicsBodyComponent physicsComponent = SandboxComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
|
||||
backup = new PhysicsBodyDataVO();
|
||||
backup.loadFromComponent(physicsComponent);
|
||||
@@ -54,8 +54,8 @@ public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
PhysicsBodyComponent physicsComponent = ComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
PhysicsBodyComponent physicsComponent = SandboxComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
|
||||
physicsComponent.bodyType = backup.bodyType;
|
||||
physicsComponent.mass = backup.mass;
|
||||
@@ -83,7 +83,7 @@ public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, PhysicsBodyDataVO vo) {
|
||||
public static Object payload(int entity, PhysicsBodyDataVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+8
-8
@@ -18,8 +18,8 @@
|
||||
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
@@ -38,7 +38,7 @@ public class UpdatePolygonDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
private void collectData() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
entityId = EntityUtils.getEntityId((Entity) payload[0]);
|
||||
entityId = EntityUtils.getEntityId((int) payload[0]);
|
||||
dataFrom = (Vector2[][]) payload[1];
|
||||
dataTo = (Vector2[][]) payload[2];
|
||||
dataFrom = dataFrom.clone();
|
||||
@@ -49,9 +49,9 @@ public class UpdatePolygonDataCommand extends EntityModifyRevertibleCommand {
|
||||
public void doAction() {
|
||||
collectData();
|
||||
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
PolygonComponent polygonComponent = ComponentRetriever.get(entity, PolygonComponent.class);
|
||||
PolygonComponent polygonComponent = SandboxComponentRetriever.get(entity, PolygonComponent.class);
|
||||
polygonComponent.vertices = dataTo;
|
||||
|
||||
EntityUtils.refreshComponents(entity);
|
||||
@@ -62,9 +62,9 @@ public class UpdatePolygonDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
PolygonComponent polygonComponent = ComponentRetriever.get(entity, PolygonComponent.class);
|
||||
PolygonComponent polygonComponent = SandboxComponentRetriever.get(entity, PolygonComponent.class);
|
||||
polygonComponent.vertices = dataFrom;
|
||||
|
||||
EntityUtils.refreshComponents(entity);
|
||||
@@ -72,8 +72,8 @@ public class UpdatePolygonDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object[] payloadInitialState(Entity entity) {
|
||||
PolygonComponent polygonComponent = ComponentRetriever.get(entity, PolygonComponent.class);
|
||||
public static Object[] payloadInitialState(int entity) {
|
||||
PolygonComponent polygonComponent = SandboxComponentRetriever.get(entity, PolygonComponent.class);
|
||||
Object[] payload = new Object[3];
|
||||
payload[0] = entity;
|
||||
payload[1] = cloneData(polygonComponent.vertices);
|
||||
|
||||
+6
-7
@@ -1,13 +1,12 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.physics.SensorComponent;
|
||||
import games.rednblack.editor.renderer.data.SensorDataVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
/**
|
||||
@@ -26,11 +25,11 @@ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
SensorDataVO vo = (SensorDataVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
SensorComponent sensorComponent = ComponentRetriever.get(entity, SensorComponent.class);
|
||||
SensorComponent sensorComponent = SandboxComponentRetriever.get(entity, SensorComponent.class);
|
||||
|
||||
backup = new SensorDataVO();
|
||||
backup.loadFromComponent(sensorComponent);
|
||||
@@ -52,8 +51,8 @@ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
SensorComponent sensorComponent = ComponentRetriever.get(entity, SensorComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
SensorComponent sensorComponent = SandboxComponentRetriever.get(entity, SensorComponent.class);
|
||||
|
||||
sensorComponent.bottom = backup.bottom;
|
||||
sensorComponent.left = backup.left;
|
||||
@@ -70,7 +69,7 @@ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, SensorDataVO vo) {
|
||||
public static Object payload(int entity, SensorDataVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.proxy.ResourceManager;
|
||||
import games.rednblack.editor.renderer.components.ShaderComponent;
|
||||
import games.rednblack.editor.renderer.data.MainItemVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
public class UpdateShaderDataCommand extends EntityModifyRevertibleCommand {
|
||||
@@ -18,12 +18,12 @@ public class UpdateShaderDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
String shaderName = (String) payload[1];
|
||||
MainItemVO.RenderingLayer renderingLayer = (MainItemVO.RenderingLayer) payload[2];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
ShaderComponent shaderComponent = ComponentRetriever.get(entity, ShaderComponent.class);
|
||||
ShaderComponent shaderComponent = SandboxComponentRetriever.get(entity, ShaderComponent.class);
|
||||
if (shaderComponent == null) {
|
||||
cancel();
|
||||
return;
|
||||
@@ -45,8 +45,8 @@ public class UpdateShaderDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
ShaderComponent shaderComponent = ComponentRetriever.get(entity, ShaderComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
ShaderComponent shaderComponent = SandboxComponentRetriever.get(entity, ShaderComponent.class);
|
||||
if (shaderComponent == null) return;
|
||||
|
||||
ResourceManager resourceManager = facade.retrieveProxy(ResourceManager.NAME);
|
||||
@@ -61,7 +61,7 @@ public class UpdateShaderDataCommand extends EntityModifyRevertibleCommand {
|
||||
facade.sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, String shaderName, MainItemVO.RenderingLayer layer) {
|
||||
public static Object payload(int entity, String shaderName, MainItemVO.RenderingLayer layer) {
|
||||
Object[] payload = new Object[3];
|
||||
payload[0] = entity;
|
||||
payload[1] = shaderName;
|
||||
|
||||
+9
-9
@@ -1,12 +1,12 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.SpineDataComponent;
|
||||
import games.rednblack.editor.renderer.data.SpineVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.h2d.extention.spine.SpineObjectComponent;
|
||||
|
||||
@@ -18,15 +18,15 @@ public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
SpineVO vo = (SpineVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new SpineVO();
|
||||
backup.loadFromEntity(entity);
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
|
||||
SpineDataComponent spineDataComponent = ComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = ComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
SpineDataComponent spineDataComponent = SandboxComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = SandboxComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
|
||||
spineDataComponent.currentAnimationName = vo.currentAnimationName;
|
||||
spineObjectComponent.setAnimation(vo.currentAnimationName);
|
||||
@@ -36,9 +36,9 @@ public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
SpineDataComponent spineDataComponent = ComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = ComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
SpineDataComponent spineDataComponent = SandboxComponentRetriever.get(entity, SpineDataComponent.class);
|
||||
SpineObjectComponent spineObjectComponent = SandboxComponentRetriever.get(entity, SpineObjectComponent.class);
|
||||
|
||||
spineDataComponent.currentAnimationName = backup.currentAnimationName;
|
||||
spineObjectComponent.setAnimation(backup.currentAnimationName);
|
||||
@@ -46,7 +46,7 @@ public class UpdateSpineDataCommand extends EntityModifyRevertibleCommand {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, SpineVO vo) {
|
||||
public static Object payload(int entity, SpineVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
+8
-8
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.graphics.g2d.Animation;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
@@ -8,6 +7,7 @@ import games.rednblack.editor.renderer.components.sprite.SpriteAnimationComponen
|
||||
import games.rednblack.editor.renderer.components.sprite.SpriteAnimationStateComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
|
||||
/**
|
||||
@@ -24,15 +24,15 @@ public class UpdateSpriteAnimationDataCommand extends EntityModifyRevertibleComm
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
int fps = (int) payload[1];
|
||||
String animName = (String) payload[2];
|
||||
Animation.PlayMode playMode = (Animation.PlayMode) payload[3];
|
||||
|
||||
SpriteAnimationComponent spriteAnimationComponent = ComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = ComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = SandboxComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
previousFps = spriteAnimationComponent.fps;
|
||||
previousAnimationName = spriteAnimationComponent.currentAnimation;
|
||||
previousPlayMode = spriteAnimationComponent.playMode;
|
||||
@@ -47,10 +47,10 @@ public class UpdateSpriteAnimationDataCommand extends EntityModifyRevertibleComm
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
SpriteAnimationComponent spriteAnimationComponent = ComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = ComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(entity, SpriteAnimationComponent.class);
|
||||
SpriteAnimationStateComponent spriteAnimationStateComponent = SandboxComponentRetriever.get(entity, SpriteAnimationStateComponent.class);
|
||||
spriteAnimationComponent.fps = previousFps;
|
||||
spriteAnimationComponent.currentAnimation = previousAnimationName;
|
||||
spriteAnimationComponent.playMode = previousPlayMode;
|
||||
@@ -59,7 +59,7 @@ public class UpdateSpriteAnimationDataCommand extends EntityModifyRevertibleComm
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, int fps, String animName, Animation.PlayMode playMode) {
|
||||
public static Object payload(int entity, int fps, String animName, Animation.PlayMode playMode) {
|
||||
Object[] payload = new Object[4];
|
||||
payload[0] = entity;
|
||||
payload[1] = fps;
|
||||
|
||||
+9
-9
@@ -1,12 +1,12 @@
|
||||
package games.rednblack.editor.controller.commands.component;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.EntityModifyRevertibleCommand;
|
||||
import games.rednblack.editor.renderer.components.particle.TalosDataComponent;
|
||||
import games.rednblack.editor.renderer.data.TalosVO;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.h2d.extension.talos.TalosComponent;
|
||||
|
||||
@@ -18,17 +18,17 @@ public class UpdateTalosDataCommand extends EntityModifyRevertibleCommand {
|
||||
@Override
|
||||
public void doAction() {
|
||||
Object[] payload = getNotification().getBody();
|
||||
Entity entity = (Entity) payload[0];
|
||||
int entity = (int) payload[0];
|
||||
TalosVO vo = (TalosVO) payload[1];
|
||||
entityId = EntityUtils.getEntityId(entity);
|
||||
|
||||
backup = new TalosVO();
|
||||
backup.loadFromEntity(entity);
|
||||
backup.loadFromEntity(entity, sandbox.getEngine());
|
||||
|
||||
TalosDataComponent dataComponent = ComponentRetriever.get(entity, TalosDataComponent.class);
|
||||
TalosDataComponent dataComponent = SandboxComponentRetriever.get(entity, TalosDataComponent.class);
|
||||
dataComponent.transform = vo.transform;
|
||||
|
||||
TalosComponent talosComponent = ComponentRetriever.get(entity, TalosComponent.class);
|
||||
TalosComponent talosComponent = SandboxComponentRetriever.get(entity, TalosComponent.class);
|
||||
talosComponent.effect.setPosition(0, 0);
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
@@ -36,18 +36,18 @@ public class UpdateTalosDataCommand extends EntityModifyRevertibleCommand {
|
||||
|
||||
@Override
|
||||
public void undoAction() {
|
||||
Entity entity = EntityUtils.getByUniqueId(entityId);
|
||||
int entity = EntityUtils.getByUniqueId(entityId);
|
||||
|
||||
TalosDataComponent particleComponent = ComponentRetriever.get(entity, TalosDataComponent.class);
|
||||
TalosDataComponent particleComponent = SandboxComponentRetriever.get(entity, TalosDataComponent.class);
|
||||
particleComponent.transform = backup.transform;
|
||||
|
||||
TalosComponent talosComponent = ComponentRetriever.get(entity, TalosComponent.class);
|
||||
TalosComponent talosComponent = SandboxComponentRetriever.get(entity, TalosComponent.class);
|
||||
talosComponent.effect.setPosition(0, 0);
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
public static Object payload(Entity entity, TalosVO vo) {
|
||||
public static Object payload(int entity, TalosVO vo) {
|
||||
Object[] payload = new Object[2];
|
||||
payload[0] = entity;
|
||||
payload[1] = vo;
|
||||
|
||||
@@ -18,10 +18,9 @@
|
||||
|
||||
package games.rednblack.editor.factory;
|
||||
|
||||
import com.badlogic.ashley.core.Engine;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.controller.commands.PasteItemsCommand;
|
||||
@@ -48,7 +47,7 @@ public class ItemFactory implements IFactory {
|
||||
private final EntityFactory entityFactory;
|
||||
private final SceneLoader sceneLoader;
|
||||
private final Sandbox sandbox;
|
||||
private Entity createdEntity;
|
||||
private int createdEntity;
|
||||
|
||||
private static ItemFactory instance;
|
||||
|
||||
@@ -97,7 +96,7 @@ public class ItemFactory implements IFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getCreatedEntity() {
|
||||
public int getCreatedEntity() {
|
||||
return createdEntity;
|
||||
}
|
||||
|
||||
@@ -144,7 +143,7 @@ public class ItemFactory implements IFactory {
|
||||
vo.originY = vo.shape.polygons[0][2].y / 2;
|
||||
|
||||
if(!setEssentialData(vo, position)) return false;
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
int entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
|
||||
@@ -161,10 +160,10 @@ public class ItemFactory implements IFactory {
|
||||
PasteItemsCommand.forceIdChange(itemVO.composite);
|
||||
createdEntity = createCompositeItem(itemVO, position);
|
||||
|
||||
if (createdEntity == null) return false;
|
||||
if (createdEntity == -1) return false;
|
||||
|
||||
//adding library name
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(createdEntity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(createdEntity, MainItemComponent.class);
|
||||
mainItemComponent.libraryLink = libraryName;
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, createdEntity);
|
||||
@@ -172,26 +171,24 @@ public class ItemFactory implements IFactory {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Entity createCompositeItem(CompositeItemVO vo, Vector2 position) {
|
||||
if(!setEssentialData(vo, position)) return null;
|
||||
public int createCompositeItem(CompositeItemVO vo, Vector2 position) {
|
||||
if(!setEssentialData(vo, position)) return -1;
|
||||
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
Engine engine = sceneLoader.getEngine();
|
||||
int entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
EntityFactory factory = sceneLoader.getEntityFactory();
|
||||
factory.initAllChildren(engine, entity, vo.composite);
|
||||
factory.initAllChildren(entity, vo.composite);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Entity createCompositeItem(Vector2 position) {
|
||||
public int createCompositeItem(Vector2 position) {
|
||||
CompositeItemVO vo = new CompositeItemVO();
|
||||
Entity entity = createCompositeItem(vo, position);
|
||||
return entity;
|
||||
return createCompositeItem(vo, position);
|
||||
}
|
||||
|
||||
public Entity createLightItem(LightVO vo, Vector2 position) {
|
||||
if(!setEssentialData(vo, position)) return null;
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
public int createLightItem(LightVO vo, Vector2 position) {
|
||||
if(!setEssentialData(vo, position)) return -1;
|
||||
int entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
/*
|
||||
@@ -204,54 +201,50 @@ public class ItemFactory implements IFactory {
|
||||
}
|
||||
|
||||
public boolean tryCreateParticleItem(String particleName, Vector2 position) {
|
||||
Entity entity = createParticleItem(particleName, position);
|
||||
int entity = createParticleItem(particleName, position);
|
||||
|
||||
/* DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
float boundBoxSize = 10f;
|
||||
dimensionsComponent.boundBox = new Rectangle(-boundBoxSize / 2f, -boundBoxSize / 2f, boundBoxSize, boundBoxSize);*/
|
||||
|
||||
if(entity == null) return false;
|
||||
|
||||
return true;
|
||||
return entity != -1;
|
||||
}
|
||||
|
||||
public Entity createParticleItem(String particleName, Vector2 position) {
|
||||
public int createParticleItem(String particleName, Vector2 position) {
|
||||
ParticleEffectVO vo = new ParticleEffectVO();
|
||||
vo.particleName = particleName;
|
||||
|
||||
if(!setEssentialData(vo, position)) return null;
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
if(!setEssentialData(vo, position)) return -1;
|
||||
int entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public boolean tryCreateTalosItem(String particleName, Vector2 position) {
|
||||
Entity entity = createTalosItem(particleName, position);
|
||||
int entity = createTalosItem(particleName, position);
|
||||
|
||||
/* DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
float boundBoxSize = 10f;
|
||||
dimensionsComponent.boundBox = new Rectangle(-boundBoxSize / 2f, -boundBoxSize / 2f, boundBoxSize, boundBoxSize);*/
|
||||
|
||||
if(entity == null) return false;
|
||||
|
||||
return true;
|
||||
return entity != -1;
|
||||
}
|
||||
|
||||
public Entity createTalosItem(String particleName, Vector2 position) {
|
||||
public int createTalosItem(String particleName, Vector2 position) {
|
||||
TalosVO vo = new TalosVO();
|
||||
vo.particleName = particleName;
|
||||
|
||||
if(!setEssentialData(vo, position)) return null;
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
if(!setEssentialData(vo, position)) return -1;
|
||||
int entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Entity createLabel(TextTool textSettings, Vector2 position) {
|
||||
public int createLabel(TextTool textSettings, Vector2 position) {
|
||||
LabelVO vo = new LabelVO();
|
||||
if(!setEssentialData(vo, position)) return null;
|
||||
if(!setEssentialData(vo, position)) return -1;
|
||||
|
||||
HyperLap2DFacade facade = HyperLap2DFacade.getInstance();
|
||||
ResourceManager resourceManager = facade.retrieveProxy(ResourceManager.NAME);
|
||||
@@ -267,7 +260,7 @@ public class ItemFactory implements IFactory {
|
||||
vo.width = 120f/Sandbox.getInstance().getPixelPerWU();
|
||||
vo.height = 50f/Sandbox.getInstance().getPixelPerWU();
|
||||
|
||||
Entity entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
int entity = entityFactory.createEntity(sandbox.getCurrentViewingEntity(), vo);
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_CREATE_ITEM, entity);
|
||||
|
||||
return entity;
|
||||
|
||||
@@ -20,7 +20,7 @@ public enum ActionFieldType implements FieldType {
|
||||
case Delay:
|
||||
return value instanceof DelayData;
|
||||
case Entity:
|
||||
return value instanceof com.badlogic.ashley.core.Entity;
|
||||
return value instanceof Integer;
|
||||
case Color:
|
||||
return value instanceof com.badlogic.gdx.graphics.Color;
|
||||
case Boolean:
|
||||
|
||||
@@ -15,6 +15,7 @@ import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
import games.rednblack.editor.proxy.ResolutionManager;
|
||||
import games.rednblack.editor.proxy.ResourceManager;
|
||||
import games.rednblack.editor.renderer.SceneConfiguration;
|
||||
import games.rednblack.editor.renderer.SceneLoader;
|
||||
import games.rednblack.editor.renderer.components.additional.ButtonComponent;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
@@ -51,9 +52,12 @@ public class LivePreviewScreen extends ScreenAdapter implements GestureDetector.
|
||||
|
||||
viewport = new ExtendViewport(worldSizeVO.getWorldWidth(), worldSizeVO.getWorldHeight());
|
||||
mCamera = (OrthographicCamera) viewport.getCamera();
|
||||
sceneLoader = new SceneLoader(resourceManager);
|
||||
sceneLoader.injectExternalItemType(new SpineItemType());
|
||||
sceneLoader.injectExternalItemType(new TalosItemType());
|
||||
SceneConfiguration config = new SceneConfiguration();
|
||||
config.setResourceRetriever(resourceManager);
|
||||
config.addExternalItemType(new SpineItemType());
|
||||
config.addExternalItemType(new TalosItemType());
|
||||
sceneLoader = new SceneLoader(config);
|
||||
|
||||
sceneLoader.loadScene(projectManager.getCurrentSceneConfigVO().sceneName, viewport);
|
||||
|
||||
bgColor = projectManager.currentProjectVO.backgroundColor;
|
||||
@@ -74,7 +78,8 @@ public class LivePreviewScreen extends ScreenAdapter implements GestureDetector.
|
||||
mCamera.position.lerp(cameraTargetPos, 0.5f);
|
||||
|
||||
viewport.apply();
|
||||
sceneLoader.getEngine().update(delta);
|
||||
sceneLoader.getEngine().setDelta(delta);
|
||||
sceneLoader.getEngine().process();
|
||||
|
||||
if (projectManager.currentProjectVO.box2dDebugRender)
|
||||
mBox2DDebugRenderer.render(sceneLoader.getWorld(), mCamera.combined);
|
||||
|
||||
@@ -18,12 +18,8 @@
|
||||
|
||||
package games.rednblack.editor.proxy;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.ashley.core.PooledEngine;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.renderer.data.ProjectInfoVO;
|
||||
@@ -70,7 +66,7 @@ public class PluginManager extends Proxy implements PluginAPI {
|
||||
private ArrayList<H2DPlugin> plugins = new ArrayList<>();
|
||||
private String pluginDir, cacheDir;
|
||||
|
||||
private HashSet<Entity> pluginEntities;
|
||||
private HashSet<Integer> pluginEntities;
|
||||
|
||||
public PluginManager() {
|
||||
super(NAME);
|
||||
@@ -91,7 +87,7 @@ public class PluginManager extends Proxy implements PluginAPI {
|
||||
plugin.initPlugin();
|
||||
}
|
||||
|
||||
public void dropDownActionSets(Set<Entity> selectedEntities, Array<String> actionsSet) {
|
||||
public void dropDownActionSets(Set<Integer> selectedEntities, Array<String> actionsSet) {
|
||||
for(H2DPlugin plugin: plugins) {
|
||||
plugin.onDropDownOpen(selectedEntities, actionsSet);
|
||||
}
|
||||
@@ -138,7 +134,7 @@ public class PluginManager extends Proxy implements PluginAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFollower(Entity entity) {
|
||||
public void removeFollower(int entity) {
|
||||
FollowersUIMediator followersUIMediator = HyperLap2DFacade.getInstance().retrieveMediator(FollowersUIMediator.NAME);
|
||||
followersUIMediator.removeFollower(entity);
|
||||
}
|
||||
@@ -215,7 +211,7 @@ public class PluginManager extends Proxy implements PluginAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PooledEngine getEngine() {
|
||||
public com.artemis.World getEngine() {
|
||||
return getSceneLoader().getEngine();
|
||||
}
|
||||
|
||||
@@ -229,13 +225,13 @@ public class PluginManager extends Proxy implements PluginAPI {
|
||||
return ItemFactory.get();
|
||||
}
|
||||
|
||||
public boolean isEntityVisible(Entity e) {
|
||||
public boolean isEntityVisible(int e) {
|
||||
LayerItemVO layer = EntityUtils.getEntityLayer(e);
|
||||
return layer != null && layer.isVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashSet<Entity> getProjectEntities() {
|
||||
public HashSet<Integer> getProjectEntities() {
|
||||
Sandbox sandbox = Sandbox.getInstance();
|
||||
return sandbox.getSelector().getAllFreeItems();
|
||||
}
|
||||
|
||||
@@ -498,8 +498,9 @@ public class ProjectManager extends Proxy {
|
||||
try {
|
||||
HashMap<String, String> fonts = fontManager.getFontsMap();
|
||||
if (fonts.containsKey(font.fontName)) {
|
||||
File source = new File(fonts.get(font.fontName));
|
||||
FileUtils.copyFileToDirectory(source, fontsDirectory.file());
|
||||
FileHandle source = new FileHandle(fonts.get(font.fontName));
|
||||
FileHandle dest = new FileHandle(fontsDirectory.path() + File.separator + font.fontName + ".ttf");
|
||||
FileUtils.copyFile(source.file(), dest.file());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package games.rednblack.editor.system;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.artemis.annotations.All;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||
import games.rednblack.editor.renderer.components.particle.ParticleComponent;
|
||||
import games.rednblack.editor.renderer.systems.ParticleSystem;
|
||||
@@ -10,11 +10,12 @@ import games.rednblack.editor.renderer.systems.ParticleSystem;
|
||||
* This system will make sure they look continuous while in editor, so user will find and see them easily.
|
||||
*
|
||||
*/
|
||||
@All(ParticleComponent.class)
|
||||
public class ParticleContinuousSystem extends ParticleSystem {
|
||||
|
||||
@Override
|
||||
protected void processEntity(Entity entity, float deltaTime) {
|
||||
super.processEntity(entity, deltaTime);
|
||||
protected void process(int entity) {
|
||||
super.process(entity);
|
||||
|
||||
ParticleComponent particleComponent = particleComponentMapper.get(entity);
|
||||
ParticleEffect particleEffect = particleComponent.particleEffect;
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
package games.rednblack.editor.system;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.artemis.annotations.All;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.physics.box2d.World;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.components.physics.PhysicsBodyComponent;
|
||||
import games.rednblack.editor.renderer.systems.PhysicsSystem;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
|
||||
@All(PhysicsBodyComponent.class)
|
||||
public class PhysicsAdjustSystem extends PhysicsSystem {
|
||||
|
||||
private final Vector2 transformVec = new Vector2();
|
||||
|
||||
public PhysicsAdjustSystem(World world) {
|
||||
super(world);
|
||||
public PhysicsAdjustSystem() {
|
||||
setPhysicsOn(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processEntity(Entity entity, float deltaTime) {
|
||||
protected void process(int entity) {
|
||||
TransformComponent transformComponent = transformComponentMapper.get(entity);
|
||||
processBody(entity);
|
||||
|
||||
PhysicsBodyComponent physicsBodyComponent = ComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
PhysicsBodyComponent physicsBodyComponent = SandboxComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
|
||||
if(physicsBodyComponent.body == null) return;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package games.rednblack.editor.system;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.artemis.annotations.All;
|
||||
import com.talosvfx.talos.runtime.ParticleEffectInstance;
|
||||
import games.rednblack.editor.renderer.components.particle.TalosDataComponent;
|
||||
import games.rednblack.h2d.extension.talos.TalosComponent;
|
||||
import games.rednblack.h2d.extension.talos.TalosSystem;
|
||||
|
||||
@@ -10,11 +11,12 @@ import games.rednblack.h2d.extension.talos.TalosSystem;
|
||||
* This system will make sure they look continuous while in editor, so user will find and see them easily.
|
||||
*
|
||||
*/
|
||||
@All({TalosComponent.class, TalosDataComponent.class})
|
||||
public class TalosContinuousSystem extends TalosSystem {
|
||||
|
||||
@Override
|
||||
protected void processEntity(Entity entity, float deltaTime) {
|
||||
super.processEntity(entity, deltaTime);
|
||||
protected void process(int entity) {
|
||||
super.process(entity);
|
||||
|
||||
TalosComponent talosComponent = particleComponentMapper.get(entity);
|
||||
ParticleEffectInstance effect = talosComponent.effect;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
@@ -123,14 +122,14 @@ public class AssetImporter {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean deleteAsset(int type, Entity root, String name) {
|
||||
public boolean deleteAsset(int type, int root, String name) {
|
||||
Asset asset = getDescriptorFor(type);
|
||||
if (asset != null)
|
||||
return asset.deleteAsset(root, name);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
for (Asset asset : new Array.ArrayIterator<>(assetDescriptors)) {
|
||||
if (asset.deleteAsset(root, name))
|
||||
return true;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package games.rednblack.editor.utils;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Matrix3;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
@@ -27,7 +26,7 @@ import games.rednblack.editor.renderer.components.DimensionsComponent;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
import games.rednblack.editor.renderer.components.light.LightObjectComponent;
|
||||
import games.rednblack.editor.renderer.components.particle.ParticleComponent;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.extension.talos.TalosComponent;
|
||||
|
||||
/**
|
||||
@@ -54,7 +53,7 @@ public class EntityBounds extends Rectangle {
|
||||
private final Array<Vector2> boundPointList = new Array<>();
|
||||
private final float[] boundPoints = new float[8];
|
||||
|
||||
public EntityBounds(Entity entity) {
|
||||
public EntityBounds(int entity) {
|
||||
setEntity(entity);
|
||||
}
|
||||
|
||||
@@ -62,9 +61,9 @@ public class EntityBounds extends Rectangle {
|
||||
|
||||
}
|
||||
|
||||
public void setEntity(Entity entity) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
public void setEntity(int entity) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
x = transformComponent.x;
|
||||
y = transformComponent.y;
|
||||
scaleX = transformComponent.scaleX * (transformComponent.flipX ? -1 : 1);
|
||||
@@ -72,7 +71,7 @@ public class EntityBounds extends Rectangle {
|
||||
width = dimensionsComponent.width;
|
||||
height = dimensionsComponent.height;
|
||||
|
||||
if (ComponentRetriever.get(entity, LightObjectComponent.class) != null) {
|
||||
if (SandboxComponentRetriever.get(entity, LightObjectComponent.class) != null) {
|
||||
x += dimensionsComponent.boundBox.x;
|
||||
y += dimensionsComponent.boundBox.y;
|
||||
scaleX = 1;
|
||||
@@ -81,8 +80,8 @@ public class EntityBounds extends Rectangle {
|
||||
height = dimensionsComponent.boundBox.height;
|
||||
}
|
||||
|
||||
if (ComponentRetriever.get(entity, ParticleComponent.class) != null
|
||||
|| ComponentRetriever.get(entity, TalosComponent.class) != null) {
|
||||
if (SandboxComponentRetriever.get(entity, ParticleComponent.class) != null
|
||||
|| SandboxComponentRetriever.get(entity, TalosComponent.class) != null) {
|
||||
width = dimensionsComponent.boundBox.width;
|
||||
height = dimensionsComponent.boundBox.height;
|
||||
dimensionsComponent.width = width;
|
||||
@@ -186,7 +185,7 @@ public class EntityBounds extends Rectangle {
|
||||
return boundPoints;
|
||||
}
|
||||
|
||||
public float[] getBoundPoints(Entity entity) {
|
||||
public float[] getBoundPoints(int entity) {
|
||||
setEntity(entity);
|
||||
return boundPoints;
|
||||
}
|
||||
@@ -197,7 +196,7 @@ public class EntityBounds extends Rectangle {
|
||||
return boundPointList;
|
||||
}
|
||||
|
||||
public Array<Vector2> getBoundPointsList(Entity entity) {
|
||||
public Array<Vector2> getBoundPointsList(int entity) {
|
||||
setEntity(entity);
|
||||
return getBoundPointsList();
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package games.rednblack.editor.utils;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.TransformComponent;
|
||||
@@ -37,17 +37,17 @@ public class MoveCommandBuilder {
|
||||
payload = new Array<>();
|
||||
}
|
||||
|
||||
public void setX(Entity entity, float x) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
public void setX(int entity, float x) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class, Sandbox.getInstance().getEngine());
|
||||
setXY(entity, x, transformComponent.y);
|
||||
}
|
||||
|
||||
public void setY(Entity entity, float y) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
public void setY(int entity, float y) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class, Sandbox.getInstance().getEngine());
|
||||
setXY(entity, transformComponent.x, y);
|
||||
}
|
||||
|
||||
public void setXY(Entity entity, float x, float y) {
|
||||
public void setXY(int entity, float x, float y) {
|
||||
Object[] data = new Object[2];
|
||||
data[0] = entity;
|
||||
data[1] = new Vector2(x, y);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
@@ -25,7 +24,7 @@ public abstract class Asset implements IAsset {
|
||||
protected ResolutionManager resolutionManager;
|
||||
protected ResourceManager resourceManager;
|
||||
|
||||
protected final ArrayList<Entity> tmpEntityList = new ArrayList<>();
|
||||
protected final ArrayList<Integer> tmpEntityList = new ArrayList<>();
|
||||
protected final ArrayList<MainItemVO> tmpImageList = new ArrayList<>();
|
||||
|
||||
public Asset() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
@@ -9,5 +8,5 @@ public interface IAsset {
|
||||
int matchType(Array<FileHandle> files);
|
||||
boolean checkExistence(Array<FileHandle> files);
|
||||
void importAsset(Array<FileHandle> files, ProgressHandler progressHandler, boolean skipRepack);
|
||||
boolean deleteAsset(Entity root, String name);
|
||||
boolean deleteAsset(int root, String name);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -74,7 +73,7 @@ public class AtlasAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
@@ -45,7 +44,7 @@ public class HyperLap2DActionAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
HashMap<String, GraphVO> libraryActions = projectManager.currentProjectInfoVO.libraryActions;
|
||||
|
||||
libraryActions.remove(name);
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
@@ -53,7 +52,7 @@ public class HyperLap2DInternalLibraryAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
@@ -16,6 +15,7 @@ import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.ZipUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
import games.rednblack.h2d.common.vo.ExportMapperVO;
|
||||
@@ -134,14 +134,14 @@ public class HyperLap2DLibraryAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
HashMap<String, CompositeItemVO> libraryItems = projectManager.currentProjectInfoVO.libraryItems;
|
||||
|
||||
libraryItems.remove(name);
|
||||
|
||||
Array<Entity> linkedEntities = EntityUtils.getByLibraryLink(name);
|
||||
for (Entity entity : linkedEntities) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
Array<Integer> linkedEntities = EntityUtils.getByLibraryLink(name);
|
||||
for (int entity : linkedEntities) {
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
mainItemComponent.libraryLink = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
@@ -15,6 +14,8 @@ import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
|
||||
import java.io.File;
|
||||
@@ -70,7 +71,7 @@ public class ImageAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
for (ResolutionEntryVO resolutionEntryVO : projectManager.getCurrentProjectInfoVO().resolutions) {
|
||||
if(!deleteSingleImage(resolutionEntryVO.name, name))
|
||||
return false;
|
||||
@@ -99,7 +100,7 @@ public class ImageAsset extends Asset {
|
||||
* Clear scenes and library items that contains deleted image
|
||||
* @param imageName image to delete
|
||||
*/
|
||||
protected void postDeleteImage(Entity root, String imageName) {
|
||||
protected void postDeleteImage(int root, String imageName) {
|
||||
deleteEntitiesWithImages(root, imageName);
|
||||
deleteAllItemsImages(imageName);
|
||||
}
|
||||
@@ -137,15 +138,15 @@ public class ImageAsset extends Asset {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteEntitiesWithImages(Entity rootEntity, String regionName) {
|
||||
private void deleteEntitiesWithImages(int rootEntity, String regionName) {
|
||||
tmpEntityList.clear();
|
||||
Consumer<Entity> action = (root) -> {
|
||||
TextureRegionComponent regionComponent = ComponentRetriever.get(root, TextureRegionComponent.class);
|
||||
Consumer<Integer> action = (root) -> {
|
||||
TextureRegionComponent regionComponent = SandboxComponentRetriever.get(root, TextureRegionComponent.class);
|
||||
if (regionComponent != null && regionComponent.regionName.equals(regionName)) {
|
||||
tmpEntityList.add(root);
|
||||
}
|
||||
|
||||
NinePatchComponent ninePatchComponent = ComponentRetriever.get(root, NinePatchComponent.class);
|
||||
NinePatchComponent ninePatchComponent = SandboxComponentRetriever.get(root, NinePatchComponent.class);
|
||||
if (ninePatchComponent != null && ninePatchComponent.textureRegionName.equals(regionName)) {
|
||||
tmpEntityList.add(root);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.kotcrab.vis.ui.util.dialog.Dialogs;
|
||||
@@ -13,6 +12,7 @@ import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -95,7 +95,7 @@ public class ParticleEffectAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
String particlePath = projectManager.getCurrentProjectPath() + File.separator + ProjectManager.PARTICLE_DIR_PATH + File.separator;
|
||||
String filePath = particlePath + name;
|
||||
|
||||
@@ -175,10 +175,10 @@ public class ParticleEffectAsset extends Asset {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteEntitiesWithParticleEffects(Entity rootEntity, String particleName) {
|
||||
private void deleteEntitiesWithParticleEffects(int rootEntity, String particleName) {
|
||||
tmpEntityList.clear();
|
||||
Consumer<Entity> action = (root) -> {
|
||||
ParticleComponent particleComponent = ComponentRetriever.get(root, ParticleComponent.class);
|
||||
Consumer<Integer> action = (root) -> {
|
||||
ParticleComponent particleComponent = SandboxComponentRetriever.get(root, ParticleComponent.class);
|
||||
if (particleComponent != null && particleComponent.particleName.equals(particleName)) {
|
||||
tmpEntityList.add(root);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import games.rednblack.editor.proxy.ProjectManager;
|
||||
@@ -53,7 +52,7 @@ public class ShaderAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -18,6 +17,7 @@ import games.rednblack.editor.utils.HyperLap2DUtils;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
import games.rednblack.h2d.extention.spine.SpineItemType;
|
||||
@@ -77,7 +77,7 @@ public class SpineAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String spineName) {
|
||||
public boolean deleteAsset(int root, String spineName) {
|
||||
for (ResolutionEntryVO resolutionEntryVO : projectManager.getCurrentProjectInfoVO().resolutions) {
|
||||
if(!deleteSpineAnimation(resolutionEntryVO.name, spineName))
|
||||
return false;
|
||||
@@ -205,7 +205,7 @@ public class SpineAsset extends Asset {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void postDeleteSpineAnimation(Entity root, String spineAnimationName) {
|
||||
protected void postDeleteSpineAnimation(int root, String spineAnimationName) {
|
||||
deleteEntitiesWithSpineAnimation(root, spineAnimationName);
|
||||
deleteAllItemsSpineAnimations(spineAnimationName);
|
||||
}
|
||||
@@ -233,10 +233,10 @@ public class SpineAsset extends Asset {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteEntitiesWithSpineAnimation(Entity rootEntity, String spineName) {
|
||||
private void deleteEntitiesWithSpineAnimation(int rootEntity, String spineName) {
|
||||
tmpEntityList.clear();
|
||||
Consumer<Entity> action = (root) -> {
|
||||
SpineDataComponent spineDataComponent = ComponentRetriever.get(root, SpineDataComponent.class);
|
||||
Consumer<Integer> action = (root) -> {
|
||||
SpineDataComponent spineDataComponent = SandboxComponentRetriever.get(root, SpineDataComponent.class);
|
||||
if (spineDataComponent != null && spineDataComponent.animationName.equals(spineName)) {
|
||||
tmpEntityList.add(root);
|
||||
}
|
||||
|
||||
+7
-6
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -13,6 +12,8 @@ import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -101,7 +102,7 @@ public class SpriteAnimationAtlasAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
for (ResolutionEntryVO resolutionEntryVO : projectManager.getCurrentProjectInfoVO().resolutions) {
|
||||
if(!deleteSpriteAnimation(resolutionEntryVO.name, name))
|
||||
return false;
|
||||
@@ -128,7 +129,7 @@ public class SpriteAnimationAtlasAsset extends Asset {
|
||||
return ImportUtils.deleteDirectory(filePath);
|
||||
}
|
||||
|
||||
protected void postDeleteSpriteAnimation(Entity root, String spriteAnimationName) {
|
||||
protected void postDeleteSpriteAnimation(int root, String spriteAnimationName) {
|
||||
deleteEntitiesWithSpriteAnimation(root, spriteAnimationName);
|
||||
deleteAllItemsSpriteAnimations(spriteAnimationName);
|
||||
}
|
||||
@@ -158,10 +159,10 @@ public class SpriteAnimationAtlasAsset extends Asset {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteEntitiesWithSpriteAnimation(Entity rootEntity, String spriteAnimationName) {
|
||||
private void deleteEntitiesWithSpriteAnimation(int rootEntity, String spriteAnimationName) {
|
||||
tmpEntityList.clear();
|
||||
Consumer<Entity> action = (root) -> {
|
||||
SpriteAnimationComponent spriteAnimationComponent = ComponentRetriever.get(root, SpriteAnimationComponent.class);
|
||||
Consumer<Integer> action = (root) -> {
|
||||
SpriteAnimationComponent spriteAnimationComponent = SandboxComponentRetriever.get(root, SpriteAnimationComponent.class);
|
||||
if (spriteAnimationComponent != null && spriteAnimationComponent.animationName.equals(spriteAnimationName)) {
|
||||
tmpEntityList.add(root);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package games.rednblack.editor.utils.asset.impl;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
@@ -15,6 +14,7 @@ import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
import games.rednblack.editor.utils.ImportUtils;
|
||||
import games.rednblack.editor.utils.asset.Asset;
|
||||
import games.rednblack.editor.utils.runtime.EntityUtils;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.editor.utils.runtime.TalosResources;
|
||||
import games.rednblack.editor.view.stage.Sandbox;
|
||||
import games.rednblack.h2d.common.ProgressHandler;
|
||||
@@ -115,7 +115,7 @@ public class TalosVFXAsset extends Asset {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAsset(Entity root, String name) {
|
||||
public boolean deleteAsset(int root, String name) {
|
||||
String particlePath = projectManager.getCurrentProjectPath() + File.separator + ProjectManager.TALOS_VFX_DIR_PATH + File.separator;
|
||||
String filePath = particlePath + name;
|
||||
|
||||
@@ -217,10 +217,10 @@ public class TalosVFXAsset extends Asset {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteEntitiesWithParticleEffects(Entity rootEntity, String particleName) {
|
||||
private void deleteEntitiesWithParticleEffects(int rootEntity, String particleName) {
|
||||
tmpEntityList.clear();
|
||||
Consumer<Entity> action = (root) -> {
|
||||
TalosDataComponent particleComponent = ComponentRetriever.get(root, TalosDataComponent.class);
|
||||
Consumer<Integer> action = (root) -> {
|
||||
TalosDataComponent particleComponent = SandboxComponentRetriever.get(root, TalosDataComponent.class);
|
||||
if (particleComponent != null && particleComponent.particleName.equals(particleName)) {
|
||||
tmpEntityList.add(root);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.badlogic.ashley.core.Component;
|
||||
import com.artemis.Component;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package games.rednblack.editor.utils.runtime;
|
||||
|
||||
import com.badlogic.ashley.core.Component;
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.ashley.core.Family;
|
||||
import com.badlogic.ashley.core.PooledEngine;
|
||||
import com.badlogic.ashley.utils.ImmutableArray;
|
||||
import com.artemis.Aspect;
|
||||
import com.artemis.Component;
|
||||
import com.artemis.EntitySubscription;
|
||||
import com.artemis.utils.IntBag;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -75,12 +74,12 @@ public class EntityUtils {
|
||||
itemTypeIconMap.put(TALOS_TYPE, "icon-particle-white");
|
||||
}
|
||||
|
||||
public static String getItemName(Entity entity) {
|
||||
ParentNodeComponent parentNodeComponent = ComponentRetriever.get(entity, ParentNodeComponent.class);
|
||||
public static String getItemName(int entity) {
|
||||
ParentNodeComponent parentNodeComponent = SandboxComponentRetriever.get(entity, ParentNodeComponent.class);
|
||||
if (parentNodeComponent == null)
|
||||
return Sandbox.getInstance().sceneControl.getCurrentSceneVO().sceneName;
|
||||
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
if (mainItemComponent.itemIdentifier != null && !mainItemComponent.itemIdentifier.isEmpty()) {
|
||||
return mainItemComponent.itemIdentifier;
|
||||
} else {
|
||||
@@ -93,21 +92,21 @@ public class EntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getItemIcon(Entity entity) {
|
||||
public static Drawable getItemIcon(int entity) {
|
||||
int type = EntityUtils.getType(entity);
|
||||
String icon = itemTypeIconMap.get(type);
|
||||
return VisUI.getSkin().getDrawable(icon);
|
||||
}
|
||||
|
||||
public static Integer getEntityId(Entity entity) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
public static Integer getEntityId(int entity) {
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
return mainItemComponent.uniqueId;
|
||||
}
|
||||
|
||||
public static Array<Integer> getEntityId(Iterable<Entity> entities) {
|
||||
public static Array<Integer> getEntityId(Iterable<Integer> entities) {
|
||||
Array<Integer> entityIds = new Array<>();
|
||||
for (Entity entity : entities) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
for (int entity : entities) {
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
if (mainItemComponent != null)
|
||||
entityIds.add(mainItemComponent.uniqueId);
|
||||
}
|
||||
@@ -115,23 +114,23 @@ public class EntityUtils {
|
||||
return entityIds;
|
||||
}
|
||||
|
||||
public static Entity getByUniqueId(Integer id) {
|
||||
public static int getByUniqueId(Integer id) {
|
||||
return Sandbox.getInstance().getSceneControl().sceneLoader.getEntityFactory().getEntityByUniqueId(id);
|
||||
}
|
||||
|
||||
public static HashSet<Entity> getByUniqueId(Array<Integer> ids) {
|
||||
HashSet<Entity> entities = new HashSet<>();
|
||||
public static HashSet<Integer> getByUniqueId(Array<Integer> ids) {
|
||||
HashSet<Integer> entities = new HashSet<>();
|
||||
for (Integer id : ids) {
|
||||
Entity entity = Sandbox.getInstance().getSceneControl().sceneLoader.getEntityFactory().getEntityByUniqueId(id);
|
||||
Integer entity = Sandbox.getInstance().getSceneControl().sceneLoader.getEntityFactory().getEntityByUniqueId(id);
|
||||
entities.add(entity);
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, Collection<Component>> cloneEntities(Set<Entity> entities) {
|
||||
/*public static HashMap<Integer, Collection<Component>> cloneEntities(Set<Integer> entities) {
|
||||
HashMap<Integer, Collection<Component>> data = new HashMap<>();
|
||||
|
||||
for (Entity entity : entities) {
|
||||
for (int entity : entities) {
|
||||
Collection<Component> components = cloneEntityComponents(entity);
|
||||
data.put(EntityUtils.getEntityId(entity), components);
|
||||
}
|
||||
@@ -139,51 +138,51 @@ public class EntityUtils {
|
||||
return data;
|
||||
}
|
||||
|
||||
public static Entity cloneEntity(PooledEngine engine, Entity entity) {
|
||||
Entity newEntity = engine.createEntity();
|
||||
public static int cloneEntity(com.artemis.World engine, int entity) {
|
||||
int newEntity = engine.create();
|
||||
Collection<Component> components = cloneEntityComponents(entity);
|
||||
for (Component component : components) {
|
||||
Component c = engine.createComponent(component.getClass());
|
||||
Component c = engine.edit(newEntity).create(component.getClass());
|
||||
ComponentCloner.set(c, component);
|
||||
newEntity.add(component);
|
||||
}
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
public static Collection<Component> cloneEntityComponents(Entity entity) {
|
||||
Collection<Component> components = ComponentCloner.cloneAll(ComponentRetriever.getComponents(entity));
|
||||
public static Collection<Component> cloneEntityComponents(int entity) {
|
||||
Array<Component> array = new Array<>();
|
||||
Collection<Component> components = ComponentCloner.cloneAll(ComponentRetriever.getComponents(entity, array));
|
||||
return components;
|
||||
}
|
||||
}*/
|
||||
|
||||
public static Vector2 getPosition(Entity entity) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
public static Vector2 getPosition(int entity) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
return new Vector2(transformComponent.x, transformComponent.y);
|
||||
}
|
||||
|
||||
public static void getPosition(Entity entity, Vector2 position) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
public static void getPosition(int entity, Vector2 position) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
position.set(transformComponent.x, transformComponent.y);
|
||||
}
|
||||
|
||||
public static TransformComponent setPosition(Entity entity, Vector2 position) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
public static TransformComponent setPosition(int entity, Vector2 position) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
transformComponent.x = position.x;
|
||||
transformComponent.y = position.y;
|
||||
return transformComponent;
|
||||
}
|
||||
|
||||
public static Vector2 getSize(Entity entity) {
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
public static Vector2 getSize(int entity) {
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
return new Vector2(dimensionsComponent.width, dimensionsComponent.height);
|
||||
}
|
||||
|
||||
public static void getSize(Entity entity, Vector2 size) {
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
public static void getSize(int entity, Vector2 size) {
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
size.set(dimensionsComponent.width, dimensionsComponent.height);
|
||||
}
|
||||
|
||||
public static DimensionsComponent setSize(Entity entity, Vector2 size) {
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
public static DimensionsComponent setSize(int entity, Vector2 size) {
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
dimensionsComponent.width = size.x;
|
||||
dimensionsComponent.height = size.y;
|
||||
if (dimensionsComponent.boundBox != null) {
|
||||
@@ -193,14 +192,14 @@ public class EntityUtils {
|
||||
return dimensionsComponent;
|
||||
}
|
||||
|
||||
public static Vector2 getRightTopPoint(Set<Entity> entities) {
|
||||
public static Vector2 getRightTopPoint(Set<Integer> entities) {
|
||||
if (entities.size() == 0) return null;
|
||||
|
||||
Vector2 rightTopPoint = getPosition(entities.stream().findFirst().get());
|
||||
|
||||
for (Entity entity : entities) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = ComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
for (int entity : entities) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
DimensionsComponent dimensionsComponent = SandboxComponentRetriever.get(entity, DimensionsComponent.class);
|
||||
|
||||
if (rightTopPoint.x < transformComponent.x + dimensionsComponent.width) {
|
||||
rightTopPoint.x = transformComponent.x + dimensionsComponent.width;
|
||||
@@ -213,13 +212,13 @@ public class EntityUtils {
|
||||
return rightTopPoint;
|
||||
}
|
||||
|
||||
public static Vector2 getLeftBottomPoint(Set<Entity> entities) {
|
||||
public static Vector2 getLeftBottomPoint(Set<Integer> entities) {
|
||||
if (entities.size() == 0) return null;
|
||||
|
||||
Vector2 leftBottomPoint = getPosition(entities.stream().findFirst().get());
|
||||
|
||||
for (Entity entity : entities) {
|
||||
TransformComponent transformComponent = ComponentRetriever.get(entity, TransformComponent.class);
|
||||
for (int entity : entities) {
|
||||
TransformComponent transformComponent = SandboxComponentRetriever.get(entity, TransformComponent.class);
|
||||
if (leftBottomPoint.x > transformComponent.x) {
|
||||
leftBottomPoint.x = transformComponent.x;
|
||||
}
|
||||
@@ -231,16 +230,16 @@ public class EntityUtils {
|
||||
return leftBottomPoint;
|
||||
}
|
||||
|
||||
public static void changeParent(HashSet<Entity> entities, Entity parent) {
|
||||
for (Entity entity : entities) {
|
||||
ParentNodeComponent parentNodeComponent = ComponentRetriever.get(entity, ParentNodeComponent.class);
|
||||
public static void changeParent(HashSet<Integer> entities, int parent) {
|
||||
for (int entity : entities) {
|
||||
ParentNodeComponent parentNodeComponent = SandboxComponentRetriever.get(entity, ParentNodeComponent.class);
|
||||
|
||||
//remove me from previous parent children list
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(parentNodeComponent.parentEntity, NodeComponent.class);
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(parentNodeComponent.parentEntity, NodeComponent.class);
|
||||
nodeComponent.children.removeValue(entity, true);
|
||||
|
||||
//add me to new parent child list
|
||||
NodeComponent rootNodeComponent = ComponentRetriever.get(parent, NodeComponent.class);
|
||||
NodeComponent rootNodeComponent = SandboxComponentRetriever.get(parent, NodeComponent.class);
|
||||
rootNodeComponent.children.add(entity);
|
||||
|
||||
//change my parent
|
||||
@@ -248,29 +247,31 @@ public class EntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static HashSet<Entity> getChildren(Entity entity) {
|
||||
HashSet<Entity> entities;
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(entity, NodeComponent.class);
|
||||
public static HashSet<Integer> getChildren(int entity) {
|
||||
HashSet<Integer> entities;
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(entity, NodeComponent.class);
|
||||
if (nodeComponent == null)
|
||||
return null;
|
||||
Entity[] children = nodeComponent.children.toArray();
|
||||
Integer[] children = nodeComponent.children.toArray();
|
||||
entities = new HashSet<>(Arrays.asList(children));
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public static int getType(Entity entity) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
public static int getType(int entity) {
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(entity, MainItemComponent.class);
|
||||
if (mainItemComponent == null)
|
||||
return UNKNOWN_TYPE;
|
||||
return mainItemComponent.entityType;
|
||||
}
|
||||
|
||||
public static Array<Entity> getByLibraryLink(String link) {
|
||||
Array<Entity> result = new Array<>();
|
||||
ImmutableArray<Entity> composites = Sandbox.getInstance().getEngine().getEntitiesFor(Family.all(NodeComponent.class).get());
|
||||
for (Entity composite : composites) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(composite, MainItemComponent.class);
|
||||
public static Array<Integer> getByLibraryLink(String link) {
|
||||
Array<Integer> result = new Array<>();
|
||||
EntitySubscription subscription = Sandbox.getInstance().getEngine().getAspectSubscriptionManager()
|
||||
.get(Aspect.all(NodeComponent.class));
|
||||
IntBag composites = subscription.getEntities();
|
||||
for (int composite : composites.getData()) {
|
||||
MainItemComponent mainItemComponent = SandboxComponentRetriever.get(composite, MainItemComponent.class);
|
||||
if (mainItemComponent.libraryLink.equals(link)) {
|
||||
result.add(composite);
|
||||
}
|
||||
@@ -279,23 +280,9 @@ public class EntityUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void reInstantiateChildren(Entity entity) {
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(entity, NodeComponent.class);
|
||||
if (nodeComponent != null) {
|
||||
CompositeVO compositeVo = new CompositeVO();
|
||||
compositeVo.loadFromEntity(entity);
|
||||
|
||||
entity.remove(NodeComponent.class);
|
||||
entity.add(new NodeComponent());
|
||||
|
||||
SceneLoader sceneLoader = Sandbox.getInstance().getSceneControl().sceneLoader;
|
||||
sceneLoader.getEntityFactory().initAllChildren(Sandbox.getInstance().getEngine(), entity, compositeVo);
|
||||
}
|
||||
}
|
||||
|
||||
public static LayerItemVO getEntityLayer(Entity entity) {
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
LayerMapComponent layerMapComponent = ComponentRetriever.get(entity.getComponent(ParentNodeComponent.class).parentEntity, LayerMapComponent.class);
|
||||
public static LayerItemVO getEntityLayer(int entity) {
|
||||
ZIndexComponent zIndexComponent = SandboxComponentRetriever.get(entity, ZIndexComponent.class);
|
||||
LayerMapComponent layerMapComponent = SandboxComponentRetriever.get(SandboxComponentRetriever.get(entity, ParentNodeComponent.class).parentEntity, LayerMapComponent.class);
|
||||
|
||||
return layerMapComponent.getLayer(zIndexComponent.layerName);
|
||||
}
|
||||
@@ -306,11 +293,11 @@ public class EntityUtils {
|
||||
* @param root
|
||||
* @param action
|
||||
*/
|
||||
public static void applyActionRecursivelyOnEntities(Entity root, Consumer<Entity> action) {
|
||||
public static void applyActionRecursivelyOnEntities(int root, Consumer<Integer> action) {
|
||||
action.accept(root);
|
||||
NodeComponent nodeComponent = ComponentRetriever.get(root, NodeComponent.class);
|
||||
NodeComponent nodeComponent = SandboxComponentRetriever.get(root, NodeComponent.class);
|
||||
if (nodeComponent != null && nodeComponent.children != null) {
|
||||
for (Entity targetEntity : nodeComponent.children) {
|
||||
for (int targetEntity : nodeComponent.children) {
|
||||
applyActionRecursivelyOnEntities(targetEntity, action);
|
||||
}
|
||||
}
|
||||
@@ -325,30 +312,31 @@ public class EntityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeEntities(ArrayList<Entity> entityList) {
|
||||
for (Entity entity : entityList) {
|
||||
Sandbox.getInstance().getEngine().removeEntity(entity);
|
||||
public static void removeEntities(ArrayList<Integer> entityList) {
|
||||
for (int entity : entityList) {
|
||||
Sandbox.getInstance().getEngine().delete(entity);
|
||||
}
|
||||
Sandbox.getInstance().getEngine().process();
|
||||
}
|
||||
|
||||
public static void refreshComponents(Entity entity) {
|
||||
TextureRegionComponent textureRegionComponent = ComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
public static void refreshComponents(int entity) {
|
||||
TextureRegionComponent textureRegionComponent = SandboxComponentRetriever.get(entity, TextureRegionComponent.class);
|
||||
if (textureRegionComponent != null) {
|
||||
textureRegionComponent.scheduleRefresh();
|
||||
}
|
||||
|
||||
PhysicsBodyComponent physicsBodyComponent = ComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
PhysicsBodyComponent physicsBodyComponent = SandboxComponentRetriever.get(entity, PhysicsBodyComponent.class);
|
||||
if (physicsBodyComponent != null) {
|
||||
physicsBodyComponent.scheduleRefresh();
|
||||
}
|
||||
|
||||
LightBodyComponent lightBodyComponent = ComponentRetriever.get(entity, LightBodyComponent.class);
|
||||
LightBodyComponent lightBodyComponent = SandboxComponentRetriever.get(entity, LightBodyComponent.class);
|
||||
if (lightBodyComponent != null) {
|
||||
lightBodyComponent.scheduleRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
public static Entity getEntityFromJson(String jsonString, int entityType, EntityFactory factory, Entity parent) {
|
||||
public static int getEntityFromJson(String jsonString, int entityType, EntityFactory factory, int parent) {
|
||||
Json json = new Json();
|
||||
if(entityType == EntityFactory.COMPOSITE_TYPE) {
|
||||
CompositeItemVO vo = json.fromJson(CompositeItemVO.class, jsonString);
|
||||
@@ -390,117 +378,119 @@ public class EntityUtils {
|
||||
LightVO vo = json.fromJson(LightVO.class, jsonString);
|
||||
return factory.createEntity(parent, vo);
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static String getJsonStringFromEntity(Entity entity) {
|
||||
public static String getJsonStringFromEntity(int entity) {
|
||||
Json json = new Json();
|
||||
int entityType = ComponentRetriever.get(entity, MainItemComponent.class).entityType;
|
||||
com.artemis.World engine = Sandbox.getInstance().getEngine();
|
||||
int entityType = SandboxComponentRetriever.get(entity, MainItemComponent.class).entityType;
|
||||
if(entityType == EntityFactory.COMPOSITE_TYPE) {
|
||||
CompositeItemVO vo = new CompositeItemVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.IMAGE_TYPE) {
|
||||
SimpleImageVO vo = new SimpleImageVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.NINE_PATCH) {
|
||||
Image9patchVO vo = new Image9patchVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LABEL_TYPE) {
|
||||
LabelVO vo = new LabelVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.PARTICLE_TYPE) {
|
||||
ParticleEffectVO vo = new ParticleEffectVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.TALOS_TYPE) {
|
||||
TalosVO vo = new TalosVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPRITE_TYPE) {
|
||||
SpriteAnimationVO vo = new SpriteAnimationVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPINE_TYPE) {
|
||||
SpineVO vo = new SpineVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.COLOR_PRIMITIVE) {
|
||||
ColorPrimitiveVO vo = new ColorPrimitiveVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LIGHT_TYPE) {
|
||||
LightVO vo = new LightVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
return json.toJson(vo);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getJsonStringFromEntities(Set<Entity> entities) {
|
||||
public static String getJsonStringFromEntities(Set<Integer> entities) {
|
||||
CompositeVO holderComposite = new CompositeVO();
|
||||
for(Entity entity : entities) {
|
||||
int entityType = ComponentRetriever.get(entity, MainItemComponent.class).entityType;
|
||||
com.artemis.World engine = Sandbox.getInstance().getEngine();
|
||||
for(int entity : entities) {
|
||||
int entityType = SandboxComponentRetriever.get(entity, MainItemComponent.class).entityType;
|
||||
if(entityType == EntityFactory.COMPOSITE_TYPE) {
|
||||
CompositeItemVO vo = new CompositeItemVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sComposites.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.IMAGE_TYPE) {
|
||||
SimpleImageVO vo = new SimpleImageVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sImages.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.NINE_PATCH) {
|
||||
Image9patchVO vo = new Image9patchVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sImage9patchs.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LABEL_TYPE) {
|
||||
LabelVO vo = new LabelVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sLabels.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.PARTICLE_TYPE) {
|
||||
ParticleEffectVO vo = new ParticleEffectVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sParticleEffects.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.TALOS_TYPE) {
|
||||
TalosVO vo = new TalosVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sTalosVFX.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPRITE_TYPE) {
|
||||
SpriteAnimationVO vo = new SpriteAnimationVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sSpriteAnimations.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.SPINE_TYPE) {
|
||||
SpineVO vo = new SpineVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sSpineAnimations.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.COLOR_PRIMITIVE) {
|
||||
ColorPrimitiveVO vo = new ColorPrimitiveVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sColorPrimitives.add(vo);
|
||||
}
|
||||
if(entityType == EntityFactory.LIGHT_TYPE) {
|
||||
LightVO vo = new LightVO();
|
||||
vo.loadFromEntity(entity);
|
||||
vo.loadFromEntity(entity, engine);
|
||||
holderComposite.sLights.add(vo);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user