continued sandbox city, public structure problem

This commit is contained in:
CharonInferar
2014-04-28 22:52:04 +02:00
parent 3948fe11f3
commit bec401c57b
10 changed files with 275 additions and 43 deletions
@@ -0,0 +1,15 @@
import sys
from services.housing import HouseTemplate
from engine.resources.scene import Point3D
def setup(core):
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)
core.housingService.addHousingTemplate(houseTemplate)
return
@@ -0,0 +1,12 @@
import sys
from services.housing import HouseTemplate
from engine.resources.scene import Point3D
def setup(core):
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)
core.housingService.addHousingTemplate(houseTemplate)
return
@@ -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
@@ -1,4 +1,12 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'deeds/structureDeed')
object.setConstructorTemplate('object/building/player/shared_construction_structure.iff')
object.setStructureTemplate('object/tangible/deed/city_deed/shared_garden_tatooine_sml_01_deed.iff')
#object.setLotRequirement(5)
object.setBMR(5)
return
def use(core, actor, object):
return
@@ -1,4 +1,12 @@
import sys
def setup(core, object):
object.setAttachment('radial_filename', 'deeds/structureDeed')
object.setConstructorTemplate('object/building/player/shared_construction_structure.iff')
object.setStructureTemplate('object/tangible/deed/city_deed/shared_shuttleport_tatooine_deed.iff')
#object.setLotRequirement(5)
object.setBMR(100)
return
def use(core, actor, object):
return
@@ -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):
+1
View File
@@ -1231,6 +1231,7 @@ public class DevService implements INetworkDispatch {
deed.setBMR(15);
deed.setAttributes();
inventory.add(deed);
return;
+18 -1
View File
@@ -74,8 +74,10 @@ public class HousingService implements INetworkDispatch {
}
if(housingTemplates.containsKey(deed.getTemplate()))
{
{
HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate());
System.out.println("DEED FOUND " + houseTemplate.getBuildingTemplate());
System.out.println("DEED TEMP " + deed.getTemplate());
EnterStructurePlacementModeMessage packet = new EnterStructurePlacementModeMessage(deed, houseTemplate.getBuildingTemplate());
actor.getClient().getSession().write(packet.serialize());
}
@@ -90,6 +92,7 @@ public class HousingService implements INetworkDispatch {
if (deed.getTemplate().contains("cityhall"))
structureLotCost = 0;
String structureTemplate = houseTemplate.getBuildingTemplate();
if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName()))
@@ -126,6 +129,20 @@ public class HousingService implements INetworkDispatch {
// Actor is inside the bounds of a city, so zoning must be checked
//actor.setAttachment("Has24HZoningFor",cityActorIsIn.getCityID()); // for testing
//actor.setAttachment("Has24HZoningUntil",System.currentTimeMillis()+1000000); // for testing
if (deed.getTemplate().contains("shuttleport")){
if (actor.getObjectID()!=cityActorIsIn.getMayorID())
actor.sendSystemMessage("You must be the mayor of this city to place the structure.", (byte) 0);
if (cityActorIsIn.getRank()<0){
actor.sendSystemMessage("@city/city:rank_req", (byte) 0);
return;
}
}
if (actor.getAttachment("Has24HZoningFor")==null || actor.getAttachment("Has24HZoningFor")==null)
return;
int cityActorHasZoning = (int)actor.getAttachment("Has24HZoningFor");
+159 -31
View File
@@ -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<Long> placedStructures = new Vector<Long>();
private Vector<Long> citizens = new Vector<Long>();
@@ -157,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
@@ -213,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
@@ -713,5 +751,95 @@ public class PlayerCity {
}
}
public void sendCityExpandMailAll() {
Vector<Long> 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<WaypointAttachment> attachments = new ArrayList<WaypointAttachment>();
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<Long> 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<WaypointAttachment> attachments = new ArrayList<WaypointAttachment>();
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<citizenCount-10;i++){
this.citizens.add(this.getMayorID());
}
}
}
}
@@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
import resources.objects.building.BuildingObject;
import resources.objects.creature.CreatureObject;
import resources.objects.deed.Player_House_Deed;
import resources.objects.tangible.TangibleObject;
import services.sui.SUIWindow;
import services.sui.SUIWindow.SUICallback;
@@ -52,6 +53,9 @@ public class PlayerCityService implements INetworkDispatch {
private Vector<PlayerCity> playerCities = new Vector<PlayerCity>();
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;
@@ -161,8 +165,12 @@ 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;
@@ -205,13 +213,19 @@ public class PlayerCityService implements INetworkDispatch {
cityHall.setConditionDamage(100);
positionY = core.terrainService.getHeight(founder.getPlanetId(), positionX, positionZ)+ 2f;
founder.setPosition(new Point3D(positionX+100,positionY,positionZ));
core.simulationService.teleport(founder, new Point3D(positionX,positionY,positionZ+150), founder.getOrientation(), 0);
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";
@@ -219,6 +233,7 @@ public class PlayerCityService implements INetworkDispatch {
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());
@@ -238,6 +253,8 @@ public class PlayerCityService implements INetworkDispatch {
shuttlePort.setDeedTemplate("object/tangible/deed/city_deed/shared_cityhall_tatooine_deed.iff");
shuttlePort.setBMR(12);
shuttlePort.setConditionDamage(100);
sandboxCityBuilt = true;
}