Heyho!
Is it possible to override the test/check methods inside the Component.UpdatePlacement(...) method (used for placement e.g.: foundations)? [maybe wrong section, sorry if thats the case]
What I want to achieve:
When a player has a certain permission (or some other conditions are allowing him to), he sould be able to "ignore" placement errors like "Placing through rock" or "Too close to another building". Unfortunately, I didn't find anything to allow such behaviour (if I just was completely blind, ignore the stuff below and please tell me how to do this ^^).
Looking through Rust using dnSpy, I found the method mentioned above. Could you add hooks to override the default behaviour? Something like this probably (I'm not exactly sure how the "hooks" should look like or if it is "easy" to implement):
...
if (!this.TestPlacingThroughRock(ref placement, target) && !Hook_PlacingThroughRock(ref placement, target)){
...
//if true, building would be blocked
}
...
if (global::BuildingProximity.Check(target.player, this, placement.position, placement.rotation) && Hook_BuildingProximityCheck(target.player, this, placement.position, placement.rotation)){
...
//if true, building would be blocked
}
...If thats not possible (like if you "just insert IL code" when nescessary or at the beginning of a method), maybe this could be an alternative:
Construction.cs:
private bool TestPlacingThroughRock(ref global::Construction.Placement placement, global::Construction.Target target) {
bool? hookResult = Hook_TestPlacingThroughRock(ref placement, target); //null - no hook, true/false - hook result
if(hookResult != null)
return (bool)hookResult;
...
}
BuildingProximity.cs:
public static bool Check(global::BasePlayer player, global::Construction construction, Vector3 position, Quaternion rotation) {
//same scheme as above
...
}(for the other (not mentioned) methods called inside the "UpdatePlacement" method something like this would be also great)
Also I dont know how the client would behave if this logic was changed. But.. lets try?
