[InfinityPBR.com] Alpha: Master Class System (Free during Alpha/Beta)

WIP Mega Thread

Hey all,

I’ve been working on this thing I call the “Master Class System”. I started to make my game, a 1st person RPG, and realized that I didn’t want to script all the classes manually. I figured there could be a way to set the default values and all the class structure in a more easy-to-user manner. For the past maybe 12 months I’ve been working on this on and off.

It’s in alpha right now. It works, can be used to make games, but could probably be much much better.

I’m hoping some of you may be interested in helping me make it better. I am by no means a great coder. But I think I’ve made something of value.

What it does
You create your classes using drop downs and buttons, adding variables, types, and linking them all together. There’s a Table Editor as well, so that you can quickly and easily populate table values, like Stats or other information.

When you’re ready, click the button and all your classes will be exported for you, and you’ll be ready to start coding your game. If you need to make changes, make them in the editor, then re-export the classes, and your changes will be there.

I made a sort of rambling demo here:

Please download the unity package below, and let me know what I can do to make this better! There’s definitely a few things I feel could be better – there’s a lot of boilerplate code that I repeat for each type, and I swear there should be an easier way to do that, to loop through all available types…but I haven’t figured it out yet. Maybe you could?

Thanks, and enjoy!

LATEST VERSION:
http://www.infinitypbr.com/files/masterclasssystem_alpha6.unitypackage

Does this handle skills too? I don’t see why it wouldn’t, just want to make sure. I’ve been looking for a sort of skill system.

1 Like

First small bit of feedback: use namespaces. PlayMaker was choking on your Strings class.

Second bit, I think the reason you have so many classes is because the classes structured like “DataInts” could be a single generic class.

public class Data<T>
{

    public string name;                             // Human Readable name
    public string dataName;                         // Data List we're referencing
    public List<T> value = new List<T>();                       // The value List

    [HideInInspector]
    public string updateName = "";
    [HideInInspector]
    public bool showList = false;
    [HideInInspector]
    public bool showThis = false;
    [HideInInspector]
    public bool storeInSaveFile = false;

    public Data()
    {

    }

    public Data(string newName)
    {
        name = newName;
    }

    public Data(string newName, string newDataName)
    {
        name = newName;
        dataName = newDataName;
    }

    public Data<T> Copy()
    {
        Data<T> copy = new Data<T>();
        copy.name = this.name;
        copy.dataName = this.dataName;
        for (int i = 0; i < this.value.Count; i++)
        {
            copy.value.Add(this.value[i]);
        }
        return copy;
    }
}
1 Like

And honestly I think that’s going to cut down your code by about 11-fold. You can create a nested loop of data types in the editor code instead of a separate loop for each data type.

I need to add a potential caveat here. Unity’s serialization system is…basic. I don’t think serializing generics is an issue, but it might be. I finally gave up on Unity serialization this year because it was forcing me into some really bad practices.

1 Like

Yes, as far as I can tell it should handle any concept at all.

Ok, new version linked up top, with “MCS” namespace, if I did it right :slight_smile:

I looked into generics, but wasn’t able to figure it out before. I"ll have to look into it again. It did sound like what I was looking for, just couldn’t get it working I guess.

Do the exported classes need to be part of a namespace too?

The exported classes do not need to be a part of a namespace since they are named by the user. However, since you’re creating what is essentially a code generation tool, you might want to consider giving the user an option to specify a namespace.

1 Like

The code above should be enough to get started. Basically, a generic lets you defer type specification until implementation time. So, worst case, instead of all of these type-specific classes, you would just have that one.

Then, in your code, instead of

List dataTexture2ds;

you would have

List<Data> dataTexture2ds;

The really sophisticated serialization of something like Odin Inspector lets you do even cooler things like specify derived types in the inspector. When you do that, you can take code reuse to a whole new level. If you ever want to see some of that, let me know and we can skype or zoom about it. Of course, for salable assets, you’re stuck with Unity serialization.

1 Like

Thanks – I started, and got stuck. I’ve been battling the flu for 2 weeks, so I think maybe a 2nd look when things are less flu-y may be good. Doesn’t help that I only look at this code every few weeks, so each time I have to figure out what I Was doing :slight_smile:

1 Like

I have the same problem with everything I try to come back and start working on. It is almost like I have to teach myself all over again. Hope you get to feeling better soon.

I’ve been following since you started this thread. The phrase “Master Class” is what sparked my attention and I started wondering about the possibility of it supporting sub classes/specialization classes. From what I’ve read so far, it doesn’t seem to be part of the original intent. Feel free to correct me if I’m wrong. :slight_smile: Maybe it will be something I can adapt down the road, if not.

What do you mean by sub classes / specialization classes?

I recall some games having something where you pick a main class and then after 10-15 levels, you can choose a sub-class/specialization. So if you start out as a mage, you might have something like elementalist, pscion, etc as different sub-classes or specializations down the line. A sub class may give options of choosing and switching between the subclasses, where a specialization might be the same thing but only allow one choice between the different options where all of the training from then on would be solely focused.

I’ve seen it in quite a few different games but at the moment it has been so long since I’ve played any that I can’t remember which ones they were. lol

Final fantasy 11 had sub classes…

Ah ok! Then yes :slight_smile:

I wasn’t sure if it was a programming thing or not – I’m aware I don’t know everything, so “Sub class” could be a thing like “Class” is a thing in programming.

In the demo, there are 32 classes, and each one has a “Single Custom Variable”, which is a custom variable with a single value, called “Parent Class”, type String. They also have a bool called “Base Class”.

The base classes will have that checked, and no Parent Class. The rest will have a Parent Class, and in the coding of the game, that’s how I’ll know if the user can get the next class.

3355588--262617--Screen Shot 2018-01-15 at 7.51.17 PM.png

2 Likes

Since you’re making the code for the classes, you could probably use reflection to make that parent class a dropdown instead of an open string field. Less for a user to fat-finger.

2 Likes

Looks like I actually did the wrong type for that. It was supposed to be of “Classes” type with “Single” as the option, meaning just a single value from the “Classes” items.

Adding new version below:
3356540--262691--Screen Shot 2018-01-16 at 12.45.56 PM.png

And then it looks like this:
3356540--262692--Screen Shot 2018-01-16 at 12.46.11 PM.png

2 Likes

This is pretty cool, Andrew. It’s kind of like nHibernate or Entity Framework. Nice job. I think genre-specific code generation tools are going to be really helpful for some people.

1 Like

Did I paint myself into a box? I may have.

PROBLEM: I want to save game data. ScriptableObjects can’t be serialized. So the “Game” class, which is a scriptable object type, either can’t be that, or I need another structure that can be serialized.

POTENTIAL SOLUTION: I’m thinking maybe there should be two main classes, a “Data” one and a “Master” one. W/ the master being the scriptable object that holds all the static data such as “Hit points per level” and “Minutes per second” etc. Stuff that doesn’t change and doesn’t get saved (because it doesn’t change).

And a 2nd one “Data”, that holds the actual data and can be serialized.

Thoughts?

I was certain scriptable objects could be serialized as .asset files. In fact, that’s their primary purpose. Perhaps there is something in the Game class that is not serializable that you have have to explicitly mark as such. However, you can always serialize to Json or xml using .Net.

Maybe – everything I’ve seen says scriptable objects can’t be serialized, but I’m sure there’d be a way around it.

I think the solution for this is to have a scriptable object for the “data” of the game – the stuff that doesn’t change. And then another script that holds the mutable data like locations of enemies, players stats etc. That would be serializable, it’d be on an object that can be loaded and DontDestroyOnLoad() etc. So I’ll go with this angle for now, and see how it works.

It’ll need to build the script, then create a prefab with the script attached, and then populate the values with the default values. Starting stats, starting locations etc.