OnEntityVisibilityCheck
OxideCarbonEntityCalled when entity visibility check occurs.
object OnEntityVisibilityCheck(BaseEntity ent, BasePlayer player, uint id, string debugName, float maximumDistance)Works — the game method in this build is the one the hook was written for.
Parameters
- ent
- BaseEntity
- player
- BasePlayer
- id
- uint
- debugName
- string
- maximumDistance
- float
Return value
objectThe returned value replaces the game result; null lets the game decide.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnEntityVisibilityCheck(BaseEntity ent, BasePlayer player, uint id, string debugName, float maximumDistance)
{
Puts("OnEntityVisibilityCheck");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // your value instead of the game result
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
bool BaseEntity.RPC_Server.IsVisible.Test(uint, string, BaseEntity, BasePlayer, float)
Passes: BaseEntity ent, BasePlayer player, uint id, string debugName, float maximumDistance
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a2, a3, a0, a1, a4)Assembly-CSharp.dll
Where it is called (this branch's game code)
public static bool Test(uint id, string debugName, BaseEntity ent, BasePlayer player, float maximumDistance)
{
if (ent == null || player == null)
{
return false;
}
object returnvar = Interface.CallHook("OnEntityVisibilityCheck", ent, player, id, debugName, maximumDistance);
if (returnvar is bool)
{
return (bool)returnvar;
}
if (GamePhysics.LineOfSight(player.eyes.center, player.eyes.position, 1218519041))
{
if (!ent.IsVisible(player.eyes.HeadRay(), 1218519041, maximumDistance))
{
// …Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.