Oh and it needs to be efficient and stuff
Cause I'll be looping through all buildings on a regular basis
I thought of a much better way, then. Use triggers, like so:
function BuildingBaseplateData::onPlant(%this)
{
%db = %this.getDatablock();
%x = %db.sizeX/2;
%y = %db.sizeY/2;
%scalevector = vectorAdd(%x SPC %y, "0 0 50");
%this.trigger = new Trigger() {
position = vectorAdd(%this.getPosition(), "0 0 25");
scale = %scalevector;
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
datablock = BuildingBaseplateTrigger;
};
}
function BuildingBaseplateTrigger::onEnterTrigger(%db, %this, %obj)
{
if(%obj.getType() !$= "Player")
return;
%obj.isInBuilding = 1;
}
function BuildingBaseplateTrigger::onLeaveTrigger(%db, %this, %obj)
{
if(%obj.getType() !$= "Player")
return;
%obj.isInBuilding = 0;
}
datablock TriggerData(BuildingBaseplateTrigger) { tickPeriodMS = 500; };
function player::isInBuilding(%this)
{
return %this.isInBuilding || 0;
}