mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
slightly better explodables
This commit is contained in:
parent
21ac9259d4
commit
98b6781970
6 changed files with 52 additions and 9 deletions
|
|
@ -148,6 +148,7 @@ class MarbleWorld extends Scheduler {
|
|||
public var powerUps:Array<PowerUp> = [];
|
||||
public var forceObjects:Array<ForceObject> = [];
|
||||
public var explodables:Array<Explodable> = [];
|
||||
public var explodablesToTick:Array<Int> = [];
|
||||
public var triggers:Array<Trigger> = [];
|
||||
public var gems:Array<Gem> = [];
|
||||
public var namedObjects:Map<String, {obj:DtsObject, elem:MissionElementBase}> = [];
|
||||
|
|
@ -278,7 +279,7 @@ class MarbleWorld extends Scheduler {
|
|||
predictions = new MarblePredictionStore();
|
||||
powerupPredictions = new PowerupPredictionStore();
|
||||
gemPredictions = new GemPredictionStore();
|
||||
explodablePredictions = new ExplodablePredictionStore();
|
||||
explodablePredictions = new ExplodablePredictionStore(cast this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -616,9 +617,12 @@ class MarbleWorld extends Scheduler {
|
|||
startTime = 1e8;
|
||||
lastMoves = new MarbleUpdateQueue();
|
||||
predictions = new MarblePredictionStore();
|
||||
powerupPredictions = new PowerupPredictionStore();
|
||||
gemPredictions = new GemPredictionStore();
|
||||
explodablePredictions = new ExplodablePredictionStore();
|
||||
powerupPredictions.reset();
|
||||
gemPredictions.reset();
|
||||
explodablePredictions.reset();
|
||||
for (exp in explodables) {
|
||||
exp.lastContactTick = -100000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1506,9 +1510,11 @@ class MarbleWorld extends Scheduler {
|
|||
if (pw.pickupClient != -1 && marbleNeedsPrediction & (1 << pw.pickupClient) > 0)
|
||||
pw.lastPickUpTime = powerupPredictions.getState(pw.netIndex);
|
||||
}
|
||||
for (exp in explodables) {
|
||||
for (expT in explodablesToTick) {
|
||||
var exp = explodables[expT];
|
||||
exp.revertContactTicks(explodablePredictions.getState(exp.netId));
|
||||
}
|
||||
explodablesToTick = [];
|
||||
var huntMode:HuntMode = cast this.gameMode;
|
||||
if (@:privateAccess huntMode.activeGemSpawnGroup != null) {
|
||||
for (activeGem in @:privateAccess huntMode.activeGemSpawnGroup) {
|
||||
|
|
|
|||
|
|
@ -221,6 +221,8 @@ class ParticleEmitter {
|
|||
var getPos:Void->Vector;
|
||||
var spawnSphereSquish:Vector;
|
||||
|
||||
var emittedParticles:Array<Particle> = [];
|
||||
|
||||
public function new(options:ParticleEmitterOptions, data:ParticleData, manager:ParticleManager, ?getPos:Void->Vector, ?spawnSphereSquish:Vector) {
|
||||
this.o = options;
|
||||
this.manager = manager;
|
||||
|
|
@ -270,6 +272,7 @@ class ParticleEmitter {
|
|||
// .add(this.o.ambientVelocity);
|
||||
var particle = new Particle(this.o.particleOptions, this.manager, this.data, time, pos, vel);
|
||||
this.manager.addParticle(data, particle);
|
||||
this.emittedParticles.push(particle);
|
||||
}
|
||||
|
||||
/** Computes the interpolated emitter position at a point in time. */
|
||||
|
|
@ -361,6 +364,12 @@ class ParticleManager {
|
|||
this.emitters.remove(emitter);
|
||||
}
|
||||
|
||||
public function removeEmitterWithParticles(emitter:ParticleEmitter) {
|
||||
this.removeEmitter(emitter);
|
||||
for (particle in emitter.emittedParticles)
|
||||
this.removeParticle(particle.data, particle);
|
||||
}
|
||||
|
||||
public function removeEverything() {
|
||||
for (ident => particles in this.particleGroups) {
|
||||
particles.remove();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
package net;
|
||||
|
||||
import src.MarbleWorld;
|
||||
import net.NetPacket.ExplodableUpdatePacket;
|
||||
import src.TimeState;
|
||||
import net.NetPacket.PowerupPickupPacket;
|
||||
|
||||
class ExplodablePredictionStore {
|
||||
var world:MarbleWorld;
|
||||
var predictions:Array<Int>;
|
||||
|
||||
public inline function new() {
|
||||
public inline function new(world:MarbleWorld) {
|
||||
predictions = [];
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public inline function alloc() {
|
||||
|
|
@ -21,5 +24,13 @@ class ExplodablePredictionStore {
|
|||
|
||||
public inline function acknowledgeExplodableUpdate(packet:ExplodableUpdatePacket) {
|
||||
predictions[packet.explodableId] = packet.serverTicks;
|
||||
if (!world.explodablesToTick.contains(packet.explodableId))
|
||||
world.explodablesToTick.push(packet.explodableId);
|
||||
}
|
||||
|
||||
public inline function reset() {
|
||||
for (i in 0...predictions.length) {
|
||||
predictions[i] = -100000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,10 @@ class GemPredictionStore {
|
|||
for (gemId in packet.gemIds)
|
||||
predictions[gemId] = false;
|
||||
}
|
||||
|
||||
public inline function reset() {
|
||||
for (i in 0...predictions.length) {
|
||||
predictions[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,4 +21,10 @@ class PowerupPredictionStore {
|
|||
public inline function acknowledgePowerupPickup(packet:PowerupPickupPacket, timeState:TimeState, futureTicks:Int) {
|
||||
predictions[packet.powerupItemId] = timeState.currentAttemptTime - futureTicks * 0.032; // Approximate
|
||||
}
|
||||
|
||||
public inline function reset() {
|
||||
for (i in 0...predictions.length) {
|
||||
predictions[i] = Math.NEGATIVE_INFINITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,11 @@ abstract class Explodable extends DtsObject {
|
|||
emitter3 = this.level.particleManager.createEmitter(sparksParticle, sparkParticleData, this.getAbsPos().getPosition());
|
||||
}
|
||||
|
||||
if (Net.isClient) {
|
||||
if (!level.explodablesToTick.contains(netId))
|
||||
level.explodablesToTick.push(netId);
|
||||
}
|
||||
|
||||
// var minePos = this.getAbsPos().getPosition();
|
||||
// var off = marble.getAbsPos().getPosition().sub(minePos);
|
||||
|
||||
|
|
@ -134,17 +139,17 @@ abstract class Explodable extends DtsObject {
|
|||
this.lastContactTick = ticks;
|
||||
if (level.timeState.ticks >= this.lastContactTick + (renewTime >> 5) || level.timeState.ticks < this.lastContactTick) {
|
||||
if (emitter1 != null) {
|
||||
this.level.particleManager.removeEmitter(emitter1);
|
||||
this.level.particleManager.removeEmitterWithParticles(emitter1);
|
||||
emitter1 = null;
|
||||
}
|
||||
|
||||
if (emitter2 != null) {
|
||||
this.level.particleManager.removeEmitter(emitter2);
|
||||
this.level.particleManager.removeEmitterWithParticles(emitter2);
|
||||
emitter2 = null;
|
||||
}
|
||||
|
||||
if (emitter3 != null) {
|
||||
this.level.particleManager.removeEmitter(emitter3);
|
||||
this.level.particleManager.removeEmitterWithParticles(emitter3);
|
||||
emitter3 = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue