public void SetResting(bool isResting) { if (isResting != this.IsResting() & isResting && this.CanMerge()) { List <Collider> list = (List <Collider>)Pool.GetList <Collider>(); Vis.Colliders <Collider>(((Component)this).get_transform().get_position(), 0.5f, list, 512, (QueryTriggerInteraction)2); using (List <Collider> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { BaseEntity baseEntity = ((Component)enumerator.Current).get_gameObject().ToBaseEntity(); if (Object.op_Implicit((Object)baseEntity)) { FireBall server = baseEntity.ToServer <FireBall>(); if (Object.op_Implicit((Object)server) && server.CanMerge() && Object.op_Inequality((Object)server, (Object)this)) { server.Invoke(new Action(this.Extinguish), 1f); server.canMerge = false; this.AddLife(server.TimeLeft() * 0.25f); } } } } // ISSUE: cast to a reference type Pool.FreeList <Collider>((List <M0>&) ref list); } this.SetFlag(BaseEntity.Flags.OnFire, isResting, false, true); }
public Vector3 GetSafeDropPosition(Vector3 position) { var eventRadius = 25f; /* */ RaycastHit hit; position.y += 200f; int blockedMask = LayerMask.GetMask(new[] { "Player (Server)", "Trigger", "Prevent Building" }); List <int> BlockedLayers = new List <int> { (int)Layer.Water, (int)Layer.Construction, (int)Layer.Trigger, (int)Layer.Prevent_Building, (int)Layer.Deployed, (int)Layer.Tree }; if (Physics.Raycast(position, Vector3.down, out hit)) { if (!BlockedLayers.Contains(hit.collider?.gameObject?.layer ?? BlockedLayers[0])) { position.y = Mathf.Max(hit.point.y, TerrainMeta.HeightMap.GetHeight(position)); var colliders = Pool.GetList <Collider>(); Vis.Colliders(position, eventRadius, colliders, blockedMask, QueryTriggerInteraction.Collide); bool blocked = colliders.Count > 0; Pool.FreeList <Collider>(ref colliders); if (!blocked) { return(position); } } } return(Vector3.zero); }
public void SetResting(bool isResting) { if (isResting != this.IsResting() & isResting && this.CanMerge()) { List <Collider> list = Pool.GetList <Collider>(); Vis.Colliders <Collider>(base.transform.position, 0.5f, list, 512, QueryTriggerInteraction.Collide); foreach (Collider collider in list) { BaseEntity baseEntity = collider.gameObject.ToBaseEntity(); if (!baseEntity) { continue; } FireBall server = baseEntity.ToServer <FireBall>(); if (!server || !server.CanMerge() || !(server != this)) { continue; } server.Invoke(new Action(this.Extinguish), 1f); server.canMerge = false; this.AddLife(server.TimeLeft() * 0.25f); } Pool.FreeList <Collider>(ref list); } base.SetFlag(BaseEntity.Flags.OnFire, isResting, false, true); }
public void DoRadialDamage() { List <Collider> obj = Pool.GetList <Collider>(); Vector3 position = base.transform.position + new Vector3(0f, radius * 0.75f, 0f); Vis.Colliders(position, radius, obj, AttackLayers); HitInfo hitInfo = new HitInfo(); hitInfo.DoHitEffects = true; hitInfo.DidHit = true; hitInfo.HitBone = 0u; hitInfo.Initiator = ((creatorEntity == null) ? GameObjectEx.ToBaseEntity(base.gameObject) : creatorEntity); hitInfo.PointStart = base.transform.position; foreach (Collider item in obj) { if (item.isTrigger && (item.gameObject.layer == 29 || item.gameObject.layer == 18)) { continue; } BaseCombatEntity baseCombatEntity = GameObjectEx.ToBaseEntity(item.gameObject) as BaseCombatEntity; if (!(baseCombatEntity == null) && baseCombatEntity.isServer && baseCombatEntity.IsAlive() && (!ignoreNPC || !baseCombatEntity.IsNpc) && baseCombatEntity.IsVisible(position)) { if (baseCombatEntity is BasePlayer) { Effect.server.Run("assets/bundled/prefabs/fx/impacts/additive/fire.prefab", baseCombatEntity, 0u, new Vector3(0f, 1f, 0f), Vector3.up); } hitInfo.PointEnd = baseCombatEntity.transform.position; hitInfo.HitPositionWorld = baseCombatEntity.transform.position; hitInfo.damageTypes.Set(DamageType.Heat, damagePerSecond * tickRate); Interface.CallHook("OnFireBallDamage", this, baseCombatEntity, hitInfo); baseCombatEntity.OnAttacked(hitInfo); } } Pool.FreeList(ref obj); }
private void CommandGetColliders(IPlayer player, string command, string[] args) { var basePlayer = player.Object as BasePlayer; if (basePlayer == null) { return; } float radius; if (args.Length < 1 || !float.TryParse(args[0], out radius)) { radius = 5f; } var output = new List <Collider>(); Vis.Colliders(basePlayer.transform.position, radius, output); var table = new TextTable(); table.AddColumns("name", "class", "is trigger"); foreach (var entry in output) { table.AddRow(entry.name, entry.GetType().FullName, entry.isTrigger.ToString()); } basePlayer.ConsoleMessage(table.ToString()); }
private object CanBuild(Planner plan, Construction prefab) { var player = plan.GetOwnerPlayer(); Vector3 pos = plan.transform.position; if (player != null && !permission.UserHasPermission(player.UserIDString, adminPermission)) { List <Collider> list = new List <Collider>(); Vis.Colliders(pos, 5f, list); for (int x = 0; x < list.Count; x++) { if ((list[x].name.Contains("iceberg") | list[x].name.Contains("ice_berg")) || (blockIceSheet && (list[x].name.Contains("icesheet") | list[x].name.Contains("ice_sheet")))) { if (asBlacklist && listOfPrefabs.Contains(prefab.fullName)) { return(false); } else if (!asBlacklist && listOfPrefabs.Contains(prefab.fullName)) { return(null); } else { return(false); } } } } return(null); }
public static void EntityComponents <T>( Vector3 position, float radius, List <T> list, int layerMask = -1, QueryTriggerInteraction triggerInteraction = 2) where T : EntityComponentBase { List <Collider> list1 = (List <Collider>)Pool.GetList <Collider>(); Vis.Colliders <Collider>(position, radius, list1, layerMask, triggerInteraction); for (int index = 0; index < list1.Count; ++index) { BaseEntity baseEntity = ((Component)list1[index]).get_gameObject().ToBaseEntity(); if (!Object.op_Equality((Object)baseEntity, (Object)null)) { T component = ((Component)baseEntity).get_gameObject().GetComponent <T>(); if (!Object.op_Equality((Object)(object)component, (Object)null)) { list.Add(component); } } } // ISSUE: cast to a reference type Pool.FreeList <Collider>((List <M0>&) ref list1); }
void Update() { var newPosition = entity.GetEstimatedWorldPosition(); if (newPosition == position) // don't continue if the position hasn't changed. this usually only occurs once { return; } if (Vector3.Distance(newPosition, Vector3.zero) < 5f) // entity moved to vector3.zero { return; } var tick = DateTime.Now; position = newPosition; var colliders = Pool.GetList <Collider>(); Vis.Colliders(position, radius, colliders, layerMask, QueryTriggerInteraction.Collide); if (colliders.Count > 0) { foreach (var collider in colliders) { var e = collider.gameObject?.ToBaseEntity() ?? null; if (e == null) { continue; } if (!prefabs.ContainsKey(e.transform.position)) { prefabs.Add(e.transform.position, new EntityInfo() { NetworkID = e.net.ID, OwnerID = e.OwnerID, Position = e.transform.position, ShortPrefabName = e.ShortPrefabName }); updated = true; if (isRocket) { entitiesHit++; } else { entitiesHit = 1; } } } Pool.FreeList <Collider>(ref colliders); } millisecondsTaken += (DateTime.Now - tick).TotalMilliseconds; }
private bool OnGround() { BaseEntity component = GetComponent <BaseEntity>(); if ((bool)component) { Construction construction = PrefabAttribute.server.Find <Construction>(component.prefabID); if ((bool)construction) { Socket_Base[] allSockets = construction.allSockets; for (int i = 0; i < allSockets.Length; i++) { SocketMod[] socketMods = allSockets[i].socketMods; for (int j = 0; j < socketMods.Length; j++) { SocketMod_AreaCheck socketMod_AreaCheck = socketMods[j] as SocketMod_AreaCheck; if ((bool)socketMod_AreaCheck && socketMod_AreaCheck.wantsInside && !socketMod_AreaCheck.DoCheck(component.transform.position, component.transform.rotation)) { if (ConVar.Physics.groundwatchdebug) { Debug.Log("GroundWatch failed: " + socketMod_AreaCheck.hierachyName); } return(false); } } } } } List <Collider> obj = Facepunch.Pool.GetList <Collider>(); Vis.Colliders(base.transform.TransformPoint(groundPosition), radius, obj, layers); foreach (Collider item in obj) { BaseEntity baseEntity = GameObjectEx.ToBaseEntity(item.gameObject); if (!baseEntity || (!(baseEntity == component) && !baseEntity.IsDestroyed && !baseEntity.isClient)) { DecayEntity decayEntity = component as DecayEntity; DecayEntity decayEntity2 = baseEntity as DecayEntity; if (!decayEntity || decayEntity.buildingID == 0 || !decayEntity2 || decayEntity2.buildingID == 0 || decayEntity.buildingID == decayEntity2.buildingID) { Facepunch.Pool.FreeList(ref obj); return(true); } } } if (ConVar.Physics.groundwatchdebug) { Debug.Log("GroundWatch failed: Legacy radius check"); } Facepunch.Pool.FreeList(ref obj); return(false); }
private bool OnGround() { bool flag; BaseEntity component = base.GetComponent <BaseEntity>(); if (component) { Construction construction = PrefabAttribute.server.Find <Construction>(component.prefabID); if (construction) { Socket_Base[] socketBaseArray = construction.allSockets; for (int i = 0; i < (int)socketBaseArray.Length; i++) { SocketMod[] socketModArray = socketBaseArray[i].socketMods; for (int j = 0; j < (int)socketModArray.Length; j++) { SocketMod_AreaCheck socketModAreaCheck = socketModArray[j] as SocketMod_AreaCheck; if (socketModAreaCheck && socketModAreaCheck.wantsInside && !socketModAreaCheck.DoCheck(component.transform.position, component.transform.rotation)) { return(false); } } } } } List <Collider> list = Pool.GetList <Collider>(); Vis.Colliders <Collider>(base.transform.TransformPoint(this.groundPosition), this.radius, list, this.layers, QueryTriggerInteraction.Collide); List <Collider> .Enumerator enumerator = list.GetEnumerator(); try { while (enumerator.MoveNext()) { BaseEntity baseEntity = enumerator.Current.gameObject.ToBaseEntity(); if (baseEntity && (baseEntity == component || baseEntity.IsDestroyed || baseEntity.isClient)) { continue; } Pool.FreeList <Collider>(ref list); flag = true; return(flag); } Pool.FreeList <Collider>(ref list); return(false); } finally { ((IDisposable)enumerator).Dispose(); } return(flag); }
BuildingPrivlidge GetCupboard(BaseCombatEntity ent) { var position = ent.GetNetworkPosition(); List <SphereCollider> colliders = new List <SphereCollider>(); Vis.Colliders(position, cupboardRadius, colliders, -1, QueryTriggerInteraction.Collide); var privlidges = colliders.Where(p => p.transform.parent?.name == "assets/prefabs/deployable/tool cupboard/cupboard.tool.deployed.prefab").ToList(); if (privlidges.Count > 0) { return(privlidges[0].transform.parent.GetComponent <BuildingPrivlidge>()); } return(null); }
public static void Components <T>(OBB bounds, List <T> list, int layerMask = -1, QueryTriggerInteraction triggerInteraction = 2) where T : Component { List <Collider> colliders = Pool.GetList <Collider>(); Vis.Colliders <Collider>(bounds, colliders, layerMask, triggerInteraction); for (int i = 0; i < colliders.Count; i++) { T component = colliders[i].gameObject.GetComponent <T>(); if (component != null) { list.Add(component); } } Pool.FreeList <Collider>(ref colliders); }
public static void Entities <T>(OBB bounds, List <T> list, int layerMask = -1, QueryTriggerInteraction triggerInteraction = 2) where T : BaseEntity { List <Collider> colliders = Pool.GetList <Collider>(); Vis.Colliders <Collider>(bounds, colliders, layerMask, triggerInteraction); for (int i = 0; i < colliders.Count; i++) { T baseEntity = (T)(colliders[i].gameObject.ToBaseEntity() as T); if (baseEntity != null) { list.Add(baseEntity); } } Pool.FreeList <Collider>(ref colliders); }
private bool OnGround() { BaseEntity component = (BaseEntity)((Component)this).GetComponent <BaseEntity>(); if (Object.op_Implicit((Object)component)) { Construction construction = PrefabAttribute.server.Find <Construction>(component.prefabID); if ((bool)((PrefabAttribute)construction)) { foreach (Socket_Base allSocket in construction.allSockets) { foreach (SocketMod socketMod in allSocket.socketMods) { SocketMod_AreaCheck socketModAreaCheck = socketMod as SocketMod_AreaCheck; if ((bool)((PrefabAttribute)socketModAreaCheck) && socketModAreaCheck.wantsInside && !socketModAreaCheck.DoCheck(((Component)component).get_transform().get_position(), ((Component)component).get_transform().get_rotation())) { return(false); } } } } } List <Collider> list = (List <Collider>)Pool.GetList <Collider>(); Vis.Colliders <Collider>(((Component)this).get_transform().TransformPoint(this.groundPosition), this.radius, list, LayerMask.op_Implicit(this.layers), (QueryTriggerInteraction)2); using (List <Collider> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { BaseEntity baseEntity = ((Component)enumerator.Current).get_gameObject().ToBaseEntity(); if (!Object.op_Implicit((Object)baseEntity) || !Object.op_Equality((Object)baseEntity, (Object)component) && !baseEntity.IsDestroyed && !baseEntity.isClient) { // ISSUE: cast to a reference type Pool.FreeList <Collider>((List <M0>&) ref list); return(true); } } } // ISSUE: cast to a reference type Pool.FreeList <Collider>((List <M0>&) ref list); return(false); }
public static void EntityComponents <T>(Vector3 position, float radius, List <T> list, int layerMask = -1, QueryTriggerInteraction triggerInteraction = 2) where T : EntityComponentBase { List <Collider> colliders = Pool.GetList <Collider>(); Vis.Colliders <Collider>(position, radius, colliders, layerMask, triggerInteraction); for (int i = 0; i < colliders.Count; i++) { BaseEntity baseEntity = colliders[i].gameObject.ToBaseEntity(); if (baseEntity != null) { T component = baseEntity.gameObject.GetComponent <T>(); if (component != null) { list.Add(component); } } } Pool.FreeList <Collider>(ref colliders); }
private string CanTeleportToPosition(BasePlayer player, Vector3 position) { List <Collider> colliders = Facepunch.Pool.GetList <Collider>(); Vis.Colliders(position, 0.1f, colliders, triggerLayer); foreach (Collider collider in colliders) { BuildingPrivlidge tc = collider.GetComponentInParent <BuildingPrivlidge>(); if (tc == null) { continue; } if (!tc.IsAuthed(player)) { Facepunch.Pool.FreeList(ref colliders); return("building blocked"); } } return(null); }
public bool CanStand() { if (nextStandTime > UnityEngine.Time.time) { return(false); } if (mountPoints[0].mountable == null) { return(false); } bool flag = false; List <Collider> obj = Facepunch.Pool.GetList <Collider>(); Vis.Colliders(mountPoints[0].mountable.eyeOverride.transform.position - base.transform.forward * 1f, 2f, obj, 2162689); if (obj.Count > 0) { flag = true; } Facepunch.Pool.FreeList(ref obj); return(!flag); }
bool OnShelves(BaseEntity entity) { GroundWatch component = entity.gameObject.GetComponent <GroundWatch>(); List <Collider> list = Facepunch.Pool.GetList <Collider>(); Vis.Colliders <Collider>(entity.transform.TransformPoint(component.groundPosition), component.radius, list, component.layers, QueryTriggerInteraction.Collide); foreach (Collider collider in list) { if (!((Object)collider.transform.root == (Object)entity.gameObject.transform.root)) { BaseEntity baseEntity = collider.gameObject.ToBaseEntity(); if ((!(bool)((Object)baseEntity) || !baseEntity.IsDestroyed && !baseEntity.isClient) && baseEntity.ShortPrefabName == "shelves") { Facepunch.Pool.FreeList <Collider>(ref list); return(true); } } } Facepunch.Pool.FreeList <Collider>(ref list); return(false); }
public bool CanStand() { if (this.nextStandTime > Time.time) { return(false); } if (this.mountPoints[0].mountable == null) { return(false); } bool flag = false; List <Collider> list = Pool.GetList <Collider>(); Vis.Colliders <Collider>(this.mountPoints[0].mountable.eyeOverride.transform.position - (base.transform.forward * 1f), 2f, list, 2162689, QueryTriggerInteraction.Collide); if (list.Count > 0) { flag = true; } Pool.FreeList <Collider>(ref list); return(!flag); }
public void WakeNearbyRigidbodies() { List <Collider> obj = Facepunch.Pool.GetList <Collider>(); Vis.Colliders(base.transform.position, 7f, obj, 34816); foreach (Collider item in obj) { Rigidbody attachedRigidbody = item.attachedRigidbody; if (attachedRigidbody != null && attachedRigidbody.IsSleeping()) { attachedRigidbody.WakeUp(); } BaseEntity baseEntity = GameObjectEx.ToBaseEntity(item); BaseRidableAnimal baseRidableAnimal; if (baseEntity != null && (object)(baseRidableAnimal = baseEntity as BaseRidableAnimal) != null && baseRidableAnimal.isServer) { baseRidableAnimal.UpdateDropToGroundForDuration(2f); } } Facepunch.Pool.FreeList(ref obj); }
public static void Entities <T>( OBB bounds, List <T> list, int layerMask = -1, QueryTriggerInteraction triggerInteraction = 2) where T : BaseEntity { List <Collider> list1 = (List <Collider>)Pool.GetList <Collider>(); Vis.Colliders <Collider>(bounds, list1, layerMask, triggerInteraction); for (int index = 0; index < list1.Count; ++index) { T baseEntity = ((Component)list1[index]).get_gameObject().ToBaseEntity() as T; if (!Object.op_Equality((Object)(object)baseEntity, (Object)null)) { list.Add(baseEntity); } } // ISSUE: cast to a reference type Pool.FreeList <Collider>((List <M0>&) ref list1); }
private bool HasPriv(BasePlayer player) { var colliders = Pool.GetList <Collider>(); Vis.Colliders(player.transform.position + new Vector3(0, player.bounds.max.y, 0), 0.2f, colliders, LayerMask.GetMask("Trigger")); foreach (var collider in colliders) { if (collider.gameObject != null && collider.gameObject.name == "areaTrigger" && collider.gameObject.layer == 18) { var cupboard = collider.gameObject.GetComponentInParent <BuildingPrivlidge>(); if (cupboard != null) { if (cupboard.IsAuthed(player)) { return(true); } } } } Pool.FreeList(ref colliders); return(false); }
public void DoRadialDamage() { List <Collider> list = (List <Collider>)Pool.GetList <Collider>(); Vector3 position = Vector3.op_Addition(((Component)this).get_transform().get_position(), new Vector3(0.0f, this.radius * 0.75f, 0.0f)); Vis.Colliders <Collider>(position, this.radius, list, LayerMask.op_Implicit(this.AttackLayers), (QueryTriggerInteraction)2); HitInfo info = new HitInfo(); info.DoHitEffects = true; info.DidHit = true; info.HitBone = 0U; info.Initiator = Object.op_Equality((Object)this.creatorEntity, (Object)null) ? ((Component)this).get_gameObject().ToBaseEntity() : this.creatorEntity; info.PointStart = ((Component)this).get_transform().get_position(); using (List <Collider> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { Collider current = enumerator.Current; if (!current.get_isTrigger() || ((Component)current).get_gameObject().get_layer() != 29 && ((Component)current).get_gameObject().get_layer() != 18) { BaseCombatEntity baseEntity = ((Component)current).get_gameObject().ToBaseEntity() as BaseCombatEntity; if (!Object.op_Equality((Object)baseEntity, (Object)null) && baseEntity.isServer && (baseEntity.IsAlive() && baseEntity.IsVisible(position, float.PositiveInfinity))) { if (baseEntity is BasePlayer) { Effect.server.Run("assets/bundled/prefabs/fx/impacts/additive/fire.prefab", (BaseEntity)baseEntity, 0U, new Vector3(0.0f, 1f, 0.0f), Vector3.get_up(), (Connection)null, false); } info.PointEnd = ((Component)baseEntity).get_transform().get_position(); info.HitPositionWorld = ((Component)baseEntity).get_transform().get_position(); info.damageTypes.Set(DamageType.Heat, this.damagePerSecond * this.tickRate); baseEntity.OnAttacked(info); } } } } // ISSUE: cast to a reference type Pool.FreeList <Collider>((List <M0>&) ref list); }
public void DoRadialDamage() { List <Collider> list = Pool.GetList <Collider>(); Vector3 vector3 = base.transform.position + new Vector3(0f, this.radius * 0.75f, 0f); Vis.Colliders <Collider>(vector3, this.radius, list, this.AttackLayers, QueryTriggerInteraction.Collide); HitInfo hitInfo = new HitInfo() { DoHitEffects = true, DidHit = true, HitBone = 0, Initiator = (this.creatorEntity == null ? base.gameObject.ToBaseEntity() : this.creatorEntity), PointStart = base.transform.position }; foreach (Collider collider in list) { if (collider.isTrigger && (collider.gameObject.layer == 29 || collider.gameObject.layer == 18)) { continue; } BaseCombatEntity baseEntity = collider.gameObject.ToBaseEntity() as BaseCombatEntity; if (baseEntity == null || !baseEntity.isServer || !baseEntity.IsAlive() || !baseEntity.IsVisible(vector3, Single.PositiveInfinity)) { continue; } if (baseEntity is BasePlayer) { Effect.server.Run("assets/bundled/prefabs/fx/impacts/additive/fire.prefab", baseEntity, 0, new Vector3(0f, 1f, 0f), Vector3.up, null, false); } hitInfo.PointEnd = baseEntity.transform.position; hitInfo.HitPositionWorld = baseEntity.transform.position; hitInfo.damageTypes.Set(DamageType.Heat, this.damagePerSecond * this.tickRate); baseEntity.OnAttacked(hitInfo); } Pool.FreeList <Collider>(ref list); }
private object CanBuild(Planner plan, Construction prefab) { var player = plan.GetOwnerPlayer(); Vector3 pos = plan.transform.position; if (player != null && !permission.UserHasPermission(player.UserIDString, adminPermission)) { List <Collider> list = new List <Collider>(); Vis.Colliders(pos, 5f, list); if (list.Any(x => config.BlockedColliders.Any(x.name.StartsWith))) { if (config.blacklist.Prefabs.Length > 0) { bool contains = config.blacklist.Prefabs.Contains(prefab.fullName); if ((config.blacklist._Blacklist && !contains) || (!config.blacklist._Blacklist && contains)) { return(null); } } return(false); } } return(null); }
public void SetResting(bool isResting) { if (isResting != IsResting() && isResting && TimeAlive() > 1f && CanMerge()) { List <Collider> obj = Pool.GetList <Collider>(); Vis.Colliders(base.transform.position, 0.5f, obj, 512); foreach (Collider item in obj) { BaseEntity baseEntity = GameObjectEx.ToBaseEntity(item.gameObject); if ((bool)baseEntity) { FireBall fireBall = baseEntity.ToServer <FireBall>(); if ((bool)fireBall && fireBall.CanMerge() && fireBall != this) { fireBall.Invoke(Extinguish, 1f); fireBall.canMerge = false; AddLife(fireBall.TimeLeft() * 0.25f); } } } Pool.FreeList(ref obj); } SetFlag(Flags.OnFire, isResting); }