public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers) { QwertyWorld modWorld = (QwertyWorld)GetModWorld("QwertyWorld"); if (QwertyWorld.DinoEvent) { int index = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory")); LegacyGameInterfaceLayer orionProgress = new LegacyGameInterfaceLayer("Dino Militia", delegate { DrawDinoEvent(Main.spriteBatch); return(true); }, InterfaceScaleType.UI); layers.Insert(index, orionProgress); } }
public override void HandlePacket(BinaryReader reader, int whoAmI) { ModMessageType msgType = (ModMessageType)reader.ReadByte(); switch (msgType) { case ModMessageType.ArrowMessage: int identity = reader.ReadInt32(); byte owner = reader.ReadByte(); int realIdentity = Projectile.GetByUUID(owner, identity); if (realIdentity != -1) { Main.projectile[realIdentity].GetGlobalProjectile <arrowHoming>().B4HomingArrow = true; } if (Main.netMode == 2) { ModPacket packet = GetPacket(); packet.Write((byte)ModMessageType.ArrowMessage); packet.Write(identity); packet.Write(owner); packet.Send(); } break; case ModMessageType.FinnedRandomSwimMessage: int identity2 = reader.ReadInt32(); byte owner2 = reader.ReadByte(); float randomSwim = reader.Read(); int realIdentity2 = Projectile.GetByUUID(owner2, identity2); if (realIdentity2 != -1) { Main.projectile[realIdentity2].ai[1] = randomSwim; } if (Main.netMode == 2) { ModPacket packet = GetPacket(); packet.Write((byte)ModMessageType.FinnedRandomSwimMessage); packet.Write(identity2); packet.Write(owner2); packet.Write(randomSwim); packet.Send(); } break; case ModMessageType.ScaleMessage: int identity3 = reader.ReadInt32(); byte owner3 = reader.ReadByte(); int realIdentity3 = Projectile.GetByUUID(owner3, identity3); if (realIdentity3 != -1) { Main.projectile[realIdentity3].scale = 3; } if (Main.netMode == 2) { ModPacket packet = GetPacket(); packet.Write((byte)ModMessageType.ScaleMessage); packet.Write(identity3); packet.Write(owner3); packet.Send(); } break; case ModMessageType.UpdateClassBools: int identity4 = reader.ReadInt32(); byte owner4 = reader.ReadByte(); int realIdentity4 = Projectile.GetByUUID(owner4, identity4); if (realIdentity4 != -1) { BitsByte flags = reader.ReadByte(); Main.projectile[realIdentity4].melee = flags[0]; Main.projectile[realIdentity4].ranged = flags[1]; Main.projectile[realIdentity4].magic = flags[2]; Main.projectile[realIdentity4].minion = flags[3]; Main.projectile[realIdentity4].thrown = flags[4]; Main.projectile[realIdentity4].GetGlobalProjectile <MorphProjectile>().morph = flags[5]; } if (Main.netMode == 2) { UpdateProjectileClass(Main.projectile[realIdentity4]); } break; case ModMessageType.UpdateLocalCursor: byte playerIndex = reader.ReadByte(); Vector2 Cursor = reader.ReadVector2(); LocalCursor[playerIndex] = Cursor; if (Main.netMode == 2) { ModPacket packet = GetPacket(); packet.Write((byte)ModMessageType.UpdateLocalCursor); // Message type, you would need to create an enum for this packet.Write(playerIndex); packet.WriteVector2(Cursor); packet.Send(); } break; case ModMessageType.UpdatePlayerVelocity: byte playerIndex2 = reader.ReadByte(); Vector2 vel = reader.ReadVector2(); Main.player[playerIndex2].velocity = vel; if (Main.netMode == 2) { UpdatePlayerVelocity(playerIndex2, vel); NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, playerIndex2); } break; case ModMessageType.UpdatePlayerPosition: byte playerIndex3 = reader.ReadByte(); Vector2 pos = reader.ReadVector2(); Main.player[playerIndex3].position = pos; if (Main.netMode == 2) { UpdatePlayerPosition(playerIndex3, pos); NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, playerIndex3); } break; case ModMessageType.ProjectileAIUpdate: int identity6 = reader.ReadInt32(); byte owner6 = reader.ReadByte(); int realIdentity6 = Projectile.GetByUUID(owner6, identity6); float ai0 = reader.ReadSingle(); float ai1 = reader.ReadSingle(); if (realIdentity6 != -1) { Main.projectile[realIdentity6].ai[0] = ai0; Main.projectile[realIdentity6].ai[1] = ai1; if (Main.netMode == 2) { ProjectileAIUpdate(Main.projectile[realIdentity6]); } } break; case ModMessageType.DivineCall: QwertyWorld.FortressBossQuotes(); Vector2 summonAt = reader.ReadVector2(); int npcID = NPC.NewNPC((int)summonAt.X, (int)summonAt.Y, NPCType("FortressBoss")); break; case ModMessageType.StartDinoEvent: QwertyWorld.DinoEvent = true; QwertyWorld.DinoKillCount = 0; if (Main.netMode == NetmodeID.Server) { NetMessage.SendData(MessageID.WorldData); // Immediately inform clients of new world state. } break; } }