Making a multiplayer mod using Mirror

Discuss modding questions and implementation details.
User avatar
Y07A
Posts: 22
Joined: Wed Oct 28, 2020 4:09 pm

Making a multiplayer mod using Mirror

Post by Y07A »

Hi, I've been working on a multiplayer build of DFU, and I want now to turn it into a mod.
I imported all multiplayer/network scripts as assets into the mod, but I get this error on entering in the game scene:
Spoiler!
[Tanguy's multiplayer 0.1] Compilation Error CS1043: Invalid accessor body `=>', expecting `;' or `{'
at line#73 column#10 " /// </summary>"
Compilation Error : Invalid accessor body `=>', expecting `;' or `{'
at line#0 column#0

UnityEngine.Debug:LogError (object)
DaggerfallWorkshop.Game.Utility.ModSupport.ModManager:CompileFromSourceAssets (string[],string) (at Assets/Game/Addons/ModSupport/ModManager.cs:778)
DaggerfallWorkshop.Game.Utility.ModSupport.Mod:CompileSourceToAssemblies () (at Assets/Game/Addons/ModSupport/Mod.cs:974)
DaggerfallWorkshop.Game.Utility.ModSupport.ModManager:Init () (at Assets/Game/Addons/ModSupport/ModManager.cs:698)
DaggerfallWorkshop.Game.Utility.ModSupport.ModManager:StateManager_OnStateChange (DaggerfallWorkshop.Game.StateManager/StateTypes) (at Assets/Game/Addons/ModSupport/ModManager.cs:1294)
DaggerfallWorkshop.Game.StateManager:TriggerStateChange (DaggerfallWorkshop.Game.StateManager/StateTypes) (at Assets/Scripts/Game/StateManager.cs:153)
DaggerfallWorkshop.Game.StateManager:ChangeState (DaggerfallWorkshop.Game.StateManager/StateTypes) (at Assets/Scripts/Game/StateManager.cs:91)
DaggerfallWorkshop.Game.StateManager:.ctor (DaggerfallWorkshop.Game.StateManager/StateTypes) (at Assets/Scripts/Game/StateManager.cs:57)
DaggerfallWorkshop.Game.GameManager:get_StateManager () (at Assets/Scripts/Game/GameManager.cs:121)
DaggerfallWorkshop.Game.Entity.PlayerEntity:Update (DaggerfallWorkshop.Game.Entity.DaggerfallEntityBehaviour) (at Assets/Scripts/Game/Entities/PlayerEntity.cs:376)
DaggerfallWorkshop.Game.Entity.DaggerfallEntityBehaviour:Update () (at Assets/Scripts/Game/Entities/DaggerfallEntityBehaviour.cs:81)
Does someone already faced this ? Your help will be welcome.
Last edited by Y07A on Sat Nov 05, 2022 7:00 pm, edited 1 time in total.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Compilation Error CS1043

Post by BadLuckBurt »

I googled the error and I think it's because there are parts of your code written in a C# syntax that is newer than what the mod compiler can handle. It's not the same compiler as Unity if I remember correctly.

The person who posted this: https://social.msdn.microsoft.com/Forum ... xamarinios has a getter and setter defined like

Code: Select all

        get => (ImageSource)GetValue(SourceProperty);
        set => SetValue(SourceProperty, value);
That would need to be rewritten to:

Code: Select all

	get { (ImageSource)GetValue(SourceProperty); }
	set { SetValue(SourceProperty, value); }
You will probably have to do something similar in your code unless there's a way to tell the mod compiler you want it to compile against a newer C# version but I don't know if that's possible.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Y07A
Posts: 22
Joined: Wed Oct 28, 2020 4:09 pm

Re: Compilation Error CS1043

Post by Y07A »

BadLuckBurt wrote: Fri Nov 04, 2022 2:56 pm I googled the error and I think it's because there are parts of your code written in a C# syntax that is newer than what the mod compiler can handle. It's not the same compiler as Unity if I remember correctly.

...
I do have some parts of the code like so, in Mirror scripts. I will try to change it to match with the compiler.
Thank you for the help.

User avatar
Y07A
Posts: 22
Joined: Wed Oct 28, 2020 4:09 pm

Re: Compilation Error CS1043

Post by Y07A »

Ok, so after trying various versions of Mirror, there is still issues with the compiler.
I think implementing multiplayer with Mirror as a mod is almost impossible due to the C# compiler but also because multiple scripts have the same name and the Mod builder doesn't seems to allow it.
I will try to make a build of the thing instead.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Compilation Error CS1043

Post by BadLuckBurt »

Y07A wrote: Sat Nov 05, 2022 12:32 pm Ok, so after trying various versions of Mirror, there is still issues with the compiler.
I think implementing multiplayer with Mirror as a mod is almost impossible due to the C# compiler but also because multiple scripts have the same name and the Mod builder doesn't seems to allow it.
I will try to make a build of the thing instead.
I'm not familiar with Mirror sadly but maybe someone else here is. The Mod Builder definitely isn't without its quirks, there used to be issues with enums and that got fixed by updating the compiler I believe so maybe that needs to be done again.

Making a build will probably work without any issues since Unity handles everything by itself, I hope it works, multiplayer has come up several times over the years and would no doubt be very popular.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Y07A
Posts: 22
Joined: Wed Oct 28, 2020 4:09 pm

Re: Compilation Error CS1043

Post by Y07A »

BadLuckBurt wrote: Sat Nov 05, 2022 2:01 pm
I'm not familiar with Mirror sadly but maybe someone else here is. The Mod Builder definitely isn't without its quirks, there used to be issues with enums and that got fixed by updating the compiler I believe so maybe that needs to be done again.

Making a build will probably work without any issues since Unity handles everything by itself, I hope it works, multiplayer has come up several times over the years and would no doubt be very popular.
I will try to put it into a mod maybe later, for now making a build with a solid multiplayer implementation seems better, at least if i succeed :lol: . My builds have some missing localetext and foes corpses disapearing, if you have any solutions on this, I will really appreciate it.

if you are interested by the thing, I post videos of the progress here: https://www.youtube.com/watch?v=-feFd_x6iL8&t=59s

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Compilation Error CS1043

Post by BadLuckBurt »

Y07A wrote: Sat Nov 05, 2022 6:34 pm I will try to put it into a mod maybe later, for now making a build with a solid multiplayer implementation seems better, at least if i succeed :lol: . My builds have some missing localetext and foes corpses disapearing, if you have any solutions on this, I will really appreciate it.

if you are interested by the thing, I post videos of the progress here: https://www.youtube.com/watch?v=-feFd_x6iL8&t=59s
I bet if you change the topic title to include the word Multiplayer, you'll see how many people are interested in this :D

I know how to fix the missing locale text but don't know about the corpses disappearing, that might be due to the net code although that's just a guess. I would recommend adding some Debug.Log calls in parts of the code that deal with the corpses to find out what happens exactly.

For the locale text, you need to rebuild some assets. If you open Window > Asset Management > Addressables > Groups in the top menu, you'll get a window that shows the Addressable Groups, at the top of this window are a few options including Build, if you click Build > New Build > Default Build Script, Unity will generate the assets that you're currently missing. If you then rebuild DFU, the missing localetext should be fixed.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Y07A
Posts: 22
Joined: Wed Oct 28, 2020 4:09 pm

Re: Compilation Error CS1043

Post by Y07A »

BadLuckBurt wrote: Sat Nov 05, 2022 6:55 pm
I bet if you change the topic title to include the word Multiplayer, you'll see how many people are interested in this :D

I know how to fix the missing locale text but don't know about the corpses disappearing, that might be due to the net code although that's just a guess. I would recommend adding some Debug.Log calls in parts of the code that deal with the corpses to find out what happens exactly.

...
Huge thanks ! that's the thing I was missing. :D
It also resolved corpses disapearing issues, I will try next week to do a github with thoses builds of the game implementing multiplayer, so people who are interested can test it.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Compilation Error CS1043

Post by BadLuckBurt »

Y07A wrote: Sat Nov 05, 2022 7:15 pm Huge thanks ! that's the thing I was missing. :D
It also resolved corpses disapearing issues, I will try next week to do a github with thoses builds of the game implementing multiplayer, so people who are interested can test it.
Nice :) good to hear it fixed both issues, saves some headaches. Looking forward to the github and playing around with this, it'll help to figure out whether this can be turned into a mod eventually or if it needs to remain a fork apart from the fact that it's just freaking awesome :lol:
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Y07A
Posts: 22
Joined: Wed Oct 28, 2020 4:09 pm

Re: Making a multiplayer mod using Mirror

Post by Y07A »

So here is the very first version of this project: https://github.com/EmptyBottleInc/DFU-T ... ultiplayer
It's a build of the 0.14.5 including multiplayer features.
This is using Kcp transport, so if you want to play online, you need to do port forwarding :shock: but dont worry I will soon make a newer version with steam Transport and a tutorial on how setup the thing to play with steam friends.

Post Reply