Skip to content

Commit

Permalink
1.0.44.1602
Browse files Browse the repository at this point in the history
  • Loading branch information
SphereII committed Aug 8, 2024
1 parent 90dfd92 commit 85b02fc
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 7 deletions.
1 change: 1 addition & 0 deletions Mods/0-SCore/0-SCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
<Compile Include="Harmony\XUIC\SirillionThings.cs" />
<Compile Include="Harmony\XUIC\XUiController.cs" />
<Compile Include="Harmony\XUIC\XUiC_ItemStack.cs" />
<Compile Include="Harmony\XUIC\XUiC_ItemStack_SlotTags.cs" />
<Compile Include="Harmony\XUIC\XUiC_TargetBar.cs" />
<Compile Include="Harmony\ZombieFeatures\EntityFlyingEAITasks.cs" />
<Compile Include="Harmony\ZombieFeatures\HeadshotOnly.cs" />
Expand Down
3 changes: 2 additions & 1 deletion Mods/0-SCore/Config/Localization.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@ xuiSCoreUtilsDisableFlickeringLightsToolTip,"Disables Flickering Lights.",""
xuiPersonalSettings,"Personal Settings",""
xuiSCoreUtilsAutoRedeemChallenges,"Auto Redeem Challenges",""
xuiSCoreUtilsAutoRedeemChallengesToolTip,"Auto Redeem Challenges as they complete.",""
ObjectiveBuffSDX_keyword,"Get",""
ObjectiveBuffSDX_keyword,"Get",""
ItemCannotBePlaced,"This item cannot go into this slot.",""
4 changes: 2 additions & 2 deletions Mods/0-SCore/Harmony/SphereIICore_Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public void InitMod(Mod _modInstance)
Log.Out(" Loading Patch: " + GetType());

// Reduce extra logging stuff
Application.SetStackTraceLogType(UnityEngine.LogType.Log, StackTraceLogType.None);
Application.SetStackTraceLogType(UnityEngine.LogType.Warning, StackTraceLogType.None);
// Application.SetStackTraceLogType(UnityEngine.LogType.Log, StackTraceLogType.None);
// Application.SetStackTraceLogType(UnityEngine.LogType.Warning, StackTraceLogType.None);


var harmony = new HarmonyLib.Harmony(GetType().ToString());
Expand Down
135 changes: 135 additions & 0 deletions Mods/0-SCore/Harmony/XUIC/XUiC_ItemStack_SlotTags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Audio;
using HarmonyLib;
using UnityEngine;

namespace SCore.Harmony.TileEntities {
public class CheckItemsForContainers {
private static bool IsStackAllowedInContainer(XUiC_ItemStack itemStack) {
switch (itemStack.StackLocation)
{
case XUiC_ItemStack.StackLocationTypes.Backpack:
case XUiC_ItemStack.StackLocationTypes.ToolBelt:
return true;
}

var currentStack = itemStack.xui.dragAndDrop?.CurrentStack;
if (currentStack == null || currentStack.IsEmpty()) return true;

// 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 block = itemStack.xui.lootContainer.blockValue.Block;
return CanPlaceItemInContainerViaTags(block, currentStack, true);
}
private static bool CanPlaceItemInContainerViaTags(Block block, ItemStack itemStack, bool showToolTip = 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"))
{
var allowedTags = FastTags<TagGroup.Global>.Parse(block.Properties.GetString("AllowTags"));
if (allowedTags.Test_AnySet(all)) return true;
if (itemStack.itemValue.ItemClass.HasAnyTags(allowedTags)) return true;
}

if (block.Properties.Contains("DisallowTags"))
{
var blockedTags = FastTags<TagGroup.Global>.Parse(block.Properties.GetString("DisallowTags"));
if (!itemStack.itemValue.ItemClass.HasAnyTags(blockedTags)) return true;
}


if (!showToolTip) return false;
var message = Localization.Get("ItemCannotBePlaced");
if (block.Properties.Contains("DisallowedKey"))
{
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);
GameManager.ShowTooltip(primaryPlayer, message);
return false;
}

// For clicking and sending objects to the toolbelt/backpack/loot container
public class TEFeatureStoragePatch {
[HarmonyPatch(typeof(TEFeatureStorage))]
[HarmonyPatch("TryStackItem")]
public class TEFeatureStorageTryStackItem {
public static bool Prefix(TEFeatureStorage __instance, ItemStack _itemStack) {
if (__instance is ITileEntityLootable tileEntityLootable)
return CanPlaceItemInContainerViaTags(tileEntityLootable.blockValue.Block, _itemStack);
return true;
}
}

[HarmonyPatch(typeof(TEFeatureStorage))]
[HarmonyPatch("AddItem")]
public class TEFeatureStorageAddItem {
public static bool Prefix(TEFeatureStorage __instance, ItemStack _itemStack) {
if (__instance is ITileEntityLootable tileEntityLootable)
return CanPlaceItemInContainerViaTags(tileEntityLootable.blockValue.Block, _itemStack);
return true;

}
}
}

// For other methods, such as automatic stashing, dragging and dropping, etc.
[HarmonyPatch]
public class XUiC_ItemStack_SlotTags {
[HarmonyTargetMethod]
static IEnumerable<MethodBase> TargetMethods() {
yield return typeof(XUiC_ItemStack).GetMethod("CanSwap");
yield return typeof(XUiC_ItemStack).GetMethod("ForceSetItemStack");
yield return typeof(XUiC_ItemStack).GetMethod("HandleDropOne");
yield return typeof(XUiC_ItemStack).GetMethod("HandleMoveToPreferredLocation");
yield return typeof(XUiC_ItemStack).GetMethod("HandlePartialStackPickup");
yield return typeof(XUiC_ItemStack).GetMethod("HandleStackSwap");
yield return typeof(XUiC_ItemStack).GetMethod("SwapItem");
}

public static bool Prefix(XUiC_ItemStack __instance) {
return IsStackAllowedInContainer(__instance);
}
}


public class XUICLootContainerCheckItemsForContainers {
[HarmonyPatch(typeof(XUiC_LootWindow))]
[HarmonyPatch("SetTileEntityChest")]
public class XUiCLootWindowSetTileEntityChest {
public static void Postfix(XUiC_LootWindow __instance, string _lootContainerName) {
if (__instance.te == null) return;

var block = __instance.te.blockValue.Block;
if (block.Properties.Contains("AllowTags"))
{
var display = block.Properties.GetString("AllowTags");
__instance.lootContainerName = $"{_lootContainerName} ( Tag Limited: {display} )";
__instance.RefreshBindings(true);
return;
}
if (block.Properties.Contains("DisallowTags"))
{
var display = block.Properties.GetString("DisallowTags");
__instance.lootContainerName = $"{_lootContainerName} ( Blocked Tags: {display} )";
__instance.RefreshBindings(true);
}

}
}
}
}
}
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.0.43.1207" />
<Version value="1.0.44.1602" />
</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.0.43.1207")]
[assembly: AssemblyFileVersion("1.0.43.1207")]
[assembly: AssemblyVersion("1.0.44.1602")]
[assembly: AssemblyFileVersion("1.0.44.1602")]
33 changes: 33 additions & 0 deletions Mods/0-SCore/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,39 @@ Direct Download to the 0-SCore.zip available on gitlab mirror:
### Change Logs

[ Change Log ]
Version: 1.0.44.1602
[ Check Items For Valid Containers]
- Introduced a new feature through a series of Harmony patches that allows you to filter items from storage containers.
- Allows you to filter items being added to any given Loot Container based on tags.
- A container with the AllowTags set to "all", will allow all items.
- A container with no AllowTags or DisallowTags will not be checked at all, and act normally.

- If a loot container has the following property, then it will only allow items that have those tags to be stored.
<!-- Only melee, axe, and repairTool items are allowed to be added -->
<!-- But it will not accept any lightarmor -->
<property name="AllowTags" value="melee,axe,repairTool" />
<property name="DisallowTags" value="lightarmor" />

<!-- Items.xml entry -->
<item name="meleeToolRepairT0StoneAxe">
<property name="Tags" value="axe,melee,light,tool,longShaft,repairTool,miningTool,attStrength,perkMiner69r,perkMotherLode,perkTheHuntsman,canHaveCosmetic,harvestingSkill,corpseRemoval"/>

<!-- Example -->
<block name="cntSphereTagTest">
<property name="Extends" value="cntWoodWritableCrate"/>
<property name="LootList" value="playerWoodWritableStorage"/>
<property name="AllowTags" value="melee,axe,repairTool" />
</block>

- If an item is blocked, a denied UI sound will be triggered.
- If an item is dragged and dropped in a blocked container, a tooltip will also display.
- Shift clicking on an item to move it will play the denied UI.

- If a block has the following Property, this will be used to check for localization and display a custom blocked message.
<property name="DisallowedKey" value="NoPickUpForNPCs" />
- This property can also exist on the Item entry as well, and will over-ride the block's message, if it's set.
- If not otherwise set, the default localization entry will be displayed.
Version: 1.0.43.1207
[ Fire Manager ]
- Removed the DynamicMeshChunk update, which was likely needless, and likely caused a performance issue.
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.
2 changes: 1 addition & 1 deletion Mods/0-SCore/Scripts/Quests/ObjectiveBuffSDX.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using UnityEngine;

internal class ObjectiveBuffSDX : BaseObjective
public class ObjectiveBuffSDX : BaseObjective
{
private string strBuff = "";

Expand Down

0 comments on commit 85b02fc

Please sign in to comment.