-
-
Notifications
You must be signed in to change notification settings - Fork 36
[upcoming] 6. Upgrading from v2
Contents |
---|
1. Hooks |
2. Additional files |
3. Cross plugin support |
4. Porting ITile |
5. Porting examples |
6. Hook upgrade paths |
Even though OTAPI3 is a complete re-write, most of the hooks still exist in one form or another - they have either been rewritten, renamed to align better with Terraria conventions or are completely supported by auto-generated runtime hooks.
The OTAPI.Hooks class still exists in OTAPI.dll, but is only provided for manual IL reworked hooks. OTAPI.Runtime.dll is used for most traditional before/after wrapped hooks and can be subscribed to at runtime without the need of pre-compilation or custom IL/wrapping.
OTAPI v2 was a single dll, this version has a few more dependencies such as ModFramework and MonoMod. If you are concerned about too many files, try and use the new single file publish tools available for you from .net5+ otherwise add some extra assembly resolve handlers and place the binaries in a sub folder or in embedded resources.
Dependency on ModFramework is currently needed specifically for ICollection<>
, which is used to replace Terraria.tile
's Tile[]
arrays to an abstract implementation.
In addition, it is also used to load supplemental modules that can feed in extra modifications written in other languages.
This dependency is certainly something to discuss, and i'm happy for you to lodge an issue or a discussion topic to talk why this wont work for your project.
ModFrameworks plugin system is active in all projects that use OTAPI no matter the type or variant. This means you can carefully write a cross platform plugin and have it be compatible on clients, pc server, mobile server & tModLoader servers. Further more plugins can now be written in various languages and have full access to .NET & Terraria using the ModFramework modules.
For the end user building a host or plugin, ITile is basically the same, to the T even..or at least an upside down L
since instead of living in OTAPI's namespace it now resides back in Terraria
beside the original implementation.
This is because unlike v2 which hardcoded ITile, it is now 100% generated from Terraria.Tile
and it feels more natural for it to be here.
Don't worry though! If this is a massive problem I don't see a problem in changing the namespace back, or we probably can come up with some sort of redirection fix.
Examples of new tooling:
Examples of TShock being ported from v2 to v3:
Use this table to see where your hook now resides.
v2 | v3 |
---|---|
OTAPI.Hooks.Game.StatusTextWrite | OTAPI.Hooks.Main.StatusTextChange |
OTAPI.Hooks.Player.NameCollision | OTAPI.Hooks.MessageBuffer.NameCollision |
OTAPI.Hooks.Player.Announce | OTAPI.Hooks.NetMessage.PlayerAnnounce |
OTAPI.Hooks.Player.PreGreet | On.Terraria.NetMessage.greetPlayer |
OTAPI.Hooks.Player.PostGreet | On.Terraria.NetMessage.greetPlayer |
OTAPI.Hooks.Player.PreUpdate | On.Terraria.Player.Update |
OTAPI.Hooks.Player.PostUpdate | On.Terraria.Player.Update |
OTAPI.Hooks.Net.RemoteClient.PreReset | On.Terraria.RemoteClient.Reset |
OTAPI.Hooks.Net.RemoteClient.PostReset | On.Terraria.RemoteClient.Reset |
OTAPI.Hooks.Net.Socket.Accepted | On.Terraria.Netplay.OnConnectionAccepted |
OTAPI.Hooks.Net.Socket.Create | OTAPI.Hooks.Netplay.CreateTcpListener |
OTAPI.Hooks.Net.ReceiveData | OTAPI.Hooks.MessageBuffer.GetData |
OTAPI.Hooks.Net.StartBroadCasting | On.Terraria.Netplay.StartBroadCasting |
OTAPI.Hooks.Net.StopBroadCasting | On.Terraria.Netplay.StopBroadCasting |
OTAPI.Hooks.Net.CheckBytes | On.Terraria.NetMessage.CheckBytes |
OTAPI.Hooks.Net.BeforeSendChatMessageToClient | On.Terraria.Chat.ChatHelper.SendChatMessageToClient |
OTAPI.Hooks.Net.AfterSendChatMessageToClient | On.Terraria.Chat.ChatHelper.SendChatMessageToClient |
OTAPI.Hooks.Net.BeforeBroadcastChatMessage | On.Terraria.Chat.ChatHelper.BroadcastChatMessage |
OTAPI.Hooks.Net.AfterBroadcastChatMessage | On.Terraria.Chat.ChatHelper.BroadcastChatMessage |
OTAPI.Hooks.Net.ReceiveBytes | On.Terraria.NetMessage.ReceiveBytes |
OTAPI.Hooks.Net.SendBytes | OTAPI.Hooks.NetMessage.SendBytes |
OTAPI.Hooks.Net.SendData | On.Terraria.NetMessage.SendData |
OTAPI.Hooks.Net.SendUnknownPacket | On.Terraria.NetMessage.OnPacketWrite |
OTAPI.Hooks.Net.SendNetData | On.Terraria.Net.NetManager.SendData |
OTAPI.Hooks.Npc.PreAI | On.Terraria.NPC.AI |
OTAPI.Hooks.Npc.PostAI | On.Terraria.NPC.AI |
OTAPI.Hooks.Npc.BossBagItem | OTAPI.Hooks.NPC.BossBag |
OTAPI.Hooks.Npc.Create | OTAPI.Hooks.NPC.Spawn |
OTAPI.Hooks.Npc.PreDropLoot | OTAPI.Hooks.NPC.DropLoot |
OTAPI.Hooks.Npc.PostDropLoot | OTAPI.Hooks.NPC.DropLoot |
OTAPI.Hooks.Npc.Killed | OTAPI.Hooks.NPC.Killed |
OTAPI.Hooks.Npc.PreNetDefaults | On.Terraria.NPC.SetDefaultsFromNetId |
OTAPI.Hooks.Npc.PostNetDefaults | On.Terraria.NPC.SetDefaultsFromNetId |
OTAPI.Hooks.Npc.PreSetDefaultsById | On.Terraria.NPC.SetDefaults |
OTAPI.Hooks.Npc.PostSetDefaultsById | On.Terraria.NPC.SetDefaults |
OTAPI.Hooks.Npc.Spawn | OTAPI.Hooks.NPC.Spawn |
OTAPI.Hooks.Npc.Strike | On.Terraria.NPC.StrikeNPC |
OTAPI.Hooks.Npc.PreTransform | OTAPI.Hooks.NPC.Transforming |
OTAPI.Hooks.Npc.PostTransform | OTAPI.Hooks.NPC.Transforming |
OTAPI.Hooks.Npc.PreUpdate | On.Terraria.NPC.UpdateNPC |
OTAPI.Hooks.Npc.PostUpdate | On.Terraria.NPC.UpdateNPC |
OTAPI.Hooks.Projectile.PreAI | On.Terraria.Projectile.AI |
OTAPI.Hooks.Projectile.PostAI | On.Terraria.Projectile.AI |
OTAPI.Hooks.Projectile.PreKill | On.Terraria.Projectile.Kill |
OTAPI.Hooks.Projectile.PostKilled | On.Terraria.Projectile.Kill |
OTAPI.Hooks.Projectile.PreSetDefaultsById | On.Terraria.Projectile.SetDefaults |
OTAPI.Hooks.Projectile.PostSetDefaultsById | On.Terraria.Projectile.SetDefaults |
OTAPI.Hooks.Projectile.PreUpdate | On.Terraria.Projectile.Update |
OTAPI.Hooks.Projectile.PostUpdate | On.Terraria.Projectile.Update |
OTAPI.Hooks.Wiring.AnnouncementBox | OTAPI.Hooks.Wiring.AnnouncementBox |
OTAPI.Hooks.World.IO.PreLoadWorld | On.Terraria.IO.WorldFile.LoadWorld |
OTAPI.Hooks.World.IO.PostLoadWorld | On.Terraria.IO.WorldFile.LoadWorld |
OTAPI.Hooks.World.IO.PreSaveWorld | On.Terraria.IO.WorldFile.SaveWorld |
OTAPI.Hooks.World.IO.PostSaveWorld | On.Terraria.IO.WorldFile.SaveWorld |
OTAPI.Hooks.World.DropMeteor | OTAPI.Hooks.WorldGen.Meteor |
OTAPI.Hooks.World.Generate | On.Terraria.WorldGen.GenerateWorld |
OTAPI.Hooks.World.PreHardmode | On.Terraria.WorldGen.StartHardmode |
OTAPI.Hooks.World.PostHardmode | On.Terraria.WorldGen.StartHardmode |
OTAPI.Hooks.World.HardmodeTileUpdate | OTAPI.Hooks.WorldGen.HardmodeTilePlace OTAPI.Hooks.WorldGen.HardmodeTileUpdate |
OTAPI.Hooks.World.SpawnNpc | On.Terraria.NPC.SpawnNPC |
OTAPI.Hooks.World.SpreadGrass | On.Terraria.WorldGen.SpreadGrass |
OTAPI.Hooks.World.Statue | OTAPI.Hooks.Item.MechSpawn OTAPI.Hooks.NPC.MechSpawn |