mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-11 21:45:43 -04:00
Merge branch 'master' of https://github.com/ProjectSWGCore/NGECore2
This commit is contained in:
@@ -55,6 +55,7 @@ import services.SkillService;
|
||||
import services.StaticService;
|
||||
import services.TerrainService;
|
||||
import services.WeatherService;
|
||||
import services.ai.AIService;
|
||||
import services.chat.ChatService;
|
||||
import services.collections.CollectionService;
|
||||
import services.combat.CombatService;
|
||||
@@ -66,6 +67,7 @@ import services.guild.GuildService;
|
||||
import services.map.MapService;
|
||||
import services.object.ObjectService;
|
||||
import services.object.UpdateService;
|
||||
import services.spawn.SpawnService;
|
||||
import services.sui.SUIService;
|
||||
import services.trade.TradeService;
|
||||
import services.travel.TravelService;
|
||||
@@ -140,6 +142,8 @@ public class NGECore {
|
||||
public CollectionService collectionService;
|
||||
public EntertainmentService entertainmentService;
|
||||
public WeatherService weatherService;
|
||||
public SpawnService spawnService;
|
||||
public AIService aiService;
|
||||
|
||||
// Login Server
|
||||
public NetworkDispatch loginDispatch;
|
||||
@@ -214,7 +218,8 @@ public class NGECore {
|
||||
skillModService = new SkillModService(this);
|
||||
equipmentService = new EquipmentService(this);
|
||||
entertainmentService = new EntertainmentService(this);
|
||||
|
||||
spawnService = new SpawnService(this);
|
||||
aiService = new AIService(this);
|
||||
|
||||
// Ping Server
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package resources.common;
|
||||
|
||||
public class TerminalType {
|
||||
public static int MISSION_GENERIC = 1;
|
||||
public static int MISSION_BOUNTYHUNTER = 2;
|
||||
public static int MISSION_ENTERTAINER = 3;
|
||||
public static int MISSION_ARTISAN = 4;
|
||||
public static int MISSION_EXPLORER = 5;
|
||||
}
|
||||
@@ -24,10 +24,12 @@ package resources.common.collidables;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
import net.engio.mbassy.bus.SyncMessageBus;
|
||||
|
||||
import org.python.core.Py;
|
||||
import org.python.core.PyObject;
|
||||
|
||||
import engine.resources.common.Event;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -37,6 +39,7 @@ public abstract class AbstractCollidable {
|
||||
private PyObject callback;
|
||||
public Vector<SWGObject> collidedObjects = new Vector<SWGObject>();
|
||||
private Planet planet;
|
||||
private SyncMessageBus<Event> eventBus = new SyncMessageBus<Event>(NGECore.getInstance().getEventBusConfig());
|
||||
|
||||
public abstract boolean doesCollide(SWGObject obj);
|
||||
public abstract boolean doesCollide(Point3D position);
|
||||
@@ -51,10 +54,16 @@ public abstract class AbstractCollidable {
|
||||
|
||||
public void addCollidedObject(SWGObject obj) {
|
||||
collidedObjects.add(obj);
|
||||
EnterEvent event = new EnterEvent();
|
||||
event.object = obj;
|
||||
eventBus.publish(event);
|
||||
}
|
||||
|
||||
public void removeCollidedObject(SWGObject obj) {
|
||||
collidedObjects.remove(obj);
|
||||
ExitEvent event = new ExitEvent();
|
||||
event.object = obj;
|
||||
eventBus.publish(event);
|
||||
}
|
||||
|
||||
public boolean isInCollisionList(SWGObject obj) {
|
||||
@@ -82,4 +91,20 @@ public abstract class AbstractCollidable {
|
||||
this.planet = planet;
|
||||
}
|
||||
|
||||
public SyncMessageBus<Event> getEventBus() {
|
||||
return eventBus;
|
||||
}
|
||||
|
||||
public class EnterEvent implements Event {
|
||||
public SWGObject object;
|
||||
}
|
||||
|
||||
public class ExitEvent implements Event {
|
||||
public SWGObject object;
|
||||
}
|
||||
|
||||
public abstract Point3D getRandomPosition(Point3D origin, float minDistance, float maxDistance);
|
||||
public abstract Point3D getRandomPosition();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
******************************************************************************/
|
||||
package resources.common.collidables;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -80,4 +82,26 @@ public class CollidableCircle extends AbstractCollidable {
|
||||
return center.getDistance(position) <= radius;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point3D getRandomPosition(Point3D origin, float minDistance, float maxDistance) {
|
||||
|
||||
Random random = new Random();
|
||||
float distance = random.nextInt((int) (maxDistance - minDistance) + 1) + minDistance;
|
||||
float angle = (float) (random.nextInt(360) * (Math.PI / 180));
|
||||
|
||||
return new Point3D((float) (origin.x + distance * Math.cos(angle)), 0, (float) (origin.z + distance * Math.sin(angle)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point3D getRandomPosition() {
|
||||
|
||||
Random random = new Random();
|
||||
float distance = random.nextInt((int) radius);
|
||||
float angle = (float) (random.nextInt(360) * (Math.PI / 180));
|
||||
|
||||
return new Point3D((float) (center.x + distance * Math.cos(angle)), 0, (float) (center.z + distance * Math.sin(angle)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
buffer.putShort((short) 11);
|
||||
|
||||
buffer.putFloat(mission.getMissionComplexity());
|
||||
buffer.put(getAsciiString("mission/mission_object"));
|
||||
buffer.putFloat(1); // mission complexity ??
|
||||
buffer.put(getAsciiString(mission.getStfFilename()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(mission.getStfName()));
|
||||
|
||||
@@ -122,17 +122,202 @@ public class MissionMessageBuilder extends ObjectMessageBuilder {
|
||||
public IoBuffer buildBaseline6() {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(121); // unk
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size);
|
||||
|
||||
buffer.flip();
|
||||
buffer = createBaseline("MISO", (byte) 6, buffer, size);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildStfDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4 + mission.getStfFilename().length() + mission.getStfName().length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(mission.getStfFilename()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(mission.getStfName()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x01, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildDifficultyLevelDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(mission.getMissionLevel());
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x05, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildStartLocationDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putFloat(mission.getMissionStartX());
|
||||
buffer.putFloat(mission.getMissionStartZ());
|
||||
buffer.putFloat(mission.getMissionStartY());
|
||||
|
||||
buffer.putLong(0);
|
||||
|
||||
buffer.putInt(CRC.StringtoCRC(mission.getMissionStartPlanet()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x06, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildCreatorNameDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionCreator().length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(mission.getMissionCreator()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x07, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildCreditsRewardDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(mission.getMissionCredits());
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x08, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildDestinationDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putFloat(mission.getMissionDestinationX());
|
||||
buffer.putFloat(mission.getMissionDestinationZ());
|
||||
buffer.putFloat(mission.getMissionDestinationY());
|
||||
|
||||
buffer.putLong(0); // Destination Object ID
|
||||
|
||||
buffer.putInt(CRC.StringtoCRC(mission.getMissionDestinationPlanet()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x09, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildTargetObjectIffDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(CRC.StringtoCRC(mission.getMissionTemplateObject()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0A, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildMissionDescriptionDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionDescription().length() + mission.getMissionDescId().length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(mission.getMissionDescription()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(mission.getMissionDescId()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0B, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildMissionTitleDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionTitle().length() + mission.getMissionTitleId().length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(mission.getMissionTitle()));
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString(mission.getMissionTitleId()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0C, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildRepeatCounterDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(mission.getMissionRepeatCounter());
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0D, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildMissionTypeDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(CRC.StringtoCRC(mission.getMissionType()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0E, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildTargetNameDelta() {
|
||||
MissionObject mission = (MissionObject) object;
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionTargetName().length(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.put(getAsciiString(mission.getMissionTargetName()));
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0F, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
|
||||
|
||||
@@ -36,11 +36,6 @@ import engine.resources.scene.Quaternion;
|
||||
|
||||
public class MissionObject extends SWGObject implements IPersistent {
|
||||
|
||||
private String stfName;
|
||||
private String customName;
|
||||
private int volume;
|
||||
|
||||
private float missionComplexity;
|
||||
private float missionDestinationX;
|
||||
private float missionDestinationY;
|
||||
private float missionDestinationZ;
|
||||
@@ -73,85 +68,41 @@ public class MissionObject extends SWGObject implements IPersistent {
|
||||
public MissionObject(long objectID, Planet planet, String template) {
|
||||
super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), template);
|
||||
}
|
||||
|
||||
public String getStfName() {
|
||||
return stfName;
|
||||
}
|
||||
|
||||
public void setStfName(String stfName) {
|
||||
this.stfName = stfName;
|
||||
}
|
||||
|
||||
public String getCustomName() {
|
||||
return customName;
|
||||
}
|
||||
|
||||
public void setCustomName(String customName) {
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
public int getVolume() {
|
||||
return volume;
|
||||
}
|
||||
|
||||
public void setVolume(int volume) {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public float getMissionComplexity() {
|
||||
return missionComplexity;
|
||||
}
|
||||
|
||||
public void setMissionComplexity(float missionComplexity) {
|
||||
this.missionComplexity = missionComplexity;
|
||||
}
|
||||
|
||||
public float getMissionStartX() {
|
||||
return missionStartX;
|
||||
}
|
||||
|
||||
public void setMissionStartX(float missionStartX) {
|
||||
this.missionStartX = missionStartX;
|
||||
}
|
||||
|
||||
public float getMissionStartY() {
|
||||
return missionStartY;
|
||||
}
|
||||
|
||||
public void setMissionStartY(float missionStartY) {
|
||||
this.missionStartY = missionStartY;
|
||||
}
|
||||
|
||||
public float getMissionStartZ() {
|
||||
return missionStartZ;
|
||||
}
|
||||
|
||||
public void setMissionStartZ(float missionStartZ) {
|
||||
this.missionStartZ = missionStartZ;
|
||||
public void setMissionStart(float x, float y, float z) {
|
||||
this.missionStartZ = z;
|
||||
this.missionStartX = x;
|
||||
this.missionStartY = y;
|
||||
}
|
||||
|
||||
public float getMissionDestinationX() {
|
||||
return missionDestinationX;
|
||||
}
|
||||
|
||||
public void setMissionDestinationX(float missionDestinationX) {
|
||||
this.missionDestinationX = missionDestinationX;
|
||||
}
|
||||
|
||||
public float getMissionDestinationY() {
|
||||
return missionDestinationY;
|
||||
}
|
||||
|
||||
public void setMissionDestinationY(float missionDestinationY) {
|
||||
this.missionDestinationY = missionDestinationY;
|
||||
}
|
||||
|
||||
public float getMissionDestinationZ() {
|
||||
return missionDestinationZ;
|
||||
}
|
||||
|
||||
public void setMissionDestinationZ(float missionDestinationZ) {
|
||||
this.missionDestinationZ = missionDestinationZ;
|
||||
public void setMissionDestination(float x, float y, float z) {
|
||||
this.missionDestinationZ = z;
|
||||
this.missionDestinationY = y;
|
||||
this.missionDestinationZ = z;
|
||||
}
|
||||
|
||||
public String getMissionDestinationPlanet() {
|
||||
|
||||
@@ -42,6 +42,7 @@ import engine.clientdata.visitors.MeshVisitor;
|
||||
import engine.clientdata.visitors.PortalVisitor;
|
||||
import engine.clientdata.visitors.PortalVisitor.Cell;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.common.Event;
|
||||
import engine.resources.common.Mesh3DTriangle;
|
||||
import engine.resources.common.Ray;
|
||||
import engine.resources.objects.SWGObject;
|
||||
@@ -957,5 +958,11 @@ public class SimulationService implements INetworkDispatch {
|
||||
collidable.doCollisionCheck(object);
|
||||
}
|
||||
}
|
||||
|
||||
public class MoveEvent implements Event {
|
||||
|
||||
public SWGObject object;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,13 +36,6 @@ public class AIService {
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
public void spawnCreature(String template, float x, float y, float z) {
|
||||
spawnCreature(template, new Point3D(x, y, z));
|
||||
}
|
||||
|
||||
public void spawnCreature(String template, Point3D position) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,28 @@
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
import net.engio.mbassy.listener.Handler;
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
import engine.resources.scene.Planet;
|
||||
|
||||
public class DynamicSpawnArea extends SpawnArea {
|
||||
|
||||
public DynamicSpawnArea(Planet planet, AbstractCollidable area) {
|
||||
super(planet, area);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onEnter(EnterEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onExit(ExitEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package services.spawn;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class LairGroupTemplate {
|
||||
|
||||
private Vector<LairSpawnTemplate> lairSpawnTemplates;
|
||||
|
||||
public Vector<LairSpawnTemplate> getLairSpawnTemplates() {
|
||||
return lairSpawnTemplates;
|
||||
}
|
||||
|
||||
public void setLairSpawnTemplates(Vector<LairSpawnTemplate> lairSpawnTemplates) {
|
||||
this.lairSpawnTemplates = lairSpawnTemplates;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,108 @@
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
public class LairSpawnArea extends SpawnArea {
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
import net.engio.mbassy.listener.Handler;
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import services.SimulationService.MoveEvent;
|
||||
import services.TerrainService;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
|
||||
public class LairSpawnArea extends SpawnArea {
|
||||
|
||||
private LairGroupTemplate lairGroup;
|
||||
|
||||
public LairSpawnArea(Planet planet, AbstractCollidable area) {
|
||||
super(planet, area);
|
||||
}
|
||||
|
||||
public LairGroupTemplate getLairGroup() {
|
||||
return lairGroup;
|
||||
}
|
||||
|
||||
public void setLairGroup(LairGroupTemplate lairGroup) {
|
||||
this.lairGroup = lairGroup;
|
||||
}
|
||||
|
||||
public void spawnLair(CreatureObject object) {
|
||||
|
||||
Vector<LairSpawnTemplate> lairTemplates = lairGroup.getLairSpawnTemplates();
|
||||
|
||||
if(lairGroup == null || lairTemplates.isEmpty())
|
||||
return;
|
||||
|
||||
Point3D randomPosition = getRandomPosition(object.getWorldPosition(), 32.f, 256.f);
|
||||
|
||||
if(randomPosition == null)
|
||||
return;
|
||||
|
||||
TerrainService terrainSvc = NGECore.getInstance().terrainService;
|
||||
|
||||
float height = terrainSvc.getHeight(getPlanet().getID(), randomPosition.x, randomPosition.z);
|
||||
randomPosition.y = height;
|
||||
|
||||
if(!terrainSvc.canBuildAtPosition(object, randomPosition.x, randomPosition.z))
|
||||
return;
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
LairSpawnTemplate lairSpawn = lairTemplates.get(random.nextInt(lairTemplates.size()));
|
||||
|
||||
int level = random.nextInt((int) (lairSpawn.getMaxLevel() - lairSpawn.getMinLevel()) + 1) + lairSpawn.getMinLevel();
|
||||
|
||||
NGECore.getInstance().spawnService.spawnLair(lairSpawn.getLairTemplate(), getPlanet(), randomPosition, level);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onEnter(EnterEvent event) {
|
||||
|
||||
SWGObject object = event.object;
|
||||
|
||||
if(object == null || !(object instanceof CreatureObject))
|
||||
return;
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
if(creature.getSlottedObject("ghost") == null)
|
||||
return;
|
||||
|
||||
spawnLair(creature);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onExit(ExitEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void onMove(MoveEvent event) {
|
||||
|
||||
SWGObject object = event.object;
|
||||
|
||||
if(object == null || !(object instanceof CreatureObject) || object.getContainer() != null)
|
||||
return;
|
||||
|
||||
CreatureObject creature = (CreatureObject) object;
|
||||
|
||||
if(creature.getSlottedObject("ghost") == null)
|
||||
return;
|
||||
|
||||
if(new Random().nextFloat() <= 0.10)
|
||||
spawnLair(creature);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
public class LairSpawnTemplate {
|
||||
|
||||
private int maxSpawnLimit;
|
||||
private LairTemplate lairTemplate;
|
||||
private int minLevel;
|
||||
private int maxLevel;
|
||||
|
||||
public int getMaxSpawnLimit() {
|
||||
return maxSpawnLimit;
|
||||
}
|
||||
|
||||
public void setMaxSpawnLimit(int maxSpawnLimit) {
|
||||
this.maxSpawnLimit = maxSpawnLimit;
|
||||
}
|
||||
|
||||
public LairTemplate getLairTemplate() {
|
||||
return lairTemplate;
|
||||
}
|
||||
|
||||
public void setLairTemplate(LairTemplate lairTemplate) {
|
||||
this.lairTemplate = lairTemplate;
|
||||
}
|
||||
|
||||
public int getMinLevel() {
|
||||
return minLevel;
|
||||
}
|
||||
|
||||
public void setMinLevel(int minLevel) {
|
||||
this.minLevel = minLevel;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public void setMaxLevel(int maxLevel) {
|
||||
this.maxLevel = maxLevel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
public class LairTemplate {
|
||||
|
||||
private String lairCRC;
|
||||
private String mobileName;
|
||||
|
||||
public String getLairCRC() {
|
||||
return lairCRC;
|
||||
}
|
||||
|
||||
public void setLairCRC(String lairCRC) {
|
||||
this.lairCRC = lairCRC;
|
||||
}
|
||||
|
||||
public String getMobileName() {
|
||||
return mobileName;
|
||||
}
|
||||
|
||||
public void setMobileName(String mobileName) {
|
||||
this.mobileName = mobileName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,11 +21,30 @@
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import net.engio.mbassy.listener.Handler;
|
||||
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
|
||||
public abstract class SpawnArea {
|
||||
|
||||
private Planet planet;
|
||||
private Vector<String> templates;
|
||||
private AbstractCollidable area;
|
||||
private Vector<SWGObject> observers = new Vector<SWGObject>();
|
||||
|
||||
public SpawnArea(Planet planet, AbstractCollidable area) {
|
||||
this.planet = planet;
|
||||
this.area = area;
|
||||
area.getEventBus().subscribe(this);
|
||||
}
|
||||
|
||||
public Planet getPlanet() {
|
||||
return planet;
|
||||
@@ -35,4 +54,58 @@ public abstract class SpawnArea {
|
||||
this.planet = planet;
|
||||
}
|
||||
|
||||
public Vector<String> getTemplates() {
|
||||
return templates;
|
||||
}
|
||||
|
||||
public void setTemplates(Vector<String> templates) {
|
||||
this.templates = templates;
|
||||
}
|
||||
|
||||
public AbstractCollidable getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setArea(AbstractCollidable area) {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@Handler
|
||||
public abstract void onEnter(EnterEvent event);
|
||||
@Handler
|
||||
public abstract void onExit(ExitEvent event);
|
||||
|
||||
public Vector<SWGObject> getObservers() {
|
||||
return observers;
|
||||
}
|
||||
|
||||
public Point3D getRandomPosition() {
|
||||
|
||||
int tries = 0;
|
||||
|
||||
while(tries++ < 10) {
|
||||
Point3D randomPos = area.getRandomPosition();
|
||||
if(area.doesCollide(randomPos))
|
||||
return randomPos;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public Point3D getRandomPosition(Point3D origin, float minDistance, float maxDistance) {
|
||||
|
||||
int tries = 0;
|
||||
|
||||
while(tries++ < 10) {
|
||||
Point3D randomPos = area.getRandomPosition(origin, minDistance, maxDistance);
|
||||
if(area.doesCollide(randomPos))
|
||||
return randomPos;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import main.NGECore;
|
||||
|
||||
public class SpawnService {
|
||||
@@ -34,6 +35,19 @@ public class SpawnService {
|
||||
|
||||
public SpawnService(NGECore core) {
|
||||
|
||||
}
|
||||
|
||||
public void spawnCreature(String template, float x, float y, float z) {
|
||||
spawnCreature(template, new Point3D(x, y, z));
|
||||
}
|
||||
|
||||
public void spawnCreature(String template, Point3D position) {
|
||||
|
||||
}
|
||||
|
||||
public void spawnLair(LairTemplate lairTemplate, Planet planet, Point3D position, int level) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,28 @@
|
||||
******************************************************************************/
|
||||
package services.spawn;
|
||||
|
||||
import net.engio.mbassy.listener.Handler;
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
import engine.resources.scene.Planet;
|
||||
|
||||
public class StaticSpawnArea extends SpawnArea {
|
||||
|
||||
public StaticSpawnArea(Planet planet, AbstractCollidable area) {
|
||||
super(planet, area);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onEnter(EnterEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Handler
|
||||
public void onExit(ExitEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -114,11 +114,14 @@ public class TravelService implements INetworkDispatch {
|
||||
Vector<TravelPoint> correctTravelPoints = new Vector<TravelPoint>();
|
||||
|
||||
for(TravelPoint tp : travelMap.get(planet)) {
|
||||
if(tp.isStarport() || tp.getPlanetName().equalsIgnoreCase(object.getPlanet().getName()))
|
||||
if(tp.isStarport() || tp.getPlanetName().equalsIgnoreCase(object.getPlanet().getName())) {
|
||||
correctTravelPoints.add(tp);
|
||||
Console.println(tp.getName());
|
||||
}
|
||||
}
|
||||
PlanetTravelPointListResponse response = new PlanetTravelPointListResponse(planetString, correctTravelPoints);
|
||||
client.getSession().write(response.serialize());
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user