netcode <3

This commit is contained in:
GinYuH authored and Cameron Ewell committed 2024-01-11 23:29:31 -05:00
1 parent 69a370e589
commit b4a4280d5e
2 files changed
+29 -5

No files matched your search

+15 -4
View File
@@ -108,10 +108,20 @@ namespace CalamityMod
AndroombaFriendly.SwapSolution(index, solType);
break;
case CalamityModMessageType.SyncAndroombaAI:
int idx = reader.ReadInt32();
int phase = reader.ReadInt32();
if (Main.netMode != NetmodeID.MultiplayerClient)
AndroombaFriendly.ChangeAI(idx, phase);
{
int idx = reader.ReadInt32();
int phase = reader.ReadInt32();
if (Main.netMode != NetmodeID.MultiplayerClient)
AndroombaFriendly.ChangeAI(idx, phase);
}
break;
case CalamityModMessageType.SyncSlabCrabAI:
{
int idx = reader.ReadInt32();
int phase = reader.ReadInt32();
if (Main.netMode != NetmodeID.MultiplayerClient)
AndroombaFriendly.ChangeAI(idx, phase);
}
break;
case CalamityModMessageType.ServersideSpawnOldDuke:
byte playerIndex2 = reader.ReadByte();
@@ -344,6 +354,7 @@ namespace CalamityMod
DeleteAllSuperDummies,
SyncAndroombaSolution,
SyncAndroombaAI,
SyncSlabCrabAI,
ServersideSpawnOldDuke,
ArmoredDiggerCountdownSync, // TODO -- remove this mechanic entirely
ProvidenceDyeConditionSync, // TODO -- this packetstorms if you hit Provi with spam weapons. It should ONLY send a packet if the status changes.
+14 -1
View File
@@ -340,8 +340,21 @@ namespace CalamityMod.NPCs.Abyss
SoundEngine.PlaySound(SoundID.Dig, NPC.Center);
if (CurrentPhase < (int)AIState.Enraged)
{
ChangePhase((int)AIState.Enraged);
if (Main.netMode == NetmodeID.SinglePlayer)
{
ChangePhase((int)AIState.Enraged);
}
else
{
var netMessage = Mod.GetPacket();
netMessage.Write((byte)CalamityModMessageType.SyncSlabCrabAI);
netMessage.Write(NPC.whoAmI);
netMessage.Write((int)AIState.Enraged);
netMessage.Send();
}
NPC.netUpdate = true;
if (Main.netMode == NetmodeID.Server)
NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, NPC.whoAmI);
}
}
}