SuAPI Core Mod Development Framework

This is the Survivalcraft 2 SuAPI (Sumod) development framework, used for creating your own third-party Mods.

The SDK for the development framework is based on .net8. If you wish to develop using this foundation, it is recommended to enable the .net8 workload in Visual Studio.

If you plan to use AI for development, please download the relevant skills and configuration information yourself.

Mod Installation Path

Android: /storage/emulated/0/download/Survivalcraft/Mods/

Windows: ./Mods/

Method for Disabling/Removing Mods:

Change the suffix from .scmod to .scmod.unint

To load a Mod into memory, the Modinfo.xml must be filled out correctly. Modinfo.xml must be placed in the root directory of the .scmod file.

[SuAPI] Night of Cold Rain (Tested for V0116).scmod
    ├── Lib/
    │   ├── X64/
    │   │   └── RainWithoutDawn.dll
    │   └── Arm64/
    │       └── RainWithoutDawn.dll
    ├── Content/
    │   └── Textures/
    └── ModInfo.xml
ï»ż<?xml version="1.0" encoding="UTF-8"?>
<Mod>
	<!-- Basic information about the Mod -->
	<ModInfo>
		<Identifier>RainWithoutDawn</Identifier>
		<LocalizedName>
			<Text lang="en_US">RainWithoutDawn</Text>
			<Text lang="zh_CN">ć†·é›šć€œ</Text>
		</LocalizedName>
		<ModVersion>
			<Version>1.0.0</Version>
			<APIVersion>2.1.0</APIVersion>
		</ModVersion>
		<Asset>
			<ContentRoot>Content</ContentRoot>
		</Asset>
	</ModInfo>

	<!-- List of other dependent Mods -->
	<Dependencies>
		<!-- Example dependency (commented) -->
		<!--
        <Dependency>
            <ModInfo>
                <Identifier>RequiredMod1</Identifier>
                <LocalizedName>
                    <Text lang="en_US">Required Mod 1</Text>
                </LocalizedName>
                <ModVersion>
                    <Version>2.3.0</Version>
                    <APIVersion>1.5.0</APIVersion>
                </ModVersion>
            </ModInfo>
        </Dependency>
        -->
	</Dependencies>
</Mod>

The entry point for a Mod is the IMod interface. Providing this information in your Mod code will automatically load it into the program.

 using SuMod;
 using SuMod.Tools;

 public class RainWithoutDawn: IMod
    {
        public string Name = "ć†·é›šć€œ";
        public string Version = "1.0.1";
        public IEnumerable<string> Dependencies = Array.Empty<string>();
        public bool IsEnabled { get; set; } = true;

        public void OnLoad(IModEventBus eventBus, IModInjector modInjector)
        {

            //modInjector.Register("Game.SubsystemTimeOfDay", );

            eventBus.SubscribeEvent("GameDatabase.GameDatabase", args =>
            {
                ; return HandleGameDatabase((Database)args[0]);
            }, EventPriority.HIGHEST);
        }
     

        public void OnUnload()
        {
            Log.Information($"OnUnload");
        }

        public object[] HandleGameDatabase(Database database)
        {
            var subsystemTimeOfDay = database.FindDatabaseObject(new Guid("1e884b27-fc1d-486a-bd0e-518e554b9734"), database.FindDatabaseObjectType("Parameter", true), true);
            subsystemTimeOfDay.Value = "RainWithoutDawn.RWDSubsystemTimeOfDay";
            /* DatabaseObject ComponentTemplatemap = new DatabaseObject(database.FindDatabaseObjectType("ComponentTemplate", true), new Guid("387007A5-9269-1362-A0E7-DFEA4AC68E02"), "Map", null);
             ComponentTemplatemap.Description = "";
             ComponentTemplatemap.ExplicitInheritanceParent = database.FindDatabaseObject(new Guid("b05700ed-7e4e-4679-98f5-b597f421496b"), database.FindDatabaseObjectType("ComponentTemplate", true), true);
             ComponentTemplatemap.NestingParent = database.FindDatabaseObject("Gameplay", database.FindDatabaseObjectType("Folder", true), true);

             DatabaseObject Parameterclass = new DatabaseObject(database.FindDatabaseObjectType("Parameter", true), new Guid("B13D2D65-46A7-D038-8111-DE8FCBA58FBC"), "Class", "SurvivalcraftMiniMap.SuComponentMap");
             Parameterclass.NestingParent = ComponentTemplatemap;

             DatabaseObject databaseObject1 = new DatabaseObject(database.FindDatabaseObjectType("MemberComponentTemplate", true), new Guid("736FC2A9-9B0A-2E00-F7C8-95A4A6811FEE"), "Map", null);
             databaseObject1.Description = "";
             databaseObject1.ExplicitInheritanceParent = database.FindDatabaseObject(new Guid("387007A5-9269-1362-A0E7-DFEA4AC68E02"), database.FindDatabaseObjectType("ComponentTemplate", true), true);

             databaseObject1.NestingParent = database.FindDatabaseObject("Player", database.FindDatabaseObjectType("EntityTemplate", true), true);*///Attach



            Log.Information($"HandleDatabase");
            return new object[] { true, database };
        }
    }

SuAPI Core

SurvivalcraftSuAPI: Survivalcraft 2 SuMod Development Framework, used for creating third-party Mods.

Mod Demo

SC-SPM/SuAPI Example Mod Set

1 Like

Latest Version Progress:

0.1.2.1: Fixed the path addresses for Android and Windows for standardization, updated the game versions to 2.4.10.8 and 2.4.40.8, and added a new event interface Frame.Update.

0.1.2.0: Added F11 fullscreen and fixed the GPUMEM counter, and adjusted multi-platform runtime to .net8.

0.1.1.8: Completed SuAPI multi-platform functional configuration and implemented core functionality.

Current Event Interfaces:

# Event Name Parameter object Return Value Convention Trigger Location Trigger Time
1 GameDatabase.GameDatabase { Database } { bool modified, Database } GameDatabase.cs:37 When the database object is created during GameDatabase initialization
2 Loading.Initialize { typeof(LoadingManager) } { false, args } (No write back) Program.cs:90 During the initial frame initialization, when FrameIndex==0
3 BlocksManager.Initialize { Block } { bool modified, Block } BlocksManager.cs:117 After block data loading is complete
4 BlocksManager.Initialize { ClothingData } { bool modified, ClothingData } ClothingBlock.cs:64 After clothing data loading is complete (Same event name as #3, but different parameter type)
5 CraftingRecipesManager.Initialize { List } { bool modified, List } CraftingRecipesManager.cs:90 After crafting recipes are loaded
6 Frame.Update null No write back Program.cs:139 During frame update (in FrameHandler.Run loop)