Skip to content

Commit

Permalink
LS: Make spreading behaviour slightly less hardcoded
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Dec 24, 2022
1 parent b9eb9f4 commit 0511fa6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
29 changes: 5 additions & 24 deletions MCGalaxy/Games/LavaSurvival/LSGame.Physics.cs
Expand Up @@ -28,8 +28,6 @@ public sealed partial class LSGame : RoundsGame
Map.UpdateBlockHandlers(Block.Deadly_ActiveWater);
Map.UpdateBlockHandlers(Block.Lava);
Map.UpdateBlockHandlers(Block.Deadly_ActiveLava);
Map.UpdateBlockHandlers(Block.FastLava);
Map.UpdateBlockHandlers(Block.Deadly_FastLava);
}

void HandleBlockHandlersUpdated(Level lvl, BlockID block) {
Expand All @@ -43,31 +41,10 @@ public sealed partial class LSGame : RoundsGame
case Block.Lava:
case Block.Deadly_ActiveLava:
lvl.PhysicsHandlers[block] = DoLava; break;
case Block.FastLava:
case Block.Deadly_FastLava:
lvl.PhysicsHandlers[block] = DoFastLava; break;
}
}

void DoWater(Level lvl, ref PhysInfo C) {
DoWaterUniformFlow(lvl, ref C);
}

void DoLava(Level lvl, ref PhysInfo C) {
// upper 3 bits are time delay
if (C.Data.Data < (4 << 5)) {
C.Data.Data += (1 << 5); return;
}

DoLavaUniformFlow(lvl, ref C);
}

void DoFastLava(Level lvl, ref PhysInfo C) {
DoLavaUniformFlow(lvl, ref C);
}


void DoWaterUniformFlow(Level lvl, ref PhysInfo C) {
ushort x = C.X, y = C.Y, z = C.Z;

if (!lvl.CheckSpongeWater(x, y, z)) {
Expand All @@ -84,8 +61,12 @@ public sealed partial class LSGame : RoundsGame
C.Data.Data = PhysicsArgs.RemoveFromChecks;
}

void DoLavaUniformFlow(Level lvl, ref PhysInfo C) {
void DoLava(Level lvl, ref PhysInfo C) {
ushort x = C.X, y = C.Y, z = C.Z;

if (C.Data.Data < spreadDelay) {
C.Data.Data++; return;
}

if (!lvl.CheckSpongeLava(x, y, z)) {
BlockID block = C.Block;
Expand Down
8 changes: 4 additions & 4 deletions MCGalaxy/Games/LavaSurvival/LSGame.cs
Expand Up @@ -35,7 +35,8 @@ public sealed partial class LSGame : RoundsGame

bool flooded, fastMode, killerMode, destroyMode, waterMode, layerMode;
BlockID floodBlock;
int curLayer, roundTotalSecs, floodDelaySecs, layerIntervalSecs;
int curLayer, spreadDelay;
int roundTotalSecs, floodDelaySecs, layerIntervalSecs;

public static LSGame Instance = new LSGame();
public LSGame() { Picker = new LevelPicker(); }
Expand Down Expand Up @@ -64,11 +65,10 @@ public sealed partial class LSGame : RoundsGame

if (waterMode) {
floodBlock = killerMode ? Block.Deadly_ActiveWater : Block.Water;
} else if (fastMode) {
floodBlock = killerMode ? Block.Deadly_FastLava : Block.FastLava;
} else {
floodBlock = killerMode ? Block.Deadly_ActiveLava : Block.Lava;
floodBlock = killerMode ? Block.Deadly_ActiveLava : Block.Lava;
}
spreadDelay = fastMode ? 0 : 4;

curLayer = 1;
roundTotalSecs = (int)cfg.RoundTime.TotalSeconds;
Expand Down

0 comments on commit 0511fa6

Please sign in to comment.