Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thunderkit Utilities #558

Merged
merged 23 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7f73102
Added asset bundles guide
Indigocoder1 Feb 28, 2024
2d9cd12
Grammar changes and formatting
Indigocoder1 Feb 28, 2024
2f03104
Grammar & readability improvements. Added prefab guide
Indigocoder1 Feb 29, 2024
612d98d
Fix a couple grammar issues
LeeTwentyThree Feb 29, 2024
c8d44e8
Fixed names and comment spaces
Indigocoder1 Mar 1, 2024
c41b416
Merge branch 'master' of https://github.com/Indigocoder1/Nautilus
Indigocoder1 Mar 1, 2024
699d92e
Replace constant classID with PrefabInfo one
Indigocoder1 Mar 1, 2024
56a92bc
Changed TechType to PascalCase
Indigocoder1 Mar 1, 2024
19bda17
Fix duplicate usage of "on"
LeeTwentyThree Mar 1, 2024
d4616b4
Add Nautilus.Utility using statement
LeeTwentyThree Mar 1, 2024
3bc5d8a
Since the prefab has a recipe, must be pickupable
LeeTwentyThree Mar 1, 2024
12d6124
Merge branch 'master' of https://github.com/Indigocoder1/Nautilus
Indigocoder1 Sep 14, 2024
f0e3d6f
Added thunderkit utilites
Indigocoder1 Sep 14, 2024
ad6de78
Added SN/BZ checking
Indigocoder1 Sep 14, 2024
cbd18cb
Added separate enums for the layers in SN & BZ
Indigocoder1 Sep 14, 2024
a6cd36c
Changed name of application modes
Indigocoder1 Sep 14, 2024
600639d
Moved material getters to MaterialUtils
Indigocoder1 Sep 14, 2024
0e5f48d
Changed layer application to use switch expression
Indigocoder1 Sep 14, 2024
50efec8
Removed unnecessary comment
Indigocoder1 Sep 14, 2024
8b2ddd0
Changed property names to respect their type name
Indigocoder1 Sep 14, 2024
a86deef
Added default index of 0 to material indices
Indigocoder1 Sep 14, 2024
1c2a2d5
Added graphic setting and reverted default build config
Indigocoder1 Sep 14, 2024
3a31553
Added graphic option to layer applier & removed outdated comment
Indigocoder1 Sep 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed names and comment spaces
  • Loading branch information
Indigocoder1 committed Mar 1, 2024
commit c8d44e86cb9920d4d641516bc72a91079a9523c0
65 changes: 33 additions & 32 deletions Nautilus/Documentation/guides/assetbundles.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,21 @@ namespace Examples
{
internal class AssetBundles : BaseUnityPlugin
{
//Usually this is done in your Plugin script but technically you can do it wherever
public static AssetBundle assetBundle { get; private set; }
// Usually this is done in your Plugin script but technically you can do it wherever
public static AssetBundle MyAssetBundle { get; private set; }

//This gets the path to the "Assets" folder inside my plugin folder
//If you don't have an assets folder you can replace "AssetsFolderPath" with Assembly.GetExecutingAssembly().Location
//That just gets the path to the .dll of the mod
// This gets the path to the "Assets" folder inside my plugin folder
// If you don't have an assets folder you can replace "AssetsFolderPath" with Assembly.GetExecutingAssembly().Location
// That just gets the path to the .dll of the mod
public static string AssetsFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Assets");

private void Awake()
{
//Keep in mind that the assetbundle can only be open in one place at a time, so keep a reference
assetBundle = AssetBundle.LoadFromFile(Path.Combine(AssetsFolderPath, "myAssetBundle"));
// Keep in mind that the assetbundle can only be open in one place at a time, so keep a reference
MyAssetBundle = AssetBundle.LoadFromFile(Path.Combine(AssetsFolderPath, "myAssetBundle"));

//This name needs to be the exact same name as the prefab you put in the bundle
GameObject mirrorVariant1 = assetBundle.LoadAsset<GameObject>("myGameObject");
// This name needs to be the exact same name as the prefab you put in the bundle
GameObject mirrorVariant1 = AssetBundle.LoadAsset<GameObject>("myGameObject");
}
}
}
Expand All @@ -174,18 +174,18 @@ namespace Examples
{
internal class AssetBundles : BaseUnityPlugin
{
//Usually this is done in your Plugin script but technically you can do it wherever
public static AssetBundle assetBundle { get; private set; }
// Usually this is done in your Plugin script but technically you can do it wherever
public static AssetBundle MyAssetBundle { get; private set; }

private void Awake()
{
//Keep in mind that the assetbundle can only be open in one place at a time, so keep a reference
//This method assumes you have a folder named "Assets" in your mod's plugin folder
//The second parameter needs to be the name of the asset bundle file (Usually they don't have file extensions)
assetBundle = AssetBundleLoadingUtils.LoadFromAssetsFolder(Assembly.GetExecutingAssembly(), "myAssetBundle")
// Keep in mind that the assetbundle can only be open in one place at a time, so keep a reference
// This method assumes you have a folder named "Assets" in your mod's plugin folder
// The second parameter needs to be the name of the asset bundle file (Usually they don't have file extensions)
MyAssetBundle = AssetBundleLoadingUtils.LoadFromAssetsFolder(Assembly.GetExecutingAssembly(), "myAssetBundle")

//This name needs to be the exact same name as the prefab you put in the bundle
GameObject mirrorVariant1 = assetBundle.LoadAsset<GameObject>("myGameObject");
// This name needs to be the exact same name as the prefab you put in the bundle
GameObject mirrorVariant1 = MyAssetBundle.LoadAsset<GameObject>("myGameObject");
}
}
}
Expand Down Expand Up @@ -219,20 +219,20 @@ namespace ExamplePrefab
{
internal static class MyCoolPrefab
{
public static TechType techType { get; private set; }
public static PrefabInfo MyPrefabInfo { get; private set; }

public static void Patch()
{
PrefabInfo prefabInfo = PrefabInfo.WithTechType("myCoolPrefab", "My Cool Prefab", "Pretty cool, right!")
.WithIcon(SpriteManager.Get(TechType.Titanium));
//Just using the Titanium sprite as a placeholder
// Just using the Titanium sprite as a placeholder

//Cache the tech type for use in other places
techType = prefabInfo.TechType;
// Cache the tech type for use in other places
MyPrefabInfo = prefabInfo;

var prefab = new CustomPrefab(prefabInfo);

//Create the recipe
// Create the recipe
RecipeData recipe = new RecipeData
{
craftAmount = 1,
Expand All @@ -243,35 +243,36 @@ namespace ExamplePrefab
},
};

//Set the prefab GamrObject to the result of the GetAssetBundlePrefab method
// Set the prefab GamrObject to the result of the GetAssetBundlePrefab method
prefab.SetGameObject(GetAssetBundlePrefab());

//Using the Seaglide as a placeholder unlock
// Using the Seaglide as a placeholder unlock
prefab.SetUnlock(TechType.Seaglide);

//Set the recipe
// Set the recipe
prefab.SetRecipe(recipe)
.WithCraftingTime(6f);

//Add the prefab to the Miscellaneous tab of the blueprints in the PDA
// Add the prefab to the Miscellaneous tab of the blueprints in the PDA
prefab.SetPdaGroupCategory(TechGroup.Miscellaneous, TechCategory.Misc);

// Register the prefab to the Nautilus prefab database
prefab.Register();
}

private static GameObject GetAssetBundlePrefab()
{
GameObject myCoolPrefab = assetBundle.LoadAsset<GameObject>("myCoolPrefab");

//The classID is the same as the one we put into the PrefabInfo.WithTechType up above
//The LargeWorldEntity.CellLevel determines how far away the object will be loaded from the player
PrefabUtils.AddBasicComponents(myCoolPrefab, "myCoolPrefab", techType, LargeWorldEntity.CellLevel.Medium);
// The classID is the same as the one we put into the PrefabInfo.WithTechType up above
// The LargeWorldEntity.CellLevel determines how far away the object will be loaded from the player
PrefabUtils.AddBasicComponents(myCoolPrefab, "myCoolPrefab", MyPrefabInfo.TechType, LargeWorldEntity.CellLevel.Medium);

//Makes the GameObject have the correct shaders
//You can use the optional inputs here to change the look of your object
// Makes the GameObject have the correct shaders
// You can use the optional inputs here to change the look of your object
MaterialUtils.ApplySNShaders(myCoolPrefab);

//Return the GameObject with all the components added
// Return the GameObject with all the components added
return myCoolPrefab;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Nautilus/Documentation/guides/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
- [Development Setup Guide](dev-setup.md)
- [Simple Mod Guide](simple-mod.md)
- [Updating from SML 2.0 to Nautilus](sml2-to-nautilus.md)
- [Using external models (Asset Bundles)](assetbundles.md)
- [Using External Assets (Asset Bundles)](assetbundles.md)
2 changes: 1 addition & 1 deletion Nautilus/Documentation/guides/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
href: simple-mod.md
- name: Updating to Nautilus
href: sml2-to-nautilus.md
- name: Using external models (Asset Bundles)
- name: Using External Assets (Asset Bundles)
href: assetbundles.md