Compare commits
6 Commits
beb2b47162
...
5e629e7890
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e629e7890 | |||
| e991a01b50 | |||
| 7a1700cec3 | |||
| 79eb5b9cdf | |||
| 7886aa6041 | |||
| b928bedeb6 |
@@ -11,6 +11,7 @@ package engine.devcmd.cmds;
|
||||
|
||||
import engine.Enum;
|
||||
import engine.devcmd.AbstractDevCmd;
|
||||
import engine.gameManager.BuildingManager;
|
||||
import engine.objects.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -25,6 +26,14 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
protected void _doCmd(PlayerCharacter pc, String[] words,
|
||||
AbstractGameObject target) {
|
||||
|
||||
String newline = "\r\n ";
|
||||
String output;
|
||||
output = "Target Region Information:" + newline;
|
||||
|
||||
Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc);
|
||||
if(building == null){
|
||||
this.throwbackInfo(pc, "No Building At This Location.") ;
|
||||
}
|
||||
Regions region = ((AbstractCharacter)target).region;
|
||||
if (region == null) {
|
||||
this.throwbackInfo(pc, "No Region Found.");
|
||||
@@ -32,9 +41,12 @@ public class RegionCmd extends AbstractDevCmd {
|
||||
}
|
||||
|
||||
if(region != null) {
|
||||
this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName());
|
||||
this.throwbackInfo(pc, "Region Name: " + region);
|
||||
this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target));
|
||||
output += "Player Info: " + ((AbstractCharacter) target).getName() + newline;
|
||||
output += "Region Building: " + building.getName() + newline;
|
||||
output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline;
|
||||
output += "is Stairs: " + region.isStairs() + newline;
|
||||
output += "is Outside: " + region.isOutside();
|
||||
this.throwbackInfo(pc, output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import engine.job.JobContainer;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.UpgradeBuildingJob;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
@@ -26,7 +27,9 @@ import engine.net.client.msg.PlaceAssetMsg;
|
||||
import engine.objects.*;
|
||||
import engine.server.MBServerStatics;
|
||||
import org.pmw.tinylog.Logger;
|
||||
import org.w3c.dom.css.Rect;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
@@ -115,7 +118,7 @@ public enum BuildingManager {
|
||||
return true;
|
||||
|
||||
//individual friend.
|
||||
if (building.getFriends().get(player.getObjectUUID()) != null)
|
||||
if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null)
|
||||
return true;
|
||||
|
||||
//Admin's can access stuff
|
||||
@@ -129,11 +132,11 @@ public enum BuildingManager {
|
||||
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
if (building.getFriends() != null && building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8)
|
||||
return true;
|
||||
|
||||
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
if (building.getFriends() != null && building.getFriends().get(player.getGuild().getObjectUUID()) != null
|
||||
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9
|
||||
&& GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
return true;
|
||||
@@ -945,4 +948,22 @@ public enum BuildingManager {
|
||||
|
||||
building.isDeranking.compareAndSet(true, false);
|
||||
}
|
||||
public static Building getBuildingAtLocation(Vector3fImmutable loc){
|
||||
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,64,MBServerStatics.MASK_BUILDING)){
|
||||
Building building = (Building)awo;
|
||||
if(building == null)
|
||||
continue;
|
||||
float minX = building.loc.x - building.getBounds().getHalfExtents().x;
|
||||
float maxX = building.loc.x + building.getBounds().getHalfExtents().x;
|
||||
float minZ = building.loc.z - building.getBounds().getHalfExtents().y;
|
||||
float maxZ = building.loc.z + building.getBounds().getHalfExtents().y;
|
||||
|
||||
boolean meetsX = loc.x > minX && loc.x < maxX;
|
||||
boolean meetsY = loc.z > minZ && loc.z < maxZ;
|
||||
if(meetsX && meetsY)
|
||||
return building;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import engine.math.Bounds;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.net.DispatchMessage;
|
||||
import engine.net.client.msg.ErrorPopupMsg;
|
||||
import engine.net.client.msg.UpdateStateMsg;
|
||||
import engine.powers.EffectsBase;
|
||||
import engine.server.MBServerStatics;
|
||||
@@ -985,7 +986,19 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
|
||||
@Override
|
||||
public final void setLoc(final Vector3fImmutable value) {
|
||||
Regions region = Regions.GetRegionForTeleport(value);
|
||||
|
||||
Building building = BuildingManager.getBuildingAtLocation(this.loc);
|
||||
Regions region = null;
|
||||
if(building != null) {
|
||||
//look for region in the building we are in
|
||||
for (Regions regionCycle : building.getBounds().getRegions()) {
|
||||
float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y;
|
||||
if(regionHeight < 10)
|
||||
regionHeight = 10;
|
||||
if (regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < regionHeight)
|
||||
region = regionCycle;
|
||||
}
|
||||
}
|
||||
float regionHeightOffset = 0;
|
||||
if(region != null){
|
||||
this.region = region;
|
||||
@@ -999,6 +1012,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
|
||||
this.inBuildingID = 0;
|
||||
this.inFloorID = -1;
|
||||
}
|
||||
|
||||
float terrainHeight = Terrain.getWorldHeight(value);
|
||||
Vector3fImmutable finalLocation = new Vector3fImmutable(value.x,terrainHeight + regionHeightOffset, value.z);
|
||||
super.setLoc(finalLocation); // set the location in the world
|
||||
|
||||
@@ -170,10 +170,10 @@ public class Regions {
|
||||
return true;
|
||||
|
||||
//next region is stairs, if they are on the same level as stairs or 1 up, world object can enter.
|
||||
if (toEnter.stairs)
|
||||
if (toEnter.isStairs())
|
||||
if (worldObject.region.level == toEnter.level || toEnter.level - 1 == worldObject.region.level)
|
||||
return true;
|
||||
if (worldObject.region.stairs) {
|
||||
if (worldObject.region.isStairs()) {
|
||||
|
||||
boolean movingUp = false;
|
||||
|
||||
@@ -239,7 +239,7 @@ public class Regions {
|
||||
return true;
|
||||
|
||||
//cant move up a level without stairs.
|
||||
if (!fromRegion.stairs)
|
||||
if (!fromRegion.isStairs())
|
||||
return false;
|
||||
|
||||
boolean movingUp = false;
|
||||
@@ -367,7 +367,8 @@ public class Regions {
|
||||
}
|
||||
|
||||
public boolean isStairs() {
|
||||
return stairs;
|
||||
|
||||
return this.highLerp.y - this.lowLerp.y > 0.25f;
|
||||
}
|
||||
|
||||
public boolean isExit() {
|
||||
|
||||
Reference in New Issue
Block a user