Location doorPos;
int x = Integer.parseInt(posElement.attributeValue("x"));
int y = Integer.parseInt(posElement.attributeValue("y"));
int z = Integer.parseInt(posElement.attributeValue("z"));
doorSet.set("pos", doorPos = new Location(x, y, z));
Polygon shape = new Polygon();
int minz = 0, maxz = 0;
Element shapeElement = doorElement.element("shape");
minz = Integer.parseInt(shapeElement.attributeValue("minz"));
maxz = Integer.parseInt(shapeElement.attributeValue("maxz"));
shape.add(Integer.parseInt(shapeElement.attributeValue("ax")), Integer.parseInt(shapeElement.attributeValue("ay")));
shape.add(Integer.parseInt(shapeElement.attributeValue("bx")), Integer.parseInt(shapeElement.attributeValue("by")));
shape.add(Integer.parseInt(shapeElement.attributeValue("cx")), Integer.parseInt(shapeElement.attributeValue("cy")));
shape.add(Integer.parseInt(shapeElement.attributeValue("dx")), Integer.parseInt(shapeElement.attributeValue("dy")));
shape.setZmin(minz);
shape.setZmax(maxz);
doorSet.set("shape", shape);
doorPos.setZ(minz + 32);
for (Iterator<Element> i = doorElement.elementIterator(); i.hasNext();)
{
Element n = i.next();
if ("set".equals(n.getName()))
{
doorSet.set(n.attributeValue("name"), n.attributeValue("value"));
}
else if ("ai_params".equals(n.getName()))
{
if (aiParams == null)
{
aiParams = new StatsSet();
doorSet.set("ai_params", aiParams);
}
for (Iterator<Element> aiParamsIterator = n.elementIterator(); aiParamsIterator.hasNext();)
{
Element aiParamElement = aiParamsIterator.next();
aiParams.set(aiParamElement.attributeValue("name"), aiParamElement.attributeValue("value"));
}
}
}
doorSet.set("uid", doorElement.attributeValue("id"));
doorSet.set("name", doorElement.attributeValue("name"));
doorSet.set("baseHpMax", doorElement.attributeValue("hp"));
doorSet.set("basePDef", doorElement.attributeValue("pdef"));
doorSet.set("baseMDef", doorElement.attributeValue("mdef"));
doorSet.set("collision_height", (maxz - minz) & 0xfff0);
doorSet.set("collision_radius", Math.max(50, Math.min(doorPos.x - shape.getXmin(), doorPos.y - shape.getYmin())));
DoorTemplate template = new DoorTemplate(doorSet);
getHolder().addTemplate(template);
}
}
}