mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 14:54:12 -04:00
Use class variable physRandom instead of declaring a new Random() instance every physics tick.
This commit is contained in:
parent
cbbb7bda0e
commit
67225c5e6e
@ -121,7 +121,7 @@ namespace MCGalaxy {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe void CalcPhysics() {
|
public void CalcPhysics() {
|
||||||
if (physics == 0) return;
|
if (physics == 0) return;
|
||||||
try {
|
try {
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
@ -144,7 +144,6 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Random rand = new Random();
|
|
||||||
for (int i = 0; i < ListCheck.Count; i++) {
|
for (int i = 0; i < ListCheck.Count; i++) {
|
||||||
Check C = ListCheck.Items[i];
|
Check C = ListCheck.Items[i];
|
||||||
IntToPos(C.b, out x, out y, out z);
|
IntToPos(C.b, out x, out y, out z);
|
||||||
@ -156,8 +155,8 @@ namespace MCGalaxy {
|
|||||||
PhysicsUpdate(x, y, z, C.time, info, this);
|
PhysicsUpdate(x, y, z, C.time, info, this);
|
||||||
if (OnPhysicsUpdateEvent.events.Count > 0)
|
if (OnPhysicsUpdateEvent.events.Count > 0)
|
||||||
OnPhysicsUpdateEvent.Call(x, y, z, C.time, info, this);
|
OnPhysicsUpdateEvent.Call(x, y, z, C.time, info, this);
|
||||||
if (info == "" || ExtraInfoPhysics.DoComplex(this, C, rand))
|
if (info == "" || ExtraInfoPhysics.DoComplex(this, C))
|
||||||
DoNormalPhysics(x, y, z, rand, C);
|
DoNormalPhysics(x, y, z, C);
|
||||||
} catch {
|
} catch {
|
||||||
listCheckExists.Set(x, y, z, false);
|
listCheckExists.Set(x, y, z, false);
|
||||||
ListCheck.Remove(C);
|
ListCheck.Remove(C);
|
||||||
@ -191,37 +190,37 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoNormalPhysics(ushort x, ushort y, ushort z, Random rand, Check C) {
|
void DoNormalPhysics(ushort x, ushort y, ushort z, Check C) {
|
||||||
switch (blocks[C.b]) {
|
switch (blocks[C.b]) {
|
||||||
case Block.air:
|
case Block.air:
|
||||||
AirPhysics.DoAir(this, C, rand); break;
|
AirPhysics.DoAir(this, C); break;
|
||||||
case Block.dirt:
|
case Block.dirt:
|
||||||
OtherPhysics.DoDirt(this, C); break;
|
OtherPhysics.DoDirt(this, C); break;
|
||||||
case Block.leaf:
|
case Block.leaf:
|
||||||
LeafPhysics.DoLeaf(this, C, rand); break;
|
LeafPhysics.DoLeaf(this, C); break;
|
||||||
case Block.shrub:
|
case Block.shrub:
|
||||||
OtherPhysics.DoShrub(this, C, rand); break;
|
OtherPhysics.DoShrub(this, C); break;
|
||||||
case Block.water:
|
case Block.water:
|
||||||
case Block.activedeathwater:
|
case Block.activedeathwater:
|
||||||
SimpleLiquidPhysics.DoWater(this, C, rand); break;
|
SimpleLiquidPhysics.DoWater(this, C); break;
|
||||||
case Block.WaterDown:
|
case Block.WaterDown:
|
||||||
ExtLiquidPhysics.DoWaterfall(this, C, rand); break;
|
ExtLiquidPhysics.DoWaterfall(this, C); break;
|
||||||
case Block.LavaDown:
|
case Block.LavaDown:
|
||||||
ExtLiquidPhysics.DoLavafall(this, C, rand); break;
|
ExtLiquidPhysics.DoLavafall(this, C); break;
|
||||||
case Block.WaterFaucet:
|
case Block.WaterFaucet:
|
||||||
ExtLiquidPhysics.DoFaucet(this, C, rand, Block.WaterDown); break;
|
ExtLiquidPhysics.DoFaucet(this, C, Block.WaterDown); break;
|
||||||
case Block.LavaFaucet:
|
case Block.LavaFaucet:
|
||||||
ExtLiquidPhysics.DoFaucet(this, C, rand, Block.LavaDown); break;
|
ExtLiquidPhysics.DoFaucet(this, C, Block.LavaDown); break;
|
||||||
case Block.lava:
|
case Block.lava:
|
||||||
case Block.activedeathlava:
|
case Block.activedeathlava:
|
||||||
SimpleLiquidPhysics.DoLava(this, C, rand); break;
|
SimpleLiquidPhysics.DoLava(this, C); break;
|
||||||
case Block.fire:
|
case Block.fire:
|
||||||
FirePhysics.Do(this, C, rand); break;
|
FirePhysics.Do(this, C); break;
|
||||||
case Block.finiteWater:
|
case Block.finiteWater:
|
||||||
case Block.finiteLava:
|
case Block.finiteLava:
|
||||||
FinitePhysics.DoWaterOrLava(this, C, rand); break;
|
FinitePhysics.DoWaterOrLava(this, C); break;
|
||||||
case Block.finiteFaucet:
|
case Block.finiteFaucet:
|
||||||
FinitePhysics.DoFaucet(this, C, rand); break;
|
FinitePhysics.DoFaucet(this, C); break;
|
||||||
case Block.sand:
|
case Block.sand:
|
||||||
case Block.gravel:
|
case Block.gravel:
|
||||||
OtherPhysics.DoFalling(this, C, blocks[C.b]); break;
|
OtherPhysics.DoFalling(this, C, blocks[C.b]); break;
|
||||||
@ -261,64 +260,64 @@ namespace MCGalaxy {
|
|||||||
OtherPhysics.DoFloatwood(this, C); break;
|
OtherPhysics.DoFloatwood(this, C); break;
|
||||||
case Block.lava_fast:
|
case Block.lava_fast:
|
||||||
case Block.fastdeathlava:
|
case Block.fastdeathlava:
|
||||||
SimpleLiquidPhysics.DoFastLava(this, C, rand); break;
|
SimpleLiquidPhysics.DoFastLava(this, C); break;
|
||||||
//Special blocks that are not saved
|
//Special blocks that are not saved
|
||||||
case Block.air_flood:
|
case Block.air_flood:
|
||||||
AirPhysics.DoFlood(this, C, rand, AirFlood.Full, Block.air_flood); break;
|
AirPhysics.DoFlood(this, C, AirFlood.Full, Block.air_flood); break;
|
||||||
case Block.air_flood_layer:
|
case Block.air_flood_layer:
|
||||||
AirPhysics.DoFlood(this, C, rand, AirFlood.Layer, Block.air_flood_layer); break;
|
AirPhysics.DoFlood(this, C, AirFlood.Layer, Block.air_flood_layer); break;
|
||||||
case Block.air_flood_down:
|
case Block.air_flood_down:
|
||||||
AirPhysics.DoFlood(this, C, rand, AirFlood.Down, Block.air_flood_down); break;
|
AirPhysics.DoFlood(this, C, AirFlood.Down, Block.air_flood_down); break;
|
||||||
case Block.air_flood_up:
|
case Block.air_flood_up:
|
||||||
AirPhysics.DoFlood(this, C, rand, AirFlood.Up, Block.air_flood_up); break;
|
AirPhysics.DoFlood(this, C, AirFlood.Up, Block.air_flood_up); break;
|
||||||
case Block.smalltnt:
|
case Block.smalltnt:
|
||||||
TntPhysics.DoSmallTnt(this, C, rand); break;
|
TntPhysics.DoSmallTnt(this, C); break;
|
||||||
case Block.bigtnt:
|
case Block.bigtnt:
|
||||||
TntPhysics.DoLargeTnt(this, C, rand, 1); break;
|
TntPhysics.DoLargeTnt(this, C, 1); break;
|
||||||
case Block.nuketnt:
|
case Block.nuketnt:
|
||||||
TntPhysics.DoLargeTnt(this, C, rand, 4); break;
|
TntPhysics.DoLargeTnt(this, C, 4); break;
|
||||||
case Block.tntexplosion:
|
case Block.tntexplosion:
|
||||||
TntPhysics.DoTntExplosion(this, C, rand); break;
|
TntPhysics.DoTntExplosion(this, C); break;
|
||||||
case Block.train:
|
case Block.train:
|
||||||
TrainPhysics.Do(this, C, rand); break;
|
TrainPhysics.Do(this, C); break;
|
||||||
case Block.magma:
|
case Block.magma:
|
||||||
ExtLiquidPhysics.DoMagma(this, C, rand); break;
|
ExtLiquidPhysics.DoMagma(this, C); break;
|
||||||
case Block.geyser:
|
case Block.geyser:
|
||||||
ExtLiquidPhysics.DoGeyser(this, C, rand); break;
|
ExtLiquidPhysics.DoGeyser(this, C); break;
|
||||||
case Block.birdblack:
|
case Block.birdblack:
|
||||||
case Block.birdwhite:
|
case Block.birdwhite:
|
||||||
case Block.birdlava:
|
case Block.birdlava:
|
||||||
case Block.birdwater:
|
case Block.birdwater:
|
||||||
BirdPhysics.Do(this, C, rand); break;
|
BirdPhysics.Do(this, C); break;
|
||||||
case Block.snaketail:
|
case Block.snaketail:
|
||||||
SnakePhysics.DoTail(this, C); break;
|
SnakePhysics.DoTail(this, C); break;
|
||||||
case Block.snake:
|
case Block.snake:
|
||||||
SnakePhysics.Do(this, C, rand); break;
|
SnakePhysics.Do(this, C); break;
|
||||||
case Block.birdred:
|
case Block.birdred:
|
||||||
case Block.birdblue:
|
case Block.birdblue:
|
||||||
case Block.birdkill:
|
case Block.birdkill:
|
||||||
HunterPhysics.DoKiller(this, C, rand, Block.air); break;
|
HunterPhysics.DoKiller(this, C, Block.air); break;
|
||||||
case Block.fishbetta:
|
case Block.fishbetta:
|
||||||
case Block.fishshark:
|
case Block.fishshark:
|
||||||
HunterPhysics.DoKiller(this, C, rand, Block.water); break;
|
HunterPhysics.DoKiller(this, C, Block.water); break;
|
||||||
case Block.fishgold:
|
case Block.fishgold:
|
||||||
case Block.fishsalmon:
|
case Block.fishsalmon:
|
||||||
case Block.fishsponge:
|
case Block.fishsponge:
|
||||||
HunterPhysics.DoFlee(this, C, rand, Block.water); break;
|
HunterPhysics.DoFlee(this, C, Block.water); break;
|
||||||
case Block.fishlavashark:
|
case Block.fishlavashark:
|
||||||
HunterPhysics.DoKiller(this, C, rand, Block.lava); break;
|
HunterPhysics.DoKiller(this, C, Block.lava); break;
|
||||||
case Block.rockethead:
|
case Block.rockethead:
|
||||||
RocketPhysics.Do(this, C, rand); break;
|
RocketPhysics.Do(this, C); break;
|
||||||
case Block.firework:
|
case Block.firework:
|
||||||
FireworkPhysics.Do(this, C, rand); break;
|
FireworkPhysics.Do(this, C); break;
|
||||||
case Block.zombiehead:
|
case Block.zombiehead:
|
||||||
ZombiePhysics.DoHead(this, C); break;
|
ZombiePhysics.DoHead(this, C); break;
|
||||||
case Block.creeper:
|
case Block.creeper:
|
||||||
ZombiePhysics.Do(this, C, rand); break;
|
ZombiePhysics.Do(this, C); break;
|
||||||
case Block.c4:
|
case Block.c4:
|
||||||
C4Physics.DoC4(this, C, rand); break;
|
C4Physics.DoC4(this, C); break;
|
||||||
case Block.c4det:
|
case Block.c4det:
|
||||||
C4Physics.DoC4Det(this, C, rand); break;
|
C4Physics.DoC4Det(this, C); break;
|
||||||
default:
|
default:
|
||||||
DoorPhysics.Do(this, C); break;
|
DoorPhysics.Do(this, C); break;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,7 @@ namespace MCGalaxy
|
|||||||
public LevelPermission permissionvisit = LevelPermission.Guest;
|
public LevelPermission permissionvisit = LevelPermission.Guest;
|
||||||
public LevelPermission pervisitmax = LevelPermission.Nobody;
|
public LevelPermission pervisitmax = LevelPermission.Nobody;
|
||||||
|
|
||||||
|
public Random physRandom = new Random();
|
||||||
public bool physPause;
|
public bool physPause;
|
||||||
public DateTime physResume;
|
public DateTime physResume;
|
||||||
public Thread physThread;
|
public Thread physThread;
|
||||||
|
@ -22,7 +22,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
public enum AirFlood { Full, Layer, Down, Up, }
|
public enum AirFlood { Full, Layer, Down, Up, }
|
||||||
public static class AirPhysics {
|
public static class AirPhysics {
|
||||||
|
|
||||||
public static void DoAir(Level lvl, Check C, Random rand) {
|
public static void DoAir(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
@ -43,7 +44,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
C.time = 255;
|
C.time = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoFlood(Level lvl, Check C, Random rand, AirFlood mode, byte block) {
|
public static void DoFlood(Level lvl, Check C, AirFlood mode, byte block) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
if (C.time >= 1) {
|
if (C.time >= 1) {
|
||||||
lvl.AddUpdate(C.b, Block.air);
|
lvl.AddUpdate(C.b, Block.air);
|
||||||
C.time = 255; return;
|
C.time = 255; return;
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class BirdPhysics {
|
public static class BirdPhysics {
|
||||||
|
|
||||||
public static void Do(Level lvl, Check C, Random rand) {
|
public static void Do(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class C4Physics {
|
public static class C4Physics {
|
||||||
|
|
||||||
public static void DoC4(Level lvl, Check C, Random rand) {
|
public static void DoC4(Level lvl, Check C) {
|
||||||
C4Data c4 = Find(lvl, ((Player)C.data).c4circuitNumber);
|
C4Data c4 = Find(lvl, ((Player)C.data).c4circuitNumber);
|
||||||
if (c4 != null) c4.list.Add(C.b);
|
if (c4 != null) c4.list.Add(C.b);
|
||||||
C.time = 255;
|
C.time = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoC4Det(Level lvl, Check C, Random rand) {
|
public static void DoC4Det(Level lvl, Check C) {
|
||||||
C4Data c4 = Find(lvl, ((Player)C.data).c4circuitNumber);
|
C4Data c4 = Find(lvl, ((Player)C.data).c4circuitNumber);
|
||||||
if (c4 != null) c4.detIndex = C.b;
|
if (c4 != null) c4.detIndex = C.b;
|
||||||
((Player)C.data).c4circuitNumber = -1;
|
((Player)C.data).c4circuitNumber = -1;
|
||||||
|
@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class ExtLiquidPhysics {
|
public static class ExtLiquidPhysics {
|
||||||
|
|
||||||
public static void DoMagma(Level lvl, Check C, Random rand) {
|
public static void DoMagma(Level lvl, Check C) {
|
||||||
C.time++;
|
C.time++;
|
||||||
if (C.time < 3) return;
|
if (C.time < 3) return;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
@ -59,7 +59,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoGeyser(Level lvl, Check C, Random rand) {
|
public static void DoGeyser(Level lvl, Check C) {
|
||||||
C.time++;
|
C.time++;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
@ -96,7 +96,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoWaterfall(Level lvl, Check C, Random rand) {
|
public static void DoWaterfall(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
byte below = lvl.GetTile(x, (ushort)(y - 1), z);
|
byte below = lvl.GetTile(x, (ushort)(y - 1), z);
|
||||||
@ -125,7 +126,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoLavafall(Level lvl, Check C, Random rand) {
|
public static void DoLavafall(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
byte below = lvl.GetTile(x, (ushort)(y - 1), z);
|
byte below = lvl.GetTile(x, (ushort)(y - 1), z);
|
||||||
@ -154,7 +156,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoFaucet(Level lvl, Check C, Random rand, byte target) {
|
public static void DoFaucet(Level lvl, Check C, byte target) {
|
||||||
C.time++;
|
C.time++;
|
||||||
if (C.time < 2) return;
|
if (C.time < 2) return;
|
||||||
C.time = 0;
|
C.time = 0;
|
||||||
@ -163,7 +165,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
int index = lvl.PosToInt(x, (ushort)(y - 1), z);
|
int index = lvl.PosToInt(x, (ushort)(y - 1), z);
|
||||||
if (index < 0) return;
|
if (index < 0) return;
|
||||||
|
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
byte block = lvl.blocks[index];
|
byte block = lvl.blocks[index];
|
||||||
if (block == Block.air || block == target) {
|
if (block == Block.air || block == target) {
|
||||||
if (rand.Next(1, 10) > 7)
|
if (rand.Next(1, 10) > 7)
|
||||||
|
@ -75,7 +75,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool DoComplex(Level lvl, Check C, Random rand) {
|
public static bool DoComplex(Level lvl, Check C) {
|
||||||
string info = C.data as string;
|
string info = C.data as string;
|
||||||
if (info == null) return true;
|
if (info == null) return true;
|
||||||
if (!info.Contains("wait") && lvl.blocks[C.b] == Block.air)
|
if (!info.Contains("wait") && lvl.blocks[C.b] == Block.air)
|
||||||
@ -126,17 +126,18 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
C.data =
|
C.data =
|
||||||
info.Substring(0, waitIndex) +
|
info.Substring(0, waitIndex) +
|
||||||
info.Substring(info.IndexOf(' ', waitIndex + 5) + 1);
|
info.Substring(info.IndexOf(' ', waitIndex + 5) + 1);
|
||||||
DoOther(lvl, C, rand, ref args);
|
DoOther(lvl, C, ref args);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
C.time++;
|
C.time++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
DoOther(lvl, C, rand, ref args);
|
DoOther(lvl, C, ref args);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoOther(Level lvl, Check C, Random rand, ref ExtraInfoArgs args) {
|
static void DoOther(Level lvl, Check C, ref ExtraInfoArgs args) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class FinitePhysics {
|
public static class FinitePhysics {
|
||||||
|
|
||||||
public unsafe static void DoWaterOrLava(Level lvl, Check C, Random rand) {
|
public unsafe static void DoWaterOrLava(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
@ -85,7 +86,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe static void DoFaucet(Level lvl, Check C, Random rand) {
|
public unsafe static void DoFaucet(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
lvl.MakeExplosion((ushort)x, (ushort)y, (ushort)z, -1);
|
lvl.MakeExplosion((ushort)x, (ushort)y, (ushort)z, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Do(Level lvl, Check C, Random rand) {
|
public static void Do(Level lvl, Check C) {
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
if (C.time < 2) {
|
if (C.time < 2) {
|
||||||
@ -62,6 +62,7 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
if (rand.Next(1, 20) == 1 && C.time % 2 == 0) {
|
if (rand.Next(1, 20) == 1 && C.time % 2 == 0) {
|
||||||
int max = rand.Next(1, 18);
|
int max = rand.Next(1, 18);
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class FireworkPhysics {
|
public static class FireworkPhysics {
|
||||||
|
|
||||||
public static void Do(Level lvl, Check C, Random rand) {
|
public static void Do(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class HunterPhysics {
|
public static class HunterPhysics {
|
||||||
|
|
||||||
public static void DoKiller(Level lvl, Check C, Random rand, byte target) {
|
public static void DoKiller(Level lvl, Check C, byte target) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
Player closest = AIPhysics.ClosestPlayer(lvl, C);
|
Player closest = AIPhysics.ClosestPlayer(lvl, C);
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
@ -65,7 +66,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
RandomlyMove(lvl, C, rand, x, y, z, target);
|
RandomlyMove(lvl, C, rand, x, y, z, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoFlee(Level lvl, Check C, Random rand, byte target) {
|
public static void DoFlee(Level lvl, Check C, byte target) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
Player closest = AIPhysics.ClosestPlayer(lvl, C);
|
Player closest = AIPhysics.ClosestPlayer(lvl, C);
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class LeafPhysics {
|
public static class LeafPhysics {
|
||||||
|
|
||||||
public static void DoLeaf(Level lvl, Check C, Random rand) {
|
public static void DoLeaf(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
if (lvl.physics > 1) { //Adv physics kills flowers and mushroos in water/lava
|
if (lvl.physics > 1) { //Adv physics kills flowers and mushroos in water/lava
|
||||||
|
@ -101,7 +101,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
C.time = 255;
|
C.time = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoShrub(Level lvl, Check C, Random rand) {
|
public static void DoShrub(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
if (lvl.physics > 1) { //Adv physics kills flowers and mushroos in water/lava
|
if (lvl.physics > 1) { //Adv physics kills flowers and mushroos in water/lava
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class RocketPhysics {
|
public static class RocketPhysics {
|
||||||
|
|
||||||
public static void Do(Level lvl, Check C, Random rand) {
|
public static void Do(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
|
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
|
||||||
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;
|
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;
|
||||||
int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1;
|
int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1;
|
||||||
|
@ -22,45 +22,47 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
public static class SimpleLiquidPhysics {
|
public static class SimpleLiquidPhysics {
|
||||||
|
|
||||||
const StringComparison comp = StringComparison.Ordinal;
|
const StringComparison comp = StringComparison.Ordinal;
|
||||||
public static void DoWater(Level lvl, Check C, Random rand) {
|
public static void DoWater(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
if (lvl.finite) {
|
if (lvl.finite) {
|
||||||
lvl.liquids.Remove(C.b);
|
lvl.liquids.Remove(C.b);
|
||||||
FinitePhysics.DoWaterOrLava(lvl, C, rand);
|
FinitePhysics.DoWaterOrLava(lvl, C);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lvl.randomFlow)
|
if (lvl.randomFlow)
|
||||||
DoWaterRandowFlow(lvl, C, rand);
|
DoWaterRandowFlow(lvl, C);
|
||||||
else
|
else
|
||||||
DoWaterUniformFlow(lvl, C, rand);
|
DoWaterUniformFlow(lvl, C);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoLava(Level lvl, Check C, Random rand) {
|
public static void DoLava(Level lvl, Check C) {
|
||||||
if (C.time < 4) {
|
if (C.time < 4) {
|
||||||
C.time++; return;
|
C.time++; return;
|
||||||
}
|
}
|
||||||
if (lvl.finite) {
|
if (lvl.finite) {
|
||||||
lvl.liquids.Remove(C.b);
|
lvl.liquids.Remove(C.b);
|
||||||
FinitePhysics.DoWaterOrLava(lvl, C, rand);
|
FinitePhysics.DoWaterOrLava(lvl, C);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lvl.randomFlow)
|
if (lvl.randomFlow)
|
||||||
DoLavaRandowFlow(lvl, C, rand, true);
|
DoLavaRandowFlow(lvl, C, true);
|
||||||
else
|
else
|
||||||
DoLavaUniformFlow(lvl, C, rand, true);
|
DoLavaUniformFlow(lvl, C, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoFastLava(Level lvl, Check C, Random rand) {
|
public static void DoFastLava(Level lvl, Check C) {
|
||||||
if (lvl.randomFlow) {
|
if (lvl.randomFlow) {
|
||||||
byte oldTime = C.time;
|
byte oldTime = C.time;
|
||||||
DoLavaRandowFlow(lvl, C, rand, false);
|
DoLavaRandowFlow(lvl, C, false);
|
||||||
if (C.time != 255)
|
if (C.time != 255)
|
||||||
C.time = oldTime;
|
C.time = oldTime;
|
||||||
} else {
|
} else {
|
||||||
DoLavaUniformFlow(lvl, C, rand, false);
|
DoLavaUniformFlow(lvl, C, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoWaterRandowFlow(Level lvl, Check C, Random rand) {
|
static void DoWaterRandowFlow(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
bool[] blocked = null;
|
bool[] blocked = null;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
@ -122,7 +124,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoWaterUniformFlow(Level lvl, Check C, Random rand) {
|
static void DoWaterUniformFlow(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
lvl.liquids.Remove(C.b);
|
lvl.liquids.Remove(C.b);
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
@ -175,7 +178,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoLavaRandowFlow(Level lvl, Check C, Random rand, bool checkWait) {
|
static void DoLavaRandowFlow(Level lvl, Check C, bool checkWait) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
bool[] blocked = null;
|
bool[] blocked = null;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
@ -234,7 +238,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoLavaUniformFlow(Level lvl, Check C, Random rand, bool checkWait) {
|
static void DoLavaUniformFlow(Level lvl, Check C, bool checkWait) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
lvl.liquids.Remove(C.b);
|
lvl.liquids.Remove(C.b);
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class SnakePhysics {
|
public static class SnakePhysics {
|
||||||
|
|
||||||
public static void Do(Level lvl, Check C, Random rand) {
|
public static void Do(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
int dirsVisited = 0, index = 0;
|
int dirsVisited = 0, index = 0;
|
||||||
|
@ -32,12 +32,14 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
lvl.Blockchange(x, y, (ushort)(z - 1), lvl.GetTile(x, y, (ushort)(z - 1)) == Block.lavastill ? Block.air : Block.lavastill);
|
lvl.Blockchange(x, y, (ushort)(z - 1), lvl.GetTile(x, y, (ushort)(z - 1)) == Block.lavastill ? Block.air : Block.lavastill);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoTntExplosion(Level lvl, Check C, Random rand) {
|
public static void DoTntExplosion(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
if (rand.Next(1, 11) <= 7)
|
if (rand.Next(1, 11) <= 7)
|
||||||
lvl.AddUpdate(C.b, Block.air);
|
lvl.AddUpdate(C.b, Block.air);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoLargeTnt(Level lvl, Check C, Random rand, int power) {
|
public static void DoLargeTnt(Level lvl, Check C, int power) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
@ -53,10 +55,12 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoSmallTnt(Level lvl, Check C, Random rand) {
|
public static void DoSmallTnt(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
Player p = C.data as Player;
|
Player p = C.data as Player;
|
||||||
|
|
||||||
if (p != null && p.PlayingTntWars) {
|
if (p != null && p.PlayingTntWars) {
|
||||||
int power = 2, threshold = 3;
|
int power = 2, threshold = 3;
|
||||||
TntWarsGame game = TntWarsGame.GetTntWarsGame(p);
|
TntWarsGame game = TntWarsGame.GetTntWarsGame(p);
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class TrainPhysics {
|
public static class TrainPhysics {
|
||||||
|
|
||||||
public static void Do(Level lvl, Check C, Random rand) {
|
public static void Do(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
|
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
|
||||||
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;
|
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;
|
||||||
int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1;
|
int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1;
|
||||||
|
@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics {
|
|||||||
|
|
||||||
public static class ZombiePhysics {
|
public static class ZombiePhysics {
|
||||||
|
|
||||||
public static void Do(Level lvl, Check C, Random rand) {
|
public static void Do(Level lvl, Check C) {
|
||||||
|
Random rand = lvl.physRandom;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user