diff --git a/src/intents/object/ObjectCreateIntent.java b/src/intents/object/ObjectCreateIntent.java new file mode 100644 index 00000000..a37d86c6 --- /dev/null +++ b/src/intents/object/ObjectCreateIntent.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package intents.object; + +import resources.control.Intent; +import resources.objects.SWGObject; + +/** + * Created by Waverunner on 8/19/2015 + */ +public class ObjectCreateIntent extends Intent { + private static final String TYPE = "ObjectCreateIntent"; + + private SWGObject object; + private boolean addToAwareness; + + public ObjectCreateIntent(SWGObject object, boolean addToAwareness) { + super(TYPE); + this.object = object; + this.addToAwareness = addToAwareness; + } + + public ObjectCreateIntent(SWGObject object) { + this(object, false); + } + + public SWGObject getObject() { + return object; + } + + public boolean isAddToAwareness() { + return addToAwareness; + } +} \ No newline at end of file diff --git a/src/intents/object/ObjectIdRequestIntent.java b/src/intents/object/ObjectIdRequestIntent.java new file mode 100644 index 00000000..784b64c4 --- /dev/null +++ b/src/intents/object/ObjectIdRequestIntent.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package intents.object; + +import resources.control.Intent; + +/** + * Created by Waverunner on 8/19/2015 + */ +public class ObjectIdRequestIntent extends Intent { + public static final String TYPE = "ObjectIdRequestIntent"; + + private String identifier; + private int amount; + + public ObjectIdRequestIntent(String identifier, int amount) { + super(TYPE); + this.identifier = identifier; + this.amount = amount; + } + + public String getIdentifier() { + return identifier; + } + + public int getAmount() { + return amount; + } +} \ No newline at end of file diff --git a/src/intents/object/ObjectIdResponseIntent.java b/src/intents/object/ObjectIdResponseIntent.java new file mode 100644 index 00000000..6799adec --- /dev/null +++ b/src/intents/object/ObjectIdResponseIntent.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com + * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. + * Our goal is to create an emulator which will provide a server for players to + * continue playing a game similar to the one they used to play. We are basing + * it on the final publish of the game prior to end-game events. + * + * This file is part of Holocore. + * + * -------------------------------------------------------------------------------- + * + * Holocore is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * Holocore 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Holocore. If not, see + ******************************************************************************/ + +package intents.object; + +import resources.control.Intent; + +import java.util.List; + +/** + * Created by Waverunner on 8/19/2015 + */ +public class ObjectIdResponseIntent extends Intent { + public static final String TYPE = "ObjectIdResponseIntent"; + + private String identifier; + private List reservedIds; + + public ObjectIdResponseIntent(String identifier, List reservedIds) { + super(TYPE); + this.identifier = identifier; + this.reservedIds = reservedIds; + } + + public String getIdentifier() { + return identifier; + } + + public List getReservedIds() { + return reservedIds; + } +} \ No newline at end of file diff --git a/src/intents/ObjectTeleportIntent.java b/src/intents/object/ObjectTeleportIntent.java similarity index 99% rename from src/intents/ObjectTeleportIntent.java rename to src/intents/object/ObjectTeleportIntent.java index 0e3c080a..da2078d3 100644 --- a/src/intents/ObjectTeleportIntent.java +++ b/src/intents/object/ObjectTeleportIntent.java @@ -25,7 +25,7 @@ * along with Holocore. If not, see . * * * ***********************************************************************************/ -package intents; +package intents.object; import resources.Location; import resources.control.Intent; diff --git a/src/resources/commands/callbacks/AdminTeleportCallback.java b/src/resources/commands/callbacks/AdminTeleportCallback.java index 05a33048..cce50654 100644 --- a/src/resources/commands/callbacks/AdminTeleportCallback.java +++ b/src/resources/commands/callbacks/AdminTeleportCallback.java @@ -27,7 +27,7 @@ ***********************************************************************************/ package resources.commands.callbacks; -import intents.ObjectTeleportIntent; +import intents.object.ObjectTeleportIntent; import resources.Location; import resources.Terrain; import resources.commands.ICmdCallback; diff --git a/src/services/objects/ObjectManager.java b/src/services/objects/ObjectManager.java index f342ffb3..c1f74c60 100644 --- a/src/services/objects/ObjectManager.java +++ b/src/services/objects/ObjectManager.java @@ -36,7 +36,10 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import intents.ObjectTeleportIntent; +import intents.object.ObjectCreateIntent; +import intents.object.ObjectIdRequestIntent; +import intents.object.ObjectIdResponseIntent; +import intents.object.ObjectTeleportIntent; import intents.PlayerEventIntent; import intents.RequestZoneInIntent; import intents.network.GalacticPacketIntent; @@ -101,6 +104,7 @@ public class ObjectManager extends Manager { registerForIntent(GalacticPacketIntent.TYPE); registerForIntent(PlayerEventIntent.TYPE); registerForIntent(ObjectTeleportIntent.TYPE); + registerForIntent(ObjectIdRequestIntent.TYPE); objectAwareness.initialize(); loadClientObjects(); maxObjectId = 1000000000; // Gets over all the buildouts/snapshots @@ -286,9 +290,32 @@ public class ObjectManager extends Manager { } } else if (i instanceof ObjectTeleportIntent) { processObjectTeleportIntent((ObjectTeleportIntent) i); + } else if (i instanceof ObjectIdRequestIntent) { + processObjectIdRequestIntent((ObjectIdRequestIntent) i); + } else if (i instanceof ObjectCreateIntent) { + processObjectCreateIntent((ObjectCreateIntent) i); } } - + + private void processObjectCreateIntent(ObjectCreateIntent intent) { + SWGObject object = intent.getObject(); + + if (intent.isAddToAwareness()) { + objectAwareness.add(object); + } + + objectMap.put(object.getObjectId(), object); + } + + private void processObjectIdRequestIntent(ObjectIdRequestIntent intent) { + List reservedIds = new ArrayList<>(); + for (int i = 0; i < intent.getAmount(); i++) { + reservedIds.add(getNextObjectId()); + } + + new ObjectIdResponseIntent(intent.getIdentifier(), reservedIds).broadcast(); + } + private void processObjectTeleportIntent(ObjectTeleportIntent oti) { SWGObject object = oti.getObject(); objectAwareness.move(object, oti.getNewLocation());