mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 21:21:41 +00:00
fix spectator display bug and add collision invulnerability
This commit is contained in:
parent
7277a43d6e
commit
651f04eaf2
4 changed files with 28 additions and 7 deletions
|
|
@ -1245,7 +1245,7 @@ class Marble extends GameObject {
|
||||||
// Marble-Marble
|
// Marble-Marble
|
||||||
var nextPos = position.add(velocity.multiply(deltaT));
|
var nextPos = position.add(velocity.multiply(deltaT));
|
||||||
for (marble in this.collisionWorld.marbleEntities) {
|
for (marble in this.collisionWorld.marbleEntities) {
|
||||||
if (marble == this.collider)
|
if (marble == this.collider || marble.ignore)
|
||||||
continue;
|
continue;
|
||||||
var otherPosition = marble.transform.getPosition();
|
var otherPosition = marble.transform.getPosition();
|
||||||
var isec = Collision.capsuleSphereNearestOverlap(position, nextPos, _radius, otherPosition, marble.radius);
|
var isec = Collision.capsuleSphereNearestOverlap(position, nextPos, _radius, otherPosition, marble.radius);
|
||||||
|
|
@ -1669,6 +1669,13 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ticks = Net.isClient ? serverTicks : timeState.ticks;
|
||||||
|
|
||||||
|
if ((ticks - this.level.serverStartTicks) < (10000 >> 5)) // 10 seconds marble collision invulnerability - competitive mode needs this
|
||||||
|
this.collider.ignore = true;
|
||||||
|
else
|
||||||
|
this.collider.ignore = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (this.controllable) {
|
// if (this.controllable) {
|
||||||
|
|
|
||||||
|
|
@ -370,12 +370,12 @@ class MarbleWorld extends Scheduler {
|
||||||
if (this.isMultiplayer) {
|
if (this.isMultiplayer) {
|
||||||
// Add us
|
// Add us
|
||||||
if (Net.isHost) {
|
if (Net.isHost) {
|
||||||
this.playGui.addPlayer(0, (Net.hostSpectate ? "[S] " : "") + Settings.highscoreName.substr(0, 15), true);
|
this.playGui.addPlayer(0, Settings.highscoreName.substr(0, 15), true);
|
||||||
} else {
|
} else {
|
||||||
this.playGui.addPlayer(Net.clientId, (Net.clientSpectate ? "[S] " : "") + Settings.highscoreName.substr(0, 15), true);
|
this.playGui.addPlayer(Net.clientId, Settings.highscoreName.substr(0, 15), true);
|
||||||
}
|
}
|
||||||
for (client in Net.clientIdMap) {
|
for (client in Net.clientIdMap) {
|
||||||
this.playGui.addPlayer(client.id, (client.spectator ? "[S] " : "") + client.name.substr(0, 15), false);
|
this.playGui.addPlayer(client.id, client.name.substr(0, 15), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -612,7 +612,7 @@ class MarbleWorld extends Scheduler {
|
||||||
this.initMarble(cc, () -> {
|
this.initMarble(cc, () -> {
|
||||||
var addedMarble = clientMarbles.get(cc);
|
var addedMarble = clientMarbles.get(cc);
|
||||||
this.restart(addedMarble); // spawn it
|
this.restart(addedMarble); // spawn it
|
||||||
this.playGui.addPlayer(cc.id, (cc.spectator ? "[S] " : "") + cc.getName(), false);
|
this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||||
this.playGui.redrawPlayerList();
|
this.playGui.redrawPlayerList();
|
||||||
|
|
||||||
// Sort all the marbles so that they are updated in a deterministic order
|
// Sort all the marbles so that they are updated in a deterministic order
|
||||||
|
|
@ -629,7 +629,7 @@ class MarbleWorld extends Scheduler {
|
||||||
this.initMarble(cc, () -> {
|
this.initMarble(cc, () -> {
|
||||||
var addedMarble = clientMarbles.get(cc);
|
var addedMarble = clientMarbles.get(cc);
|
||||||
this.restart(addedMarble); // spawn it
|
this.restart(addedMarble); // spawn it
|
||||||
this.playGui.addPlayer(cc.id, (cc.spectator ? "[S] " : "") + cc.getName(), false);
|
this.playGui.addPlayer(cc.id, cc.getName(), false);
|
||||||
this.playGui.redrawPlayerList();
|
this.playGui.redrawPlayerList();
|
||||||
|
|
||||||
// Sort all the marbles so that they are updated in a deterministic order
|
// Sort all the marbles so that they are updated in a deterministic order
|
||||||
|
|
@ -913,6 +913,8 @@ class MarbleWorld extends Scheduler {
|
||||||
for (client => marble in this.clientMarbles)
|
for (client => marble in this.clientMarbles)
|
||||||
marble.setMode(Play);
|
marble.setMode(Play);
|
||||||
|
|
||||||
|
this.playGui.redrawPlayerList(); // Update spectators display
|
||||||
|
|
||||||
this.playGui.setCenterText('go');
|
this.playGui.setCenterText('go');
|
||||||
|
|
||||||
var huntMode = cast(this.gameMode, HuntMode);
|
var huntMode = cast(this.gameMode, HuntMode);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import src.Debug;
|
||||||
class SphereCollisionEntity extends CollisionEntity {
|
class SphereCollisionEntity extends CollisionEntity {
|
||||||
public var radius:Float;
|
public var radius:Float;
|
||||||
public var marble:Marble;
|
public var marble:Marble;
|
||||||
|
public var ignore:Bool = false;
|
||||||
|
|
||||||
var _dbgEntity2:h3d.scene.Mesh;
|
var _dbgEntity2:h3d.scene.Mesh;
|
||||||
|
|
||||||
|
|
@ -75,6 +76,8 @@ class SphereCollisionEntity extends CollisionEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function sphereIntersection(collisionEntity:SphereCollisionEntity, timeState:TimeState) {
|
public override function sphereIntersection(collisionEntity:SphereCollisionEntity, timeState:TimeState) {
|
||||||
|
if (ignore)
|
||||||
|
return [];
|
||||||
var contacts = [];
|
var contacts = [];
|
||||||
var thispos = transform.getPosition();
|
var thispos = transform.getPosition();
|
||||||
var position = collisionEntity.transform.getPosition();
|
var position = collisionEntity.transform.getPosition();
|
||||||
|
|
|
||||||
|
|
@ -683,7 +683,16 @@ class PlayGui {
|
||||||
default:
|
default:
|
||||||
col3;
|
col3;
|
||||||
};
|
};
|
||||||
pl.push('<font color="${color}">${i + 1}. ${Util.rightPad(item.name, 25, 3)}</font>');
|
var isSpectating = false;
|
||||||
|
if (item.us) {
|
||||||
|
if (Net.isHost)
|
||||||
|
isSpectating = Net.hostSpectate;
|
||||||
|
if (Net.isClient)
|
||||||
|
isSpectating = Net.clientSpectate;
|
||||||
|
} else {
|
||||||
|
isSpectating = Net.clientIdMap[item.id].spectator;
|
||||||
|
}
|
||||||
|
pl.push('<font color="${color}">${i + 1}. ${isSpectating ? "[S] " : ""}${Util.rightPad(item.name, 25, 3)}</font>');
|
||||||
var connPing = item.us ? (Net.isHost ? 0 : Net.clientConnection.pingTicks) : (item.id == 0 ? 0 : Net.clientIdMap[item.id].pingTicks);
|
var connPing = item.us ? (Net.isHost ? 0 : Net.clientConnection.pingTicks) : (item.id == 0 ? 0 : Net.clientIdMap[item.id].pingTicks);
|
||||||
var pingStatus = "unknown";
|
var pingStatus = "unknown";
|
||||||
if (connPing <= 5)
|
if (connPing <= 5)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue