Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
77 changes: 77 additions & 0 deletions Growing/PlantInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Growing = Il2CppScheduleOne.Growing;
#elif (MONOMELON || MONOBEPINEX)
using S1Growing = ScheduleOne.Growing;
#endif

using S1API.Internal.Utils;
using S1API.Items;
using UnityEngine;

namespace S1API.Growing
{
/// <summary>
/// Represents an instance of a growing plant in the world.
/// </summary>
public class PlantInstance
{
/// <summary>
/// INTERNAL: The in-game Plant object.
/// </summary>
internal readonly S1Growing.Plant S1Plant;

/// <summary>
/// INTERNAL: Create a wrapper around an existing Plant.
/// </summary>
/// <param name="plant">The in-game Plant to wrap.</param>
internal PlantInstance(S1Growing.Plant plant)
{
S1Plant = plant;
}

/// <summary>
/// The current growth stage as a float from 0.0 to 1.0.
/// </summary>
public float NormalizedGrowth =>
S1Plant.NormalizedGrowthProgress;

/// <summary>
/// Whether the plant is fully grown.
/// </summary>
public bool IsFullyGrown =>
S1Plant.IsFullyGrown;

/// <summary>
/// The SeedDefinition that this plant originated from.
/// </summary>
public SeedDefinition SeedDefinition =>
new SeedDefinition(S1Plant.SeedDefinition);

/// <summary>
/// The quality level of this plant.
/// </summary>
public float Quality =>
S1Plant.QualityLevel;

/// <summary>
/// The yield level (amount) of this plant.
/// </summary>
public float Yield =>
S1Plant.YieldLevel;

/// <summary>
/// The GameObject of the plant.
/// </summary>
public GameObject GameObject =>
S1Plant.gameObject;

/// <summary>
/// Destroys this plant in-game.
/// </summary>
/// <param name="dropScraps">Whether to drop trash scraps.</param>
public void Destroy(bool dropScraps = false)
{
S1Plant.Destroy(dropScraps);
}
}
}
57 changes: 57 additions & 0 deletions Growing/SeedCreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Growing = Il2CppScheduleOne.Growing;
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
using S1Registry = Il2CppScheduleOne.Registry;
#elif (MONOMELON || MONOBEPINEX)
using S1Growing = ScheduleOne.Growing;
using S1ItemFramework = ScheduleOne.ItemFramework;
using S1Registry = ScheduleOne.Registry;
#endif

using UnityEngine;
using System.Linq;


namespace S1API.Growing
{
/// <summary>
/// The seed Creator for custom seeds to be added.
/// </summary>
public static class SeedCreator
{
public static SeedDefinition CreateSeed(
string id,
string name,
string description,
int stackLimit = 10,
GameObject functionSeedPrefab = null,
GameObject plantPrefab = null,
Sprite icon = null)
{
S1Growing.SeedDefinition seed = ScriptableObject.CreateInstance<S1Growing.SeedDefinition>();

seed.ID = id;
seed.Name = name;
seed.Description = description;
seed.StackLimit = stackLimit;
seed.Category = S1ItemFramework.EItemCategory.Growing;

// if (icon != null)
// {
// seed.Icon = icon;
// }
// commented out for more test later.

if (functionSeedPrefab != null)
seed.FunctionSeedPrefab = functionSeedPrefab.GetComponent<S1Growing.FunctionalSeed>();

if (plantPrefab != null)
seed.PlantPrefab = plantPrefab.GetComponent<S1Growing.Plant>();

S1Registry.Instance.AddToRegistry(seed);

return new SeedDefinition(seed);
}

}
}
54 changes: 54 additions & 0 deletions Growing/SeedDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Growing = Il2CppScheduleOne.Growing;
#elif (MONOMELON || MONOBEPINEX)
using S1Growing = ScheduleOne.Growing;
#endif

using S1API.Internal.Utils;
using S1API.Items;

namespace S1API.Growing
{
/// <summary>
/// Represents the definition of a Seed item (what you buy in shops).
/// </summary>
public class SeedDefinition : ItemDefinition
{
/// <summary>
/// INTERNAL: Stored reference to the SeedDefinition.
/// </summary>
internal S1Growing.SeedDefinition S1SeedDefinition =>
CrossType.As<S1Growing.SeedDefinition>(S1ItemDefinition);

/// <summary>
/// INTERNAL: Create a new wrapper around an existing SeedDefinition.
/// </summary>
/// <param name="definition">The in-game SeedDefinition to wrap.</param>
internal SeedDefinition(S1Growing.SeedDefinition definition) : base(definition) { }

/// <summary>
/// The prefab that is spawned when planting this seed.
/// </summary>
public UnityEngine.GameObject FunctionalSeedPrefab =>
S1SeedDefinition.FunctionSeedPrefab?.gameObject;

/// <summary>
/// The plant prefab this seed grows into.
/// </summary>
public UnityEngine.GameObject PlantPrefab =>
S1SeedDefinition.PlantPrefab?.gameObject;

/// <summary>
/// Creates an instance of this seed in the world (FunctionalSeed prefab).
/// </summary>
public UnityEngine.GameObject CreateSeedInstance()
{
if (S1SeedDefinition.FunctionSeedPrefab != null)
return UnityEngine.Object.Instantiate(S1SeedDefinition.FunctionSeedPrefab).gameObject;

throw new System.NullReferenceException("No FunctionalSeedPrefab assigned to this SeedDefinition!");
}


}
}
55 changes: 55 additions & 0 deletions Growing/SeedInstance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Growing = Il2CppScheduleOne.Growing;
#elif (MONOMELON || MONOBEPINEX)
using S1Growing = ScheduleOne.Growing;
#endif

using UnityEngine;
using S1API.Internal.Utils;

namespace S1API.Growing
{
/// <summary>
/// Represents an instance of a functional seed in the world.
/// (Not just the definition — this is the physical object you interact with.)
/// </summary>
public class SeedInstance
{
/// <summary>
/// INTERNAL: Reference to the in-game FunctionalSeed object.
/// </summary>
internal readonly S1Growing.FunctionalSeed S1FunctionalSeed;

/// <summary>
/// INTERNAL: Creates a wrapper around the existing FunctionalSeed.
/// </summary>
/// <param name="functionalSeed">The FunctionalSeed object to wrap.</param>
internal SeedInstance(S1Growing.FunctionalSeed functionalSeed)
{
S1FunctionalSeed = functionalSeed;
}

/// <summary>
/// The underlying GameObject of this seed.
/// </summary>
private GameObject GameObject =>
S1FunctionalSeed.gameObject;

/// <summary>
/// Whether the seed currently has exited its vial.
/// </summary>
public bool HasExitedVial { get; private set; } = false;

/// <summary>
/// Force the seed to exit the vial manually.
/// </summary>
public void ForceExitVial()
{
if (S1FunctionalSeed.Vial != null)
{
S1FunctionalSeed.TriggerExit(S1FunctionalSeed.Vial.GetComponent<Collider>());
HasExitedVial = true;
}
}
}
}
70 changes: 70 additions & 0 deletions Items/ItemCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
namespace S1API.Items
{
/// <summary>
/// A list of item categories available in-game.
/// </summary>
public enum ItemCategory
{
/// <summary>
/// Represents items such as Cocaine, Weed, etc.
/// Oddly, SpeedGrow is in this category as of (v0.3.4f8).
/// </summary>
Product,

/// <summary>
/// Represents items such as Baggies, Bricks, Jars, etc.
/// </summary>
Packaging,

/// <summary>
/// Represents items such as Soil, Fertilizer, Pots, etc.
/// </summary>
Growing,

/// <summary>
/// Represents equipment tools such as the clippers.
/// Oddly, trash bags is in this category as of (v0.3.4f8).
/// </summary>
Tools,

/// <summary>
/// Represents items such as TV, Trash Can, Bed, etc.
/// </summary>
Furniture,

/// <summary>
/// Represents items such as Floor Lamps, Halogen Lights, etc.
/// </summary>
Lighting,

/// <summary>
/// Represents cash-based items.
/// </summary>
Cash,

/// <summary>
/// Represents items such as Cuke, Energy Drink, etc.
/// </summary>
Consumable,

/// <summary>
/// Represents items such as Drying Rack, Brick Press, Mixing Station, etc.
/// </summary>
Equipment,

/// <summary>
/// Represents items such as Acid, Banana, Chili, etc.
/// </summary>
Ingredient,

/// <summary>
/// Represents items such as GoldBar, WallClock, WoodSign, etc.
/// </summary>
Decoration,

/// <summary>
/// Represents clothing items.
/// </summary>
Clothing
}
}
Loading
Loading