Remove RemovableObject class
This commit is contained in:
Submodule h2d-libgdx-typinglabel-extension updated: c2690a20e9...345ceda938
Submodule hyperlap2d-runtime-libgdx updated: e6ff3a644f...c01a5e40d4
@@ -76,6 +76,7 @@ public class DeleteItemsCommand extends EntityModifyRevertibleCommand {
|
||||
public void undoAction() {
|
||||
Json json = HyperJson.getJson();
|
||||
CompositeItemVO compositeVO = json.fromJson(CompositeItemVO.class, backup);
|
||||
compositeVO.cleanIds();
|
||||
Set<Integer> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);
|
||||
|
||||
sandbox.getEngine().process();
|
||||
|
||||
+1
-5
@@ -2,7 +2,6 @@ package games.rednblack.editor.controller.commands;
|
||||
|
||||
import com.artemis.Component;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.RemovableObject;
|
||||
import games.rednblack.editor.utils.runtime.ComponentCloner;
|
||||
import games.rednblack.editor.utils.runtime.SandboxComponentRetriever;
|
||||
import games.rednblack.h2d.common.MsgAPI;
|
||||
@@ -23,15 +22,12 @@ public class RemoveComponentFromItemCommand extends EntityModifyRevertibleComman
|
||||
Object[] payload = getNotification().getBody();
|
||||
entity = (int) payload[0];
|
||||
componentClass = (Class<? extends Component>) payload[1];
|
||||
component = ComponentCloner.get(SandboxComponentRetriever.get(entity, componentClass));
|
||||
component = ComponentCloner.get(SandboxComponentRetriever.get(entity, componentClass), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction() {
|
||||
collectData();
|
||||
if (component instanceof RemovableObject) {
|
||||
((RemovableObject) component).onRemove();
|
||||
}
|
||||
sandbox.getEngine().edit(entity).remove(component.getClass());
|
||||
sandbox.getEngine().process();
|
||||
|
||||
|
||||
-4
@@ -43,8 +43,6 @@ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand {
|
||||
sensorComponent.rightSpanPercent = vo.rightSpanPercent;
|
||||
sensorComponent.topSpanPercent = vo.topSpanPercent;
|
||||
|
||||
sensorComponent.scheduleRefresh();
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
@@ -62,8 +60,6 @@ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand {
|
||||
sensorComponent.leftSpanPercent = backup.leftSpanPercent;
|
||||
sensorComponent.rightSpanPercent = backup.rightSpanPercent;
|
||||
sensorComponent.topSpanPercent = backup.topSpanPercent;
|
||||
|
||||
sensorComponent.scheduleRefresh();
|
||||
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Collection;
|
||||
*/
|
||||
public class ComponentCloner {
|
||||
|
||||
public static <E extends Component> E get(E source) {
|
||||
public static <E extends Component> E get(E source, boolean ignoreTransient) {
|
||||
Class<?> eClass = source.getClass();
|
||||
E target = null;
|
||||
try {
|
||||
@@ -42,6 +42,9 @@ public class ComponentCloner {
|
||||
for(int i = 0; i < targetFields.length; i++) {
|
||||
int modifiers = targetFields[i].getModifiers();
|
||||
if(Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers)) {
|
||||
if (ignoreTransient && Modifier.isTransient(modifiers))
|
||||
continue;
|
||||
|
||||
targetFields[i].set(target, sourceFields[i].get(source));
|
||||
}
|
||||
}
|
||||
@@ -51,6 +54,9 @@ public class ComponentCloner {
|
||||
|
||||
return target;
|
||||
}
|
||||
public static <E extends Component> E get(E source) {
|
||||
return get(source, false);
|
||||
}
|
||||
|
||||
|
||||
public static <E extends Component> void set(E target, E source) {
|
||||
|
||||
Reference in New Issue
Block a user