mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -04:00
fix gun destroy
This commit is contained in:
parent
52a691c039
commit
6420b2bece
@ -28,6 +28,12 @@ namespace MCGalaxy.Games {
|
|||||||
public override string Name { get { return "Gun"; } }
|
public override string Name { get { return "Gun"; } }
|
||||||
|
|
||||||
protected override void OnActivated(byte yaw, byte pitch, BlockID block) {
|
protected override void OnActivated(byte yaw, byte pitch, BlockID block) {
|
||||||
|
AmmunitionData args = MakeArgs(yaw, pitch, block);
|
||||||
|
SchedulerTask task = new SchedulerTask(GunCallback, args, TimeSpan.Zero, true);
|
||||||
|
p.CriticalTasks.Add(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AmmunitionData MakeArgs(byte yaw, byte pitch, BlockID block) {
|
||||||
AmmunitionData args = new AmmunitionData();
|
AmmunitionData args = new AmmunitionData();
|
||||||
args.block = block;
|
args.block = block;
|
||||||
|
|
||||||
@ -35,9 +41,7 @@ namespace MCGalaxy.Games {
|
|||||||
args.dir = DirUtils.GetDirVector(yaw, pitch);
|
args.dir = DirUtils.GetDirVector(yaw, pitch);
|
||||||
args.pos = args.PosAt(3);
|
args.pos = args.PosAt(3);
|
||||||
args.iterations = 4;
|
args.iterations = 4;
|
||||||
|
return args;
|
||||||
SchedulerTask task = new SchedulerTask(GunCallback, args, TimeSpan.Zero, true);
|
|
||||||
p.CriticalTasks.Add(task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual bool OnHitBlock(AmmunitionData args, Vec3U16 pos, BlockID block) {
|
protected virtual bool OnHitBlock(AmmunitionData args, Vec3U16 pos, BlockID block) {
|
||||||
@ -68,7 +72,7 @@ namespace MCGalaxy.Games {
|
|||||||
return args.visible.Count > 0;
|
return args.visible.Count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GunCallback(SchedulerTask task) {
|
protected void GunCallback(SchedulerTask task) {
|
||||||
AmmunitionData args = (AmmunitionData)task.State;
|
AmmunitionData args = (AmmunitionData)task.State;
|
||||||
if (args.moving) {
|
if (args.moving) {
|
||||||
args.moving = TickGun(args);
|
args.moving = TickGun(args);
|
||||||
@ -104,8 +108,11 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
protected override bool OnHitBlock(AmmunitionData args, Vec3U16 pos, BlockID block) {
|
protected override bool OnHitBlock(AmmunitionData args, Vec3U16 pos, BlockID block) {
|
||||||
if (p.level.physics < 2 || block == Block.Glass) return true;
|
if (p.level.physics < 2 || block == Block.Glass) return true;
|
||||||
|
|
||||||
|
if (!p.level.Props[block].LavaKills) return true;
|
||||||
// Penetrative gun goes through blocks lava can go through
|
// Penetrative gun goes through blocks lava can go through
|
||||||
return !p.level.Props[block].LavaKills;
|
p.level.Blockchange(pos.X, pos.Y, pos.Z, Block.Air);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user