C
C#6mo ago
Wx78

Hello im repairing an old mod from Risk of Rain 2 and need help.

using BepInEx;
using R2API;
using RoR2;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using static RoR2.GenericPickupController;
using RoR2.Items;
using RoR2.Artifacts;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime;
using static RoR2.Console;
using BepInEx.Logging;

namespace LunarCommandEssence
{
//This is an example plugin that can be put in BepInEx/plugins/ExamplePlugin/ExamplePlugin.dll to test out.
//It's a small plugin that adds a relatively simple item to the game, and gives you that item whenever you press F2.

//This attribute specifies that we have a dependency on R2API, as we're using it to add our item to the game.
//You don't need this if you're not using R2API in your plugin, it's just to tell BepInEx to initialize R2API before this plugin so it's safe to use R2API.
[BepInDependency(R2API.R2API.PluginGUID)]

//This attribute is required, and lists metadata for your plugin.
[BepInPlugin(PluginGUID, PluginName, PluginVersion)]

//This is the main declaration of our plugin class. BepInEx searches for all classes inheriting from BaseUnityPlugin to initialize on startup.
//BaseUnityPlugin itself inherits from MonoBehaviour, so you can use this as a reference for what you can declare and use in your plugin class: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
public class LunarCommandEssence : BaseUnityPlugin
{
//The Plugin GUID should be a unique ID for this plugin, which is human readable (as it is used in places like the config).
//If we see this PluginGUID as it is on thunderstore, we will deprecate this mod. Change the PluginAuthor and the PluginName !
public const string PluginGUID = PluginAuthor + "." + PluginName;
public const string PluginAuthor = "Wx78";
public const string PluginName = "FixedLunarCommandEssence";
public const string PluginVersion = "1.0.3";
private object LunarCommandEssences;

public void Awake()
{
Log.Init(Logger);
PickupDropletController.onDropletHitGroundServer += PickupDropletController_onDropletHitGroundServer;
Log.Info(nameof(Awake) + " done.");



}


//public class LunarCommand : BaseUnityPlugin

private void PickupDropletController_onDropletHitGroundServer(
ref GenericPickupController.CreatePickupInfo CreatePickupInfo,
ref bool shouldSpawn)
{
if (!this.LunarCommandEssences.value)
return;
PickupIndex pickupIndex = ((GenericPickupController.CreatePickupInfo)ref CreatePickupInfo).pickupIndex;
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef == null || (pickupDef.itemIndex != ItemIndex.None || ItemCatalog.GetItemDef(pickupDef.itemIndex).tier != ItemTier.Lunar) || (pickupDef.equipmentIndex != EquipmentIndex.None || !EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex).isLunar))
{
return;
}

GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(CommandArtifactManager.commandCubePrefab, CreatePickupInfo.position, CreatePickupInfo.rotation);
gameObject.GetComponent<PickupIndexNetworker>().NetworkpickupIndex = pickupIndex;
gameObject.GetComponent<PickupPickerController>().SetOptionsFromPickupForCommandArtifact(pickupIndex);
NetworkServer.Spawn(gameObject);
shouldSpawn = false;
Log.Info(nameof(PickupDropletController_onDropletHitGroundServer) + " done.");
}






}








}
using BepInEx;
using R2API;
using RoR2;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using static RoR2.GenericPickupController;
using RoR2.Items;
using RoR2.Artifacts;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime;
using static RoR2.Console;
using BepInEx.Logging;

namespace LunarCommandEssence
{
//This is an example plugin that can be put in BepInEx/plugins/ExamplePlugin/ExamplePlugin.dll to test out.
//It's a small plugin that adds a relatively simple item to the game, and gives you that item whenever you press F2.

//This attribute specifies that we have a dependency on R2API, as we're using it to add our item to the game.
//You don't need this if you're not using R2API in your plugin, it's just to tell BepInEx to initialize R2API before this plugin so it's safe to use R2API.
[BepInDependency(R2API.R2API.PluginGUID)]

//This attribute is required, and lists metadata for your plugin.
[BepInPlugin(PluginGUID, PluginName, PluginVersion)]

//This is the main declaration of our plugin class. BepInEx searches for all classes inheriting from BaseUnityPlugin to initialize on startup.
//BaseUnityPlugin itself inherits from MonoBehaviour, so you can use this as a reference for what you can declare and use in your plugin class: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
public class LunarCommandEssence : BaseUnityPlugin
{
//The Plugin GUID should be a unique ID for this plugin, which is human readable (as it is used in places like the config).
//If we see this PluginGUID as it is on thunderstore, we will deprecate this mod. Change the PluginAuthor and the PluginName !
public const string PluginGUID = PluginAuthor + "." + PluginName;
public const string PluginAuthor = "Wx78";
public const string PluginName = "FixedLunarCommandEssence";
public const string PluginVersion = "1.0.3";
private object LunarCommandEssences;

public void Awake()
{
Log.Init(Logger);
PickupDropletController.onDropletHitGroundServer += PickupDropletController_onDropletHitGroundServer;
Log.Info(nameof(Awake) + " done.");



}


//public class LunarCommand : BaseUnityPlugin

private void PickupDropletController_onDropletHitGroundServer(
ref GenericPickupController.CreatePickupInfo CreatePickupInfo,
ref bool shouldSpawn)
{
if (!this.LunarCommandEssences.value)
return;
PickupIndex pickupIndex = ((GenericPickupController.CreatePickupInfo)ref CreatePickupInfo).pickupIndex;
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef == null || (pickupDef.itemIndex != ItemIndex.None || ItemCatalog.GetItemDef(pickupDef.itemIndex).tier != ItemTier.Lunar) || (pickupDef.equipmentIndex != EquipmentIndex.None || !EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex).isLunar))
{
return;
}

GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(CommandArtifactManager.commandCubePrefab, CreatePickupInfo.position, CreatePickupInfo.rotation);
gameObject.GetComponent<PickupIndexNetworker>().NetworkpickupIndex = pickupIndex;
gameObject.GetComponent<PickupPickerController>().SetOptionsFromPickupForCommandArtifact(pickupIndex);
NetworkServer.Spawn(gameObject);
shouldSpawn = false;
Log.Info(nameof(PickupDropletController_onDropletHitGroundServer) + " done.");
}






}








}
My Microsoft Visual Studio in which i code in is giving me errors in line 61 for "Value" and line 63 for ref
No description
No description
27 Replies
Angius
Angius6mo ago
1. C# is case-sensitive. value and Value are not the same thing 2. That's not how ref works
Wx78
Wx78OP6mo ago
@ZZZZZZZZZZZZZZZZZZZZZZZZZ first thank you and second how does it work?
Angius
Angius6mo ago
It's only valid for method arguments
Wx78
Wx78OP6mo ago
what would i need to insert then?
Wx78
Wx78OP6mo ago
thx#
Angius
Angius6mo ago
¯\_(ツ)_/¯
Angius
Angius6mo ago
No description
Angius
Angius6mo ago
Should prolly just delete all of this Also, it's usually a good idea to learn using a language first, before trying to modify complex code written in that language
Wx78
Wx78OP6mo ago
I just wanted to fix that mod because it had a useful feature that is annoying otherwise @ZZZZZZZZZZZZZZZZZZZZZZZZZ the value issue still isnt resolved
Angius
Angius6mo ago
Same error?
Wx78
Wx78OP6mo ago
pretty much
Angius
Angius6mo ago
What type is LunarCommandEssences?
Wx78
Wx78OP6mo ago
Nstrip?
No description
Wx78
Wx78OP6mo ago
no thats LunarCommandEssence thats the wrong one i think its bool tho
Angius
Angius6mo ago
Think or know?
Angius
Angius6mo ago
Because from error message alone I can tell that here it's of type object
No description
Wx78
Wx78OP6mo ago
i dont know
Wx78
Wx78OP6mo ago
No description
Angius
Angius6mo ago
It tells you that it's a field in this class So go look at that field And tell me what type it is (it's object btw) object does not have a property .Value
Wx78
Wx78OP6mo ago
@ZZZZZZZZZZZZZZZZZZZZZZZZZ fixed it
No description
Wx78
Wx78OP6mo ago
its a bool now
Angius
Angius6mo ago
A bool does not have a value property either So just remove it Since a bool itself is... a bool
Wx78
Wx78OP6mo ago
it works ?
No description
Wx78
Wx78OP6mo ago
why tho i dont understand now why does it work when it shouldnt have value?
Angius
Angius6mo ago
Well now it's a ConfigEntry<bool> So entirely possible that a ConfigEntry<T> does, indeed, have a .Value property Not a .value one though
Wx78
Wx78OP6mo ago
ok thank you!
Want results from more Discord servers?
Add your server