Thanks, I hadn't noticed that, maybe make them non-static variables?๐คจ
Making this plugin work with multiple ranges isn't going to be straight forward.
I've submitted an Oxide PR to allow the OnSamSiteTargetScan(SamSite samSite, List<SamSite.ISamSiteTarget> targetList) hook to be cancelable. My recommendation is that the Sam Site Range plugin cancel that hook and implement custom logic to find nearby targets. You can start by copying the vanilla code and just changing the range.
However, there are two gotchas:
- After the hook runs, the vanilla logic will loop the
targetList and call target.IsVisible(eyePoint.transform.position, item2.SAMTargetType.scanRadius * 2f). Depending on the range that the plugin is configured with, that check might cause entities to not be targeted. - After selecting a target, the
SamSite.FixedUpdate() method will constantly check that the target is still within range, based on currentTarget.SAMTargetType.scanRadius.
Depending on the range configured in the plugin, those gotchas could cause the following issues.
- An entity that is within the confiured Sam Site range might not be targeted.
- An entity could remain a target outside of the configured Sam Site range.
To solve, you would probably have to create a separate ISamSiteTarget instance per combination of Sam Site and eligible target. A naiive way of achieving that would be to create instances of a custom class on the fly, but that would likely result in significant unnecessary garbage collection. However, you could implement a pool to avoid the GC overhead. Let me know if you have any better ideas.