Assembly Definition, Saving System Failure and Access to External Scripts

OK so… I ran into a brand new problem. I purchased Malbers’ Assets a while ago (as I need creatures to populate my game’s wildlife, and a few new bosses), and something that he has that peaked my curiosity, is a variable that stores the last animal the player has driven, and who he can call

Now, to make my player’s life a little easier, I want to save that variable, so when they return to the game after a while, they have something to mount/drive and don’t have to go and hunt animals all over again, unless they want to (mainly because you can call these animals by whistling to them, especially if you go very far away from your mount, and it’s not following you)

However, from the get-go, I ran into a major problem, where Malbers’ ‘MRider.cs’ script does NOT recognize our ‘GameDevTV.Saving’ library (I have no idea how any of that works, so bear with me because I’m clueless here), which means I can’t even import the ‘IJsonSaveable’ interface to work with, let alone work on saving the required variable, and this is the first time I have ever run into a problem that looks like this

After a little bit of heavy research, I learned of a solution called “Assembly Definition”, essentially a way to assemble the scripts and somehow get his code to work with mine.

After taking the big risk of actually attempting to implement it (Please don’t do that, I don’t recommend it!), I got into working on the saving system for his script, but that failed miserably.

As soon as I ran my game, let’s just say Saving or Saving and Quitting my game was just pure disaster as a result. It would never work with my game for some reason, and I honestly didn’t understand much about what the reason was. In the end, I was forced to reverse what I did, because I had no idea what’s going on…

So, I come here seeking a solution for that problem. Anyone knows how to fix this issue?

I also messaged MalberS about it, but I’m waiting for a response from his side as well

As a rule of thumb, if your code is in an Assembly Definition, then it can only see code in the definition or definitions that it explicitly references. It can’t see any code in Assets that isn’t in an Assembly Definition (actually, to be specific, all code that is in an Assembly Definition is kept in the Assembly-CSharp Assembly). Assembly-CSharp is not allowed to be referenced by our custom Assembly definitions, however. Assembly-CSharp, on the other hand, can see ALL of the other Assembly Definitions as long as the defines and platforms match.

That’s why Malbers can’t see the Saving System.

So… the new version of the Saving System that I’m writing actually will be in an Assembly Definition. If you hold on till that’s released (it will be compatible with our current system, this is mainly making the system more portable and less co-mingled with the RPG course), then you’ll be able to add an assembly reference to Malbers’ Assembly Definition and reference the saving…

Alternatively (and simpler at this point), you could expose a getter/setter for the properties you want to save in the Malbers script, and make a script outside of the Malbers directory (so it’s back in Assembly-CSharp) that captures and restores the values to the Malbers script.

Ahh, there’s a problem with that approach. The problem is MalberS does a lot of operations on that saved variable, so restoring it will need to be done within the same Assembly (I think…?! I’m a little baffled here) file, otherwise a few really interesting concepts done by that will be cancelled, because the setter can’t refer the correct file, which beats the entire purpose of what I’m trying to do

In other words, I have no way around getting the Assembly right, without messing the important part up :sweat_smile:

Now you have me at a spot that just has to ask: Any Estimated Time of Arrival of the new system?

In the meanwhile I decided to try and work on a dodging state for my player (I split this into two parts: dodging from FreeLook state, and dodging from Targeting state. Each state has it’s own script, and whilst the freelook uses a simple animation, which will correspond to the direction the player is moving in, the targeting will use a blend tree), as I wait out on that one (and the police distance/dynamic-respawning system. I still have no idea how to even start working on that one, since I already have a RespawnManager and AggroGroup systems in place…) but the movement is zero for some reason…

Edit: I finished both the combat and the FreeLook Dodging Systems, and they work beautifully (at a 98% rating, because holding two buttons whilst dodging in combat, without a ‘FaceMovementDirection()’ function in there, can really make the player look in two different ways at once, like something out of a Quantum Field :slight_smile:)

Wait… is somebody starting to notice that changes in code can lead to unintended consequences? :slight_smile:

You might consider asking Malbers to write a Getter and Setter that safely lets you retrieve and set the variable you want to save (the setter should take care of any pesky behind the scenes details that need to get done.). He understands his code better than anybody else. Then you can write a class that uses that Getter/Setter to Capture/Restore the variable.

lol, believe me I’ve been carefully messing with code whenever I want to add in a new feature for some time now. If I have tried everything I can (safely, of course) and still can’t figure it out a while later, then I’ll ask around here xD

welp, he just sent me a screenshot showing me the setter, something to clear it off and something to get the player to start mounted on his animal. I asked him for a getter, but I think for now this should be sufficient to start coding it out

The problem I have is… is where’s the best position to do that, on the player himself, or…? (I think on the player himself should do the trick for this one, since that’s where the variable exists as well anyway)

we found another way around it. Haven’t worked on it yet, but I got his script to recognize my saving system

I’m dealing with a whole other problem now :sweat_smile:

I haven’t had a chance to work more on the Saving System rewrite, but it occurs to me that I do have a fairly decent explanation of Assembly Definitions within what I have written of the tutorial.

You can check out what I have so far here:

Then the idea will be that you can add the assembly that you put the Json Saving System in to the referenced assemblies in the Malbers assembly definition. Then Malbers will have access to the Json Saving System.

1 Like

Whilst my backup does its thing, I’ll go through the link. I skimmed through it before bed a few hours ago, time to go through it again

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms