forked from Mirrors/openclonk
reintroduce position parameter in (Can)InsertMaterial
parent
b403bb6357
commit
67e00d8a98
|
@ -28,6 +28,12 @@
|
|||
<desc>Y insert position or offset</desc>
|
||||
<optional />
|
||||
</param>
|
||||
<param>
|
||||
<type>proplist</type>
|
||||
<name>out_insertpos</name>
|
||||
<desc>If a writeable proplist is passed, members x and y are filled with the position at which the material would be inserted.</desc>
|
||||
<optional />
|
||||
</param>
|
||||
</params>
|
||||
</syntax>
|
||||
<desc>Tests if a material pixel at the given position can be inserted.</desc>
|
||||
|
|
|
@ -40,7 +40,13 @@
|
|||
<desc>vertical speed of material pixel to be inserted</desc>
|
||||
<optional />
|
||||
</param>
|
||||
</params>
|
||||
<param>
|
||||
<type>proplist</type>
|
||||
<name>out_insertpos</name>
|
||||
<desc>If a writeable proplist is passed, members x and y are filled with the actual insertion position.</desc>
|
||||
<optional />
|
||||
</param>
|
||||
</params>
|
||||
</syntax>
|
||||
<desc>Inserts a material pixel at the given position and given speed.</desc>
|
||||
<remark>If the target position already contains material of the same density as the inserted material, the engine will search upwards for a proper insertion position.</remark>
|
||||
|
|
|
@ -332,18 +332,32 @@ static bool FnSmoke(C4PropList * _this, long tx, long ty, long level, long dwClr
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool FnInsertMaterial(C4PropList * _this, long mat, long x, long y, long vx, long vy)
|
||||
static bool FnInsertMaterial(C4PropList * _this, long mat, long x, long y, long vx, long vy, C4PropList *insert_position)
|
||||
{
|
||||
if (Object(_this)) { x+=Object(_this)->GetX(); y+=Object(_this)->GetY(); }
|
||||
int32_t insert_x=x, insert_y=y;
|
||||
return ::Landscape.InsertMaterial(mat,&insert_x,&insert_y,vx,vy);
|
||||
if (!::Landscape.InsertMaterial(mat,&insert_x,&insert_y,vx,vy)) return false;
|
||||
// output insertion position if desired
|
||||
if (insert_position && !insert_position->IsFrozen())
|
||||
{
|
||||
insert_position->SetProperty(P_X, C4VInt(insert_x));
|
||||
insert_position->SetProperty(P_Y, C4VInt(insert_y));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool FnCanInsertMaterial(C4PropList * _this, long mat, long x, long y)
|
||||
static bool FnCanInsertMaterial(C4PropList * _this, long mat, long x, long y, C4PropList *insert_position)
|
||||
{
|
||||
if (Object(_this)) { x+=Object(_this)->GetX(); y+=Object(_this)->GetY(); }
|
||||
int32_t insert_x=x, insert_y=y;
|
||||
return ::Landscape.InsertMaterial(mat,&insert_x,&insert_y,0,0,true);
|
||||
if (!::Landscape.InsertMaterial(mat,&insert_x,&insert_y,0,0,true)) return false;
|
||||
// output insertion position if desired
|
||||
if (insert_position && !insert_position->IsFrozen())
|
||||
{
|
||||
insert_position->SetProperty(P_X, C4VInt(insert_x));
|
||||
insert_position->SetProperty(P_Y, C4VInt(insert_y));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue