Skip to content

Commit 4ad98ce

Browse files
authored
Merge pull request #74 from KaBooMa/pr-verification
Pr verification
2 parents 70b7a7d + 4d97715 commit 4ad98ce

16 files changed

+1019
-66
lines changed

Growing/PlantInstance.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#if (IL2CPPMELON || IL2CPPBEPINEX)
2+
using S1Growing = Il2CppScheduleOne.Growing;
3+
#elif (MONOMELON || MONOBEPINEX)
4+
using S1Growing = ScheduleOne.Growing;
5+
#endif
6+
7+
using S1API.Internal.Utils;
8+
using S1API.Items;
9+
using UnityEngine;
10+
11+
namespace S1API.Growing
12+
{
13+
/// <summary>
14+
/// Represents an instance of a growing plant in the world.
15+
/// </summary>
16+
public class PlantInstance
17+
{
18+
/// <summary>
19+
/// INTERNAL: The in-game Plant object.
20+
/// </summary>
21+
internal readonly S1Growing.Plant S1Plant;
22+
23+
/// <summary>
24+
/// INTERNAL: Create a wrapper around an existing Plant.
25+
/// </summary>
26+
/// <param name="plant">The in-game Plant to wrap.</param>
27+
internal PlantInstance(S1Growing.Plant plant)
28+
{
29+
S1Plant = plant;
30+
}
31+
32+
/// <summary>
33+
/// The current growth stage as a float from 0.0 to 1.0.
34+
/// </summary>
35+
public float NormalizedGrowth =>
36+
S1Plant.NormalizedGrowthProgress;
37+
38+
/// <summary>
39+
/// Whether the plant is fully grown.
40+
/// </summary>
41+
public bool IsFullyGrown =>
42+
S1Plant.IsFullyGrown;
43+
44+
/// <summary>
45+
/// The SeedDefinition that this plant originated from.
46+
/// </summary>
47+
public SeedDefinition SeedDefinition =>
48+
new SeedDefinition(S1Plant.SeedDefinition);
49+
50+
/// <summary>
51+
/// The quality level of this plant.
52+
/// </summary>
53+
public float Quality =>
54+
S1Plant.QualityLevel;
55+
56+
/// <summary>
57+
/// The yield level (amount) of this plant.
58+
/// </summary>
59+
public float Yield =>
60+
S1Plant.YieldLevel;
61+
62+
/// <summary>
63+
/// The GameObject of the plant.
64+
/// </summary>
65+
public GameObject GameObject =>
66+
S1Plant.gameObject;
67+
68+
/// <summary>
69+
/// Destroys this plant in-game.
70+
/// </summary>
71+
/// <param name="dropScraps">Whether to drop trash scraps.</param>
72+
public void Destroy(bool dropScraps = false)
73+
{
74+
S1Plant.Destroy(dropScraps);
75+
}
76+
}
77+
}

Growing/SeedCreator.cs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#if (IL2CPPMELON || IL2CPPBEPINEX)
2+
using S1Growing = Il2CppScheduleOne.Growing;
3+
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
4+
using S1Registry = Il2CppScheduleOne.Registry;
5+
#elif (MONOMELON || MONOBEPINEX)
6+
using S1Growing = ScheduleOne.Growing;
7+
using S1ItemFramework = ScheduleOne.ItemFramework;
8+
using S1Registry = ScheduleOne.Registry;
9+
#endif
10+
11+
using UnityEngine;
12+
using System.Linq;
13+
14+
15+
namespace S1API.Growing
16+
{
17+
/// <summary>
18+
/// The seed Creator for custom seeds to be added.
19+
/// </summary>
20+
public static class SeedCreator
21+
{
22+
public static SeedDefinition CreateSeed(
23+
string id,
24+
string name,
25+
string description,
26+
int stackLimit = 10,
27+
GameObject functionSeedPrefab = null,
28+
GameObject plantPrefab = null,
29+
Sprite icon = null)
30+
{
31+
S1Growing.SeedDefinition seed = ScriptableObject.CreateInstance<S1Growing.SeedDefinition>();
32+
33+
seed.ID = id;
34+
seed.Name = name;
35+
seed.Description = description;
36+
seed.StackLimit = stackLimit;
37+
seed.Category = S1ItemFramework.EItemCategory.Growing;
38+
39+
// if (icon != null)
40+
// {
41+
// seed.Icon = icon;
42+
// }
43+
// commented out for more test later.
44+
45+
if (functionSeedPrefab != null)
46+
seed.FunctionSeedPrefab = functionSeedPrefab.GetComponent<S1Growing.FunctionalSeed>();
47+
48+
if (plantPrefab != null)
49+
seed.PlantPrefab = plantPrefab.GetComponent<S1Growing.Plant>();
50+
51+
S1Registry.Instance.AddToRegistry(seed);
52+
53+
return new SeedDefinition(seed);
54+
}
55+
56+
}
57+
}

Growing/SeedDefinition.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#if (IL2CPPMELON || IL2CPPBEPINEX)
2+
using S1Growing = Il2CppScheduleOne.Growing;
3+
#elif (MONOMELON || MONOBEPINEX)
4+
using S1Growing = ScheduleOne.Growing;
5+
#endif
6+
7+
using S1API.Internal.Utils;
8+
using S1API.Items;
9+
10+
namespace S1API.Growing
11+
{
12+
/// <summary>
13+
/// Represents the definition of a Seed item (what you buy in shops).
14+
/// </summary>
15+
public class SeedDefinition : ItemDefinition
16+
{
17+
/// <summary>
18+
/// INTERNAL: Stored reference to the SeedDefinition.
19+
/// </summary>
20+
internal S1Growing.SeedDefinition S1SeedDefinition =>
21+
CrossType.As<S1Growing.SeedDefinition>(S1ItemDefinition);
22+
23+
/// <summary>
24+
/// INTERNAL: Create a new wrapper around an existing SeedDefinition.
25+
/// </summary>
26+
/// <param name="definition">The in-game SeedDefinition to wrap.</param>
27+
internal SeedDefinition(S1Growing.SeedDefinition definition) : base(definition) { }
28+
29+
/// <summary>
30+
/// The prefab that is spawned when planting this seed.
31+
/// </summary>
32+
public UnityEngine.GameObject FunctionalSeedPrefab =>
33+
S1SeedDefinition.FunctionSeedPrefab?.gameObject;
34+
35+
/// <summary>
36+
/// The plant prefab this seed grows into.
37+
/// </summary>
38+
public UnityEngine.GameObject PlantPrefab =>
39+
S1SeedDefinition.PlantPrefab?.gameObject;
40+
41+
/// <summary>
42+
/// Creates an instance of this seed in the world (FunctionalSeed prefab).
43+
/// </summary>
44+
public UnityEngine.GameObject CreateSeedInstance()
45+
{
46+
if (S1SeedDefinition.FunctionSeedPrefab != null)
47+
return UnityEngine.Object.Instantiate(S1SeedDefinition.FunctionSeedPrefab).gameObject;
48+
49+
throw new System.NullReferenceException("No FunctionalSeedPrefab assigned to this SeedDefinition!");
50+
}
51+
52+
53+
}
54+
}

Growing/SeedInstance.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#if (IL2CPPMELON || IL2CPPBEPINEX)
2+
using S1Growing = Il2CppScheduleOne.Growing;
3+
#elif (MONOMELON || MONOBEPINEX)
4+
using S1Growing = ScheduleOne.Growing;
5+
#endif
6+
7+
using UnityEngine;
8+
using S1API.Internal.Utils;
9+
10+
namespace S1API.Growing
11+
{
12+
/// <summary>
13+
/// Represents an instance of a functional seed in the world.
14+
/// (Not just the definition — this is the physical object you interact with.)
15+
/// </summary>
16+
public class SeedInstance
17+
{
18+
/// <summary>
19+
/// INTERNAL: Reference to the in-game FunctionalSeed object.
20+
/// </summary>
21+
internal readonly S1Growing.FunctionalSeed S1FunctionalSeed;
22+
23+
/// <summary>
24+
/// INTERNAL: Creates a wrapper around the existing FunctionalSeed.
25+
/// </summary>
26+
/// <param name="functionalSeed">The FunctionalSeed object to wrap.</param>
27+
internal SeedInstance(S1Growing.FunctionalSeed functionalSeed)
28+
{
29+
S1FunctionalSeed = functionalSeed;
30+
}
31+
32+
/// <summary>
33+
/// The underlying GameObject of this seed.
34+
/// </summary>
35+
private GameObject GameObject =>
36+
S1FunctionalSeed.gameObject;
37+
38+
/// <summary>
39+
/// Whether the seed currently has exited its vial.
40+
/// </summary>
41+
public bool HasExitedVial { get; private set; } = false;
42+
43+
/// <summary>
44+
/// Force the seed to exit the vial manually.
45+
/// </summary>
46+
public void ForceExitVial()
47+
{
48+
if (S1FunctionalSeed.Vial != null)
49+
{
50+
S1FunctionalSeed.TriggerExit(S1FunctionalSeed.Vial.GetComponent<Collider>());
51+
HasExitedVial = true;
52+
}
53+
}
54+
}
55+
}

Items/ItemCategory.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
namespace S1API.Items
2+
{
3+
/// <summary>
4+
/// A list of item categories available in-game.
5+
/// </summary>
6+
public enum ItemCategory
7+
{
8+
/// <summary>
9+
/// Represents items such as Cocaine, Weed, etc.
10+
/// Oddly, SpeedGrow is in this category as of (v0.3.4f8).
11+
/// </summary>
12+
Product,
13+
14+
/// <summary>
15+
/// Represents items such as Baggies, Bricks, Jars, etc.
16+
/// </summary>
17+
Packaging,
18+
19+
/// <summary>
20+
/// Represents items such as Soil, Fertilizer, Pots, etc.
21+
/// </summary>
22+
Growing,
23+
24+
/// <summary>
25+
/// Represents equipment tools such as the clippers.
26+
/// Oddly, trash bags is in this category as of (v0.3.4f8).
27+
/// </summary>
28+
Tools,
29+
30+
/// <summary>
31+
/// Represents items such as TV, Trash Can, Bed, etc.
32+
/// </summary>
33+
Furniture,
34+
35+
/// <summary>
36+
/// Represents items such as Floor Lamps, Halogen Lights, etc.
37+
/// </summary>
38+
Lighting,
39+
40+
/// <summary>
41+
/// Represents cash-based items.
42+
/// </summary>
43+
Cash,
44+
45+
/// <summary>
46+
/// Represents items such as Cuke, Energy Drink, etc.
47+
/// </summary>
48+
Consumable,
49+
50+
/// <summary>
51+
/// Represents items such as Drying Rack, Brick Press, Mixing Station, etc.
52+
/// </summary>
53+
Equipment,
54+
55+
/// <summary>
56+
/// Represents items such as Acid, Banana, Chili, etc.
57+
/// </summary>
58+
Ingredient,
59+
60+
/// <summary>
61+
/// Represents items such as GoldBar, WallClock, WoodSign, etc.
62+
/// </summary>
63+
Decoration,
64+
65+
/// <summary>
66+
/// Represents clothing items.
67+
/// </summary>
68+
Clothing
69+
}
70+
}

0 commit comments

Comments
 (0)