From e45a7934891efedf4985dc7960cf7212f1508377 Mon Sep 17 00:00:00 2001 From: Obique PSWG Date: Thu, 3 Mar 2016 21:32:06 -0600 Subject: [PATCH] Created a DestroyObjectIntent --- src/intents/object/DestroyObjectIntent.java | 48 +++++++++++++++++++++ src/intents/object/ObjectCreatedIntent.java | 27 ++++++++++++ src/services/objects/ObjectManager.java | 29 ++++++++++--- 3 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 src/intents/object/DestroyObjectIntent.java diff --git a/src/intents/object/DestroyObjectIntent.java b/src/intents/object/DestroyObjectIntent.java new file mode 100644 index 000000000..957f16209 --- /dev/null +++ b/src/intents/object/DestroyObjectIntent.java @@ -0,0 +1,48 @@ +/*********************************************************************************** +* 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; + +public class DestroyObjectIntent extends Intent { + + public static final String TYPE = "DestroyObjectIntent"; + + private final SWGObject obj; + + public DestroyObjectIntent(SWGObject obj) { + super(TYPE); + this.obj = obj; + } + + public SWGObject getObject() { + return obj; + } + +} diff --git a/src/intents/object/ObjectCreatedIntent.java b/src/intents/object/ObjectCreatedIntent.java index 3357518cd..b1d017285 100644 --- a/src/intents/object/ObjectCreatedIntent.java +++ b/src/intents/object/ObjectCreatedIntent.java @@ -1,3 +1,30 @@ +/*********************************************************************************** +* 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; diff --git a/src/services/objects/ObjectManager.java b/src/services/objects/ObjectManager.java index 12e2a689f..0a00c39d5 100644 --- a/src/services/objects/ObjectManager.java +++ b/src/services/objects/ObjectManager.java @@ -35,6 +35,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import intents.object.DestroyObjectIntent; import intents.object.ObjectCreatedIntent; import intents.object.ObjectTeleportIntent; import intents.player.DeleteCharacterIntent; @@ -92,6 +93,7 @@ public class ObjectManager extends Manager { registerForIntent(GalacticPacketIntent.TYPE); registerForIntent(ObjectTeleportIntent.TYPE); registerForIntent(ObjectCreatedIntent.TYPE); + registerForIntent(DestroyObjectIntent.TYPE); registerForIntent(DeleteCharacterIntent.TYPE); } @@ -174,12 +176,23 @@ public class ObjectManager extends Manager { @Override public void onIntentReceived(Intent i) { - if (i instanceof GalacticPacketIntent) { - processGalacticPacketIntent((GalacticPacketIntent) i); - } else if (i instanceof ObjectCreatedIntent) { - processObjectCreatedIntent((ObjectCreatedIntent) i); - } else if (i instanceof DeleteCharacterIntent) { - deleteObject(((DeleteCharacterIntent) i).getCreature().getObjectId()); + switch (i.getType()) { + case GalacticPacketIntent.TYPE: + if (i instanceof GalacticPacketIntent) + processGalacticPacketIntent((GalacticPacketIntent) i); + break; + case ObjectCreatedIntent.TYPE: + if (i instanceof ObjectCreatedIntent) + processObjectCreatedIntent((ObjectCreatedIntent) i); + break; + case DestroyObjectIntent.TYPE: + if (i instanceof DestroyObjectIntent) + processDestroyObjectIntent((DestroyObjectIntent) i); + break; + case DeleteCharacterIntent.TYPE: + if (i instanceof DeleteCharacterIntent) + deleteObject(((DeleteCharacterIntent) i).getCreature().getObjectId()); + break; } } @@ -187,6 +200,10 @@ public class ObjectManager extends Manager { putObject(intent.getObject()); } + private void processDestroyObjectIntent(DestroyObjectIntent doi) { + destroyObject(doi.getObject()); + } + private void processGalacticPacketIntent(GalacticPacketIntent gpi) { Packet packet = gpi.getPacket(); if (packet instanceof SelectCharacter) {