AutoSteer [Spaar`s Modloader]

#1
So I revamped my InjectionHelper class and made radical improvements to what can be done using dynamic type creation and IL cloning.
This is the result: the AutoSteer feature from MultiMod.
This mod has no GUI; the AutoSteer toggle is available in the Property Tuner of each steering block.

The mod dll is attached.
Installation (From ITR's thread; too lazy to type my own):
Change-log:
v2.1.5:
  • Removed a piece of code that spammed the output log
v2.1:
  • Made the rotation modulo 360, so turning a steering block 360 degrees won't rotate it back to 0
  • Added a threshold to rotated angle, so it doesn't overshoot when returning
  • Used FixedUpdate() instead of Update(), maybe that might fix some out of sync issues? I don't know...
v2.0:
  • Ditched the whole dynamic type class and used @spaar's way for overriding functions
v1.0:
  • Same AutoSteer features as in MultiMod
Known Bugs:
  • AutoSteer toggle doesn't save
Please don't hesitate to inform me of any bugs or suggestions.
Enjoy!

Attached Files
AutoSteerMod.dll
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#2
cysto said:
Installation (From ITR's thread; too lazy to type my own)
You know, you could copy one of the threads that links to Spaar's Modloader thread :p
 
#3
I actually copied this from my Unlimited Cannon mod thread as well, so double the laziness XD Anyway, I'll update the main post.
By the way, do you think I'm over-complicating the mods? :p I mean, is there another way to achieve the same effect without dynamic types?
I tried adding a component to steering blocks that essentially does the same function (changing the value of moveAxis to -1 or 1, depending on the deviation of the steering block), however, moveAxis was being set in the original Update method in the SteeringWheel component, so the autosteer component was being overriden.
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#4
Are you using Update(), FixedUpdate() or LateUpdate()?
 
#5
In this mod? Or the one that failed?
I'm assuming you meant the one that failed. I used Update since SteeringWheel component actually uses Update, rather than FixedUpdate (even though it's changing rotation, I don't know why the devs kept it so).
I still believe that just adding a component without effectively disabling the original one would mess up everything, values would overlap, and even if it achieved the desired effect, I guess it would still be uncertain whether or not it will work everytime (depending on the order of execution of the methods).
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#6
Then it should be possible to use LateUpdate, since that happens after Update.
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#7
How are you doing it now though?
 

spaar

Active Member
#8
I have a question:
The code the decompiler produces is quite hard to read, but if I see that correctly, you are basically creating a patched version of the SteeringWheel component, removing all SteeringWheels and adding your new component instead, right?
If so, why not just create a class that extends SteeringWheel and overwrites whatever you need to change at compile time and that replace the SteeringWheels with that?

Nice to see that you are managing to re-create some features of MultiMod with the mod loader :)
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#9
spaar said:
If so, why not just create a class that extends SteeringWheel and overwrites whatever you need to change at compile time and that replace the SteeringWheels with that?
Don't the functions have to be declared as external then? Or am I thinking of something else?
 

spaar

Active Member
#10
ITR said:
Don't the functions have to be declared as external then? Or am I thinking of something else?
I think you are thinking of something else. External functions in .Net are functions that are actually implemented in native code as far as I know.
What I describe is actually what I'm doing in the scripting mod. I need to allow the number field to allow the user to also enter variable names, so I created a class that extends SimpleNumberField. In there I overwrite the methods that have behaviour that I don't want with my own versions. Then I just go ahead and delete every SimpleNumberField component I can find, first adding my own version to the game object and copying the variables of the old one to the new one.
 
#11
Well, there goes a couple dozen hours XD I guess your way should work, because it's sort of exactly what I'm achieving with dynamic types. Oh well, I hope it comes to good use in the future.
 

Z3r0

New Member
#15
there's a bug(well I guess its not actually a bug, more my pc's fault), when I turn it, then when it's coming back to default position, it overturns a little, then it comes back and overturns again and keeps doing it so it just goes back and forth, though other people probably didn't get this because I don't get good fps cause my pc stinks, so because of the low fps it doesn't make small movements per a frame, so it doesn't ever get to default position perfectly, but did you do auto steer in multimod differently cause it didn't happen for me in that, though I under stand you probably did because you're using spaars modloader, so you cant do some things you could
 

ITR

l̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ֍̫̜̥̭͖̱̟̟͉͙̜̰ͅl̺̤͈̘̰̺͉̳͉̖̝̱̻̠̦͈ͅ
Staff member
#16
Z3r0 said:
there's a bug(well I guess its not actually a bug, more my pc's fault), when I turn it, then when it's coming back to default position, it overturns a little, then it comes back and overturns again and keeps doing it so it just goes back and forth, though other people probably didn't get this because I don't get good fps cause my pc stinks, so because of the low fps it doesn't make small movements per a frame, so it doesn't ever get to default position perfectly, but did you do auto steer in multimod differently cause it didn't happen for me in that, though I under stand you probably did because you're using spaars modloader, so you cant do some things you could
Oh, that's probably due to lag making the delta time too high. If it is, it's fixable by doing
Code:
if(deg<Time.fixedDeltaTime){deg = 0;}else{deg -= Time.fixedDeltaTime;}
 
#18
I had to create a account here just to say...Your mod is making my game lag... Alright i think its something with too many updates happening causing my cpu to burn my house down( sry 4 bed engish )

Cysto pls fix
 
Top