Updated Housing service

Housing service detects if new citizen builds structure
and adds him as citizen to the city
This commit is contained in:
CharonInferar
2014-04-24 14:10:46 +02:00
parent 982c4604b8
commit 5987b86a3d
22 changed files with 172 additions and 101 deletions
+19 -1
View File
@@ -119,7 +119,9 @@ public class HousingService implements INetworkDispatch {
// Name the sign
TangibleObject sign = (TangibleObject) building.getAttachment("structureSign");
String playerFirstName = actor.getCustomName().split(" ")[0];
sign.setCustomName2(playerFirstName + "'s House");
if (sign !=null)
sign.setCustomName2(playerFirstName + "'s House");
//building.add(sign);
core.objectService.destroyObject(deed);
@@ -140,6 +142,20 @@ public class HousingService implements INetworkDispatch {
actor.setAttachment("residentCity", newCity.getCityID());
}
// Check for city founders joining a new city
PlayerCity cityActorIsIn = core.playerCityService.getCityObjectIsIn(actor);
actor.setAttachment("Has24HZoningFor",cityActorIsIn.getCityID()); // for testing
int cityActorHasZoning = (int)actor.getAttachment("Has24HZoningFor");
if (cityActorIsIn!=null && cityActorHasZoning==cityActorIsIn.getCityID()){
if (! cityActorIsIn.getCitizens().contains(actor.getObjectID())){
building.setAttachment("structureCity", cityActorIsIn.getCityID());
// actor.setAttachment("residentCity", cityActorIsIn.getCityID()); He must do it manually
cityActorIsIn.addCitizen(actor.getObjectID());
cityActorIsIn.addNewStructure(building.getObjectID());
}
}
// Save structure to DB
//building.createTransaction(core.getBuildingODB().getEnvironment());
@@ -436,6 +452,8 @@ public class HousingService implements INetworkDispatch {
public void declareResidency(SWGObject owner, TangibleObject target) {
final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct");
building.setResidency((CreatureObject)owner);
PlayerCity cityActorIsIn = core.playerCityService.getCityObjectIsIn(owner);
owner.setAttachment("residentCity", cityActorIsIn.getCityID());
//owner.setResidence();
}