Skip to content

Commit

Permalink
Remove DI for now.
Browse files Browse the repository at this point in the history
Until I can figure out how it should actually work.
  • Loading branch information
MrPurple6411 committed Jan 17, 2023
1 parent f5cfc65 commit 63f2358
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 466 deletions.
26 changes: 1 addition & 25 deletions Example mod/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
using BepInEx;
using BepInEx.Logging;
using SMLHelper.Utility;
using SMLHelper.DependencyInjection;
using SMLHelper.Assets;
using System.Collections.Generic;
using System.IO;
using System.Reflection;

[BepInPlugin(GUID, MODNAME, VERSION)]
[BepInDependency("com.ahk1221.smlhelper", BepInDependency.DependencyFlags.HardDependency)]
Expand All @@ -41,26 +36,7 @@ internal class SaveData: SaveDataCache

public void Awake()
{
// Create
var builder = PrefabManager.CreateBuilder(this);
// Add
builder.Assets.AddCustomPrefab(new NuclearBattery());

var nuke2 = new EasyBattery("nuke2", "Nuclear Battery 2.0", "OOP Battery Test", true)
{
PluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
PowerCapacity = 69420,
AddToFabricator = true,
Parts = new List<TechType>() { TechType.Copper, TechType.AcidMushroom, TechType.AcidMushroom, TechType.AcidMushroom },
};

builder.Assets.AddPrefab(nuke2);
builder.Assets.AddService<IGreeting, SayHi>();

// Run
builder.Build();
// Get Service
builder.GetService<IGreeting>().Greetings();
NuclearBattery.CreateAndRegister();

LogSource = base.Logger;

Expand Down
20 changes: 7 additions & 13 deletions Example mod/NuclearBatteryExample.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
namespace SMLHelper.Examples;

using System.Collections;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using SMLHelper.API;
using SMLHelper.Assets;
using SMLHelper.Assets.Interfaces;
using SMLHelper.Assets.PrefabTemplates;
using SMLHelper.Crafting;
using SMLHelper.DependencyInjection;
using SMLHelper.Handlers;
using UnityEngine;
using static CraftData;
Expand Down Expand Up @@ -39,25 +36,22 @@ public NuclearBattery()
.WithIcon(SpriteManager.Get(TechType.PrecursorIonBattery));
}

[InjectionSetup]
private void Setup(ManualLogSource logger)
{
logger.LogDebug($"{nameof(NuclearBattery)} Patched.");
}

public IEnumerator GetGameObjectAsync(IOut<GameObject> gameObject)
{
var battery = new EnergySourceTemplate(69420)
{
ModelData = new CBModelData
{
UseIonModelsAsBase = true
}
IsPowerCell = false,
UseIonModel = true
};

var task = new TaskResult<GameObject>();
yield return battery.GetPrefabAsync(task);

gameObject.Set(task.Get());
}

internal static void CreateAndRegister()
{
new NuclearBattery().RegisterPrefab();
}
}
166 changes: 0 additions & 166 deletions SMLHelper/Assets/DependencyInjection/AssetBuilder.cs

This file was deleted.

40 changes: 0 additions & 40 deletions SMLHelper/Assets/DependencyInjection/AssetCollection.cs

This file was deleted.

36 changes: 0 additions & 36 deletions SMLHelper/Assets/DependencyInjection/AssetDescriptor.cs

This file was deleted.

7 changes: 0 additions & 7 deletions SMLHelper/Assets/DependencyInjection/Attributes.cs

This file was deleted.

42 changes: 0 additions & 42 deletions SMLHelper/Assets/DependencyInjection/Extensions.cs

This file was deleted.

Loading

0 comments on commit 63f2358

Please sign in to comment.