protected bool ValidateEyePos(BasePlayer player, Vector3 eyePos) { bool flag = true; if (Vector3Ex.IsNaNOrInfinity(eyePos)) { string shortPrefabName = this.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Contains NaN (" + shortPrefabName + ")"); player.stats.combat.Log(this, "eye_nan"); flag = false; } if (ConVar.AntiHack.eye_protection > 0) { float num1 = 1f + ConVar.AntiHack.eye_forgiveness; double eyeClientframes = (double)ConVar.AntiHack.eye_clientframes; float eyeServerframes = ConVar.AntiHack.eye_serverframes; float num2 = (float)(eyeClientframes / 60.0); float num3 = eyeServerframes * Mathx.Max(Time.get_deltaTime(), Time.get_smoothDeltaTime(), Time.get_fixedDeltaTime()); float num4 = (player.desyncTime + num2 + num3) * num1; if (ConVar.AntiHack.eye_protection >= 1) { double num5 = (double)player.MaxVelocity(); Vector3 parentVelocity = player.GetParentVelocity(); double magnitude = (double)((Vector3) ref parentVelocity).get_magnitude(); float num6 = (float)(num5 + magnitude); float num7 = player.BoundsPadding() + num4 * num6; float num8 = Vector3.Distance(player.eyes.position, eyePos); if ((double)num8 > (double)num7) { string shortPrefabName = this.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Distance (" + shortPrefabName + " on attack with " + (object)num8 + "m > " + (object)num7 + "m)"); player.stats.combat.Log(this, "eye_distance"); flag = false; } } if (ConVar.AntiHack.eye_protection >= 2) { Vector3 center = player.eyes.center; Vector3 position = player.eyes.position; Vector3 p2 = eyePos; if (!GamePhysics.LineOfSight(center, position, p2, 2162688, 0.0f)) { string shortPrefabName = this.ShortPrefabName; AntiHack.Log(player, AntiHackType.EyeHack, "Line of sight (" + shortPrefabName + " on attack) " + (object)center + " " + (object)position + " " + (object)p2); player.stats.combat.Log(this, "eye_los"); flag = false; } } if (!flag) { AntiHack.AddViolation(player, AntiHackType.EyeHack, ConVar.AntiHack.eye_penalty); } } return(flag); }
internal bool IsInside(Vector3 vPos) { return(!Vector3Ex.IsNaNOrInfinity(vPos) && ((Bounds) ref this.worldBounds).Contains(vPos) && (!Object.op_Inequality((Object)TerrainMeta.Terrain, (Object)null) || vPos.y >= TerrainMeta.Position.y && !TerrainMeta.OutOfMargin(vPos))); }
public void DoBuild(Construction.Target target, Construction component) { BasePlayer ownerPlayer = this.GetOwnerPlayer(); if (!Object.op_Implicit((Object)ownerPlayer) || target.ray.IsNaNOrInfinity() || (Vector3Ex.IsNaNOrInfinity(target.position) || Vector3Ex.IsNaNOrInfinity(target.normal))) { return; } if ((PrefabAttribute)target.socket != (PrefabAttribute)null) { if (!target.socket.female) { ownerPlayer.ChatMessage("Target socket is not female. (" + target.socket.socketName + ")"); return; } if (Object.op_Inequality((Object)target.entity, (Object)null) && target.entity.IsOccupied(target.socket)) { ownerPlayer.ChatMessage("Target socket is occupied. (" + target.socket.socketName + ")"); return; } } else if (ConVar.AntiHack.eye_protection >= 2) { Vector3 center = ownerPlayer.eyes.center; Vector3 position1 = ownerPlayer.eyes.position; Vector3 origin = ((Ray) ref target.ray).get_origin(); Vector3 position2 = target.position; Vector3 p1 = position1; Vector3 p2 = origin; Vector3 p3 = position2; if (!GamePhysics.LineOfSight(center, p1, p2, p3, 2162688, 0.01f)) { ownerPlayer.ChatMessage("Line of sight blocked."); return; } } Construction.lastPlacementError = "No Error"; GameObject go = this.DoPlacement(target, component); if (Object.op_Equality((Object)go, (Object)null)) { ownerPlayer.ChatMessage("Can't place: " + Construction.lastPlacementError); } if (!Object.op_Inequality((Object)go, (Object)null)) { return; } Interface.CallHook("OnEntityBuilt", (object)this, (object)go); Deployable deployable = this.GetDeployable(); if ((PrefabAttribute)deployable != (PrefabAttribute)null) { BaseEntity baseEntity = go.ToBaseEntity(); if (deployable.setSocketParent && Object.op_Inequality((Object)target.entity, (Object)null) && (target.entity.SupportsChildDeployables() && Object.op_Implicit((Object)baseEntity))) { baseEntity.SetParent(target.entity, true, false); } if (deployable.wantsInstanceData && this.GetOwnerItem().instanceData != null) { (baseEntity as IInstanceDataReceiver).ReceiveInstanceData(this.GetOwnerItem().instanceData); } if (deployable.copyInventoryFromItem) { StorageContainer component1 = (StorageContainer)((Component)baseEntity).GetComponent <StorageContainer>(); if (Object.op_Implicit((Object)component1)) { component1.ReceiveInventoryFromItem(this.GetOwnerItem()); } } ItemModDeployable modDeployable = this.GetModDeployable(); if (Object.op_Inequality((Object)modDeployable, (Object)null)) { modDeployable.OnDeployed(baseEntity, ownerPlayer); } } this.PayForPlacement(ownerPlayer, component); }
public bool IsNaNOrInfinity() { return(Vector3Ex.IsNaNOrInfinity(this.PointStart) || Vector3Ex.IsNaNOrInfinity(this.PointEnd) || (Vector3Ex.IsNaNOrInfinity(this.HitPositionWorld) || Vector3Ex.IsNaNOrInfinity(this.HitPositionLocal)) || (Vector3Ex.IsNaNOrInfinity(this.HitNormalWorld) || Vector3Ex.IsNaNOrInfinity(this.HitNormalLocal) || (Vector3Ex.IsNaNOrInfinity(this.ProjectileVelocity) || float.IsNaN(this.ProjectileDistance))) || float.IsInfinity(this.ProjectileDistance)); }