Hello
I have been trying to identify some console log error spam of ArgumentNullExceptions caused by one of my plugins. It is supposed to prevent certain animals spawning in certain areas at certain times of day, so instead of being able to use chicken.population or boar.population svars I needed to solve this programmatically.
For some reason tho when specifically killing boars or chickens in OnEntitySpawned it would afterwards spam the console with ArgumentNullExceptions, as many exception messages as animals were killed. I have not been able to identify any other entities where this occurs.
Minimum reproducable example:
namespace Oxide.Plugins
{
[Info("Test", "Longoon", "1.0")]
class Test : RustPlugin
{
void OnEntitySpawned(BaseNetworkable entity)
{
if (entity.PrefabName == "assets/rust.ai/agents/boar/boar.prefab" || entity.PrefabName == "assets/rust.ai/agents/chicken/chicken.prefab")
{
entity.Kill();
Puts("Incoming ArgumentNullException");
}
}
}
}To reproduce:
1. Spool up a new Rust Server with Oxide
2. Once it's fully loaded add above Test.cs into the Oxide plugins folder
3. Wait for the server to spawn some Chickens or Boars, usually takes a minute
4. You will see a bunch of "Incoming ArgumentNullException" messages followed by a bunch of ArgumentNullExceptions
So my questions are:
1. Is this the proper way of killing/preventing animals from spawning?
2. If it is, then why am I getting all of these Exceptions? If it's not then what should I be doing instead?
I have already tried to debug RustDedicated in VisualStudio, enabled ArgumentNullException in Break When Thrown in Exception Settings and tried all available Code Types when attaching to the server, I was unable to get VS to break when these occur.
Thanks for your help!
