Skip to content

Commit a23a58e

Browse files
committed
Merge branch 'beta' of https://github.com/ifBars/S1API into beta
2 parents a3c0ea2 + 5179859 commit a23a58e

12 files changed

Lines changed: 77 additions & 144 deletions

S1API/Entities/NPC.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,8 +1719,13 @@ public void LerpScale(float scale, float lerpTime) =>
17191719
/// <summary>
17201720
/// Causes the NPC to become panicked.
17211721
/// </summary>
1722-
public void Panic() =>
1723-
S1NPC.SetPanicked();
1722+
public void Panic()
1723+
{
1724+
if (!SafeIsServer())
1725+
return;
1726+
1727+
S1NPC.SetPanicked_Server();
1728+
}
17241729

17251730
/// <summary>
17261731
/// Causes the NPC to stop panicking, if they are currently.

S1API/Growing/SeedCreator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#if (IL2CPPMELON)
22
using S1Growing = Il2CppScheduleOne.Growing;
33
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
4+
using S1CoreItemFramework = Il2CppScheduleOne.Core.Items.Framework;
45
using S1Registry = Il2CppScheduleOne.Registry;
56
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
67
using S1Growing = ScheduleOne.Growing;
78
using S1ItemFramework = ScheduleOne.ItemFramework;
9+
using S1CoreItemFramework = ScheduleOne.Core.Items.Framework;
810
using S1Registry = ScheduleOne.Registry;
911
#endif
1012

@@ -32,7 +34,7 @@ public static SeedDefinition CreateSeed(
3234
seed.Name = name;
3335
seed.Description = description;
3436
seed.StackLimit = stackLimit;
35-
seed.Category = S1ItemFramework.EItemCategory.Agriculture;
37+
seed.Category = S1CoreItemFramework.EItemCategory.Agriculture;
3638

3739
// if (icon != null)
3840
// {

S1API/Internal/Patches/LoadingScreenPatches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private static void CloseLoadingScreenDirectly(S1UI.LoadingScreen loadingScreen)
211211
{
212212
ReflectionUtils.TrySetFieldOrProperty(loadingScreen, "IsOpen", false);
213213

214-
var musicPlayer = S1DevUtilities.Singleton<S1Audio.MusicPlayer>.Instance;
214+
var musicPlayer = S1DevUtilities.Singleton<S1Audio.MusicManager>.Instance;
215215
if (musicPlayer != null)
216216
{
217217
musicPlayer.SetTrackEnabled("Loading Screen", enabled: false);

S1API/Internal/Patches/NPCPatches.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,36 @@ private static bool NPCHealth_Revive_Prefix(S1NPCs.NPCHealth __instance)
15791579
if (apiNpc == null || !apiNpc.IsCustomNPC)
15801580
return true; // use original for base NPCs
15811581

1582-
// Skip S1API NPCs for now
1583-
return false;
1582+
try
1583+
{
1584+
bool healthSet = Utils.ReflectionUtils.TrySetFieldOrProperty(
1585+
__instance, "<Health>k__BackingField", __instance.MaxHealth);
1586+
bool isDeadSet = Utils.ReflectionUtils.TrySetFieldOrProperty(__instance, "IsDead", false);
1587+
bool isKnockedOutSet = Utils.ReflectionUtils.TrySetFieldOrProperty(__instance, "IsKnockedOut", false);
1588+
1589+
if (!healthSet || !isDeadSet || !isKnockedOutSet)
1590+
{
1591+
MelonLogger.Warning(
1592+
$"[S1API] Revive guard reflection failed for custom NPC '{baseNpc?.ID ?? "<unknown>"}' " +
1593+
$"(Health={healthSet}, IsDead={isDeadSet}, IsKnockedOut={isKnockedOutSet}); falling back to original revive.");
1594+
return true;
1595+
}
1596+
1597+
// Disable behaviours locally (non-networked equivalent of Disable_Server)
1598+
baseNpc.Behaviour.DeadBehaviour?.Disable();
1599+
baseNpc.Behaviour.UnconsciousBehaviour?.Disable();
1600+
1601+
// Fire revive event so downstream listeners still react
1602+
__instance.onRevive?.Invoke();
1603+
1604+
return false; // skip original to avoid SyncVar/networking calls
1605+
}
1606+
catch (Exception ex)
1607+
{
1608+
MelonLogger.Warning(
1609+
$"[S1API] Revive guard failed for custom NPC '{baseNpc?.ID ?? "<unknown>"}': {ex.Message}. Falling back to original revive.");
1610+
return true;
1611+
}
15841612
}
15851613

15861614
/// <summary>

S1API/Items/AdditiveDefinitionBuilder.cs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#if (IL2CPPMELON)
22
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
3+
using S1CoreItemFramework = Il2CppScheduleOne.Core.Items.Framework;
34
using S1Registry = Il2CppScheduleOne.Registry;
45
using S1Storage = Il2CppScheduleOne.Storage;
56
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
67
using S1ItemFramework = ScheduleOne.ItemFramework;
8+
using S1CoreItemFramework = ScheduleOne.Core.Items.Framework;
79
using S1Registry = ScheduleOne.Registry;
810
using S1Storage = ScheduleOne.Storage;
911
#endif
@@ -39,11 +41,10 @@ internal AdditiveDefinitionBuilder()
3941
_definition.StackLimit = 10;
4042
_definition.BasePurchasePrice = 10f;
4143
_definition.ResellMultiplier = 0.5f;
42-
_definition.Category = S1ItemFramework.EItemCategory.Agriculture;
43-
_definition.legalStatus = S1ItemFramework.ELegalStatus.Legal;
44+
_definition.Category = S1CoreItemFramework.EItemCategory.Agriculture;
45+
_definition.legalStatus = S1CoreItemFramework.ELegalStatus.Legal;
4446
_definition.AvailableInDemo = true;
4547
_definition.UsableInFilters = true;
46-
_definition.LabelDisplayColor = Color.white;
4748

4849
// Provide a minimal StoredItem placeholder so the field is never null in tooling/inspectors.
4950
_storedItemPlaceholder = new GameObject("S1API_DefaultStoredItem");
@@ -82,10 +83,8 @@ private void CopyPropertiesFrom(S1ItemFramework.AdditiveDefinition source)
8283
_definition.Description = source.Description;
8384
_definition.Category = source.Category;
8485
_definition.StackLimit = source.StackLimit;
85-
_definition.Keywords = source.Keywords;
8686
_definition.AvailableInDemo = source.AvailableInDemo;
8787
_definition.UsableInFilters = source.UsableInFilters;
88-
_definition.LabelDisplayColor = source.LabelDisplayColor;
8988
_definition.Icon = source.Icon;
9089
_definition.legalStatus = source.legalStatus;
9190
_definition.PickpocketDifficultyMultiplier = source.PickpocketDifficultyMultiplier;
@@ -116,7 +115,7 @@ public AdditiveDefinitionBuilder WithBasicInfo(string id, string name, string de
116115
_definition.ID = id;
117116
_definition.Name = name;
118117
_definition.Description = description;
119-
_definition.Category = (S1ItemFramework.EItemCategory)category;
118+
_definition.Category = (S1CoreItemFramework.EItemCategory)category;
120119

121120
var displayName = string.IsNullOrEmpty(name) ? id : name;
122121
if (!string.IsNullOrEmpty(displayName))
@@ -164,25 +163,7 @@ public AdditiveDefinitionBuilder WithPricing(float basePurchasePrice, float rese
164163
/// </summary>
165164
public AdditiveDefinitionBuilder WithLegalStatus(LegalStatus status)
166165
{
167-
_definition.legalStatus = (S1ItemFramework.ELegalStatus)status;
168-
return this;
169-
}
170-
171-
/// <summary>
172-
/// Sets the color of the label displayed in UI.
173-
/// </summary>
174-
public AdditiveDefinitionBuilder WithLabelColor(Color color)
175-
{
176-
_definition.LabelDisplayColor = color;
177-
return this;
178-
}
179-
180-
/// <summary>
181-
/// Sets keywords used for filtering and searching this additive.
182-
/// </summary>
183-
public AdditiveDefinitionBuilder WithKeywords(params string[] keywords)
184-
{
185-
_definition.Keywords = keywords;
166+
_definition.legalStatus = (S1CoreItemFramework.ELegalStatus)status;
186167
return this;
187168
}
188169

S1API/Items/BuildableItemDefinition.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ public BuildSoundType BuildSoundType
4141
set => S1BuildableItemDefinition.BuildSoundType = (S1ItemFramework.BuildableItemDefinition.EBuildSoundType)value;
4242
}
4343

44-
/// <summary>
45-
/// The color displayed on the item's label in the UI.
46-
/// </summary>
47-
public new Color LabelDisplayColor
48-
{
49-
get => S1BuildableItemDefinition.LabelDisplayColor;
50-
set => S1BuildableItemDefinition.LabelDisplayColor = value;
51-
}
5244
}
5345

5446
/// <summary>

S1API/Items/BuildableItemDefinitionBuilder.cs

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#if (IL2CPPMELON)
22
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
3+
using S1CoreItemFramework = Il2CppScheduleOne.Core.Items.Framework;
34
using S1Registry = Il2CppScheduleOne.Registry;
45
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
56
using S1ItemFramework = ScheduleOne.ItemFramework;
7+
using S1CoreItemFramework = ScheduleOne.Core.Items.Framework;
68
using S1Registry = ScheduleOne.Registry;
79
#endif
810

@@ -30,11 +32,10 @@ internal BuildableItemDefinitionBuilder()
3032
_definition.StackLimit = 10;
3133
_definition.BasePurchasePrice = 10f;
3234
_definition.ResellMultiplier = 0.5f;
33-
_definition.Category = S1ItemFramework.EItemCategory.Furniture;
34-
_definition.legalStatus = S1ItemFramework.ELegalStatus.Legal;
35+
_definition.Category = S1CoreItemFramework.EItemCategory.Furniture;
36+
_definition.legalStatus = S1CoreItemFramework.ELegalStatus.Legal;
3537
_definition.AvailableInDemo = true;
3638
_definition.UsableInFilters = true;
37-
_definition.LabelDisplayColor = Color.white;
3839
_definition.BuildSoundType = S1ItemFramework.BuildableItemDefinition.EBuildSoundType.Wood;
3940
}
4041

@@ -57,10 +58,8 @@ private void CopyPropertiesFrom(S1ItemFramework.BuildableItemDefinition source)
5758
_definition.Description = source.Description;
5859
_definition.Category = source.Category;
5960
_definition.StackLimit = source.StackLimit;
60-
_definition.Keywords = source.Keywords;
6161
_definition.AvailableInDemo = source.AvailableInDemo;
6262
_definition.UsableInFilters = source.UsableInFilters;
63-
_definition.LabelDisplayColor = source.LabelDisplayColor;
6463
_definition.Icon = source.Icon;
6564
_definition.legalStatus = source.legalStatus;
6665
_definition.PickpocketDifficultyMultiplier = source.PickpocketDifficultyMultiplier;
@@ -144,7 +143,7 @@ public BuildableItemDefinitionBuilder WithPricing(float basePurchasePrice, float
144143
/// <returns>The builder instance for fluent chaining.</returns>
145144
public BuildableItemDefinitionBuilder WithCategory(ItemCategory category)
146145
{
147-
_definition.Category = (S1ItemFramework.EItemCategory)category;
146+
_definition.Category = (S1CoreItemFramework.EItemCategory)category;
148147
return this;
149148
}
150149

@@ -159,36 +158,14 @@ public BuildableItemDefinitionBuilder WithStackLimit(int limit)
159158
return this;
160159
}
161160

162-
/// <summary>
163-
/// Sets keywords used for filtering and searching this item.
164-
/// </summary>
165-
/// <param name="keywords">Array of keywords.</param>
166-
/// <returns>The builder instance for fluent chaining.</returns>
167-
public BuildableItemDefinitionBuilder WithKeywords(params string[] keywords)
168-
{
169-
_definition.Keywords = keywords;
170-
return this;
171-
}
172-
173-
/// <summary>
174-
/// Sets the color of the label displayed in UI.
175-
/// </summary>
176-
/// <param name="color">The color to use for the item label.</param>
177-
/// <returns>The builder instance for fluent chaining.</returns>
178-
public BuildableItemDefinitionBuilder WithLabelColor(Color color)
179-
{
180-
_definition.LabelDisplayColor = color;
181-
return this;
182-
}
183-
184161
/// <summary>
185162
/// Sets the legal status of the item.
186163
/// </summary>
187164
/// <param name="status">Whether the item is legal or illegal.</param>
188165
/// <returns>The builder instance for fluent chaining.</returns>
189166
public BuildableItemDefinitionBuilder WithLegalStatus(LegalStatus status)
190167
{
191-
_definition.legalStatus = (S1ItemFramework.ELegalStatus)status;
168+
_definition.legalStatus = (S1CoreItemFramework.ELegalStatus)status;
192169
return this;
193170
}
194171

S1API/Items/ClothingItemDefinitionBuilder.cs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#if (IL2CPPMELON)
22
using S1Clothing = Il2CppScheduleOne.Clothing;
33
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
4+
using S1CoreItemFramework = Il2CppScheduleOne.Core.Items.Framework;
45
using S1Registry = Il2CppScheduleOne.Registry;
56
using Il2CppCollections = Il2CppSystem.Collections.Generic;
67
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
78
using S1Clothing = ScheduleOne.Clothing;
89
using S1ItemFramework = ScheduleOne.ItemFramework;
10+
using S1CoreItemFramework = ScheduleOne.Core.Items.Framework;
911
using S1Registry = ScheduleOne.Registry;
1012
using Il2CppCollections = System.Collections.Generic;
1113
#endif
@@ -34,12 +36,11 @@ internal ClothingItemDefinitionBuilder()
3436
_definition.StackLimit = 10;
3537
_definition.BasePurchasePrice = 10f;
3638
_definition.ResellMultiplier = 0.5f;
37-
_definition.Category = S1ItemFramework.EItemCategory.Clothing;
38-
_definition.legalStatus = S1ItemFramework.ELegalStatus.Legal;
39+
_definition.Category = S1CoreItemFramework.EItemCategory.Clothing;
40+
_definition.legalStatus = S1CoreItemFramework.ELegalStatus.Legal;
3941
_definition.AvailableInDemo = true;
4042
_definition.UsableInFilters = true;
41-
_definition.LabelDisplayColor = Color.white;
42-
43+
4344
// Clothing-specific defaults
4445
_definition.Slot = S1Clothing.EClothingSlot.Head;
4546
_definition.ApplicationType = S1Clothing.EClothingApplicationType.Accessory;
@@ -72,8 +73,6 @@ internal ClothingItemDefinitionBuilder(S1Clothing.ClothingDefinition source)
7273
_definition.legalStatus = source.legalStatus;
7374
_definition.AvailableInDemo = source.AvailableInDemo;
7475
_definition.UsableInFilters = source.UsableInFilters;
75-
_definition.LabelDisplayColor = source.LabelDisplayColor;
76-
_definition.Keywords = source.Keywords;
7776
_definition.StoredItem = source.StoredItem;
7877
_definition.Equippable = source.Equippable;
7978

@@ -215,28 +214,6 @@ public ClothingItemDefinitionBuilder WithPricing(float basePurchasePrice, float
215214
return this;
216215
}
217216

218-
/// <summary>
219-
/// Sets keywords used for filtering and searching this item.
220-
/// </summary>
221-
/// <param name="keywords">Array of keywords.</param>
222-
/// <returns>The builder instance for fluent chaining.</returns>
223-
public ClothingItemDefinitionBuilder WithKeywords(params string[] keywords)
224-
{
225-
_definition.Keywords = keywords;
226-
return this;
227-
}
228-
229-
/// <summary>
230-
/// Sets the color of the label displayed in UI.
231-
/// </summary>
232-
/// <param name="color">The color to use for the item label.</param>
233-
/// <returns>The builder instance for fluent chaining.</returns>
234-
public ClothingItemDefinitionBuilder WithLabelColor(Color color)
235-
{
236-
_definition.LabelDisplayColor = color;
237-
return this;
238-
}
239-
240217
/// <summary>
241218
/// Builds the clothing item definition, registers it with the game's registry, and returns a wrapper.
242219
/// </summary>

S1API/Items/ItemDefinition.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#if (IL2CPPMELON)
22
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
3+
using S1CoreItemFramework = Il2CppScheduleOne.Core.Items.Framework;
34
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
45
using S1ItemFramework = ScheduleOne.ItemFramework;
6+
using S1CoreItemFramework = ScheduleOne.Core.Items.Framework;
57
#endif
68

79
using UnityEngine;
@@ -74,7 +76,7 @@ public int StackLimit
7476
public ItemCategory Category
7577
{
7678
get => (ItemCategory)S1ItemDefinition.Category;
77-
set => S1ItemDefinition.Category = (S1ItemFramework.EItemCategory)value;
79+
set => S1ItemDefinition.Category = (S1CoreItemFramework.EItemCategory)value;
7880
}
7981

8082
/// <summary>
@@ -101,28 +103,10 @@ public bool AvailableInDemo
101103
public LegalStatus LegalStatus
102104
{
103105
get => (LegalStatus)S1ItemDefinition.legalStatus;
104-
set => S1ItemDefinition.legalStatus = (S1ItemFramework.ELegalStatus)value;
106+
set => S1ItemDefinition.legalStatus = (S1CoreItemFramework.ELegalStatus)value;
105107
}
106108

107109

108-
/// <summary>
109-
/// The color of the label shown in UI.
110-
/// </summary>
111-
public Color LabelDisplayColor
112-
{
113-
get => S1ItemDefinition.LabelDisplayColor;
114-
set => S1ItemDefinition.LabelDisplayColor = value;
115-
}
116-
117-
/// <summary>
118-
/// Any keywords used to filter/search this item.
119-
/// </summary>
120-
public string[] Keywords
121-
{
122-
get => S1ItemDefinition.Keywords;
123-
set => S1ItemDefinition.Keywords = value;
124-
}
125-
126110
/// <summary>
127111
/// Creates a new item instance with the specified quantity.
128112
/// </summary>

0 commit comments

Comments
 (0)