ModAPI Hub keyboard_arrow_right Mods keyboard_arrow_right BuilderCore

BuilderCore

Hazard
Subscribe to this mod
Like
BUILDER CORE

A mod with libraries for importing meshes and saving objects.


How to use Builder Core in your mod?

-You will need to add BuilderCore.dll to your references in a mod project.
To do so, download this mod, and run the game once with it installed. After launching, modapi will create a file in your game dir with other dll files.
Then, in your project in Visual Studio, inside Solution window right click on 'References'
6Wx7F5m.png


And select 'Add Reference...'
kPuvrsJ.png


You need to find the BuilderCore.dll. Click on browse.
4yRgKw0.png


Navigate to your steam folder. From there, go to
Steam\steamapps\common\The Forest\TheForest_Data\Managed
uv6V8je.png


Check the box next to BuilderCore.dll and press 'Ok'
9gHzgWd.png


Note.
Whenever you launch a game via modapi, BuilderCore.dll is replaced. You will have to add a reference again.




To be able to use BuilderCore, you need to add this line on the top of your document:
Code:
using BuilderCore;
nVkqNQx.png



After that you're ready to start using it.




Documentation


Core.ReadMeshFromOBJ(string Filepath)

returns a mesh object.
parameters:
  • Filepath - the path to a file with a .obj extension

Core.ReadMesh(string Filepath)

returns a mesh object. older way of importing meshes, but faster than reading .obj files. Requires a file created using this algorytm
parameters:
  • Filepath - the path to a file.


Core.CreateMaterial(BuildingData data)
returns a material using unity's standard shader. uses only material variables of Building data
parameters:
  • data - a object of type BuildingData. It contains simplified information about shader properties. See more information on BuildingData class below.

Example:
Code:
Material mat = Core.CreateMaterial(new BuildingData() { Smoothness = 1, MainColor = Color.red, Metalic = 1, EmissionColor = new Color(0.3f, 0f, 0f) } ); gameObject.GetComponent().material = mat;


Core.CreatePrefab(Building b)
Creates a gameobject from data inside Building class.
parameters:
  • b - object of type Building, contains an array of BuildingData.


Core.AddBuilding(Building building, int ID)

Creates a prefab and adds it to a prefab list. Used to later create copies of the prefab using Core.Instantiate(...)
parameters:
  • building - object of type Building containing information about the prefab.
  • ID - integer, key of prefab in the prefab list. Used to instantiate.


Core.Instantiate(int prefabID, Vector3 position)
Core.Instantiate(int prefabID, Vector3 position, out uint Index)

Creates a copy of a prefab created using Core.AddBuilding(...)
parameters:
  • prefabID
  • position
  • Index - index on the list of placed objects.


Core.Remove(GameObject go)
Destroys the gameobject and removes it from item list so it doesnt get saved.
parameters:
  • go - GameObject to remove


BuildingData class

Constructors:

new BuildingData() - creates an object with default values.

Fields:
  • Material related fields:
    • RenderMode - renderMode - Opaque, Cutout, Fade, Transparent mode of rendering the material
    • Texture2D MainTexture - Albedo texture
    • Color MainColor - Albedo color
    • Texture2D BumpMap - Normal map
    • float BumpScale - normal map's bumpiness. Default 1 Materials with bump map can appear comepletely dark. To fix it, change SSAO to 'unity' from 'amplify'
    • Texture2D HeightMap - Height map
    • float HeightAmount - scale of the heightmap. Range 0.005 - 0.08. Default 0.02
    • Texture2D Occlusion - Occlusion map - information about which areas of the model should receive high or low indirect lighting
    • float OcclusionStrenght - strenght of the occlusion map. Range 0 - 1
    • Texture2D EmissionMap - texture to glow on the object
    • Color EmissionColor - color of the glow on the object
    • float Smoothness - smoothness amount. Range 0-1. Default 0.5
    • float Metalic - metalic amount. Range 0-1. Default 0
    • Texture2D MetalicTexture- Texture of the metallic effect
  • Building related fields:
    • Mesh mesh - mesh of the model.
    • public Vector3 scale - scale of the model. Default zero zero zero
    • public Vector3 offset - offset of the model. Default zero zero zero
    • public bool AddCollider - should there be a mesh collider on the object. Default true
    • bool Convex - should the collider be convex. Default false
    • System.Type[] componets - components on the model. default empty array

NOT YET IMPLEMENTED:
Here are ways to achieve more with your mods, that arent yet used BuilderCore 1.5.5
  • Loading HD images.
    • Code:
      Texture2D GetTexture(string path,bool CompressTexture =false) { //read a file at given path byte[] data = File.ReadAllBytes(path); //checks if the file contains a valid 'header' //every png and jpeg file have the first several bytes predefined. //checking them allows for validating the file. if ((data[0] == 137 && data[1] == 80 && data[2] == 78 && data[3] == 71 && data[4] == 13 && data[5] == 10 && data[6] == 26 && data[7] == 10) || (data[0] == 0xFF && data[1] == 0xD8 && data[2] == 0xFF)) { Texture2D t = new Texture2D(1, 1, TextureFormat.RGBA32, false, true); t.LoadImage(data); t.Apply(); if (CompressTexture) { t.Compress(true); } return t; } else { ModAPI.Log.Write("Missing texture " + path); return null; } }
  • Loading an AudioClip from a .wav, .ogg or .mp3 file
    • Code:
      //since this method uses Www, it has to be a coroutine, //to call this method, use StartCoroutine(GetAudioClip(...)); IEnumerator GetAudioClip(string path) { WWW audioWWW = new WWW("file://" + path); yield return audioWWW; AudioClip clip = path.EndsWith(".mp3") ? audioWWW.GetAudioClip (true, true, AudioType.MPEG) : clip = audioWWW.GetAudioClip(true, true); if (clip != null) { someAudioclipVariable = clip; //success, some variable outside the coroutine is assigned. } else { ModAPI.Log.Write("Missing audio " + path); } }
File BuilderCore-1.5.5-fa9b59a862d9328f106d9c9bb36f4bec.mod
Compatible 1.09
Version 1.5.5

videogame_asset The Forest label Buildings
  • Version 1.5.5 (1.09) 01. Sep 2018
    12.48 kB
    535,640 downloads

Download

Downloading ModAPI...

1 Your download is ready!

Extract the .zip file to
C:/Program Files (x86)/
Or choose another location. Do not extract it inside the Steam game folder.

2 Start ModAPI.exe

3 Enable mods

4 Start the game

You can launch your game regularly through Steam without ModAPI after the first launch.

FAQ