lava core: only have solid mask when frozen

This causes less lag.
install-platforms
Maikel de Vries 2017-06-11 14:50:25 +02:00
parent 16c2fd80d5
commit bfe9449256
2 changed files with 26 additions and 9 deletions

View File

@ -5,7 +5,6 @@
@author Win, Maikel @author Win, Maikel
*/ */
local size; local size;
public func InitAttach(object parent) public func InitAttach(object parent)
@ -15,13 +14,18 @@ public func InitAttach(object parent)
return; return;
} }
public func SetSize(int size) public func SetSize(int to_size)
{ {
// Rotate core to solidmask. size = to_size;
// Rotate core to match solidmask.
var r = -70; var r = -70;
var fsin = Sin(r, 10 * size), fcos = Cos(r, 10 * size); var fsin = Sin(r, 10 * size), fcos = Cos(r, 10 * size);
SetObjDrawTransform(+fcos, +fsin, 0, -fsin, +fcos, 0); SetObjDrawTransform(+fcos, +fsin, 0, -fsin, +fcos, 0);
// Update solid mask. return;
}
public func AddSolidMask()
{
var solid_size = 2 * ((size * 20 / 100 + 2) / 2) + 4; var solid_size = 2 * ((size * 20 / 100 + 2) / 2) + 4;
solid_size = BoundBy(solid_size, 4, 28); solid_size = BoundBy(solid_size, 4, 28);
var solid_x = (1 + solid_size / 2) * (solid_size - 4); var solid_x = (1 + solid_size / 2) * (solid_size - 4);
@ -29,6 +33,12 @@ public func SetSize(int size)
return; return;
} }
public func RemoveSolidMask()
{
SetSolidMask();
return;
}
/*-- Saving --*/ /*-- Saving --*/

View File

@ -160,10 +160,14 @@ local FxCoreBehavior = new Effect
var angle = Random(360); var angle = Random(360);
if (prey) if (prey)
angle = Angle(Target->GetX(), Target->GetY(), prey->GetX(), prey->GetY()); angle = Angle(Target->GetX(), Target->GetY(), prey->GetX(), prey->GetY());
var test_x = Sin(angle, Target->GetCon() / 4); // Test if shot is not blocked by the shell.
var test_y = -Cos(angle, Target->GetCon() / 4); if (Target.shell)
if (!PathFree(Target->GetX(), Target->GetY(), Target->GetX() + test_x, Target->GetY() + test_y)) {
var shell_angle = Normalize(Target.shell->GetR() + 90, 0);
var diff_angle = angle - shell_angle;
if (!Inside(diff_angle, -30, 30) && diff_angle < 330 && diff_angle > -330)
return; return;
}
var bubble = Target->CreateObject(BoilingLava_Bubble); var bubble = Target->CreateObject(BoilingLava_Bubble);
bubble->SetVelocity(angle, RandomX(30, 40)); bubble->SetVelocity(angle, RandomX(30, 40));
@ -195,7 +199,6 @@ local FxCoreBehavior = new Effect
var cnat = Target->GetContact(-1); var cnat = Target->GetContact(-1);
if (!Target->InLiquid()) if (!Target->InLiquid())
{ {
//Log("[%d]%v out of liquid", FrameCounter(), Target);
cnat = cnat | CNAT_Top; cnat = cnat | CNAT_Top;
} }
var other_core = Target->FindObject(Find_ID(LavaCore), Find_Exclude(Target), Target->Find_Distance(20 + Target.MaxSize)); var other_core = Target->FindObject(Find_ID(LavaCore), Find_Exclude(Target), Target->Find_Distance(20 + Target.MaxSize));
@ -321,6 +324,7 @@ public func Fossilize()
{ {
shell->SetMeshMaterial("LavaShellStoneMat"); shell->SetMeshMaterial("LavaShellStoneMat");
shell->SetRDir(0); shell->SetRDir(0);
shell->AddSolidMask();
} }
return; return;
} }
@ -332,7 +336,10 @@ public func Revive()
SetComDir(COMD_None); SetComDir(COMD_None);
SetMeshMaterial("LavaCoreMat"); SetMeshMaterial("LavaCoreMat");
if (shell) if (shell)
{
shell->SetMeshMaterial("LavaShellMat"); shell->SetMeshMaterial("LavaShellMat");
shell->RemoveSolidMask();
}
return; return;
} }