Skip to content

Commit

Permalink
1.2.8.1136
Browse files Browse the repository at this point in the history
  • Loading branch information
SphereII committed Dec 14, 2024
1 parent 1a8b99b commit 8a6bdb2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
30 changes: 24 additions & 6 deletions Mods/0-SCore/Harmony/XUIC/XUiC_ItemStack_SlotTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
namespace SCore.Harmony.TileEntities {
public class CheckItemsForContainers {
private static bool IsStackAllowedInContainer(XUiC_ItemStack itemStack) {
if (itemStack == null) return true;
switch (itemStack.StackLocation)
{
case XUiC_ItemStack.StackLocationTypes.Backpack:
case XUiC_ItemStack.StackLocationTypes.ToolBelt:

return true;
}

Expand All @@ -20,13 +22,14 @@ private static bool IsStackAllowedInContainer(XUiC_ItemStack itemStack) {

// Only run on loot containers and their slots.
if (itemStack.xui.lootContainer == null) return true;

if (itemStack.StackLocation != XUiC_ItemStack.StackLocationTypes.LootContainer) return true;

var blockValue = GameManager.Instance.World.GetBlock(itemStack.xui.lootContainer.ToWorldPos());
var block = blockValue.Block;
return CanPlaceItemInContainerViaTags(block, currentStack, true);
}

private static bool CanPlaceItemInContainerViaTags(Block block, ItemStack itemStack, bool showToolTip = false) {
if (itemStack.itemValue.HasMetadata("NoStorage"))
{
Expand All @@ -38,13 +41,13 @@ private static bool CanPlaceItemInContainerViaTags(Block block, ItemStack itemSt
{
DisplayToolTip(block, itemStack);
return false;
}
}
}

}

// If the tags don't exist, skip all the checks.
if (!block.Properties.Contains("AllowTags") && !block.Properties.Contains("DisallowTags")) return true;

var all = FastTags<TagGroup.Global>.Parse("all");
if (block.Properties.Contains("AllowTags"))
{
Expand All @@ -71,10 +74,12 @@ private static void DisplayToolTip(Block block, ItemStack itemStack) {
{
message = Localization.Get(block.Properties.GetString("DisallowedKey"));
}

if (itemStack.itemValue.ItemClass.Properties.Contains("DisallowedKey"))
{
message = Localization.Get(itemStack.itemValue.ItemClass.Properties.GetString("DisallowedKey"));
}

Manager.PlayInsidePlayerHead("ui_denied");
var primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
XUiC_PopupToolTip.ClearTooltips(primaryPlayer.playerUI.xui);
Expand All @@ -88,7 +93,9 @@ public class TEFeatureStoragePatch {
public class TEFeatureStorageTryStackItem {
public static bool Prefix(TEFeatureStorage __instance, ItemStack _itemStack) {
if (__instance is ITileEntityLootable tileEntityLootable)
{
return CanPlaceItemInContainerViaTags(tileEntityLootable.blockValue.Block, _itemStack);
}
return true;
}
}
Expand All @@ -100,7 +107,6 @@ public static bool Prefix(TEFeatureStorage __instance, ItemStack _itemStack) {
if (__instance is ITileEntityLootable tileEntityLootable)
return CanPlaceItemInContainerViaTags(tileEntityLootable.blockValue.Block, _itemStack);
return true;

}
}
}
Expand All @@ -124,6 +130,18 @@ public static bool Prefix(XUiC_ItemStack __instance) {
}
}

public class XUiM_LootContainerItemStackPatch {
[HarmonyPatch(typeof(XUiM_LootContainer))]
[HarmonyPatch("AddItem")]
public class XUiMLootContainerItemStackPatchAddItem {
public static bool Prefix(ItemStack _itemStack, XUi _xui) {
if ( _xui.lootContainer == null ) return true;
var blockValue = GameManager.Instance.World.GetBlock(_xui.lootContainer.ToWorldPos());
var block = blockValue.Block;
return CanPlaceItemInContainerViaTags(block, _itemStack, true);
}
}
}

public class XUICLootContainerCheckItemsForContainers {
[HarmonyPatch(typeof(XUiC_LootWindow))]
Expand All @@ -141,13 +159,13 @@ public static void Postfix(XUiC_LootWindow __instance, string _lootContainerName
__instance.RefreshBindings(true);
return;
}

if (block.Properties.Contains("DisallowTags"))
{
var display = block.Properties.GetString("DisallowTags");
__instance.lootContainerName = $"{_lootContainerName} ( Blocked Tags: {display} )";
__instance.RefreshBindings(true);
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Mods/0-SCore/ModInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<Description value="SCore Mod" />
<DisplayName value="0-SCore" />
<Website value="" />
<Version value="1.2.4.1601" />
<Version value="1.2.8.1136" />
</xml>
4 changes: 2 additions & 2 deletions Mods/0-SCore/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("20.0.*")]

[assembly: AssemblyVersion("1.2.4.1601")]
[assembly: AssemblyFileVersion("1.2.4.1601")]
[assembly: AssemblyVersion("1.2.8.1136")]
[assembly: AssemblyFileVersion("1.2.8.1136")]
4 changes: 4 additions & 0 deletions Mods/0-SCore/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Direct Download to the 0-SCore.zip available on gitlab mirror: https://github.co
### Change Logs

[ Change Log ]
Version: 1.2.8.1136
[ NPCs ]
- Fixed an issue where NPCs could be added to Drone

Version: 1.2.4.1601
[ Block Triggered SDX ]
- Fixed an issue with the ActivateOnLook check
Expand Down
Binary file modified Mods/0-SCore/SCore.dll
Binary file not shown.
Binary file modified Mods/0-SCore/SCore.pdb
Binary file not shown.

0 comments on commit 8a6bdb2

Please sign in to comment.