mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-08-27 17:57:22 -04:00
Fixed character creation script, more work on cloning, added java sui callbacks
This commit is contained in:
@@ -264,7 +264,7 @@ public class CharacterService implements INetworkDispatch {
|
||||
object._add(weapon);
|
||||
object.setWeaponId(weapon.getObjectID());
|
||||
|
||||
core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", object);
|
||||
core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", core, object);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
package services;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -37,10 +39,14 @@ import resources.common.FileUtilities;
|
||||
import resources.common.Opcodes;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import services.sui.SUIService.ListBoxType;
|
||||
import services.sui.SUIWindow;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
@@ -180,6 +186,28 @@ public class PlayerService implements INetworkDispatch {
|
||||
core.scriptService.callScript("scripts/expertise/", "addExpertisePoint", expertiseBox, core, creature);
|
||||
|
||||
}
|
||||
|
||||
public void sendCloningWindow(CreatureObject creature) {
|
||||
|
||||
//if(creature.getPosture() != 14)
|
||||
// return;
|
||||
|
||||
List<SWGObject> cloners = core.staticService.getCloningFacilitiesByPlanet(creature.getPlanet());
|
||||
Vector<String> cloneData = new Vector<String>();
|
||||
Point3D position = creature.getWorldPosition();
|
||||
|
||||
for(SWGObject cloner : cloners) {
|
||||
|
||||
cloneData.add(core.mapService.getClosestCityName(cloner) + " (" + String.valueOf(position.getDistance2D(cloner.getPosition())) + "m)");
|
||||
|
||||
}
|
||||
|
||||
SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@base_player:revive_title", "@base_player:revive_closest : " + "\n" + "@base_player:revive_bind : " + "\n" + "Cash Balance : " + creature.getCashCredits() + "\n" + "Select the desired option and click OK.",
|
||||
cloneData, creature, null, 0);
|
||||
|
||||
core.suiService.openSUIWindow(window);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
@@ -548,6 +548,7 @@ public class SimulationService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void transferToPlanet(SWGObject object, Planet planet, Point3D newPos, Quaternion newOrientation) {
|
||||
|
||||
@@ -21,8 +21,12 @@
|
||||
******************************************************************************/
|
||||
package services;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import resources.objects.building.BuildingObject;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
@@ -95,5 +99,19 @@ public class StaticService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<SWGObject> getCloningFacilitiesByPlanet(Planet planet) {
|
||||
|
||||
List<SWGObject> objects = core.simulationService.get(planet, 0, 0, 8300);
|
||||
List<SWGObject> cloners = new ArrayList<SWGObject>();
|
||||
|
||||
for(SWGObject obj : objects) {
|
||||
if(obj instanceof BuildingObject && (obj.getTemplate().contains("cloning_facility") || obj.getTemplate().contains("cloning_tatooine") || obj.getTemplate().contains("cloning_naboo") || obj.getTemplate().contains("cloning_corellia")))
|
||||
cloners.add(obj);
|
||||
}
|
||||
|
||||
return cloners;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Grid2D;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
@@ -113,4 +114,27 @@ public class MapService implements INetworkDispatch {
|
||||
locationMap.get(planet).add(location);
|
||||
}
|
||||
|
||||
public String getClosestCityName(SWGObject object) {
|
||||
|
||||
Vector<MapLocation> locations = locationMap.get(object.getPlanet());
|
||||
float closestDistance = Float.MAX_VALUE;
|
||||
String closestName = "";
|
||||
Point3D objPos = object.getWorldPosition();
|
||||
|
||||
for(MapLocation location : locations) {
|
||||
|
||||
if(location.getCategory() == 17) {
|
||||
Point3D position = new Point3D(location.getX(), 0, location.getY());
|
||||
if(position.getDistance2D(objPos) < closestDistance) {
|
||||
closestDistance = position.getDistance2D(objPos);
|
||||
closestName = location.getName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return closestName;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import protocol.swg.objectControllerObjects.ObjectMenuResponse;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
import resources.common.Opcodes;
|
||||
import resources.common.RadialOptions;
|
||||
import services.sui.SUIWindow.SUICallback;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
@@ -152,6 +153,9 @@ public class SUIService implements INetworkDispatch {
|
||||
|
||||
func.__call__(Py.java2py(core), Py.java2py(owner), Py.java2py(suiEvent.getEventType()), Py.java2py(suiEvent.getReturnList()));
|
||||
|
||||
SUICallback callback = window.getCallbackByEventId(suiEvent.getEventType());
|
||||
callback.process(owner, suiEvent.getEventType(), suiEvent.getReturnList());
|
||||
|
||||
windowMap.remove(window.getWindowId());
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class SUIWindow {
|
||||
private float maxDistance = 0;
|
||||
private Vector<SUIWindowComponent> components = new Vector<SUIWindowComponent>();
|
||||
private Map<Integer, PyObject> callbacks = new ConcurrentHashMap<Integer, PyObject>();
|
||||
private Map<Integer, SUICallback> javaCallbacks = new ConcurrentHashMap<Integer, SUICallback>();
|
||||
|
||||
|
||||
public SUIWindow(String script, SWGObject owner, int windowId, SWGObject rangeObject, float maxDistance) {
|
||||
@@ -114,6 +115,30 @@ public class SUIWindow {
|
||||
|
||||
}
|
||||
|
||||
public void addHandler(int eventId, String source, byte trigger, Vector<String> returnParams, SUICallback handleFunc) {
|
||||
|
||||
SUIWindowComponent component = new SUIWindowComponent();
|
||||
component.setType((byte) 5);
|
||||
|
||||
component.getNarrowParams().add(source);
|
||||
|
||||
component.getNarrowParams().add(new String(new byte[] { trigger }));
|
||||
component.getNarrowParams().add("handleSUI");
|
||||
|
||||
for(String returnParam : returnParams) {
|
||||
|
||||
for(String str : returnParam.split(":")) {
|
||||
component.getNarrowParams().add(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
components.add(component);
|
||||
javaCallbacks.put(eventId, handleFunc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addDataSource(String name, String value) {
|
||||
|
||||
SUIWindowComponent component = new SUIWindowComponent();
|
||||
@@ -178,12 +203,27 @@ public class SUIWindow {
|
||||
return callbacks.get(eventId);
|
||||
}
|
||||
|
||||
public Map<Integer, SUICallback> getJavaCallbacks() {
|
||||
return javaCallbacks;
|
||||
}
|
||||
|
||||
public SUICallback getCallbackByEventId(int eventId) {
|
||||
return javaCallbacks.get(eventId);
|
||||
}
|
||||
|
||||
|
||||
public enum Trigger {;
|
||||
public static byte TRIGGER_UPDATE = 4;
|
||||
public static byte TRIGGER_OK = 9;
|
||||
public static byte TRIGGER_CANCEL = 10;
|
||||
|
||||
}
|
||||
|
||||
public interface SUICallback {
|
||||
|
||||
public void process(SWGObject owner, int eventType, Vector<String> returnList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class SUIWindowComponent {
|
||||
private byte type;
|
||||
private Vector<String> narrowParams = new Vector<String>();
|
||||
private Vector<String> wideParams = new Vector<String>();
|
||||
private long objectId;
|
||||
|
||||
public byte getType() {
|
||||
return type;
|
||||
@@ -47,6 +48,12 @@ public class SUIWindowComponent {
|
||||
public void setWideParams(Vector<String> wideParams) {
|
||||
this.wideParams = wideParams;
|
||||
}
|
||||
public long getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
public void setObjectId(long objectId) {
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user