Creating a basic creature - LeeTwentyThree/ECCLibrary-Legacy GitHub Wiki
Once you have set up your asset bundle and mod framework, you are ready to get started on your first creature.
- Create a new class and name it something unique.
- Add these two lines to the top:
using ECCLibrary;
andusing UnityEngine;
. - Also ensure this class inherits from
ECCLibrary.CreatureAsset
.
- You should have some errors at this point.
- Automatically implement the abstract class and automatically generate the constructor.
- To do that (In Visual Studio), simply select the class name and press
Ctrl + .
and you should see all the actions that I listed, plus a few more.
- To do that (In Visual Studio), simply select the class name and press
- Please fill out all these overrides. Leaving any override as
throw new NotImplementedException();
will cause errors.- Most of these overrides are documented! Simply hover over their names and it should show a short description.
- There is much more to it than this, but we should make sure it is working first.
It may look different if new abstract properties were added/made obsolete since the creation of this guide.
using ECCLibrary;
using UnityEngine;
//any other necessary 'using statements'
public class ExampleCreature : CreatureAsset
{
public ExampleCreature(string classId, string friendlyName, string description, GameObject model, Texture2D spriteTexture) : base(classId, friendlyName, description, model, spriteTexture)
{
}
public override BehaviourType BehaviourType => BehaviourType.SmallFish;
public override LargeWorldEntity.CellLevel CellLevel => LargeWorldEntity.CellLevel.Near;
public override SwimRandomData SwimRandomSettings => new SwimRandomData(true, new Vector3(10f, 10f, 10f), 3f, 1f, 0.1f);
public override EcoTargetType EcoTargetType => EcoTargetType.SmallFish;
public override void AddCustomBehaviour(CreatureComponents components)
{
//if you have special components you want to add here (like your own custom CreatureActions) then add them here
}
public override void SetLiveMixinData(ref LiveMixinData liveMixinData)
{
liveMixinData.maxHealth = 20f;
}
}
- Go to the main Patch method in your mod.
- Create a new static field
- Set that new static field to a new instance of your CreatureAsset using the constructor you made (after you do the AssetBundle stuff).
- Access that creature asset instance and call its Patch method.
using QModManager.API.ModLoading;
using ECCLibrary;
using UnityEngine;
[QModCore]
public static class QPatch
{
public static AssetBundle assetBundle;
public static ExampleCreature exampleCreature;
[QModPatch]
public static void Patch()
{
assetBundle = ECCHelpers.LoadAssetBundleFromAssetsFolder(Assembly.GetExecutingAssembly(), "deextinctionassets");
ECCAudio.RegisterClips(assetBundle);
exampleCreature
= new ExampleCreature("ExampleCreature", "Example creature", "An example creature. Does not really exist.", assetBundle.LoadAsset<GameObject>("ExampleCreaturePrefab"), assetBundle.LoadAsset<Texture2D>("ExampleCreatureIcon"));
exampleCreature.Patch();
}
}
Now you should be able to spawn your creature in game with the spawn
command. For example, with the code above, you would do spawn examplecreature
.
If you have done everything correctly, you should see your creature swimming around in-game!
Please continue onto this page when you are ready: