mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 03:39:00 +00:00
Fixed fireball rollback sync.
This commit is contained in:
parent
dd9c03404e
commit
45380d170f
@ -55,9 +55,10 @@ func toPbRoomDownsyncFrame(rdf *battle.RoomDownsyncFrame) *pb.RoomDownsyncFrame
|
||||
|
||||
for i, last := range rdf.MeleeBullets {
|
||||
pbBullet := &pb.MeleeBullet{
|
||||
BulletLocalId: last.Bullet.BulletLocalId,
|
||||
OriginatedRenderFrameId: last.Bullet.OriginatedRenderFrameId,
|
||||
OffenderJoinIndex: last.Bullet.OffenderJoinIndex,
|
||||
BulletLocalId: last.BattleAttr.BulletLocalId,
|
||||
OriginatedRenderFrameId: last.BattleAttr.OriginatedRenderFrameId,
|
||||
OffenderJoinIndex: last.BattleAttr.OffenderJoinIndex,
|
||||
TeamId: last.BattleAttr.TeamId,
|
||||
|
||||
StartupFrames: last.Bullet.StartupFrames,
|
||||
CancellableStFrame: last.Bullet.CancellableStFrame,
|
||||
@ -79,16 +80,16 @@ func toPbRoomDownsyncFrame(rdf *battle.RoomDownsyncFrame) *pb.RoomDownsyncFrame
|
||||
HitboxSizeY: last.Bullet.HitboxSizeY,
|
||||
|
||||
BlowUp: last.Bullet.BlowUp,
|
||||
TeamId: last.Bullet.TeamId,
|
||||
}
|
||||
ret.MeleeBullets[i] = pbBullet
|
||||
}
|
||||
|
||||
for i, last := range rdf.FireballBullets {
|
||||
pbBullet := &pb.FireballBullet{
|
||||
BulletLocalId: last.Bullet.BulletLocalId,
|
||||
OriginatedRenderFrameId: last.Bullet.OriginatedRenderFrameId,
|
||||
OffenderJoinIndex: last.Bullet.OffenderJoinIndex,
|
||||
BulletLocalId: last.BattleAttr.BulletLocalId,
|
||||
OriginatedRenderFrameId: last.BattleAttr.OriginatedRenderFrameId,
|
||||
OffenderJoinIndex: last.BattleAttr.OffenderJoinIndex,
|
||||
TeamId: last.BattleAttr.TeamId,
|
||||
|
||||
StartupFrames: last.Bullet.StartupFrames,
|
||||
CancellableStFrame: last.Bullet.CancellableStFrame,
|
||||
@ -110,7 +111,6 @@ func toPbRoomDownsyncFrame(rdf *battle.RoomDownsyncFrame) *pb.RoomDownsyncFrame
|
||||
HitboxSizeY: last.Bullet.HitboxSizeY,
|
||||
|
||||
BlowUp: last.Bullet.BlowUp,
|
||||
TeamId: last.Bullet.TeamId,
|
||||
|
||||
VirtualGridX: last.VirtualGridX,
|
||||
VirtualGridY: last.VirtualGridY,
|
||||
|
@ -348,7 +348,7 @@ func (pR *Room) fireballDownsyncStr(fireball *battle.FireballBullet) string {
|
||||
if nil == fireball {
|
||||
return ""
|
||||
}
|
||||
s := fmt.Sprintf("{%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d}", fireball.Bullet.BulletLocalId, fireball.Bullet.OriginatedRenderFrameId, fireball.Bullet.OffenderJoinIndex, fireball.VirtualGridX, fireball.VirtualGridY, fireball.VelX, fireball.VelY, fireball.DirX, fireball.DirY, fireball.Bullet.HitboxSizeX, fireball.Bullet.HitboxSizeY)
|
||||
s := fmt.Sprintf("{%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d}", fireball.BattleAttr.BulletLocalId, fireball.BattleAttr.OriginatedRenderFrameId, fireball.BattleAttr.OffenderJoinIndex, fireball.VirtualGridX, fireball.VirtualGridY, fireball.VelX, fireball.VelY, fireball.DirX, fireball.DirY, fireball.Bullet.HitboxSizeX, fireball.Bullet.HitboxSizeY)
|
||||
|
||||
return s
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -24,11 +24,11 @@
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 7
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 8
|
||||
"__id__": 9
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -92,7 +92,7 @@
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": {
|
||||
"__id__": 6
|
||||
"__id__": 7
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -149,14 +149,17 @@
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_active": false,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 5
|
||||
"__id__": 6
|
||||
},
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
@ -220,9 +223,7 @@
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "e92702d5-d5fd-49e6-ab6b-2296b43fa6d6"
|
||||
},
|
||||
"_spriteFrame": null,
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillType": 0,
|
||||
@ -239,6 +240,25 @@
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Animation",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"_defaultClip": {
|
||||
"__uuid__": "ba12416b-eec3-4260-8402-7fc25b125624"
|
||||
},
|
||||
"_clips": [
|
||||
{
|
||||
"__uuid__": "ba12416b-eec3-4260-8402-7fc25b125624"
|
||||
}
|
||||
],
|
||||
"playOnLoad": false,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
|
@ -457,7 +457,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
216.50635094610968,
|
||||
209.57814771583418,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -440,7 +440,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
215.94663282292512,
|
||||
209.57814771583418,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -191,8 +191,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0.8,
|
||||
0.8,
|
||||
1.2,
|
||||
1.2,
|
||||
1
|
||||
]
|
||||
},
|
||||
@ -464,7 +464,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
215.64032554232523,
|
||||
209.57814771583418,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -27,7 +27,7 @@ cc.Class({
|
||||
this.speciesName = speciesName;
|
||||
this.effAnimNode = this.animNode.getChildByName(this.speciesName);
|
||||
this.effAnimNode.active = true;
|
||||
//this.updateAnim(speciesName, fireballBullet, rdf);
|
||||
this.updateAnim(speciesName, fireballBullet, rdf);
|
||||
},
|
||||
|
||||
onLoad() {},
|
||||
|
@ -742,9 +742,9 @@ cc.Class({
|
||||
if (null == lhs || null == rhs) return false;
|
||||
if (null == lhs && null != rhs) return false;
|
||||
if (null != lhs && null == rhs) return false;
|
||||
if (lhs.Bullet.BulletLocalId != rhs.Bullet.BulletLocalId) return false;
|
||||
if (lhs.Bullet.OffenderJoinIndex != rhs.Bullet.OffenderJoinIndex) return false;
|
||||
if (lhs.Bullet.OriginatedRenderFrameId != rhs.Bullet.OriginatedRenderFrameId) return false;
|
||||
if (lhs.BattleAttr.BulletLocalId != rhs.BattleAttr.BulletLocalId) return false;
|
||||
if (lhs.BattleAttr.OffenderJoinIndex != rhs.BattleAttr.OffenderJoinIndex) return false;
|
||||
if (lhs.BattleAttr.OriginatedRenderFrameId != rhs.BattleAttr.OriginatedRenderFrameId) return false;
|
||||
return true;
|
||||
},
|
||||
|
||||
@ -752,31 +752,32 @@ cc.Class({
|
||||
if (null == lhs || null == rhs) return false;
|
||||
if (null == lhs && null != rhs) return false;
|
||||
if (null != lhs && null == rhs) return false;
|
||||
if (lhs.Bullet.BulletLocalId != rhs.Bullet.BulletLocalId) return false;
|
||||
if (lhs.Bullet.OffenderJoinIndex != rhs.Bullet.OffenderJoinIndex) return false;
|
||||
if (lhs.Bullet.OriginatedRenderFrameId != rhs.Bullet.OriginatedRenderFrameId) return false;
|
||||
if (lhs.BattleAttr.BulletLocalId != rhs.BattleAttr.BulletLocalId) return false;
|
||||
if (lhs.BattleAttr.OffenderJoinIndex != rhs.BattleAttr.OffenderJoinIndex) return false;
|
||||
if (lhs.BattleAttr.OriginatedRenderFrameId != rhs.BattleAttr.OriginatedRenderFrameId) return false;
|
||||
|
||||
if (lhs.VirtualGridX != rhs.Bullet.VirtualGridX) return false;
|
||||
if (lhs.VirtualGridY != rhs.Bullet.VirtualGridY) return false;
|
||||
if (lhs.DirX != rhs.DirX) return false;
|
||||
if (lhs.DirY != rhs.DirY) return false;
|
||||
if (lhs.VelX != rhs.VelX) return false;
|
||||
if (lhs.VelY != rhs.VelY) return false;
|
||||
if (lhs.Speed != rhs.Speed) return false;
|
||||
if (lhs.SpeciesId != rhs.SpeciesId) return false;
|
||||
|
||||
if (lhs.Bullet.VirtualGridX != rhs.Bullet.VirtualGridX) return false;
|
||||
if (lhs.Bullet.VirtualGridY != rhs.Bullet.VirtualGridY) return false;
|
||||
if (lhs.Bullet.DirX != rhs.Bullet.DirX) return false;
|
||||
if (lhs.Bullet.DirY != rhs.Bullet.DirY) return false;
|
||||
if (lhs.Bullet.VelX != rhs.Bullet.VelX) return false;
|
||||
if (lhs.Bullet.VelY != rhs.Bullet.VelY) return false;
|
||||
if (lhs.Bullet.Speed != rhs.Bullet.Speed) return false;
|
||||
if (lhs.Bullet.SpeciesId != rhs.Bullet.SpeciesId) return false;
|
||||
return true;
|
||||
},
|
||||
|
||||
equalRoomDownsyncFrames(lhs, rhs) {
|
||||
if (null == lhs || null == rhs) return false;
|
||||
for (let k in lhs.players) {
|
||||
if (!this.equalPlayers(lhs.players[k], rhs.players[k])) return false;
|
||||
for (let k in lhs.PlayersArr) {
|
||||
if (!this.equalPlayers(lhs.PlayersArr[k], rhs.PlayersArr[k])) return false;
|
||||
}
|
||||
for (let k in lhs.meleeBullets) {
|
||||
if (!this.equalMeleeBullets(lhs.meleeBullets[k], rhs.meleeBullets[k])) return false;
|
||||
for (let k in lhs.MeleeBullets) {
|
||||
if (!this.equalMeleeBullets(lhs.MeleeBullets[k], rhs.MeleeBullets[k])) return false;
|
||||
}
|
||||
for (let k in lhs.fireballBullet) {
|
||||
if (!this.equalMeleeBullets(lhs.meleeBullets[k], rhs.meleeBullets[k])) return false;
|
||||
if (!this.equalFireballBullets(lhs.FireballBullets[k], rhs.FireballBullets[k])) return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@ -1093,10 +1094,6 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame
|
||||
}
|
||||
},
|
||||
|
||||
_renderFireballBullet(fireballBullet, rdf) {
|
||||
const self = this;
|
||||
},
|
||||
|
||||
applyRoomDownsyncFrameDynamics(rdf, prevRdf) {
|
||||
const self = this;
|
||||
const playersArr = rdf.PlayersArr;
|
||||
@ -1117,31 +1114,32 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame
|
||||
const fireball = pqNode.value;
|
||||
fireball.node.setPosition(cc.v2(Number.MAX_VALUE, Number.MAX_VALUE));
|
||||
}
|
||||
const fireballBullets = rdf.FireballBullets;
|
||||
for (let k in fireballBullets) {
|
||||
const fireballBullet = fireballBullets[k];
|
||||
for (let k in rdf.FireballBullets) {
|
||||
const fireballBullet = rdf.FireballBullets[k];
|
||||
if (
|
||||
fireballBullet.Bullet.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames <= rdf.Id
|
||||
fireballBullet.BattleAttr.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames <= rdf.Id
|
||||
&&
|
||||
fireballBullet.Bullet.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames + fireballBullet.Bullet.ActiveFrames > rdf.Id
|
||||
fireballBullet.BattleAttr.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames + fireballBullet.Bullet.ActiveFrames > rdf.Id
|
||||
) {
|
||||
let pqNode = self.cachedFireballs.popAny(fireballBullet.Bullet.BulletLocalId);
|
||||
let pqNode = self.cachedFireballs.popAny(fireballBullet.BattleAttr.BulletLocalId);
|
||||
const speciesName = `Fireball${fireballBullet.SpeciesId}`;
|
||||
const [wx, wy] = gopkgs.VirtualGridToWorldPos(fireballBullet.VirtualGridX, fireballBullet.VirtualGridY);
|
||||
|
||||
if (null == pqNode) {
|
||||
pqNode = self.cachedFireballs.pop();
|
||||
console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.Bullet.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, activeFrames=${fireballBullet.Bullet.ActiveFrames}, using a new fireball node for rendering for bulletLocalId=${fireballBullet.Bullet.BulletLocalId} at wpos=(${wx},${wy})`);
|
||||
//console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, using a new fireball node for rendering for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`);
|
||||
} else {
|
||||
console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.Bullet.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, activeFrames=${fireballBullet.Bullet.ActiveFrames}, using a cached fireball node for rendering for bulletLocalId=${fireballBullet.Bullet.BulletLocalId} at wpos=(${wx},${wy})`);
|
||||
//console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, using a cached fireball node for rendering for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId} at wpos=(${wx},${wy})`);
|
||||
}
|
||||
const cachedFireball = pqNode.value;
|
||||
cachedFireball.setSpecies(speciesName, fireballBullet, rdf);
|
||||
cachedFireball.lastUsed = self.renderFrameId;
|
||||
cachedFireball.bulletLocalId = fireballBullet.Bullet.BulletLocalId;
|
||||
cachedFireball.bulletLocalId = fireballBullet.BattleAttr.BulletLocalId;
|
||||
cachedFireball.node.setPosition(cc.v2(wx, wy));
|
||||
|
||||
self.cachedFireballs.push(cachedFireball.lastUsed, cachedFireball, fireballBullet.Bullet.BulletLocalId);
|
||||
self.cachedFireballs.push(cachedFireball.lastUsed, cachedFireball, fireballBullet.BattleAttr.BulletLocalId);
|
||||
} else {
|
||||
//console.log(`@rdf.Id=${rdf.Id}, origRdfId=${fireballBullet.BattleAttr.OriginatedRenderFrameId}, startupFrames=${fireballBullet.Bullet.StartupFrames}, activeFrames=${fireballBullet.Bullet.ActiveFrames}, not rendering fireball node for bulletLocalId=${fireballBullet.BattleAttr.BulletLocalId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1271,7 +1269,7 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame
|
||||
|
||||
fireballDownsyncStr(fireball) {
|
||||
if (null == fireball) return "";
|
||||
return `{${fireball.Bullet.BulletLocalId},${fireball.Bullet.OriginatedRenderFrameId},${fireball.Bullet.OffenderJoinIndex},${fireball.VirtualGridX},${fireball.VirtualGridY},${fireball.VelX},${fireball.VelY},${fireball.DirX},${fireball.DirY},${fireball.Bullet.HitboxSizeX},${fireball.Bullet.HitboxSizeY}}`;
|
||||
return `{${fireball.BattleAttr.BulletLocalId},${fireball.BattleAttr.OriginatedRenderFrameId},${fireball.BattleAttr.OffenderJoinIndex},${fireball.VirtualGridX},${fireball.VirtualGridY},${fireball.VelX},${fireball.VelY},${fireball.DirX},${fireball.DirY},${fireball.Bullet.HitboxSizeX},${fireball.Bullet.HitboxSizeY}}`;
|
||||
},
|
||||
|
||||
inputFrameDownsyncStr(inputFrameDownsync) {
|
||||
@ -1366,11 +1364,11 @@ actuallyUsedinputList:{${self.inputFrameDownsyncStr(actuallyUsedInputClone)}}`);
|
||||
for (let k in rdf.MeleeBullets) {
|
||||
const meleeBullet = rdf.MeleeBullets[k];
|
||||
if (
|
||||
meleeBullet.Bullet.OriginatedRenderFrameId + meleeBullet.Bullet.StartupFrames <= rdf.Id
|
||||
meleeBullet.BattleAttr.OriginatedRenderFrameId + meleeBullet.Bullet.StartupFrames <= rdf.Id
|
||||
&&
|
||||
meleeBullet.Bullet.OriginatedRenderFrameId + meleeBullet.Bullet.StartupFrames + meleeBullet.Bullet.ActiveFrames > rdf.Id
|
||||
meleeBullet.BattleAttr.OriginatedRenderFrameId + meleeBullet.Bullet.StartupFrames + meleeBullet.Bullet.ActiveFrames > rdf.Id
|
||||
) {
|
||||
const offender = rdf.PlayersArr[meleeBullet.Bullet.OffenderJoinIndex - 1];
|
||||
const offender = rdf.PlayersArr[meleeBullet.BattleAttr.OffenderJoinIndex - 1];
|
||||
if (1 == offender.JoinIndex) {
|
||||
g2.strokeColor = cc.Color.BLUE;
|
||||
} else {
|
||||
@ -1398,11 +1396,11 @@ actuallyUsedinputList:{${self.inputFrameDownsyncStr(actuallyUsedInputClone)}}`);
|
||||
for (let k in rdf.FireballBullets) {
|
||||
const fireballBullet = rdf.FireballBullets[k];
|
||||
if (
|
||||
fireballBullet.Bullet.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames <= rdf.Id
|
||||
fireballBullet.BattleAttr.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames <= rdf.Id
|
||||
&&
|
||||
fireballBullet.Bullet.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames + fireballBullet.Bullet.ActiveFrames > rdf.Id
|
||||
fireballBullet.BattleAttr.OriginatedRenderFrameId + fireballBullet.Bullet.StartupFrames + fireballBullet.Bullet.ActiveFrames > rdf.Id
|
||||
) {
|
||||
const offender = rdf.PlayersArr[fireballBullet.Bullet.OffenderJoinIndex - 1];
|
||||
const offender = rdf.PlayersArr[fireballBullet.BattleAttr.OffenderJoinIndex - 1];
|
||||
if (1 == offender.JoinIndex) {
|
||||
g2.strokeColor = cc.Color.BLUE;
|
||||
} else {
|
||||
|
@ -541,10 +541,13 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
|
||||
switch v := skillConfig.Hits[thatPlayerInNextFrame.ActiveSkillHit].(type) {
|
||||
case *MeleeBullet:
|
||||
var newBullet MeleeBullet = *v // Copied primitive fields into an onstack variable
|
||||
newBullet.Bullet.BulletLocalId = bulletLocalId
|
||||
newBullet.BattleAttr = &BulletBattleAttr{
|
||||
BulletLocalId: bulletLocalId,
|
||||
OriginatedRenderFrameId: currRenderFrame.Id,
|
||||
OffenderJoinIndex: joinIndex,
|
||||
TeamId: currPlayerDownsync.BulletTeamId,
|
||||
}
|
||||
bulletLocalId++
|
||||
newBullet.Bullet.OriginatedRenderFrameId = currRenderFrame.Id
|
||||
newBullet.Bullet.OffenderJoinIndex = joinIndex
|
||||
nextRenderFrameMeleeBullets = append(nextRenderFrameMeleeBullets, &newBullet)
|
||||
if NO_LOCK_VEL != v.Bullet.SelfLockVelX {
|
||||
hasLockVel = true
|
||||
@ -556,10 +559,13 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
|
||||
}
|
||||
case *FireballBullet:
|
||||
var newBullet FireballBullet = *v // Copied primitive fields into an onstack variable
|
||||
newBullet.Bullet.BulletLocalId = bulletLocalId
|
||||
newBullet.BattleAttr = &BulletBattleAttr{
|
||||
BulletLocalId: bulletLocalId,
|
||||
OriginatedRenderFrameId: currRenderFrame.Id,
|
||||
OffenderJoinIndex: joinIndex,
|
||||
TeamId: currPlayerDownsync.BulletTeamId,
|
||||
}
|
||||
bulletLocalId++
|
||||
newBullet.Bullet.OriginatedRenderFrameId = currRenderFrame.Id
|
||||
newBullet.Bullet.OffenderJoinIndex = joinIndex
|
||||
newBullet.VirtualGridX, newBullet.VirtualGridY = currPlayerDownsync.VirtualGridX+xfac*newBullet.Bullet.HitboxOffsetX, currPlayerDownsync.VirtualGridY+newBullet.Bullet.HitboxOffsetY
|
||||
newBullet.DirX = xfac
|
||||
newBullet.DirY = 0
|
||||
@ -669,8 +675,8 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
|
||||
// 3. Add bullet colliders into collision system
|
||||
bulletColliders := make([]*resolv.Object, 0, len(currRenderFrame.MeleeBullets)) // Will all be removed at the end of this function due to the need for being rollback-compatible
|
||||
for _, meleeBullet := range currRenderFrame.MeleeBullets {
|
||||
if (meleeBullet.Bullet.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames <= currRenderFrame.Id) && (meleeBullet.Bullet.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames+meleeBullet.Bullet.ActiveFrames > currRenderFrame.Id) {
|
||||
offender := currRenderFrame.PlayersArr[meleeBullet.Bullet.OffenderJoinIndex-1]
|
||||
if (meleeBullet.BattleAttr.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames <= currRenderFrame.Id) && (meleeBullet.BattleAttr.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames+meleeBullet.Bullet.ActiveFrames > currRenderFrame.Id) {
|
||||
offender := currRenderFrame.PlayersArr[meleeBullet.BattleAttr.OffenderJoinIndex-1]
|
||||
|
||||
xfac := int32(1) // By now, straight Punch offset doesn't respect "y-axis"
|
||||
if 0 > offender.DirX {
|
||||
@ -681,7 +687,7 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
|
||||
newBulletCollider := GenerateRectCollider(bulletWx, bulletWy, hitboxSizeWx, hitboxSizeWy, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, collisionSpaceOffsetX, collisionSpaceOffsetY, meleeBullet, "MeleeBullet")
|
||||
collisionSys.Add(newBulletCollider)
|
||||
bulletColliders = append(bulletColliders, newBulletCollider)
|
||||
} else if meleeBullet.Bullet.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames+meleeBullet.Bullet.ActiveFrames > currRenderFrame.Id {
|
||||
} else if meleeBullet.BattleAttr.OriginatedRenderFrameId+meleeBullet.Bullet.StartupFrames+meleeBullet.Bullet.ActiveFrames > currRenderFrame.Id {
|
||||
nextRenderFrameMeleeBullets = append(nextRenderFrameMeleeBullets, meleeBullet)
|
||||
}
|
||||
}
|
||||
@ -697,15 +703,16 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
|
||||
Speed: prevFireball.Speed,
|
||||
SpeciesId: prevFireball.SpeciesId,
|
||||
Bullet: prevFireball.Bullet,
|
||||
BattleAttr: prevFireball.BattleAttr,
|
||||
}
|
||||
if (fireballBullet.Bullet.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames < currRenderFrame.Id) && (fireballBullet.Bullet.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames+fireballBullet.Bullet.ActiveFrames > currRenderFrame.Id) {
|
||||
if (fireballBullet.BattleAttr.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames < currRenderFrame.Id) && (fireballBullet.BattleAttr.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames+fireballBullet.Bullet.ActiveFrames > currRenderFrame.Id) {
|
||||
bulletWx, bulletWy := VirtualGridToWorldPos(fireballBullet.VirtualGridX, fireballBullet.VirtualGridY)
|
||||
hitboxSizeWx, hitboxSizeWy := VirtualGridToWorldPos(fireballBullet.Bullet.HitboxSizeX, fireballBullet.Bullet.HitboxSizeY)
|
||||
newBulletCollider := GenerateRectCollider(bulletWx, bulletWy, hitboxSizeWx, hitboxSizeWy, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, SNAP_INTO_PLATFORM_OVERLAP, collisionSpaceOffsetX, collisionSpaceOffsetY, fireballBullet, "FireballBullet")
|
||||
collisionSys.Add(newBulletCollider)
|
||||
bulletColliders = append(bulletColliders, newBulletCollider)
|
||||
} else if fireballBullet.Bullet.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames+fireballBullet.Bullet.ActiveFrames > currRenderFrame.Id {
|
||||
// fmt.Printf("Pushing static fireball to next frame @currRenderFrame.Id=%d, bulletLocalId=%d, virtualGridX=%d, virtualGridY=%d\n", currRenderFrame.Id, fireballBullet.BulletLocalId, fireballBullet.VirtualGridX, fireballBullet.VirtualGridY)
|
||||
} else if fireballBullet.BattleAttr.OriginatedRenderFrameId+fireballBullet.Bullet.StartupFrames+fireballBullet.Bullet.ActiveFrames > currRenderFrame.Id {
|
||||
// fmt.Printf("Pushing static fireball to next frame @currRenderFrame.Id=%d, bulletLocalId=%d, virtualGridX=%d, virtualGridY=%d\n", currRenderFrame.Id, fireballBullet.BattleAttr.BulletLocalId, fireballBullet.VirtualGridX, fireballBullet.VirtualGridY)
|
||||
nextRenderFrameFireballBullets = append(nextRenderFrameFireballBullets, fireballBullet)
|
||||
}
|
||||
}
|
||||
@ -843,12 +850,12 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
|
||||
switch v := bulletCollider.Data.(type) {
|
||||
case *MeleeBullet:
|
||||
bulletShape := bulletCollider.Shape.(*resolv.ConvexPolygon)
|
||||
offender := currRenderFrame.PlayersArr[v.Bullet.OffenderJoinIndex-1]
|
||||
offender := currRenderFrame.PlayersArr[v.BattleAttr.OffenderJoinIndex-1]
|
||||
for _, obj := range collision.Objects {
|
||||
defenderShape := obj.Shape.(*resolv.ConvexPolygon)
|
||||
switch t := obj.Data.(type) {
|
||||
case *PlayerDownsync:
|
||||
if v.Bullet.OffenderJoinIndex == t.JoinIndex {
|
||||
if v.BattleAttr.OffenderJoinIndex == t.JoinIndex {
|
||||
continue
|
||||
}
|
||||
overlapped, _, _, _ := calcPushbacks(0, 0, bulletShape, defenderShape)
|
||||
@ -885,12 +892,12 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
|
||||
}
|
||||
case *FireballBullet:
|
||||
bulletShape := bulletCollider.Shape.(*resolv.ConvexPolygon)
|
||||
offender := currRenderFrame.PlayersArr[v.Bullet.OffenderJoinIndex-1]
|
||||
offender := currRenderFrame.PlayersArr[v.BattleAttr.OffenderJoinIndex-1]
|
||||
for _, obj := range collision.Objects {
|
||||
defenderShape := obj.Shape.(*resolv.ConvexPolygon)
|
||||
switch t := obj.Data.(type) {
|
||||
case *PlayerDownsync:
|
||||
if v.Bullet.OffenderJoinIndex == t.JoinIndex {
|
||||
if v.BattleAttr.OffenderJoinIndex == t.JoinIndex {
|
||||
continue
|
||||
}
|
||||
overlapped, _, _, _ := calcPushbacks(0, 0, bulletShape, defenderShape)
|
||||
@ -1071,11 +1078,13 @@ func AlignPolygon2DToBoundingBox(input *Polygon2D) *Polygon2D {
|
||||
|
||||
func NewMeleeBullet(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, startupFrames, cancellableStFrame, cancellableEdFrame, activeFrames, hitStunFrames, blockStunFrames, pushbackVelX, pushbackVelY, damage, selfLockVelX, selfLockVelY, hitboxOffsetX, hitboxOffsetY, hitboxSizeX, hitboxSizeY int32, blowUp bool, teamId int32) *MeleeBullet {
|
||||
return &MeleeBullet{
|
||||
Bullet: &BulletConfig{
|
||||
BattleAttr: &BulletBattleAttr{
|
||||
BulletLocalId: bulletLocalId,
|
||||
OriginatedRenderFrameId: originatedRenderFrameId,
|
||||
OffenderJoinIndex: offenderJoinIndex,
|
||||
|
||||
TeamId: teamId,
|
||||
},
|
||||
Bullet: &BulletConfig{
|
||||
StartupFrames: startupFrames,
|
||||
CancellableStFrame: cancellableStFrame,
|
||||
CancellableEdFrame: cancellableEdFrame,
|
||||
@ -1096,8 +1105,6 @@ func NewMeleeBullet(bulletLocalId, originatedRenderFrameId, offenderJoinIndex, s
|
||||
HitboxSizeY: hitboxSizeY,
|
||||
|
||||
BlowUp: blowUp,
|
||||
|
||||
TeamId: teamId,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -1112,11 +1119,13 @@ func NewFireballBullet(bulletLocalId, originatedRenderFrameId, offenderJoinIndex
|
||||
VelY: velY,
|
||||
Speed: speed,
|
||||
SpeciesId: speciesId,
|
||||
Bullet: &BulletConfig{
|
||||
BattleAttr: &BulletBattleAttr{
|
||||
BulletLocalId: bulletLocalId,
|
||||
OriginatedRenderFrameId: originatedRenderFrameId,
|
||||
OffenderJoinIndex: offenderJoinIndex,
|
||||
|
||||
TeamId: teamId,
|
||||
},
|
||||
Bullet: &BulletConfig{
|
||||
StartupFrames: startupFrames,
|
||||
CancellableStFrame: cancellableStFrame,
|
||||
CancellableEdFrame: cancellableEdFrame,
|
||||
@ -1137,8 +1146,6 @@ func NewFireballBullet(bulletLocalId, originatedRenderFrameId, offenderJoinIndex
|
||||
HitboxSizeY: hitboxSizeY,
|
||||
|
||||
BlowUp: blowUp,
|
||||
|
||||
TeamId: teamId,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -63,11 +63,6 @@ type Barrier struct {
|
||||
}
|
||||
|
||||
type BulletConfig struct {
|
||||
BulletLocalId int32 // for referencing cached nodes in frontend rendering
|
||||
|
||||
// for offender
|
||||
OriginatedRenderFrameId int32 // Copied from the first bullet for all subsequent bullets
|
||||
OffenderJoinIndex int32 // Copied to favor collision handling of the dispatched bullet
|
||||
StartupFrames int32 // from "OriginatedRenderFrameId"
|
||||
CancellableStFrame int32 // from "OriginatedRenderFrameId"
|
||||
CancellableEdFrame int32 // from "OriginatedRenderFrameId"
|
||||
@ -91,11 +86,19 @@ type BulletConfig struct {
|
||||
BlowUp bool
|
||||
|
||||
CancelTransit map[int]int
|
||||
}
|
||||
|
||||
type BulletBattleAttr struct {
|
||||
BulletLocalId int32 // for referencing cached nodes in frontend rendering
|
||||
|
||||
// for offender
|
||||
OriginatedRenderFrameId int32 // Copied from the first bullet for all subsequent bullets
|
||||
OffenderJoinIndex int32 // Copied to favor collision handling of the dispatched bullet
|
||||
TeamId int32
|
||||
}
|
||||
|
||||
type MeleeBullet struct {
|
||||
BattleAttr *BulletBattleAttr
|
||||
Bullet *BulletConfig
|
||||
}
|
||||
|
||||
@ -108,6 +111,7 @@ type FireballBullet struct {
|
||||
VelY int32
|
||||
Speed int32
|
||||
SpeciesId int32
|
||||
BattleAttr *BulletBattleAttr
|
||||
Bullet *BulletConfig
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user