CanBeTargeted
OxidePlayerobject CanBeTargeted(BaseCombatEntity obj, AutoTurret autoTurret)
object CanBeTargeted(BaseCombatEntity potentialtarget, HelicopterTurret helicopterTurret)
object CanBeTargeted(BasePlayer basePlayer, FlameTurret flameTurret)
object CanBeTargeted(BasePlayer basePlayer, object this => l2)
object CanBeTargeted()Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.
Parameters
- obj
- BaseCombatEntity
- autoTurret
- AutoTurret
Return value
objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.
Example
object — you can affect the game: return a value to change or cancel the action.
private object CanBeTargeted(BaseCombatEntity obj, AutoTurret autoTurret)
{
Puts("CanBeTargeted");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return null; // null — the game continues as usual
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
bool AutoTurret.ObjectVisible(BaseCombatEntity)
Passes: BaseCombatEntity obj, AutoTurret autoTurret
Method changed — checkReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0, this)Assembly-CSharp.dll
Where it is called (this branch's game code)
public bool ObjectVisible(BaseCombatEntity obj)
{
object returnvar = Interface.CallHook("CanBeTargeted", obj, this);
if (returnvar is bool)
{
return (bool)returnvar;
}
Vector3 position = eyePos.transform.position;
if (GamePhysics.CheckSphere(position, 0.1f, 136314880))
{
return false;
// …Injection point 2
Rust.opj (Oxide)
bool HelicopterTurret.InFiringArc(BaseCombatEntity)
Passes: BaseCombatEntity potentialtarget, HelicopterTurret helicopterTurret
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0, this)Assembly-CSharp.dll
Where it is called (this branch's game code)
public bool InFiringArc(BaseCombatEntity potentialtarget)
{
object returnvar = Interface.CallHook("CanBeTargeted", potentialtarget, this);
if (returnvar is bool)
{
return (bool)returnvar;
}
return AngleToTarget(potentialtarget) < 80f;
}Injection point 3
Rust.opj (Oxide)
bool FlameTurret.CheckTrigger()
Passes: BasePlayer basePlayer, FlameTurret flameTurret
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (l7, this)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
IPrivilege privilege = null;
foreach (BaseEntity item in entityContents)
{
BasePlayer basePlayer = item as BasePlayer;
if (basePlayer == null || basePlayer.IsSleeping() || !basePlayer.IsAlive() || basePlayer.transform.position.y > GetEyePosition().y + 0.5f)
{
continue;
}
object returnvar = Interface.CallHook("CanBeTargeted", basePlayer, this);
if (returnvar is bool)
{
return (bool)returnvar;
}
if (!flag2)
{
flag2 = true;
privilege = GetCachedPrivilege();
// …Injection point 4
Rust.opj (Oxide)
bool GunTrap.CheckTrigger()
Passes: BasePlayer basePlayer, object this => l2
WorksReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (l7, this => l2)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
IPrivilege privilege = null;
foreach (BaseEntity item in entityContents)
{
BasePlayer basePlayer = item as BasePlayer;
if (basePlayer == null || basePlayer.IsSleeping() || !basePlayer.IsAlive())
{
continue;
}
Interface.CallHook("CanBeTargeted", basePlayer, this => l2);
if (!flag2)
{
flag2 = true;
privilege = GetCachedPrivilege();
}
if (privilege != null && privilege.IsAuthed(basePlayer))
{
continue;
// …Injection point 5
Rust.opj (Oxide)
bool GunTrap.CheckTrigger()
Passes: —
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
{
continue;
}
if (!flag2)
{
flag2 = true;
privilege = GetCachedPrivilege();
}
object result = Interface.CallHook("CanBeTargeted");
// … проверка результата (Modify-хук, см. Rust.opj)
if (privilege != null && privilege.IsAuthed(basePlayer))
{
continue;
}
if (obj == null)
{
obj = Pool.Get<List<RaycastHit>>();
// …Injection point 6
Rust.opj (Oxide)
bool GunTrap.CheckTrigger()
Passes: —
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
{
continue;
}
if (!flag2)
{
flag2 = true;
privilege = GetCachedPrivilege();
}
object result = Interface.CallHook("CanBeTargeted");
// … проверка результата (Modify-хук, см. Rust.opj)
if (privilege != null && privilege.IsAuthed(basePlayer))
{
continue;
}
if (obj == null)
{
obj = Pool.Get<List<RaycastHit>>();
// …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.