Note: I will be skimming over details here about OOP
Types in Programming
Generally speaking, most programming langauge have a notion of types, but what they? In short types tell the programming environment what type of data something is so it can be worked with.
For example, division is something that should only work with certain types of data, such being intergers or floating point/decimal numbers.
Basically all data has a certain type which dictates what operations can be performeed on it as well as what it can do.
More complex types are also composed from other types, for example an array is just a list of a bunch of data which all have other types, or objects/classes which have fields/properties of simpler types(Think of how sprite.x is really just the sprite storing a decimal in the x field). These composite types are useful, but what if we need shared behavior?
Which leads us right into a concept known as inheritance.
Inheritance
Inheritance is a fairly simple concept, you take an existing composite type(say you have a class called Animal) and use it as a base to build something a bit more specific(say a Dog type that inherits from Animal), which allows you to have a common set of behaviors. If you have a function that accepts an argument of type Animal, you can also pass a variable of type Dog and it'll work just fine, because the Dog class inherited all the behaviors from the Animal class.
Turns out, this also applies to the Fraymakers API, if you've spent any amount of time using the api methods, you'll notice that a lot of object types have a quite a few methods in common. Let's look at a really simple method .getX(), which happens to work on a ton of types, Character, GameObject, Entity, Projectile, Assist, CustomGameObjector Vfx, but looking at the Api docs, you'll notice its on the entity page, this is because Entity defines this behavior, whilst everything else builds upon it.
This also has some other implications, which allow quite a bit of flexibility, let's look at the function camera.addForcedTarget, if we look at its type signature:
addForcedTarget(entity:Entity)you'll notice it specified an entity, but you can also use anything that inherits from Entity, as whatever Entity can do Character, GameObject, Entity, Projectile, Assist, CustomGameObjector Vfx can do.
Only thing to note is that this does not apply backwards, so if a function expects a GameObject, you cannot pass an Entity as GameObject is capable of more, but you can pass Character,Projectile, Assist, CustomGameObject or of course, GameObject itself.
The reason this is possible is due to something known as casting, where something can be seamelessly be "converted"/treated as another type if its compatible.
- types that inherit from other parent types can be used when the parent is expected(e.g you can use a
Characterwhere aGameObjectis expected) - When passing data into functions pay attention to the type it accepts, you can only pass data that either that type or inherits from it in some way (You cannot pass a
GameObjectwhen aCharacteris expected).
A basic understanding of this can help you avoid a ton of errors, and potentially write code that's more flexible.
Types in Fraymakers
Here's a class/type tree for some common fraymakers types, data taken from https://github.com/Fraymakers/api-types-plugin/blob/main/src/ts/typedefs/fraymakers-api.d.ts
Basically, sub-list items inherit from thier list ancestors, not exactly comprehensive but should have you covered.