mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 05:01:38 +00:00
network powerup particles (roughly)
This commit is contained in:
parent
084627fa37
commit
ad6afce5d7
3 changed files with 42 additions and 9 deletions
|
|
@ -332,6 +332,7 @@ class Marble extends GameObject {
|
||||||
var netFlags:Int = 0;
|
var netFlags:Int = 0;
|
||||||
var serverTicks:Int;
|
var serverTicks:Int;
|
||||||
var recvServerTick:Int;
|
var recvServerTick:Int;
|
||||||
|
var serverUsePowerup:Bool;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
|
|
@ -377,6 +378,8 @@ class Marble extends GameObject {
|
||||||
var isUltra = true;
|
var isUltra = true;
|
||||||
|
|
||||||
this.posStore = new Vector();
|
this.posStore = new Vector();
|
||||||
|
this.lastRenderPos = new Vector();
|
||||||
|
this.netSmoothOffset = new Vector();
|
||||||
this.netCorrected = false;
|
this.netCorrected = false;
|
||||||
|
|
||||||
var marbleDts = new DtsObject();
|
var marbleDts = new DtsObject();
|
||||||
|
|
@ -1739,14 +1742,22 @@ class Marble extends GameObject {
|
||||||
this.collisionWorld.updateTransform(this.collider);
|
this.collisionWorld.updateTransform(this.collider);
|
||||||
this.collider.velocity = this.velocity;
|
this.collider.velocity = this.velocity;
|
||||||
|
|
||||||
if (this.heldPowerup != null && m.powerup && !this.outOfBounds) {
|
if (this.heldPowerup != null
|
||||||
|
&& (m.powerup || (Net.isClient && this.serverUsePowerup && !this.controllable))
|
||||||
|
&& !this.outOfBounds) {
|
||||||
var pTime = timeState.clone();
|
var pTime = timeState.clone();
|
||||||
pTime.dt = timeStep;
|
pTime.dt = timeStep;
|
||||||
pTime.currentAttemptTime = passedTime;
|
pTime.currentAttemptTime = passedTime;
|
||||||
|
var netUpdate = this.isNetUpdate;
|
||||||
|
if (this.serverUsePowerup)
|
||||||
|
this.isNetUpdate = false;
|
||||||
this.heldPowerup.use(cast this, pTime);
|
this.heldPowerup.use(cast this, pTime);
|
||||||
|
this.isNetUpdate = netUpdate;
|
||||||
this.heldPowerup = null;
|
this.heldPowerup = null;
|
||||||
if (!this.isNetUpdate)
|
this.serverUsePowerup = false;
|
||||||
this.netFlags |= MarbleNetFlags.PickupPowerup;
|
if (!this.isNetUpdate) {
|
||||||
|
this.netFlags |= MarbleNetFlags.PickupPowerup | MarbleNetFlags.UsePowerup;
|
||||||
|
}
|
||||||
if (this.level.isRecording) {
|
if (this.level.isRecording) {
|
||||||
this.level.replay.recordPowerupPickup(null);
|
this.level.replay.recordPowerupPickup(null);
|
||||||
}
|
}
|
||||||
|
|
@ -1873,6 +1884,7 @@ class Marble extends GameObject {
|
||||||
this.blastUseTick = p.blastTick;
|
this.blastUseTick = p.blastTick;
|
||||||
this.helicopterUseTick = p.heliTick;
|
this.helicopterUseTick = p.heliTick;
|
||||||
this.megaMarbleUseTick = p.megaTick;
|
this.megaMarbleUseTick = p.megaTick;
|
||||||
|
this.serverUsePowerup = p.netFlags & MarbleNetFlags.UsePowerup > 0;
|
||||||
// this.currentUp = p.gravityDirection;
|
// this.currentUp = p.gravityDirection;
|
||||||
this.level.setUp(cast this, p.gravityDirection, this.level.timeState);
|
this.level.setUp(cast this, p.gravityDirection, this.level.timeState);
|
||||||
if (this.outOfBounds && !p.oob && this.controllable)
|
if (this.outOfBounds && !p.oob && this.controllable)
|
||||||
|
|
@ -1880,7 +1892,10 @@ class Marble extends GameObject {
|
||||||
this.outOfBounds = p.oob;
|
this.outOfBounds = p.oob;
|
||||||
this.camera.oob = p.oob;
|
this.camera.oob = p.oob;
|
||||||
if (p.powerUpId == 0x1FF) {
|
if (p.powerUpId == 0x1FF) {
|
||||||
this.level.deselectPowerUp(cast this);
|
if (!this.serverUsePowerup)
|
||||||
|
this.level.deselectPowerUp(cast this);
|
||||||
|
else
|
||||||
|
Console.log("Using powerup");
|
||||||
} else {
|
} else {
|
||||||
this.level.pickUpPowerUp(cast this, this.level.powerUps[p.powerUpId]);
|
this.level.pickUpPowerUp(cast this, this.level.powerUps[p.powerUpId]);
|
||||||
}
|
}
|
||||||
|
|
@ -1888,6 +1903,11 @@ class Marble extends GameObject {
|
||||||
// Pad null move on client
|
// Pad null move on client
|
||||||
this.connection.moveManager.duplicateLastMove();
|
this.connection.moveManager.duplicateLastMove();
|
||||||
}
|
}
|
||||||
|
if (Net.isClient && !this.controllable && (this.serverTicks - this.blastUseTick) < 12) {
|
||||||
|
var ticksSince = (this.serverTicks - this.blastUseTick);
|
||||||
|
this.blastWave.doSequenceOnceBeginTime = this.level.timeState.timeSinceLoad - ticksSince * 0.032;
|
||||||
|
this.blastUseTime = this.level.timeState.currentAttemptTime - ticksSince * 0.032;
|
||||||
|
}
|
||||||
|
|
||||||
// if (this.controllable && Net.isClient) {
|
// if (this.controllable && Net.isClient) {
|
||||||
// // We are client, need to do something about the queue
|
// // We are client, need to do something about the queue
|
||||||
|
|
@ -2354,10 +2374,10 @@ class Marble extends GameObject {
|
||||||
if (!this.isNetUpdate) {
|
if (!this.isNetUpdate) {
|
||||||
if (this.controllable)
|
if (this.controllable)
|
||||||
AudioManager.playSound(ResourceLoader.getResource('data/sound/use_blast.wav', ResourceLoader.getAudio, this.soundResources));
|
AudioManager.playSound(ResourceLoader.getResource('data/sound/use_blast.wav', ResourceLoader.getAudio, this.soundResources));
|
||||||
}
|
|
||||||
this.blastWave.doSequenceOnceBeginTime = this.level.timeState.timeSinceLoad;
|
|
||||||
this.blastUseTime = this.level.timeState.currentAttemptTime;
|
|
||||||
|
|
||||||
|
this.blastWave.doSequenceOnceBeginTime = this.level.timeState.timeSinceLoad;
|
||||||
|
this.blastUseTime = this.level.timeState.currentAttemptTime;
|
||||||
|
}
|
||||||
this.blastTicks = 0;
|
this.blastTicks = 0;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2476,7 +2496,7 @@ class Marble extends GameObject {
|
||||||
this.blastTicks = 0;
|
this.blastTicks = 0;
|
||||||
this.helicopterUseTick = 0;
|
this.helicopterUseTick = 0;
|
||||||
this.megaMarbleUseTick = 0;
|
this.megaMarbleUseTick = 0;
|
||||||
this.netFlags = MarbleNetFlags.DoBlast | MarbleNetFlags.DoMega | MarbleNetFlags.DoHelicopter | MarbleNetFlags.PickupPowerup | MarbleNetFlags.GravityChange;
|
this.netFlags = MarbleNetFlags.DoBlast | MarbleNetFlags.DoMega | MarbleNetFlags.DoHelicopter | MarbleNetFlags.PickupPowerup | MarbleNetFlags.GravityChange | MarbleNetFlags.UsePowerup;
|
||||||
this.lastContactNormal = new Vector(0, 0, 1);
|
this.lastContactNormal = new Vector(0, 0, 1);
|
||||||
this.contactEntities = [];
|
this.contactEntities = [];
|
||||||
this._firstTick = true;
|
this._firstTick = true;
|
||||||
|
|
@ -2489,6 +2509,7 @@ class Marble extends GameObject {
|
||||||
this.netSmoothOffset = new Vector();
|
this.netSmoothOffset = new Vector();
|
||||||
this.lastRenderPos = new Vector();
|
this.lastRenderPos = new Vector();
|
||||||
this.netCorrected = false;
|
this.netCorrected = false;
|
||||||
|
this.serverUsePowerup = false;
|
||||||
if (this._radius != this._prevRadius) {
|
if (this._radius != this._prevRadius) {
|
||||||
this._radius = this._prevRadius;
|
this._radius = this._prevRadius;
|
||||||
this._marbleScale = this._renderScale = this._defaultScale;
|
this._marbleScale = this._renderScale = this._defaultScale;
|
||||||
|
|
@ -2507,6 +2528,9 @@ class Marble extends GameObject {
|
||||||
this.slipSound.stop();
|
this.slipSound.stop();
|
||||||
if (this.helicopterSound != null)
|
if (this.helicopterSound != null)
|
||||||
this.helicopterSound.stop();
|
this.helicopterSound.stop();
|
||||||
|
this.shadowVolume.remove();
|
||||||
|
this.helicopter.remove();
|
||||||
|
this.blastWave.remove();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
removeChildren();
|
removeChildren();
|
||||||
camera = null;
|
camera = null;
|
||||||
|
|
|
||||||
|
|
@ -1155,7 +1155,7 @@ class MarbleWorld extends Scheduler {
|
||||||
// Marble states
|
// Marble states
|
||||||
for (marb in this.marbles) {
|
for (marb in this.marbles) {
|
||||||
var oldFlags = @:privateAccess marb.netFlags;
|
var oldFlags = @:privateAccess marb.netFlags;
|
||||||
@:privateAccess marb.netFlags = MarbleNetFlags.DoBlast | MarbleNetFlags.DoMega | MarbleNetFlags.DoHelicopter | MarbleNetFlags.PickupPowerup | MarbleNetFlags.GravityChange;
|
@:privateAccess marb.netFlags = MarbleNetFlags.DoBlast | MarbleNetFlags.DoMega | MarbleNetFlags.DoHelicopter | MarbleNetFlags.PickupPowerup | MarbleNetFlags.GravityChange | MarbleNetFlags.UsePowerup;
|
||||||
|
|
||||||
var innerMove = @:privateAccess marb.lastMove;
|
var innerMove = @:privateAccess marb.lastMove;
|
||||||
if (innerMove == null) {
|
if (innerMove == null) {
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ enum abstract MarbleNetFlags(Int) from Int to Int {
|
||||||
var DoMega = 1 << 2;
|
var DoMega = 1 << 2;
|
||||||
var PickupPowerup = 1 << 3;
|
var PickupPowerup = 1 << 3;
|
||||||
var GravityChange = 1 << 4;
|
var GravityChange = 1 << 4;
|
||||||
|
var UsePowerup = 1 << 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:publicFields
|
@:publicFields
|
||||||
|
|
@ -103,6 +104,12 @@ class MarbleUpdatePacket implements NetPacket {
|
||||||
b.writeFlag(false);
|
b.writeFlag(false);
|
||||||
}
|
}
|
||||||
b.writeFlag(oob);
|
b.writeFlag(oob);
|
||||||
|
if (netFlags & MarbleNetFlags.UsePowerup > 0) {
|
||||||
|
b.writeFlag(true);
|
||||||
|
} else {
|
||||||
|
b.writeFlag(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (netFlags & MarbleNetFlags.PickupPowerup > 0) {
|
if (netFlags & MarbleNetFlags.PickupPowerup > 0) {
|
||||||
b.writeFlag(true);
|
b.writeFlag(true);
|
||||||
b.writeInt(powerUpId, 9);
|
b.writeInt(powerUpId, 9);
|
||||||
|
|
@ -142,6 +149,8 @@ class MarbleUpdatePacket implements NetPacket {
|
||||||
this.netFlags |= MarbleNetFlags.DoMega;
|
this.netFlags |= MarbleNetFlags.DoMega;
|
||||||
}
|
}
|
||||||
oob = b.readFlag();
|
oob = b.readFlag();
|
||||||
|
if (b.readFlag())
|
||||||
|
this.netFlags |= MarbleNetFlags.UsePowerup;
|
||||||
if (b.readFlag()) {
|
if (b.readFlag()) {
|
||||||
powerUpId = b.readInt(9);
|
powerUpId = b.readInt(9);
|
||||||
this.netFlags |= MarbleNetFlags.PickupPowerup;
|
this.netFlags |= MarbleNetFlags.PickupPowerup;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue