function fxDTSBrick::onPlant(%this)
{
Parent::onPlant(%this);
if(%this.dataBlock.isVWCapturePoint)
{
%this.createTriggerZone(VWcontrolTriggerData);
}
}
function fxDTSBrick::onRemove(%this)
{
if(%this.dataBlock.isVWCapturePoint)
{
if(isObject(%this.triggerZone))
{
%this.triggerZone.delete();
}
}
Parent::onRemove(%this);
}
function fxDTSBrick::createTriggerZone(%brick,%triggerData)
{
if(!isObject(%triggerData))
{
error("ERROR: Trigger data \"" @ %triggerData @ "\" does not exist for " @ %this.dataBlock.getName() @ " brick!");
return;
}
if(%triggerData.getClassName() !$= "TriggerData")
{
error("ERROR: \"" @ %triggerData @ "\" is not a TriggerData datablock!");
return;
}
%t = new Trigger()
{
dataBlock = %triggerData;
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
};
if(!isObject(%t))
{
error("ERROR: Could not create trigger for " @ %this.dataBlock.getName() @ " brick!");
return;
}
missionCleanup.add(%t);
//The trigger is made slightly larger than the brick and offset
%boxMin = getWords(%brick.getWorldBox(), 0, 2);
%boxMax = getWords(%brick.getWorldBox(), 3, 5);
%boxDiff = vectorSub(%boxMax, %boxMin);
%boxDiff = vectorAdd(%boxDiff, "0 0 0.2");
%t.setScale(%boxDiff);
%posA = %brick.getWorldBoxCenter();
%posB = %t.getWorldBoxCenter();
%posDiff = vectorSub(%posA, %posB);
%posDiff = vectorAdd(%posDiff, "0 0 0.1");
%t.setTransform(%posDiff);
%this.triggerZone = %t;
%t.spawnBrick = %brick;
}