diff --git a/scripts/commands/grantzoningrights.py b/scripts/commands/grantzoningrights.py new file mode 100644 index 00000000..21cbbb8d --- /dev/null +++ b/scripts/commands/grantzoningrights.py @@ -0,0 +1,40 @@ +import sys +from java.lang import System +from resources.common import OutOfBand +from resources.common import ProsePackage +import main.NGECore + +def setup(): + return + +def run(core, actor, target, commandString): + + if target == None: + return + + #if !actor.hasSkill('Politician'): + #You must be a Politician to enable city zoning. + #actor.sendSystemMessage('@city/city:zoning_skill', 0) + #return + + thisCity = main.NGECore.getInstance().playerCityService.getCityObjectIsIn(actor) + + if thisCity == None: + #not_in_city_limits + actor.sendSystemMessage('@city/city:not_in_city_limits', 0) + return + + if thisCity.getMayorID()!=actor.getObjectID() and not thisCity.isMilitiaMember(actor.getObjectID()): + #You must be the mayor of the city or a member of the city militia to grant zoning rights. + actor.sendSystemMessage('@city/city:grant_rights_fail', 0) + actor.sendSystemMessage('thisCity.getMayorID() %s' % thisCity.getMayorID(), 0) + actor.sendSystemMessage('actor.getObjectID() %s' % actor.getObjectID(), 0) + return + + #You have granted %TO zoning rights for 24 hours. + actor.sendSystemMessage(OutOfBand.ProsePackage("@city/city:rights_granted_self", "TO", target.getCustomName()), 0) + target.setAttachment('Has24HZoningFor',thisCity.getCityID()) + target.setAttachment('Has24HZoningUntil',System.currentTimeMillis()+60*60*24) + target.sendSystemMessage(OutOfBand.ProsePackage("@city/city:rights_granted", "TO", thisCity.getCityName()), 0) + + return \ No newline at end of file diff --git a/scripts/houses/player_garden_tatooine_sml_01.py b/scripts/houses/player_garden_tatooine_sml_01.py new file mode 100644 index 00000000..ed3b2981 --- /dev/null +++ b/scripts/houses/player_garden_tatooine_sml_01.py @@ -0,0 +1,15 @@ +import sys +from services.housing import HouseTemplate +from engine.resources.scene import Point3D + +def setup(housingTemplates): + houseTemplate = HouseTemplate("object/tangible/deed/city_deed/shared_garden_tatooine_sml_01_deed.iff", "object/building/player/city/shared_garden_tatooine_sml_01.iff", 0) + + houseTemplate.addBuildingSign("object/tangible/sign/player/shared_house_address.iff", Point3D(1, 2, 3)) + houseTemplate.addPlaceablePlanet("tatooine") + houseTemplate.addPlaceablePlanet("dantooine") + houseTemplate.addPlaceablePlanet("lok") + houseTemplate.setDefaultItemLimit(0) + + housingTemplates.put(houseTemplate.getDeedTemplate(), houseTemplate) + return \ No newline at end of file diff --git a/scripts/houses/player_shuttleport_tatooine.py b/scripts/houses/player_shuttleport_tatooine.py new file mode 100644 index 00000000..4d7e480f --- /dev/null +++ b/scripts/houses/player_shuttleport_tatooine.py @@ -0,0 +1,12 @@ +import sys +from services.housing import HouseTemplate +from engine.resources.scene import Point3D + +def setup(housingTemplates): + houseTemplate = HouseTemplate("object/tangible/deed/city_deed/shared_shuttleport_tatooine_deed.iff", "object/building/tatooine/shared_shuttleport_tatooine.iff", 1) + + houseTemplate.addBuildingSign("object/tangible/sign/player/shared_house_address.iff", Point3D(float(3.5),float(-0.3),float(3.5))) + houseTemplate.addPlaceablePlanet("tatooine") + houseTemplate.setDefaultItemLimit(0) + housingTemplates.put(houseTemplate.getDeedTemplate(), houseTemplate) + return \ No newline at end of file diff --git a/scripts/object/building/player/city/garden_tatooine_sml_01.py b/scripts/object/building/player/city/garden_tatooine_sml_01.py index ccad8904..287ca8f0 100644 --- a/scripts/object/building/player/city/garden_tatooine_sml_01.py +++ b/scripts/object/building/player/city/garden_tatooine_sml_01.py @@ -1,4 +1,14 @@ import sys +from engine.resources.scene import Point3D +from engine.resources.scene import Quaternion def setup(core, object): + sign = core.objectService.createChildObject(object, 'object/tangible/sign/player/shared_house_address.iff', -13.7, 3, 9.1, -1, 0, -1) + print(sign) + object.setAttachment("structureSign", sign) + + structureterminal = core.objectService.createChildObject(object, 'object/tangible/terminal/shared_terminal_player_structure.iff', -17.2, 1.5 , 8, 1, 0 ,4) + #structureterminal.setAttachment('radial_filename', 'structure_management_terminal') + structureterminal.setAttachment('housing_parentstruct', object) + return \ No newline at end of file diff --git a/scripts/object/tangible/deed/city_deed/garden_tatooine_sml_01_deed.py b/scripts/object/tangible/deed/city_deed/garden_tatooine_sml_01_deed.py index ccad8904..07ab9319 100644 --- a/scripts/object/tangible/deed/city_deed/garden_tatooine_sml_01_deed.py +++ b/scripts/object/tangible/deed/city_deed/garden_tatooine_sml_01_deed.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'deeds/structureDeed') + return + +def use(core, actor, object): return \ No newline at end of file diff --git a/scripts/object/tangible/deed/city_deed/shuttleport_tatooine_deed.py b/scripts/object/tangible/deed/city_deed/shuttleport_tatooine_deed.py index ccad8904..07ab9319 100644 --- a/scripts/object/tangible/deed/city_deed/shuttleport_tatooine_deed.py +++ b/scripts/object/tangible/deed/city_deed/shuttleport_tatooine_deed.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'deeds/structureDeed') + return + +def use(core, actor, object): return \ No newline at end of file diff --git a/scripts/radial/terminal/city_maintenance_terminal.py b/scripts/radial/terminal/city_maintenance_terminal.py index ef951426..e5bab716 100644 --- a/scripts/radial/terminal/city_maintenance_terminal.py +++ b/scripts/radial/terminal/city_maintenance_terminal.py @@ -24,6 +24,10 @@ def createRadial(core, owner, target, radials): radials.add(RadialOptions(3, 121, 0, '@city/city:non_citizen_city_status')) radials.add(RadialOptions(3, 122, 0, '@city/city:rank_info_t')) radials.add(RadialOptions(3, 123, 0, '@city/city:citizen_list_t')) + radials.add(RadialOptions(3, 230, 0, '@city/city:revoke_citizenship')) + + radials.add(RadialOptions(3, 231, 0, 'Add 10 citizens')) + radials.add(RadialOptions(3, 232, 0, 'Deduct 10 citizens')) return @@ -80,14 +84,26 @@ def handleSelection(core, owner, target, option): if owner is not None: handleCitizenList(core, owner, target, option) return - -def handleSetCityName(core, owner, target, option): - window = core.suiService.createInputBox(2,'@city/city:city_name_new_t','@city/city:city_name_new_d', owner, target, 0) - returnList = Vector() - returnList.add('txtInput:LocalText') - window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, setnameCallBack) - window.addHandler(1, '', Trigger.TRIGGER_CANCEL, returnList, setnameCallBack) - core.suiService.openSUIWindow(window); + + if option == 231: + if owner is not None: + handle10Add(core, owner, target, option) + return + + if option == 232: + if owner is not None: + handle10Deduct(core, owner, target, option) + return + +def handle10Add(core, owner, target, option): + playerCity = main.NGECore.getInstance().playerCityService.getPlayerCity(owner) + playerCity.Add10MoreCitizens() + return + + +def handle10Deduct(core, owner, target, option): + playerCity = main.NGECore.getInstance().playerCityService.getPlayerCity(owner) + playerCity.Deduct10Citizens() return def setnameCallBack(owner, window, eventType, returnList): diff --git a/src/resources/common/BountyListItem.java b/src/resources/common/BountyListItem.java index 696d24df..a50272e8 100644 --- a/src/resources/common/BountyListItem.java +++ b/src/resources/common/BountyListItem.java @@ -1,106 +1,106 @@ -/******************************************************************************* - * Copyright (c) 2013 - * - * 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 . - * - * 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; - -import java.util.ArrayList; -import java.util.List; - -import com.sleepycat.persist.model.Entity; -import com.sleepycat.persist.model.PrimaryKey; - -@Entity -public class BountyListItem { - - @PrimaryKey - private long objectId; - private int creditReward; - private String profession; - private String faction; - private String name; - private List assignedHunters; - - public BountyListItem() { } - - public BountyListItem(long objectId, int creditReward, String profession, String faction, String name) { - this.objectId = objectId; - this.creditReward = creditReward; - this.profession = profession; - this.faction = faction; - this.setName(name); - this.setAssignedHunters(new ArrayList(3)); - } - - public long getObjectId() { - return objectId; - } - public void setObjectId(long objectId) { - this.objectId = objectId; - } - public int getCreditReward() { - return creditReward; - } - public void setCreditReward(int creditReward) { - this.creditReward = creditReward; - } - public String getProfession() { - return profession; - } - public void setProfession(String profession) { - this.profession = profession; - } - - public String getFaction() { - return faction; - } - - public void setFaction(String faction) { - this.faction = faction; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public void addBounty(int amountToAdd) { - this.creditReward += amountToAdd; - } - - public List getAssignedHunters() { - return assignedHunters; - } - - public void setAssignedHunters(List assignedHunters) { - this.assignedHunters = assignedHunters; - } - - public void addBountyHunter(long objectId) { - assignedHunters.add(objectId); - } - - public void removeBountyHunter(long objectId) { - assignedHunters.remove(objectId); - } -} +/******************************************************************************* + * Copyright (c) 2013 + * + * 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 . + * + * 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; + +import java.util.ArrayList; +import java.util.List; + +import com.sleepycat.persist.model.Entity; +import com.sleepycat.persist.model.PrimaryKey; + +@Entity +public class BountyListItem { + + @PrimaryKey + private long objectId; + private int creditReward; + private String profession; + private String faction; + private String name; + private List assignedHunters; + + public BountyListItem() { } + + public BountyListItem(long objectId, int creditReward, String profession, String faction, String name) { + this.objectId = objectId; + this.creditReward = creditReward; + this.profession = profession; + this.faction = faction; + this.setName(name); + this.setAssignedHunters(new ArrayList(3)); + } + + public long getObjectId() { + return objectId; + } + public void setObjectId(long objectId) { + this.objectId = objectId; + } + public int getCreditReward() { + return creditReward; + } + public void setCreditReward(int creditReward) { + this.creditReward = creditReward; + } + public String getProfession() { + return profession; + } + public void setProfession(String profession) { + this.profession = profession; + } + + public String getFaction() { + return faction; + } + + public void setFaction(String faction) { + this.faction = faction; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void addBounty(int amountToAdd) { + this.creditReward += amountToAdd; + } + + public List getAssignedHunters() { + return assignedHunters; + } + + public void setAssignedHunters(List assignedHunters) { + this.assignedHunters = assignedHunters; + } + + public void addBountyHunter(long objectId) { + assignedHunters.add(objectId); + } + + public void removeBountyHunter(long objectId) { + assignedHunters.remove(objectId); + } +} diff --git a/src/resources/objectives/BountyMissionObjective.java b/src/resources/objectives/BountyMissionObjective.java index 96b90c88..e17de5cd 100644 --- a/src/resources/objectives/BountyMissionObjective.java +++ b/src/resources/objectives/BountyMissionObjective.java @@ -1,80 +1,80 @@ -/******************************************************************************* - * Copyright (c) 2013 - * - * 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 . - * - * 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.objectives; - -import java.util.Random; - -import engine.resources.scene.Point3D; -import main.NGECore; -import resources.common.BountyListItem; -import resources.objects.creature.CreatureObject; -import resources.objects.mission.MissionObject; -import services.mission.MissionObjective; - -public class BountyMissionObjective extends MissionObjective { - - private Point3D lastKnownLocation; - private long markObjId; - - public BountyMissionObjective(MissionObject parent) { - super(parent); - } - - @Override - public void activate(NGECore core, CreatureObject player) { - if (isActivated()) - return; - - BountyListItem bountyTarget = core.missionService.getBountyListItem(getMissionObject().getBountyObjId()); - - setMarkObjId(bountyTarget.getObjectId()); - - // TODO: Change this to a comm message. - player.sendSystemMessage("@mission/mission_bounty_informant:target_hard_" + Integer.toString(new Random().nextInt(5)), (byte) 0); - - - } - - @Override - public void complete(NGECore core, CreatureObject player) { - - } - - @Override - public void abort(NGECore core, CreatureObject player) { - - } - - @Override - public void update(NGECore core, CreatureObject player) { - - } - - public Point3D getLastKnownLocation() { return lastKnownLocation; } - - public void setLastKnownLocation(Point3D lastKnownLocation) { this.lastKnownLocation = lastKnownLocation; } - - public long getMarkObjId() { return markObjId; } - - public void setMarkObjId(long markObjId) { this.markObjId = markObjId; } - -} +/******************************************************************************* + * Copyright (c) 2013 + * + * 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 . + * + * 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.objectives; + +import java.util.Random; + +import engine.resources.scene.Point3D; +import main.NGECore; +import resources.common.BountyListItem; +import resources.objects.creature.CreatureObject; +import resources.objects.mission.MissionObject; +import services.mission.MissionObjective; + +public class BountyMissionObjective extends MissionObjective { + + private Point3D lastKnownLocation; + private long markObjId; + + public BountyMissionObjective(MissionObject parent) { + super(parent); + } + + @Override + public void activate(NGECore core, CreatureObject player) { + if (isActivated()) + return; + + BountyListItem bountyTarget = core.missionService.getBountyListItem(getMissionObject().getBountyObjId()); + + setMarkObjId(bountyTarget.getObjectId()); + + // TODO: Change this to a comm message. + player.sendSystemMessage("@mission/mission_bounty_informant:target_hard_" + Integer.toString(new Random().nextInt(5)), (byte) 0); + + + } + + @Override + public void complete(NGECore core, CreatureObject player) { + + } + + @Override + public void abort(NGECore core, CreatureObject player) { + + } + + @Override + public void update(NGECore core, CreatureObject player) { + + } + + public Point3D getLastKnownLocation() { return lastKnownLocation; } + + public void setLastKnownLocation(Point3D lastKnownLocation) { this.lastKnownLocation = lastKnownLocation; } + + public long getMarkObjId() { return markObjId; } + + public void setMarkObjId(long markObjId) { this.markObjId = markObjId; } + +} diff --git a/src/services/DevService.java b/src/services/DevService.java index e2bd4390..270587d7 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -91,6 +91,7 @@ public class DevService implements INetworkDispatch { if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); if(creature.getClient().isGM()) suiOptions.put((long) 125, "Crafting Tools"); if(creature.getClient().isGM()) suiOptions.put((long) 130, "Vehicle Deeds"); + if(creature.getClient().isGM()) suiOptions.put((long) 121, "Sandbox City"); break; case 3: // [Items] Weapons @@ -1176,6 +1177,10 @@ public class DevService implements INetworkDispatch { inventory.add(deed); return; + + case 121: + NGECore.getInstance().playerCityService.buildSandboxTestCity(player); + case 125: TangibleObject genericCraftingTool = (TangibleObject) core.objectService.createObject("object/tangible/crafting/station/shared_generic_tool.iff", planet); genericCraftingTool.setCustomName("Generic Crafting Tool"); diff --git a/src/services/playercities/PlayerCity.java b/src/services/playercities/PlayerCity.java index 34afeef9..2fbb7179 100644 --- a/src/services/playercities/PlayerCity.java +++ b/src/services/playercities/PlayerCity.java @@ -42,7 +42,7 @@ import engine.resources.scene.Point3D; public class PlayerCity { - public static final int DESERTED = 0; + public static final int NEWCITY = 0; public static final int OUTPOST = 1; public static final int VILLAGE = 2; public static final int TOWNSHIP = 3; @@ -106,8 +106,11 @@ public class PlayerCity { private boolean registered = false; private boolean zoningEnabled = false; - private final long cityUpdateSpan = 7*86400*1000; - private final long legislationPeriod = 21*86400*1000; + //private final long cityUpdateSpan = 7*86400*1000; + private final long cityUpdateSpan = 100*1000; + + //private final long legislationPeriod = 21*86400*1000; + private final long legislationPeriod = 100*1000; private Vector placedStructures = new Vector(); private Vector citizens = new Vector(); @@ -129,6 +132,7 @@ public class PlayerCity { setNextElectionDate(foundationTime+legislationPeriod); citizens.add(founder.getObjectID()); this.cityID = cityID; + setMayorID(founder.getObjectID()); } public void handleGrantZoning() { @@ -156,36 +160,67 @@ public class PlayerCity { public void processCityUpdate() { // has something changed? System.out.println("processCityUpdate"); - int censusResult = citizens.size(); - // ToDo: Consider 1 rank per update changes - if (censusResult<5){ - setRank(DESERTED); // City is technically not a city anymore - setCityRadius(0); - } + int censusResult = citizens.size(); + int currentRank = getRank(); - if (censusResult>=5 && censusResult<10){ - setRank(OUTPOST); - setCityRadius(150); - } + switch (currentRank) { + case NEWCITY : if (censusResult>=5){ + setRank(++currentRank); // Expand to Outpost + sendCityExpandMailAll(); + } + + if (censusResult<5){ + // kill city + } + break; + + case OUTPOST : if (censusResult>=10){ + setRank(++currentRank); // Expand to Village + sendCityExpandMailAll(); + } + if (censusResult<5){ + setRank(--currentRank); // Contract to Deserted + sendCityContractMailAll(); + } + break; + + case VILLAGE : if (censusResult>=15){ + setRank(++currentRank); // Expand to Township + sendCityExpandMailAll(); + } + if (censusResult<10){ + setRank(--currentRank); // Contract to Outpost + sendCityContractMailAll(); + } + break; + + case TOWNSHIP : if (censusResult>=30){ + setRank(++currentRank); // Expand to City + sendCityExpandMailAll(); + } + if (censusResult<15){ + setRank(--currentRank); // Contract to Village + sendCityContractMailAll(); + } + break; + + case CITY : if (censusResult>=40){ + setRank(++currentRank); // Expand to Metropolis + sendCityExpandMailAll(); + } + if (censusResult<15){ + setRank(--currentRank); // Contract to Township + sendCityContractMailAll(); + } + break; + + case METROPOLIS : if (censusResult<40){ + setRank(--currentRank); // Contract to City + sendCityContractMailAll(); + } + break; + - if (censusResult>=10 && censusResult<15){ - setRank(VILLAGE); - setCityRadius(200); - } - - if (censusResult>=15 && censusResult<30){ - setRank(TOWNSHIP); - setCityRadius(300); - } - - if (censusResult>=30 && censusResult<40){ - setRank(CITY); - setCityRadius(400); - } - - if (censusResult>=40){ - setRank(METROPOLIS); - setCityRadius(450); } // collect taxes @@ -212,6 +247,10 @@ public class PlayerCity { setNextCityUpdate(System.currentTimeMillis()+cityUpdateSpan); } + public void cityFixUp(){ + + } + public void demolishHighRankStructures() { // Check if there are any structures in the city // that require a higher rank than the current one @@ -263,8 +302,10 @@ public class PlayerCity { if (citizenList.contains(founderId) && (long)citizenObject.getAttachment("residentCity")==this.getCityID()) founderCitizenCount++; } - if (founderCitizenCount==founders.size()) - return true; // All founders are citizens now + if (founderCitizenCount==founders.size()){ + return true; // All founders are citizens now + + } return false; } @@ -475,6 +516,7 @@ public class PlayerCity { public void setCityName(String cityName) { this.cityName = cityName; sendNameChangeMail(cityName); + return; } public int getCityID() { @@ -548,6 +590,20 @@ public class PlayerCity { public void setZoningEnabled(boolean zoningEnabled) { this.zoningEnabled = zoningEnabled; } + + public boolean isMilitiaMember(long actor){ + if (getMilitiaList().contains(actor)) + return true; + + return false; + } + + public boolean hasCitizen(long actor){ + if (getCitizens().contains(actor)) + return true; + + return false; + } public static String[] getSpecialisationSTFNames() { return specialisationSTFNames; @@ -695,5 +751,95 @@ public class PlayerCity { } } + + public void sendCityExpandMailAll() { + Vector citizenList = getCitizens(); + for (long citizen : citizenList){ + CreatureObject citizenObject = (CreatureObject) NGECore.getInstance().objectService.getObject(citizen); + Mail actorMail = new Mail(); + actorMail.setMailId(NGECore.getInstance().chatService.generateMailId()); + actorMail.setRecieverId(citizen); + actorMail.setStatus(Mail.NEW); + actorMail.setTimeStamp((int) (new Date().getTime() / 1000)); + actorMail.setMessage("@city/city:city_expand_body"); + actorMail.setSubject("@city/city:city_expand_subject"); + actorMail.setSenderName("City " + this.cityName); + + List attachments = new ArrayList(); + WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", citizenObject.getPlanet(), citizenObject.getPosition().x, 0 ,citizenObject.getPosition().z); + WaypointAttachment attachment = new WaypointAttachment(); + attachment.active = false; + attachment.cellID = constructionWaypoint.getCellId(); + attachment.color = (byte)1; + attachment.name = "City"; + attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(citizenObject.getPlanet().getName()); + attachment.positionX = citizenObject.getPosition().x; + attachment.positionY = 0; + attachment.positionZ = citizenObject.getPosition().z; + attachments.add(attachment); + actorMail.setAttachments(attachments); + + NGECore.getInstance().chatService.storePersistentMessage(actorMail); + + } + } + + public void sendCityContractMailAll() { + + Vector citizenList = getCitizens(); + for (long citizen : citizenList){ + CreatureObject citizenObject = (CreatureObject) NGECore.getInstance().objectService.getObject(citizen); + Mail actorMail = new Mail(); + actorMail.setMailId(NGECore.getInstance().chatService.generateMailId()); + actorMail.setRecieverId(citizen); + actorMail.setStatus(Mail.NEW); + actorMail.setTimeStamp((int) (new Date().getTime() / 1000)); + actorMail.setMessage("@city/city:city_contract_body"); + actorMail.setSubject("@city/city:city_contract_subject"); + actorMail.setSenderName("City " + this.cityName); + + List attachments = new ArrayList(); + WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", citizenObject.getPlanet(), citizenObject.getPosition().x, 0 ,citizenObject.getPosition().z); + WaypointAttachment attachment = new WaypointAttachment(); + attachment.active = false; + attachment.cellID = constructionWaypoint.getCellId(); + attachment.color = (byte)1; + attachment.name = "City"; + attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(citizenObject.getPlanet().getName()); + attachment.positionX = citizenObject.getPosition().x; + attachment.positionY = 0; + attachment.positionZ = citizenObject.getPosition().z; + attachments.add(attachment); + actorMail.setAttachments(attachments); + + NGECore.getInstance().chatService.storePersistentMessage(actorMail); + } + } + + + + + // Test method to be deleted later + public void Add10MoreCitizens() { + synchronized(citizens){ + for (int i=0;i<10;i++){ + this.citizens.add(this.getMayorID()); + } + + } + } + + + // Test method to be deleted later + public void Deduct10Citizens() { + int citizenCount = this.getCitizens().size(); + synchronized(citizens){ + this.citizens.clear(); + + for (int i=0;i playerCities = new Vector(); private int cityID = 0; // This must be persisted or handled via objectservice somehow + // static helper variable to be deleted later + public static boolean sandboxCityBuilt = false; + public PlayerCityService(NGECore core) { this.core = core; @@ -95,7 +103,8 @@ public class PlayerCityService implements INetworkDispatch { synchronized(playerCities){ for (PlayerCity city : playerCities){ int radius = city.getCityRadius(); - if (object.getPosition().getDistance2D(city.getCityCenterPosition()) returnList = new Vector(); + returnList.add("txtInput:LocalText"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + if (returnList.size()==0) + return; + PlayerCity playerCity = main.NGECore.getInstance().playerCityService.getPlayerCity((CreatureObject) owner); + playerCity.setCityName(returnList.get(0)); + //owner.sendSystemMessage("@city/city:name_changed", 0); + core.suiService.closeSUIWindow(owner, 0); + newCitySUI2((CreatureObject) owner, playerCity); + } + }); + core.suiService.openSUIWindow(window); + } + + public void newCitySUI2(CreatureObject citizen, final PlayerCity newCity) { final SUIWindow window = core.suiService.createSUIWindow("Script.messageBox", citizen, citizen, 0); window.setProperty("bg.caption.lblTitle:Text", "@city/city:rank0"); window.setProperty("Prompt.lblPrompt:Text", "@city/city:new_city_body"); @@ -135,6 +164,99 @@ public class PlayerCityService implements INetworkDispatch { }); core.suiService.openSUIWindow(window); } + + + // Test method to be deleted later + public void buildSandboxTestCity(CreatureObject founder) { + + if (sandboxCityBuilt) + return; + + float positionX = 2170.0F; + float positionY = 1.0F; + float positionZ = -4659.0F; + + String structureTemplate = "object/building/player/city/shared_cityhall_tatooine.iff"; + + BuildingObject cityHall = (BuildingObject) core.objectService.createObject(structureTemplate, 0, founder.getPlanet(), new Point3D(positionX, positionY, positionZ), founder.getOrientation()); + core.simulationService.add(cityHall, cityHall.getPosition().x, cityHall.getPosition().z, true); + + SWGObject sign = core.objectService.createChildObject((SWGObject)cityHall, "object/tangible/sign/player/shared_house_address.iff", -7.39F, 2.36F, 2, -1, 0, -1); + cityHall.setAttachment("structureSign", sign); + + PlayerCity sandboxCity = null; + synchronized(playerCities){ + sandboxCity = new PlayerCity(founder,cityID++); + sandboxCity.setCityName("Sandbox City"); + playerCities.add(sandboxCity); + } + + cityHall.setAttachment("structureCity", sandboxCity.getCityID()); + founder.setAttachment("residentCity", sandboxCity.getCityID()); + // Name the sign +// TangibleObject sign = (TangibleObject) cityHall.getAttachment("structureSign"); +// String playerFirstName = founder.getCustomName().split(" ")[0]; +// +// if (sign !=null) +// sign.setCustomName2(playerFirstName + "'s House"); + + + + // Structure management + Vector admins = new Vector<>(); + admins.add(founder.getObjectID()); + + cityHall.setAttachment("structureOwner", founder.getObjectID()); + cityHall.setAttachment("structureAdmins", admins); + cityHall.setDeedTemplate("object/tangible/deed/city_deed/shared_cityhall_tatooine_deed.iff"); + cityHall.setBMR(325); + cityHall.setConditionDamage(100); + + + positionY = core.terrainService.getHeight(founder.getPlanetId(), positionX, positionZ); + founder.setPosition(new Point3D(positionX,positionY,positionZ+50)); + core.simulationService.teleport(founder, new Point3D(positionX,positionY,positionZ+50), founder.getOrientation(), 0); + + TangibleObject swoopDeed = (TangibleObject) core.objectService.createObject("object/tangible/deed/vehicle_deed/shared_speederbike_swoop_deed.iff", founder.getPlanet()); + SWGObject inventory = founder.getSlottedObject("inventory"); + inventory.add(swoopDeed); + + TangibleObject shuttleportDeed = (TangibleObject) core.objectService.createObject("object/tangible/deed/city_deed/shared_shuttleport_tatooine_deed.iff", founder.getPlanet()); + inventory.add(shuttleportDeed); + + TangibleObject garden1 = (TangibleObject) core.objectService.createObject("object/tangible/deed/city_deed/shared_garden_tatooine_sml_01_deed.iff", founder.getPlanet()); + inventory.add(garden1); + + + //structureTemplate = "object/building/player/city/shared_shuttleport_tatooine.iff"; + structureTemplate = "object/building/tatooine/shared_shuttleport_tatooine.iff"; + positionX = 2170.0F; + positionY = 1.0F; + positionZ = -4559.0F; + positionY = core.terrainService.getHeight(founder.getPlanetId(), positionX, positionZ); + + //StructureObject shuttlePort = (StructureObject) core.objectService.createObject(structureTemplate, 0, founder.getPlanet(), new Point3D(positionX, positionY, positionZ), founder.getOrientation()); + //BuildingObject shuttlePort = (BuildingObject) core.objectService.createObject(structureTemplate, 0, founder.getPlanet(), new Point3D(positionX, positionY, positionZ), founder.getOrientation()); + //shuttlePort.setAttachment("cellsSorted", new Boolean(true)); + //"bigSpawnRange" + + //core.simulationService.add(shuttlePort, shuttlePort.getPosition().x, shuttlePort.getPosition().z, true); +// sign = core.objectService.createChildObject((SWGObject)shuttlePort, "object/tangible/sign/player/shared_house_address.iff", -7.39F, 2.36F, 2, -1, 0, -1); +// shuttlePort.setAttachment("structureSign", sign); + + // Structure management + admins = new Vector<>(); + admins.add(founder.getObjectID()); + +// shuttlePort.setAttachment("structureOwner", founder.getObjectID()); +// shuttlePort.setAttachment("structureAdmins", admins); +// shuttlePort.setDeedTemplate("object/tangible/deed/city_deed/shared_cityhall_tatooine_deed.iff"); +// shuttlePort.setBMR(12); +// shuttlePort.setConditionDamage(100); + + sandboxCityBuilt = true; + } + @Override public void insertOpcodes(Map arg0,