Space Engineers

Space Engineers

[OBSOLETE] Smart Turrets
Jimmacle Dec 18, 2017 @ 2:58pm
Performance Concerns/Suggestions
I have some significant concerns about how well this mod performs because it handles its own state very inefficiently and it doesn't look like a lot of care was taken to optimize it or make sure it behaves properly in multiplayer.

1) Don't use mod storage as "live" variable storage. It's designed to store data when blocks are saved and loaded, not for you to parse the contents during runtime. This is going to be **incredibly** slower than simply using a class that you serialize when the game is saved/loaded.
2) Don't use a dozen different GUIDs for mod storage, create a single class that holds all your data and serialize that.
3) Don't compare distances using Vector3D.Distance. Use the squared distance instead because it's faster to calculate and works just fine for greater/less comparisons.
4) There is 0 multiplayer sync code and the game doesn't do that for you. You need to sync your block and control states between the server/clients to make sure they don't get out of sync. You also need to take multiplayer into account and only change the state of blocks from the server, then sync that to the clients.
5) I'm seeing a lot of redundant collection iteration that can be removed by simply restructuring your code a little.
6) Divide your code up into different classes/files and use a consistent/standard naming scheme. This will help you a lot when it comes to maintenance. It looks like almost everything is in a single session component which is really hard to read, consider using entity components so you don't have to track each block's state in a "global" scope.
7) Don't just drop your VS solution into the Scripts folder, it contains a lot of unnecessary files that bloat the size of the workshop item.

That's just what I found from skimming the code. Join the modding channel in the KSH Discord server, there are lots of modders who will be able to give you more advice. https://discord.gg/keenswh
Last edited by Jimmacle; Dec 18, 2017 @ 3:17pm
< >
Showing 1-4 of 4 comments
Zelious  [developer] Dec 18, 2017 @ 5:13pm 
Thanks for all the advice! This is actually my first large scale project in C#, I have only used JS before so I didn't really think about the whole 'store things in classes' idea until the mod was almost done. I also had no idea about syncing or how the game would handle multiplayer as I have zero friends who play regularly to test with, will need to look into that. Oh and I completely forgot that my VS solution was in there!
Zader64 Dec 18, 2017 @ 7:28pm 
C:\Users\Brody\AppData\Roaming\SpaceEngineers
Zelious  [developer] Dec 18, 2017 @ 8:21pm 
?
FurtiveSage Jan 22, 2018 @ 8:00am 
How is the multiplayer coming along. I would love to add this to my DS 8~)
< >
Showing 1-4 of 4 comments
Per page: 1530 50