Skip to content
Open
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
27 changes: 20 additions & 7 deletions ShareSuite/ChatHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,26 @@ public static void SendRichPickupMessage(CharacterMaster player, PickupDef picku

if (temporary)
{
var singlePickupMessage =
$"<color=#{playerColor}>{body.GetUserName()}</color> <color=#{GrayColor}>picked up</color> " +
$"<color=#{ColorUtility.ToHtmlStringRGB(pickupColor)}>" +
$"{(string.IsNullOrEmpty(pickupName) ? "???" : pickupName)} ({itemCount})</color> <color=#{GrayColor}>for themselves. </color>" +
$"<color=#{NotSharingColor}>(Item is temporary, so not shared)</color>";
Chat.SendBroadcastChat(new Chat.SimpleChatMessage { baseToken = singlePickupMessage });
return;
if (ShareSuite.TemporaryItemsShared.Value)
{
var tempPickupMessage =
$"<color=#{playerColor}>{body.GetUserName()}</color> <color=#{GrayColor}>picked up temporary</color> " +
$"<color=#{ColorUtility.ToHtmlStringRGB(pickupColor)}>" +
$"{(string.IsNullOrEmpty(pickupName) ? "???" : pickupName)} ({itemCount})</color> <color=#{GrayColor}>for everyone</color>" +
$"{ItemPickupFormatter(body)}<color=#{GrayColor}>.</color>";
Chat.SendBroadcastChat(new Chat.SimpleChatMessage { baseToken = tempPickupMessage });
return;
}
else
{
var singlePickupMessage =
$"<color=#{playerColor}>{body.GetUserName()}</color> <color=#{GrayColor}>picked up</color> " +
$"<color=#{ColorUtility.ToHtmlStringRGB(pickupColor)}>" +
$"{(string.IsNullOrEmpty(pickupName) ? "???" : pickupName)} ({itemCount})</color> <color=#{GrayColor}>for themselves. </color>" +
$"<color=#{NotSharingColor}>(Item is temporary, so not shared)</color>";
Chat.SendBroadcastChat(new Chat.SimpleChatMessage { baseToken = singlePickupMessage });
return;
}
}

if (Blacklist.HasItem(pickupDef.itemIndex) || !ItemSharingHooks.IsValidItemPickup(pickupDef.pickupIndex))
Expand Down
16 changes: 10 additions & 6 deletions ShareSuite/ItemSharingHooks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EntityStates.Scrapper;
using IL.RoR2.Achievements.FalseSon;
using MonoMod.Cil;
using R2API.Utils;
using RewiredConsts;
Expand Down Expand Up @@ -156,7 +157,7 @@ private static void OnGrantItem(On.RoR2.GenericPickupController.orig_AttemptGran
&& IsValidItemPickup(self.pickupIndex)
&& IsValidPickupObject(self, body)
&& GeneralHooks.IsMultiplayer()
&& !self.pickup.isTempItem) // Don't share the item with anyone else if the item is temporary
&& (!self.pickup.isTempItem || ShareSuite.TemporaryItemsShared.Value)) // Don't share the item with anyone else if the item is temporary unless TemporaryItemsShared is enabled
{
if (ShareSuite.RandomizeSharedPickups.Value)
{
Expand Down Expand Up @@ -196,7 +197,7 @@ private static void OnGrantItem(On.RoR2.GenericPickupController.orig_AttemptGran

var giveItem = PickupCatalog.GetPickupDef(pickupIndex.Value);

HandleGiveItem(player, giveItem);
HandleGiveItem(player, giveItem, self.pickup.isTempItem);
// Alternative: Only show pickup text for yourself
// var givePickupDef = PickupCatalog.GetPickupDef(givePickupIndex);
// Chat.AddPickupMessage(body, givePickupDef.nameToken, givePickupDef.baseColor, 1);
Expand All @@ -209,7 +210,7 @@ private static void OnGrantItem(On.RoR2.GenericPickupController.orig_AttemptGran
// Otherwise give everyone the same item
else
{
HandleGiveItem(player, item);
HandleGiveItem(player, item, self.pickup.isTempItem);
}
}

Expand Down Expand Up @@ -314,7 +315,7 @@ private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractio
else
{
Log.Debug("Sharesuite: handling give item");
HandleGiveItem(characterBody.master, PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()));
HandleGiveItem(characterBody.master, PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()), false);
}

Log.Debug("Sharesuite: orig");
Expand Down Expand Up @@ -521,9 +522,12 @@ internal static void SetInstanceField(Type type, object instance, string fieldNa
? collection[Random.Range(0, collection.Count)]
: (T?) null;

private static void HandleGiveItem(CharacterMaster characterMaster, PickupDef pickupDef)
private static void HandleGiveItem(CharacterMaster characterMaster, PickupDef pickupDef, bool tempItem)
{
characterMaster.inventory.GiveItem(pickupDef.itemIndex);
if (!tempItem)
characterMaster.inventory.GiveItemPermanent(pickupDef.itemIndex);
else
characterMaster.inventory.GiveItemTemp(pickupDef.itemIndex);

var connectionId = characterMaster.playerCharacterMasterController.networkUser?.connectionToClient
?.connectionId;
Expand Down
12 changes: 12 additions & 0 deletions ShareSuite/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"ShareSuite": {
"commandName": "Project"
},
"RoR2 Mod Launch": {
"commandName": "Executable",
"executablePath": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Risk of Rain 2\\Risk of Rain 2.exe",
"commandLineArgs": "--doorstop-enabled true --doorstop-target-assembly \"%appdata%\\r2modmanPlus-local\\RiskOfRain2\\profiles\\Default\\BepInEx\\core\\BepInEx.Preloader.dll\""
}
}
}
29 changes: 29 additions & 0 deletions ShareSuite/ShareSuite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static ConfigEntry<bool>
LunarItemsShared,
BossItemsShared,
VoidItemsShared,
TemporaryItemsShared,
RichMessagesEnabled,
DropBlacklistedEquipmentOnShare,
PrinterCauldronFixEnabled,
Expand Down Expand Up @@ -190,6 +191,13 @@ private void InitConfig()
"Toggles item sharing for void (purple/corrupted) items."
);

TemporaryItemsShared = Config.Bind(
"Settings",
"TemporaryItemsShared",
false,
"Toggles item sharing for temporary items."
);

RichMessagesEnabled = Config.Bind(
"Settings",
"RichMessagesEnabled",
Expand Down Expand Up @@ -625,6 +633,27 @@ private static void CcVoidItemsShared(ConCommandArgs args)
}
}

// TemporaryItemsShared
[ConCommand(commandName = "ss_TemporaryItemsShared", flags = ConVarFlags.None,
helpText = "Modifies whether temporary items are shared or not.")]
private static void CcTemporaryItemsShared(ConCommandArgs args)
{
if (args.Count == 0)
{
Debug.Log(TemporaryItemsShared.Value);
return;
}

var valid = TryGetBool(args[0]);
if (!valid.HasValue)
Debug.Log("Couldn't parse to boolean.");
else
{
TemporaryItemsShared.Value = valid.Value;
Debug.Log($"Temporary item sharing set to {TemporaryItemsShared.Value}.");
}
}

// RichMessagesEnabled
[ConCommand(commandName = "ss_RichMessagesEnabled", flags = ConVarFlags.None,
helpText = "Modifies whether rich messages are enabled or not.")]
Expand Down
9 changes: 9 additions & 0 deletions ShareSuite/ShareSuite.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>RoR2 Mod Launch</ActiveDebugProfile>
</PropertyGroup>
</Project>