mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-09-04 02:09:35 -04:00
Fix and improve active shards logic
This commit is contained in:
+9
-2
@@ -1293,7 +1293,10 @@ Gfx *lvRender(Gfx *gdl)
|
||||
PROFILE(PROFILEMARKER_LVR_BEAMS, gdl = propsRenderBeams(gdl));
|
||||
}
|
||||
|
||||
PROFILE(PROFILEMARKER_LVR_SHARDS, gdl = shardsRender(gdl));
|
||||
if (g_ShardsActive) {
|
||||
PROFILE(PROFILEMARKER_LVR_SHARDS, gdl = shardsRender(gdl));
|
||||
}
|
||||
|
||||
PROFILE(PROFILEMARKER_LVR_SPARKS, gdl = sparksRender(gdl));
|
||||
PROFILE(PROFILEMARKER_LVR_WEATHER, gdl = weatherRender(gdl));
|
||||
|
||||
@@ -2018,7 +2021,11 @@ void lvTick(void)
|
||||
PROFILE(PROFILEMARKER_LVT_ROOMS, roomsTick());
|
||||
skyTick();
|
||||
PROFILE(PROFILEMARKER_LVT_CASINGS, casingsTick());
|
||||
PROFILE(PROFILEMARKER_LVT_SHARDS, shardsTick());
|
||||
|
||||
if (g_ShardsActive) {
|
||||
PROFILE(PROFILEMARKER_LVT_SHARDS, shardsTick());
|
||||
}
|
||||
|
||||
PROFILE(PROFILEMARKER_LVT_SPARKS, sparksTick());
|
||||
PROFILE(PROFILEMARKER_LVT_WALLHITS, wallhitsTick());
|
||||
|
||||
|
||||
+9
-2
@@ -18,6 +18,8 @@ struct shard *g_Shards;
|
||||
|
||||
s32 g_NextShardNum = 0;
|
||||
bool g_ShardsActive = false;
|
||||
bool g_GlassShardsActive = false;
|
||||
bool g_WoodShardsActive = false;
|
||||
|
||||
void shardCreate(s16 room, struct coord *pos, f32 rotx, f32 size, s32 type);
|
||||
|
||||
@@ -452,8 +454,13 @@ Gfx *shardsRenderGlass(Gfx *gdl)
|
||||
|
||||
Gfx *shardsRender(Gfx *gdl)
|
||||
{
|
||||
gdl = shardsRenderWood(gdl);
|
||||
gdl = shardsRenderGlass(gdl);
|
||||
if (g_WoodShardsActive) {
|
||||
gdl = shardsRenderWood(gdl);
|
||||
}
|
||||
|
||||
if (g_GlassShardsActive) {
|
||||
gdl = shardsRenderGlass(gdl);
|
||||
}
|
||||
|
||||
return gdl;
|
||||
}
|
||||
|
||||
@@ -26,4 +26,8 @@ void shardsReset(void)
|
||||
}
|
||||
|
||||
g_NextShardNum = 0;
|
||||
|
||||
g_ShardsActive = false;
|
||||
g_WoodShardsActive = false;
|
||||
g_GlassShardsActive = false;
|
||||
}
|
||||
|
||||
+24
-22
@@ -10,34 +10,36 @@ void shardsTick(void)
|
||||
s32 i;
|
||||
s32 j;
|
||||
|
||||
if (g_ShardsActive) {
|
||||
lvupdate = (g_Vars.lvupdate60 < TICKS(15)) ? g_Vars.lvupdate60 : TICKS(15);
|
||||
lvupdate = (g_Vars.lvupdate60 < TICKS(15)) ? g_Vars.lvupdate60 : TICKS(15);
|
||||
|
||||
for (i = 0; i < g_MaxShards; i++) {
|
||||
if (g_Shards[i].age60 > 0) {
|
||||
g_Shards[i].age60 += (s32)lvupdate;
|
||||
g_ShardsActive = false;
|
||||
g_WoodShardsActive = false;
|
||||
g_GlassShardsActive = false;
|
||||
|
||||
g_Shards[i].rot.x += g_Shards[i].rotspeed.x * lvupdate;
|
||||
g_Shards[i].rot.y += g_Shards[i].rotspeed.y * lvupdate;
|
||||
g_Shards[i].rot.z += g_Shards[i].rotspeed.z * lvupdate;
|
||||
g_Shards[i].pos.x += g_Shards[i].vel.x * lvupdate;
|
||||
g_Shards[i].pos.z += g_Shards[i].vel.z * lvupdate;
|
||||
for (i = 0; i < g_MaxShards; i++) {
|
||||
if (g_Shards[i].age60 > 0) {
|
||||
g_Shards[i].age60 += (s32)lvupdate;
|
||||
|
||||
for (j = 0; j < (s32)lvupdate; j++) {
|
||||
g_Shards[i].pos.y += g_Shards[i].vel.y;
|
||||
g_Shards[i].vel.y -= PALUPF(0.1f);
|
||||
}
|
||||
g_Shards[i].rot.x += g_Shards[i].rotspeed.x * lvupdate;
|
||||
g_Shards[i].rot.y += g_Shards[i].rotspeed.y * lvupdate;
|
||||
g_Shards[i].rot.z += g_Shards[i].rotspeed.z * lvupdate;
|
||||
g_Shards[i].pos.x += g_Shards[i].vel.x * lvupdate;
|
||||
g_Shards[i].pos.z += g_Shards[i].vel.z * lvupdate;
|
||||
|
||||
if (g_Shards[i].age60 >= TICKS(150)) {
|
||||
g_Shards[i].age60 = 0;
|
||||
}
|
||||
for (j = 0; j < (s32)lvupdate; j++) {
|
||||
g_Shards[i].pos.y += g_Shards[i].vel.y;
|
||||
g_Shards[i].vel.y -= PALUPF(0.1f);
|
||||
}
|
||||
|
||||
if (g_Shards[i].pos.y < -30000 || g_Shards[i].pos.y > 30000) {
|
||||
g_Shards[i].age60 = 0;
|
||||
}
|
||||
if (g_Shards[i].age60 >= TICKS(150) || g_Shards[i].pos.y < -30000 || g_Shards[i].pos.y > 30000) {
|
||||
g_Shards[i].age60 = 0;
|
||||
} else {
|
||||
g_ShardsActive = true;
|
||||
|
||||
if (!g_ShardsActive) {
|
||||
g_ShardsActive = true;
|
||||
if (g_Shards[i].type == SHARDTYPE_GLASS) {
|
||||
g_GlassShardsActive = true;
|
||||
} else if (g_Shards[i].type == SHARDTYPE_WOOD) {
|
||||
g_WoodShardsActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,6 +463,8 @@ extern bool g_SparksAreActive;
|
||||
extern struct weatherdata *g_WeatherData;
|
||||
extern s32 g_NextShardNum;
|
||||
extern bool g_ShardsActive;
|
||||
extern bool g_WoodShardsActive;
|
||||
extern bool g_GlassShardsActive;
|
||||
extern s32 var800800f0jf;
|
||||
extern s32 g_ScaleX;
|
||||
extern s32 var80080108jf;
|
||||
|
||||
Reference in New Issue
Block a user