using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HG.Reflection;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: AssemblyTitle("dropitem")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("dropitem")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2b5ce9b2-30a8-4211-843f-ab7bba2de5e0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
internal static class log
{
private static ManualLogSource logger;
internal static void start(ManualLogSource logSource)
{
logger = logSource;
}
internal static void start(string name)
{
logger = Logger.CreateLogSource(name);
}
internal static void info(object data)
{
logger.LogInfo(data);
}
internal static void message(object data)
{
logger.LogMessage(data);
}
internal static void warning(object data)
{
logger.LogWarning(data);
}
internal static void error(object data)
{
logger.LogError(data);
}
internal static void fatal(object data)
{
logger.LogFatal(data);
}
}
namespace Dropitem;
internal class DropAll : MonoBehaviour
{
private const float period = 0.2f;
private NetworkUser target;
private Transform targetTransform;
private NetworkUser sender;
private Inventory inventory;
private List<ItemIndex> items;
private float timer = 0.2f - Time.fixedDeltaTime;
private Vector3 currentDirection;
private Quaternion rotation;
public void Assign(NetworkUser target, NetworkUser sender, Transform transform)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
this.target = target;
this.sender = sender;
targetTransform = transform;
inventory = target.master.inventory;
items = inventory.itemAcquisitionOrder;
int num = items.Count + inventory.GetEquipmentSlotCount();
if (num <= 0)
{
log.warning("Empty inventory");
Object.Destroy((Object)(object)((Component)this).gameObject);
}
else
{
currentDirection = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 15f + Vector3.forward * 8f * (0.8f + (float)num / 80f));
rotation = Quaternion.AngleAxis(360f / (float)num, Vector3.up);
}
}
private void FixedUpdate()
{
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Invalid comparison between Unknown and I4
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Invalid comparison between Unknown and I4
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
NetworkUser obj = target;
if (obj != null)
{
CharacterMaster master = obj.master;
if (((master != null) ? new bool?(master.hasBody) : null) == true)
{
NetworkUser obj2 = sender;
if (obj2 != null)
{
CharacterMaster master2 = obj2.master;
if (((master2 != null) ? new bool?(master2.hasBody) : null) == true && Object.op_Implicit((Object)(object)inventory))
{
timer += Time.fixedDeltaTime;
if (!(timer >= 0.2f))
{
return;
}
timer -= 0.2f;
for (int num = items.Count - 1; num >= -1; num--)
{
if (num == -1)
{
for (uint num2 = 0u; num2 < inventory.GetEquipmentSlotCount(); num2++)
{
EquipmentIndex equipmentIndex = inventory.GetEquipment(num2).equipmentIndex;
if ((int)equipmentIndex != -1)
{
Drop.MakePickupDroplet(PickupCatalog.FindPickupIndex(equipmentIndex), targetTransform.position, currentDirection);
inventory.SetEquipmentIndexForSlot((EquipmentIndex)(-1), num2);
currentDirection = rotation * currentDirection;
return;
}
}
log.info("Drop all complete");
Object.Destroy((Object)(object)((Component)this).gameObject);
break;
}
ItemDef itemDef = ItemCatalog.GetItemDef(items[num]);
if ((int)itemDef.tier != 5 && !((Object)(object)itemDef == (Object)(object)Items.CaptainDefenseMatrix))
{
int num3 = inventory.GetItemCount(items[num]);
if (num3 > 15)
{
num3 = 15;
}
timer -= (float)num3 * 0.02f;
Drop.MakePickupDroplet(PickupCatalog.FindPickupIndex(items[num]), targetTransform.position, currentDirection, num3);
inventory.RemoveItem(items[num], num3);
if (inventory.GetItemCount(itemDef) == 0)
{
currentDirection = rotation * currentDirection;
}
break;
}
}
return;
}
}
}
}
log.warning("Lost body, aborting drop all");
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
internal class DragItem : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler, IInitializePotentialDragHandler, IPointerClickHandler
{
public enum ItemType : byte
{
None,
Item,
Equipment
}
public ItemType type;
private static GameObject draggedIcon;
private static RectTransform m_DraggingPlane;
public void OnBeginDrag(PointerEventData eventData)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if ((int)eventData.button != 1)
{
if (Object.op_Implicit((Object)(object)draggedIcon))
{
Object.Destroy((Object)(object)draggedIcon);
}
draggedIcon = new GameObject("dragged icon");
draggedIcon.transform.SetParent(Main.hud.mainContainer.transform);
draggedIcon.transform.SetAsLastSibling();
RawImage val = draggedIcon.AddComponent<RawImage>();
if (type == ItemType.Item)
{
val.texture = ((Component)this).GetComponent<RawImage>().texture;
}
if (type == ItemType.Equipment)
{
val.texture = ((Component)this).GetComponent<EquipmentIcon>().iconImage.texture;
}
((Graphic)val).raycastTarget = false;
((Graphic)val).color = new Color(1f, 1f, 1f, 0.6f);
RectTransform component = draggedIcon.GetComponent<RectTransform>();
((Transform)component).localScale = ((Transform)component).localScale / 128f;
Transform transform = ((Component)Main.hud.canvas).transform;
m_DraggingPlane = (RectTransform)(object)((transform is RectTransform) ? transform : null);
}
}
public void OnDrag(PointerEventData data)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)draggedIcon))
{
RectTransform component = draggedIcon.GetComponent<RectTransform>();
Vector3 position = default(Vector3);
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_DraggingPlane, data.position, data.pressEventCamera, ref position))
{
((Transform)component).position = position;
((Transform)component).rotation = ((Transform)m_DraggingPlane).rotation;
}
}
}
public void OnEndDrag(PointerEventData eventData)
{
if (Object.op_Implicit((Object)(object)draggedIcon))
{
Object.Destroy((Object)(object)draggedIcon);
}
}
public void OnInitializePotentialDrag(PointerEventData eventData)
{
eventData.useDragThreshold = false;
}
public void OnPointerClick(PointerEventData eventData)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
if ((int)eventData.button != 1 && GetPlayerAndItem(out var player, out var args))
{
if ((Object)(object)player.networkUser != (Object)(object)NetworkUser.localPlayers[0])
{
args.Add(NetworkUser.readOnlyInstancesList.IndexOf(player.networkUser).ToString());
}
Console.instance.RunCmd(new CmdSender(NetworkUser.localPlayers[0]), "dropitem", args);
}
}
public bool GetPlayerAndItem(out PlayerCharacterMasterController player, out List<string> args)
{
switch (type)
{
case ItemType.Item:
return FromItem(out player, out args);
case ItemType.Equipment:
return FromEquip(out player, out args);
default:
log.warning("unknown type of clicked object");
player = null;
args = null;
return false;
}
}
private bool FromItem(out PlayerCharacterMasterController player, out List<string> args)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
args = new List<string> { StringParsers.ReformatString(Language.GetString(ItemCatalog.GetItemDef(((Component)this).GetComponent<ItemIcon>().itemIndex).nameToken)) };
ItemInventoryDisplay componentInParent = ((Component)this).GetComponentInParent<ItemInventoryDisplay>();
object obj;
if (componentInParent == null)
{
obj = null;
}
else
{
Inventory inventory = componentInParent.inventory;
if (inventory == null)
{
obj = null;
}
else
{
CharacterMaster component = ((Component)inventory).GetComponent<CharacterMaster>();
obj = ((component != null) ? component.playerCharacterMasterController : null);
}
}
player = (PlayerCharacterMasterController)obj;
if (!Object.op_Implicit((Object)(object)player))
{
log.warning("null player");
return false;
}
return true;
}
private bool FromEquip(out PlayerCharacterMasterController player, out List<string> args)
{
args = new List<string> { "e" };
Inventory targetInventory = ((Component)this).GetComponent<EquipmentIcon>().targetInventory;
CharacterMaster val = ((targetInventory != null) ? ((Component)targetInventory).GetComponent<CharacterMaster>() : null);
player = ((val != null) ? val.playerCharacterMasterController : null);
if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)player))
{
log.warning("null master");
return false;
}
return true;
}
}
internal class Give
{
public const string green = "<color=#96EBAA>";
public const string player = "<color=#AAE6F0>";
public const string error = "<color=#FF8282>";
public const string bold = "<color=#ff4646>";
public static string Give_item(NetworkUser sender, string[] args)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Invalid comparison between Unknown and I4
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Invalid comparison between Unknown and I4
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Invalid comparison between Unknown and I4
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Invalid comparison between Unknown and I4
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Invalid comparison between Unknown and I4
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Invalid comparison between Unknown and I4
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
NetworkUserId id = sender.id;
if (Drop.blockedUserIds.Contains(id))
{
return "<color=#FF8282>You are blocked from dropping items</color>";
}
Inventory val = (((Object)(object)sender != (Object)null) ? sender.master.inventory : null);
NetworkUser netUserFromString = StringParsers.GetNetUserFromString(args[1]);
if ((Object)(object)netUserFromString == (Object)null)
{
return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[1] + "</color>'</color>";
}
Inventory val2 = (((Object)(object)netUserFromString != (Object)null) ? netUserFromString.master.inventory : null);
if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
{
return "<color=#ff4646>ERROR: null inventory</color>";
}
if ((Object)(object)val == (Object)(object)val2)
{
return "<color=#FF8282>Target can not be the sender</color>";
}
string text = "<color=#AAE6F0>" + netUserFromString.masterController.GetDisplayName() + "</color>";
string text2 = "<color=#AAE6F0>" + sender.masterController.GetDisplayName() + "</color>";
EquipmentIndex val3 = (EquipmentIndex)(-1);
ItemIndex val4 = (ItemIndex)(-1);
if (args[0].ToLower() == "e" || args[0].ToLower() == "equip" || args[0].ToLower() == "equipment")
{
val3 = val.GetEquipmentIndex();
if ((int)val3 == -1)
{
return "<color=#FF8282>Sender does not have an </color><color=#ff7d00>equipment</color>";
}
}
else
{
val4 = StringParsers.FindItemInInventroy(args[0], val);
}
PickupIndex val5;
string text3;
if ((int)val4 == -1)
{
if ((int)val3 == -1)
{
val3 = val.GetEquipmentIndex();
if ((int)val3 == -1 || !StringParsers.ReformatString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val3).nameToken)).Contains(StringParsers.ReformatString(args[0])))
{
return "<color=#FF8282>Could not find item '<color=#ff4646>" + args[0] + "</color>' in " + text2 + "<color=#AAE6F0>'s</color> inventory</color>";
}
}
if ((int)val2.GetEquipmentIndex() != -1)
{
return "<color=#FF8282>Target already has an equipment</color>";
}
val5 = PickupCatalog.FindPickupIndex(val3);
text3 = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val3).nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor));
if (val3 != val.GetEquipmentIndex())
{
return "<color=#FF8282>Sender does not have </color><color=#ff4646>" + text3 + "</color>";
}
val2.SetEquipmentIndex(val3);
val.SetEquipmentIndex((EquipmentIndex)(-1));
return "<color=#96EBAA>" + text2 + " gave " + text3 + " to </color>" + text;
}
ItemDef itemDef = ItemCatalog.GetItemDef(val4);
val5 = PickupCatalog.FindPickupIndex(val4);
text3 = Util.GenerateColoredString(Language.GetString(itemDef.nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor));
if ((Object)(object)itemDef == (Object)(object)Items.CaptainDefenseMatrix || ((int)itemDef.tier == 5 && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeConsumed && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeVoidConsumed && (Object)(object)itemDef != (Object)(object)Items.FragileDamageBonusConsumed && (Object)(object)itemDef != (Object)(object)Items.HealingPotionConsumed && (Object)(object)itemDef != (Object)(object)Items.RegeneratingScrapConsumed))
{
return text3 + "<color=#FF8282> is not dropable</color>";
}
int num = val.GetItemCount(val4);
if (num == 0)
{
return "<color=#FF8282>Sender does not have </color>" + text3;
}
if (num > 1)
{
text3 += Util.GenerateColoredString("s", Color32.op_Implicit(PickupCatalog.GetPickupDef(val5).baseColor));
}
if (num > 30)
{
num = 30;
}
val2.GiveItem(val4, num);
val.RemoveItem(val4, num);
return string.Format("{0}{1} gave {2} {3} to </color>{4}", "<color=#96EBAA>", text2, num, text3, text);
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCGiveItem(ConCommandArgs args)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
if (((ConCommandArgs)(ref args)).Count < 2)
{
Debug.LogError((object)"Requires at least 2 arguments: giveitem {Itemname} {{Playername}");
return;
}
if ((Object)(object)args.sender == (Object)null)
{
Debug.LogError((object)"Command cannot be used by dedicated servers.");
return;
}
string[] args2 = new string[2]
{
((ConCommandArgs)(ref args))[0],
((ConCommandArgs)(ref args))[1]
};
if (((ConCommandArgs)(ref args))[0].ToUpperInvariant() == "HELP")
{
Debug.Log((object)"<color=#AAE6F0>/g itemname playername\nWill transfer items from sender's inventory into playername's inventory");
return;
}
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = Give_item(args.sender, args2)
});
}
}
[BepInPlugin("dropitemguid", "Dropitem", "2.1.0")]
public class Main : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static hook_Awake <>9__2_0;
internal void <Awake>b__2_0(orig_Awake orig, HUD self)
{
hud = self;
orig.Invoke(self);
}
}
internal static HUD hud;
private static GameObject _pickupPrefab;
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Expected O, but got Unknown
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Expected O, but got Unknown
log.start(((BaseUnityPlugin)this).Logger);
Console.RunCmd += new hook_RunCmd(hook_RunCmd);
GameObject obj = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/ScoreboardStrip.prefab").WaitForCompletion();
obj.AddComponent<ScoreboardDrop>();
((Component)obj.GetComponentInChildren<EquipmentIcon>()).gameObject.AddComponent<DragItem>().type = DragItem.ItemType.Equipment;
GameObject obj2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/HUDSimple.prefab").WaitForCompletion();
Transform obj3 = obj2.transform.Find("MainContainer/MainUIArea/SpringCanvas/TopCenterCluster/ItemInventoryDisplayRoot/ItemInventoryDisplay");
GameObject val = ((obj3 != null) ? ((Component)obj3).gameObject : null);
if (Object.op_Implicit((Object)(object)val))
{
val.AddComponent<ScoreboardDrop>();
}
else
{
log.error("failed to find ItemInventoryDisplay");
}
EquipmentIcon[] componentsInChildren = obj2.GetComponentsInChildren<EquipmentIcon>();
foreach (EquipmentIcon val2 in componentsInChildren)
{
if (((Object)val2).name == "EquipmentSlot")
{
((Component)val2).gameObject.AddComponent<DragItem>().type = DragItem.ItemType.Equipment;
}
}
Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/ItemIcon.prefab").WaitForCompletion().AddComponent<DragItem>()
.type = DragItem.ItemType.Item;
object obj4 = <>c.<>9__2_0;
if (obj4 == null)
{
hook_Awake val3 = delegate(orig_Awake orig, HUD self)
{
hud = self;
orig.Invoke(self);
};
<>c.<>9__2_0 = val3;
obj4 = (object)val3;
}
HUD.Awake += (hook_Awake)obj4;
GenericPickupController.CreatePickup += new hook_CreatePickup(GenericPickupController_CreatePickup_DetectDropped);
log.info("dropitem loaded");
}
private static void hook_RunCmd(orig_RunCmd orig, Console self, CmdSender sender, string concommandName, List<string> userArgs)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Expected O, but got Unknown
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected O, but got Unknown
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Expected O, but got Unknown
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Expected O, but got Unknown
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Expected O, but got Unknown
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Expected O, but got Unknown
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Expected O, but got Unknown
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Expected O, but got Unknown
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: Expected O, but got Unknown
if (!NetworkServer.active || (Object)(object)Run.instance == (Object)null || !concommandName.Equals("say", StringComparison.InvariantCultureIgnoreCase))
{
orig.Invoke(self, sender, concommandName, userArgs);
return;
}
string text = userArgs.FirstOrDefault();
if (string.IsNullOrWhiteSpace(text) || !text.StartsWith("/"))
{
orig.Invoke(self, sender, concommandName, userArgs);
return;
}
string[] source = text.Split(new char[1] { ' ' });
string text2 = source.FirstOrDefault().Substring(1);
string[] array = source.Skip(1).ToArray();
if (text2.ToUpperInvariant() == "DROP" || text2.ToUpperInvariant() == "D" || text2.ToUpperInvariant() == "DROPITEM")
{
Chat.SendBroadcastChat((ChatMessageBase)new UserChatMessage
{
sender = ((Component)sender.networkUser).gameObject,
text = text
});
if (array.Length == 0 || array[0] == "" || array[0].ToUpperInvariant() == "HELP")
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#AAE6F0>/d itemname playername\nItems with spaces need to be typed without them:\nScrap, Green -> scrapg</color>"
});
return;
}
string text3 = Drop.Drop_item(sender.networkUser, array);
if (text3 == null)
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#ff4646>ERROR: null output</color>"
});
}
else
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = text3
});
}
}
else if (text2.ToUpperInvariant() == "BLOCK" || text2.ToUpperInvariant() == "BLOCKUSER" || text2.ToUpperInvariant() == "B" || text2.ToUpperInvariant() == "UNBLOCK" || text2.ToUpperInvariant() == "UNBLOCKUSER")
{
Chat.SendBroadcastChat((ChatMessageBase)new UserChatMessage
{
sender = ((Component)sender.networkUser).gameObject,
text = text
});
if (array.Length == 0 || array[0] == "" || array[0].ToUpperInvariant() == "HELP")
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#AAE6F0>/block playername</color>"
});
return;
}
string text4 = Drop.BlockUser(sender.networkUser, array);
if (text4 == null)
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#ff4646>ERROR: null output</color>"
});
}
else
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = text4
});
}
}
else if (text2.ToUpperInvariant() == "GIVE" || text2.ToUpperInvariant() == "G" || text2.ToUpperInvariant() == "GIVEITEM")
{
Chat.SendBroadcastChat((ChatMessageBase)new UserChatMessage
{
sender = ((Component)sender.networkUser).gameObject,
text = text
});
if (array.Length < 2 || array[0] == "" || array[0].ToUpperInvariant() == "HELP")
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#AAE6F0>/g itemname playername\nWill transfer items from sender's inventory into playername's inventory"
});
return;
}
string text5 = Give.Give_item(sender.networkUser, array);
if (text5 == null)
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#ff4646>ERROR: null output</color>"
});
}
else
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = text5
});
}
}
else
{
orig.Invoke(self, sender, concommandName, userArgs);
}
}
private static GenericPickupController GenericPickupController_CreatePickup_DetectDropped(orig_CreatePickup orig, ref CreatePickupInfo createPickupInfo)
{
if (Object.op_Implicit((Object)(object)GetPickupPrefab()) && (Object)(object)createPickupInfo.prefabOverride == (Object)(object)GetPickupPrefab())
{
createPickupInfo.prefabOverride = GenericPickupController.pickupPrefab;
GenericPickupController obj = orig.Invoke(ref createPickupInfo);
obj.NetworkRecycled = true;
return obj;
}
return orig.Invoke(ref createPickupInfo);
}
public static GameObject GetPickupPrefab(bool generateIfNull = false)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
if (generateIfNull && !Object.op_Implicit((Object)(object)_pickupPrefab))
{
_pickupPrefab = new GameObject("DropItemPrefab");
}
return _pickupPrefab;
}
}
internal class Drop
{
public const string green = "<color=#96EBAA>";
public const string player = "<color=#AAE6F0>";
public const string error = "<color=#FF8282>";
public const string bold = "<color=#ff4646>";
public static List<NetworkUserId> blockedUserIds = new List<NetworkUserId>();
private static bool isNegative = false;
public static string Drop_item(NetworkUser sender, string[] args)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Invalid comparison between Unknown and I4
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Invalid comparison between Unknown and I4
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Invalid comparison between Unknown and I4
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Invalid comparison between Unknown and I4
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Invalid comparison between Unknown and I4
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
NetworkUserId id = sender.id;
if (blockedUserIds.Contains(id))
{
return "<color=#FF8282>You are blocked from dropping items</color>";
}
NetworkUser val = sender;
Inventory val2 = (((Object)(object)sender != (Object)null) ? sender.master.inventory : null);
if (args.Count() >= 2)
{
val = StringParsers.GetNetUserFromString(args[1]);
if ((Object)(object)val == (Object)null)
{
return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[1] + "</color>'</color>";
}
val2 = (((Object)(object)val == (Object)null) ? val2 : val.master.inventory);
}
if ((Object)(object)val2 == (Object)null)
{
return "<color=#ff4646>ERROR: null inventory</color>";
}
CharacterBody currentBody = sender.GetCurrentBody();
Transform val3 = ((currentBody != null) ? ((Component)currentBody.coreTransform).transform : null);
if ((Object)(object)val3 == (Object)null)
{
return "<color=#FF8282>Must be alive to drop items</color>";
}
Vector3 velocity = sender.GetCurrentBody().inputBank.aimDirection;
velocity.y = 0f;
velocity = ((Vector3)(ref velocity)).normalized * 8f + Vector3.up * 15f;
string text = "<color=#AAE6F0>" + val.masterController.GetDisplayName() + "</color>";
string text2 = "<color=#AAE6F0>" + sender.masterController.GetDisplayName() + "</color>";
EquipmentIndex val4 = (EquipmentIndex)(-1);
ItemIndex val5 = (ItemIndex)(-1);
if (args[0].ToLower() == "all")
{
new GameObject("DropAll").AddComponent<DropAll>().Assign(val, sender, val3);
if ((Object)(object)val == (Object)(object)sender)
{
return "<color=#96EBAA>Dropping all items from </color>" + text;
}
return "<color=#96EBAA>" + text2 + " is dropping all items from </color>" + text;
}
if (args[0].ToLower() == "e" || args[0].ToLower() == "equip" || args[0].ToLower() == "equipment")
{
val4 = val2.GetEquipmentIndex();
if ((int)val4 == -1)
{
return "<color=#FF8282>Target does not have an </color><color=#ff7d00>equipment</color>";
}
}
else
{
val5 = StringParsers.FindItemInInventroy(args[0], val2);
}
PickupIndex val6;
string text3;
if ((int)val5 == -1)
{
if ((int)val4 == -1)
{
val4 = val2.GetEquipmentIndex();
if ((int)val4 == -1 || !StringParsers.ReformatString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val4).nameToken)).Contains(StringParsers.ReformatString(args[0])))
{
return "<color=#FF8282>Could not find item '<color=#ff4646>" + args[0] + "</color>' in " + text + "<color=#AAE6F0>'s</color> inventory</color>";
}
}
val6 = PickupCatalog.FindPickupIndex(val4);
text3 = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(val4).nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val6).baseColor));
if (val4 != val2.GetEquipmentIndex())
{
return "<color=#FF8282>Target does not have </color><color=#ff4646>" + text3 + "</color>";
}
MakePickupDroplet(val6, val3.position, velocity);
val2.SetEquipmentIndex((EquipmentIndex)(-1));
if ((Object)(object)val == (Object)(object)sender)
{
return "<color=#96EBAA>Dropped " + text3 + " from </color>" + text;
}
return "<color=#96EBAA>" + text2 + " is dropping " + text3 + " from </color>" + text;
}
ItemDef itemDef = ItemCatalog.GetItemDef(val5);
val6 = PickupCatalog.FindPickupIndex(val5);
text3 = Util.GenerateColoredString(Language.GetString(itemDef.nameToken), Color32.op_Implicit(PickupCatalog.GetPickupDef(val6).baseColor));
if ((Object)(object)itemDef == (Object)(object)Items.CaptainDefenseMatrix || ((int)itemDef.tier == 5 && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeConsumed && (Object)(object)itemDef != (Object)(object)Items.ExtraLifeVoidConsumed && (Object)(object)itemDef != (Object)(object)Items.FragileDamageBonusConsumed && (Object)(object)itemDef != (Object)(object)Items.HealingPotionConsumed && (Object)(object)itemDef != (Object)(object)Items.RegeneratingScrapConsumed))
{
return text3 + "<color=#FF8282> is not dropable</color>";
}
int num = val2.GetItemCount(val5);
if (num == 0)
{
return "<color=#FF8282>Target does not have </color>" + text3;
}
if (num > 1)
{
text3 += Util.GenerateColoredString("s", Color32.op_Implicit(PickupCatalog.GetPickupDef(val6).baseColor));
}
if (num > 20)
{
num = 20;
}
MakePickupDroplet(val6, val3.position, velocity, num);
val2.RemoveItem(val5, num);
if ((Object)(object)val == (Object)(object)sender)
{
return string.Format("{0}{1} dropped {2} {3}</color>", "<color=#96EBAA>", text, num, text3);
}
return string.Format("{0}{1} is dropping {2} {3} from </color>{4}", "<color=#96EBAA>", text2, num, text3, text);
}
public static string BlockUser(NetworkUser sender, string[] args)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)LocalUserManager.GetFirstLocalUser().currentNetworkUser != (Object)(object)sender)
{
return "<color=#FF8282>Sender is not host</color>";
}
NetworkUser netUserFromString = StringParsers.GetNetUserFromString(args[0]);
if ((Object)(object)netUserFromString == (Object)null)
{
return "<color=#FF8282>Could not find specified </color>player<color=#FF8282> '<color=#ff4646>" + args[0] + "</color>'</color>";
}
if ((Object)(object)netUserFromString == (Object)(object)sender)
{
return "<color=#FF8282>Can not block self</color>";
}
NetworkUserId id = netUserFromString.id;
if (blockedUserIds.Remove(id))
{
return "<color=#96EBAA>Unblocked <color=#AAE6F0>" + netUserFromString.masterController.GetDisplayName() + "</color></color>";
}
blockedUserIds.Add(id);
return "<color=#96EBAA>Blocked <color=#AAE6F0>" + netUserFromString.masterController.GetDisplayName() + "</color></color>";
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCDIDropItem(ConCommandArgs args)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
if (((ConCommandArgs)(ref args)).Count == 0)
{
Debug.LogError((object)"Requires at least 1 argument: dropitem {itemname} ({PlayerID:self}|{Playername})");
return;
}
if ((Object)(object)args.sender == (Object)null && ((ConCommandArgs)(ref args)).Count < 2)
{
Debug.LogError((object)"Command must be fully qualified on dedicated servers.");
return;
}
string[] args2 = ((((ConCommandArgs)(ref args)).Count >= 2) ? new string[2]
{
((ConCommandArgs)(ref args))[0],
((ConCommandArgs)(ref args))[1]
} : new string[1] { ((ConCommandArgs)(ref args))[0] });
if (((ConCommandArgs)(ref args))[0].ToUpperInvariant() == "HELP")
{
Debug.Log((object)"<color=#AAE6F0>/d itemname playername\nItems with spaces need to be typed without them:\nScrap, Green -> scrapg</color>");
return;
}
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = Drop_item(args.sender, args2)
});
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCDIBlockUser(ConCommandArgs args)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (((ConCommandArgs)(ref args)).Count == 0)
{
Debug.LogError((object)"Requires at least 1 argument: blockuser {Playername}");
return;
}
Debug.Log((object)BlockUser(args.sender, new string[1] { ((ConCommandArgs)(ref args))[0] }));
}
internal static void MakePickupDroplet(PickupIndex pickupIndex, Vector3 position, Vector3 velocity, int amount = 1)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < amount; i++)
{
CreatePickupInfo val = default(CreatePickupInfo);
val.rotation = Quaternion.Euler(0f, 180f * (float)i / (float)amount + DoIsNegative(), 0f);
((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
val.prefabOverride = Main.GetPickupPrefab(generateIfNull: true);
PickupDropletController.CreatePickupDroplet(val, position, velocity * (1f + (float)i / 60f));
}
}
private static float DoIsNegative()
{
isNegative = !isNegative;
return isNegative ? 180 : 0;
}
}
internal class ScoreboardDrop : MonoBehaviour, IDropHandler, IEventSystemHandler
{
public void OnDrop(PointerEventData eventData)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
if ((int)eventData.button == 1)
{
return;
}
object obj;
if (eventData == null)
{
obj = null;
}
else
{
GameObject pointerDrag = eventData.pointerDrag;
obj = ((pointerDrag != null) ? pointerDrag.GetComponent<DragItem>() : null);
}
DragItem dragItem = (DragItem)obj;
if (!Object.op_Implicit((Object)(object)dragItem))
{
log.warning("Dragged object does not have DragItem component");
}
else
{
if (!dragItem.GetPlayerAndItem(out var player, out var args))
{
return;
}
PlayerCharacterMasterController val = ((Component)this).GetComponent<ScoreboardStrip>()?.userPlayerCharacterMasterController;
if (!Object.op_Implicit((Object)(object)val))
{
ItemInventoryDisplay component = ((Component)this).GetComponent<ItemInventoryDisplay>();
object obj2;
if (component == null)
{
obj2 = null;
}
else
{
Inventory inventory = component.inventory;
obj2 = ((inventory != null) ? ((Component)inventory).GetComponent<CharacterMaster>().playerCharacterMasterController : null);
}
val = (PlayerCharacterMasterController)obj2;
}
if (!Object.op_Implicit((Object)(object)val))
{
log.warning("null target player");
return;
}
string text;
if ((Object)(object)player != (Object)(object)val)
{
if ((Object)(object)player.networkUser != (Object)(object)NetworkUser.localPlayers[0])
{
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = "<color=#FF8282>Can only give items from your inventory</color>"
});
return;
}
text = "giveitem";
args.Add(NetworkUser.readOnlyInstancesList.IndexOf(val.networkUser).ToString());
}
else
{
text = "dropitem";
if ((Object)(object)player.networkUser != (Object)(object)NetworkUser.localPlayers[0])
{
args.Add(NetworkUser.readOnlyInstancesList.IndexOf(player.networkUser).ToString());
}
}
Console.instance.RunCmd(new CmdSender(NetworkUser.localPlayers[0]), text, args);
}
}
}
internal sealed class StringParsers
{
internal static ItemIndex FindItemInInventroy(string input, Inventory inventory)
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
List<ItemIndex> itemAcquisitionOrder = inventory.itemAcquisitionOrder;
if (!itemAcquisitionOrder.Any())
{
return (ItemIndex)(-1);
}
input = ReformatString(input);
if (int.TryParse(input, out var result))
{
if (result > itemAcquisitionOrder.Count || result < 0)
{
return (ItemIndex)(-1);
}
if (result == 0)
{
return itemAcquisitionOrder[itemAcquisitionOrder.Count - 1];
}
return itemAcquisitionOrder[itemAcquisitionOrder.Count - result];
}
for (int num = itemAcquisitionOrder.Count - 1; num >= 0; num--)
{
ItemDef itemDef = ItemCatalog.GetItemDef(itemAcquisitionOrder[num]);
if (ReformatString(Language.GetString(itemDef.nameToken)).Contains(input))
{
return itemDef.itemIndex;
}
}
return (ItemIndex)(-1);
}
public static EquipmentIndex GetEquipFromPartial(string name)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
name = ReformatString(name);
EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
foreach (EquipmentDef val in equipmentDefs)
{
if (ReformatString(Language.GetString(val.nameToken)).Contains(name))
{
return val.equipmentIndex;
}
}
return (EquipmentIndex)(-1);
}
internal static NetworkUser GetNetUserFromString(string name)
{
if (int.TryParse(name, out var result))
{
if (result < NetworkUser.readOnlyInstancesList.Count && result >= 0)
{
return NetworkUser.readOnlyInstancesList[result];
}
return null;
}
name = ReformatString(name);
foreach (NetworkUser readOnlyInstances in NetworkUser.readOnlyInstancesList)
{
if (ReformatString(readOnlyInstances.userName).StartsWith(name))
{
return readOnlyInstances;
}
}
foreach (NetworkUser readOnlyInstances2 in NetworkUser.readOnlyInstancesList)
{
if (ReformatString(readOnlyInstances2.userName).Contains(name))
{
return readOnlyInstances2;
}
}
return null;
}
internal static string ReformatString(string input)
{
return Regex.Replace(input, "[ '_.,-]", string.Empty).ToLower();
}
}