// get zone entities from existing zone, returning zoneShape "undef" signals failure HashSet <BuildingBlock> getZoneEntities(BasePlayer player, string zoneId, out Option zoneShape) { HashSet <BuildingBlock> structure = new HashSet <BuildingBlock>(); // get zone information Dictionary <string, string> zoneInfo = (Dictionary <string, string>)ZoneManager?.Call("ZoneFieldList", new object[] { zoneId }); if (zoneInfo == null || zoneInfo.Count() == 0) { // failed to find zone - send message, flag zoneShape as undef SendReply(player, wrapSize(12, wrapColor("red", String.Format(GetMessage("ZoneNotFound"), zoneId)))); zoneShape = Option.undef; return(null); } // get zone values Vector3 zoneLocation = parseVector3(zoneInfo["Location"]); Vector3 zoneSize = parseVector3(zoneInfo["size"]); Vector3 rotation = parseVector3(zoneInfo["rotation"]); float zoneRadius = Convert.ToSingle(zoneInfo["radius"]); List <BaseEntity> list = Pool.GetList <BaseEntity>(); // find intersecting entities if (zoneSize != Vector3.zero) { zoneShape = Option.box; BoxEntities <BaseEntity>(zoneLocation, zoneSize / 2f, Quaternion.Euler(rotation), list, layerMasks); } else { zoneShape = Option.sphere; Vis.Entities <BaseEntity>(zoneLocation, zoneRadius, list, layerMasks); } // add building blocks to structure set BuildingBlock fbuildingblock; for (int i = 0; i < list.Count; i++) { BaseEntity hit = list[i]; if (hit.GetComponentInParent <BuildingBlock>() != null) { fbuildingblock = hit.GetComponentInParent <BuildingBlock>(); if (!(structure.Contains(fbuildingblock))) { structure.Add(fbuildingblock); } } } return(structure); }
public void BuildingCheck() { List <DecayEntity> obj = Pool.GetList <DecayEntity>(); Vis.Entities(WorldSpaceBounds(), obj, 2097152); foreach (DecayEntity item in obj) { if (item.isServer && item.IsAlive()) { item.Kill(DestroyMode.Gib); } } Pool.FreeList(ref obj); }
public static void PhysicsChanged(Vector3 origin, float radius, int layerMask) { List <BaseEntity> obj = Facepunch.Pool.GetList <BaseEntity>(); Vis.Entities(origin, radius, obj, layerMask); foreach (BaseEntity item in obj) { if (!item.IsDestroyed && !item.isClient && !(item is BuildingBlock)) { item.BroadcastMessage("OnPhysicsNeighbourChanged", SendMessageOptions.DontRequireReceiver); } } Facepunch.Pool.FreeList(ref obj); }
void playerBlastDamage(BasePlayer player, float damageamount, Rust.DamageType damagetype, HitInfo hitInfo) { List <BaseCombatEntity> playerlist = new List <BaseCombatEntity>(); Vis.Entities <BaseCombatEntity>(hitInfo.HitPositionWorld, DamageRadius, playerlist); foreach (BaseCombatEntity p in playerlist) { if (!(p is BuildingPrivlidge)) { p.Hurt(damageamount, damagetype, player, UseProt); } } }
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 void drawZ(Graphics g, functionType function) { graphics = g; Point2D prevPoint, leftPoint = new Point2D(NULL, NULL), rigthPoint = new Point2D(NULL, NULL); for (double currentZ = zMax; currentZ >= zMin; currentZ -= zStep) { double y; y = function(xMin, currentZ); prevPoint = c3Dto2D(xMin, y, currentZ); DrawifOK(prevPoint, ref leftPoint); if (!(CheckPoint(prevPoint) && CheckPoint(leftPoint))) { continue; } Vis prevVisible = CheckVis(prevPoint); Point2D currentPoint = new Point2D(); for (double currentX = xMin; currentX <= xMax; currentX += xStep) { cur = false; if (currentX > xMax - zStep / 2) { // cur = true; } y = function(currentX, currentZ); currentPoint = c3Dto2D(currentX, y, currentZ); if (!CheckPoint(currentPoint)) { continue; } Vis currentVisibily = CheckVis(currentPoint); if (currentVisibily == prevVisible) { if (currentVisibily == Vis.lower || currentVisibily == Vis.upper) { DrawLine(prevPoint, currentPoint); Smooth(prevPoint, currentPoint); } prevVisible = currentVisibily; prevPoint = currentPoint; } DrawifOK(currentPoint, ref rigthPoint); } } }
// determine if player is in range of a repair bench or research table bool IsPlayerInRange(BasePlayer player) { List <StorageContainer> entities = new List <StorageContainer>(); Vis.Entities(player.transform.position, ConfigValue <float>(Option.proximity), entities); foreach (StorageContainer e in entities) { if ((ConfigValue <bool>(Option.useRepairBench) && e is RepairBench) || (ConfigValue <bool>(Option.useResearchTable) && e is ResearchTable)) { return(true); } } return(false); }
public NPCShopKeeper GetNPCShopKeeper() { List <NPCShopKeeper> obj = Pool.GetList <NPCShopKeeper>(); Vis.Entities(base.transform.position, 2f, obj, 131072); NPCShopKeeper result = null; if (obj.Count > 0) { result = obj[0]; } Pool.FreeList(ref obj); return(result); }
// Kill minicopter hook private void KillMyMinicopterPlease(BasePlayer player) { bool foundcopter = false; if (mindistance == 0f) { foundcopter = true; } else { List <BaseEntity> copterlist = new List <BaseEntity>(); Vis.Entities <BaseEntity>(player.transform.position, mindistance, copterlist); foreach (BaseEntity p in copterlist) { var foundent = p.GetComponentInParent <MiniCopter>() ?? null; if (foundent != null) { foundcopter = true; } } } if (storedData.playerminiID.ContainsKey(player.userID) == true && foundcopter) { uint deluint; storedData.playerminiID.TryGetValue(player.userID, out deluint); var tokill = BaseNetworkable.serverEntities.Find(deluint); if (tokill != null) { tokill.Kill(BaseNetworkable.DestroyMode.Gib); } storedData.playerminiID.Remove(player.userID); var myKey = currentMounts.FirstOrDefault(x => x.Value == player.userID).Key; currentMounts.Remove(myKey); if (storedData.playercounter.ContainsKey(player.userID) & !useCooldown) { storedData.playercounter.Remove(player.userID); } SaveData(); } else if (foundcopter == false) { #if DEBUG Puts($"Player too far from copter to destroy."); #endif PrintMsgL(player, "DistanceMsg", mindistance); } }
public List <T> GetRecords <T>(MemoryStream stream) where T : ICsvReadable, new() { using var vis = new Vis <T>(_activationMethod); if (stream.TryGetBuffer(out var buf)) { CsvSyncInput.ForMemory(buf).Process(vis); } else { CsvSyncInput.ForStream(stream).Process(vis); } return(vis.Records); }
public NPCShopKeeper GetNPCShopKeeper() { List <NPCShopKeeper> list = Pool.GetList <NPCShopKeeper>(); Vis.Entities <NPCShopKeeper>(base.transform.position, 2f, list, 131072, QueryTriggerInteraction.Collide); NPCShopKeeper item = null; if (list.Count > 0) { item = list[0]; } Pool.FreeList <NPCShopKeeper>(ref list); return(item); }
public void Remove() { if (!_created) { return; } #if DEBUG Interface.Oxide.LogWarning($"Removing portal {ID}"); #endif if (Primary.Wheel != null) { if (!Primary.Wheel.IsDestroyed) { Primary.Wheel.Kill(); } if (!Primary.Sphere.IsDestroyed) { Primary.Sphere.Kill(); } } UnityEngine.Object.Destroy(Primary.GameObject); if (Secondary.Wheel != null) { if (!Secondary.Wheel.IsDestroyed) { Secondary.Wheel.Kill(); } if (!Secondary.Sphere.IsDestroyed) { Secondary.Sphere.Kill(); } } UnityEngine.Object.Destroy(Secondary.GameObject); List <SpinnerWheel> wheels = new List <SpinnerWheel>(); Vis.Entities(Primary.Location.Vector3, 0.05f, wheels); foreach (var wheel in wheels) { wheel.Kill(); } Vis.Entities(Secondary.Location.Vector3, 0.05f, wheels); foreach (var wheel in wheels) { wheel.Kill(); } _created = false; }
public void UpdateTargetList() { List <BaseEntity> list = Facepunch.Pool.GetList <BaseEntity>(); Vis.Entities <BaseEntity>(base.transform.position, this.searchRange, list, 133120, QueryTriggerInteraction.Collide); foreach (BaseEntity baseEntity in list) { if (!(baseEntity is BasePlayer)) { continue; } BasePlayer basePlayer = baseEntity as BasePlayer; if (basePlayer.IsDead() || basePlayer is Scientist || !this.VisibilityTest(baseEntity)) { continue; } bool flag = false; foreach (BradleyAPC.TargetInfo targetInfo in this.targetList) { if (targetInfo.entity != baseEntity) { continue; } targetInfo.lastSeenTime = UnityEngine.Time.time; flag = true; goto Label0; } Label0: if (flag) { continue; } BradleyAPC.TargetInfo targetInfo1 = Facepunch.Pool.Get <BradleyAPC.TargetInfo>(); targetInfo1.Setup(baseEntity, UnityEngine.Time.time); this.targetList.Add(targetInfo1); } for (int i = this.targetList.Count - 1; i >= 0; i--) { BradleyAPC.TargetInfo item = this.targetList[i]; BasePlayer basePlayer1 = item.entity as BasePlayer; if (item.entity == null || UnityEngine.Time.time - item.lastSeenTime > this.memoryDuration || basePlayer1.IsDead()) { this.targetList.Remove(item); Facepunch.Pool.Free <BradleyAPC.TargetInfo>(ref item); } } Facepunch.Pool.FreeList <BaseEntity>(ref list); this.targetList.Sort(new Comparison <BradleyAPC.TargetInfo>(this.SortTargets)); }
void AddSphere(BasePlayer player, bool showall, bool adminshow) { if (isAllowed(player, "visualcupboard.allowed") || isAllowed(player, "visualcupboard.admin")) { List <BaseCombatEntity> cblist = new List <BaseCombatEntity>(); Vis.Entities <BaseCombatEntity>(player.transform.position, ShowCupboardsWithinRangeOf, cblist); foreach (BaseCombatEntity bp in cblist) { if (bp is BuildingPrivlidge) { if (bp.GetComponent <ToolCupboardSphere>() == null) { Vector3 pos = bp.transform.position; if (!adminshow) { if (player.userID == bp.OwnerID) { for (int i = 0; i < VisualDarkness; i++) { sphereobj = bp.gameObject.AddComponent <ToolCupboardSphere>(); if (showall) { sphereobj.showall = true; } GameManager.Destroy(sphereobj, DurationToShowRadius); } } } if (adminshow) { for (int i = 0; i < VisualDarkness; i++) { sphereobj = bp.gameObject.AddComponent <ToolCupboardSphere>(); sphereobj.showall = true; GameManager.Destroy(sphereobj, DurationToShowRadius); } player.SendConsoleCommand("ddraw.text", 10f, Color.red, pos + Vector3.up, FindPlayerName(bp.OwnerID)); PrintWarning("Tool Cupboard Owner " + bp.OwnerID + " : " + FindPlayerName(bp.OwnerID)); } } } } return; } SendReply(player, lang.GetMessage("notallowed", this)); return; }
private void CheckForSpawns() { if (configData.Spawnable.Enabled) { if (saveableCars.Count < configData.Spawnable.Max) { object position = null; if (!Spawns) { PrintError("Spawns Database can not be found! Unable to autospawn cars"); return; } object success = Spawns.Call("GetSpawnsCount", configData.Spawnable.Spawnfile); if (success is string) { PrintError("An invalid spawnfile has been set in the config. Unable to autospawn cars : " + (string)success); return; } success = Spawns.Call("GetRandomSpawn", configData.Spawnable.Spawnfile); if (success is string) { PrintError((string)success); return; } else { position = (Vector3)success; } if (position != null) { List <BaseCar> entities = Facepunch.Pool.GetList <BaseCar>(); Vis.Entities((Vector3)position, 5f, entities); if (entities.Count > 0) { timer.In(60, CheckForSpawns); } else { SpawnAtLocation((Vector3)position, new Quaternion(), true); timer.In(configData.Spawnable.Time, CheckForSpawns); } Facepunch.Pool.FreeList(ref entities); } } } }
// Make sure nothing is clipping into recycler. Pretty hacky method, but the recycler doesn't block things like other deployables. object CanBuild(Planner plan, Construction prefab, Vector3 position) { BasePlayer player = plan.GetOwnerPlayer(); List <Recycler> recyclers = new List <Recycler>(); Vis.Entities(position, prefab.bounds.size.magnitude / 3f, recyclers, 1 << (int)Layer.Deployed); if (recyclers.Count <= 0) { return(null); } return(true); }
public NPCShopKeeper GetNPCShopKeeper() { List <NPCShopKeeper> list = (List <NPCShopKeeper>)Pool.GetList <NPCShopKeeper>(); Vis.Entities <NPCShopKeeper>(((Component)this).get_transform().get_position(), 2f, list, 131072, (QueryTriggerInteraction)2); NPCShopKeeper npcShopKeeper = (NPCShopKeeper)null; if (list.Count > 0) { npcShopKeeper = list[0]; } // ISSUE: cast to a reference type Pool.FreeList <NPCShopKeeper>((List <M0>&) ref list); return(npcShopKeeper); }
public static float CalculateArtificialTemperature(Transform forTransform) { Vector3 position = forTransform.position; List <GrowableHeatSource> obj = Facepunch.Pool.GetList <GrowableHeatSource>(); Vis.Components(position, ConVar.Server.artificialTemperatureGrowableRange, obj, 256); float num = 0f; foreach (GrowableHeatSource item in obj) { num = Mathf.Max(item.ApplyHeat(position), num); } Facepunch.Pool.FreeList(ref obj); return(num); }
public void BuildingCheck() { List <DecayEntity> list = Pool.GetList <DecayEntity>(); Vis.Entities <DecayEntity>(base.WorldSpaceBounds(), list, 2097152, QueryTriggerInteraction.Collide); foreach (DecayEntity decayEntity in list) { if (!decayEntity.isServer || !decayEntity.IsAlive()) { continue; } decayEntity.Kill(BaseNetworkable.DestroyMode.Gib); } Pool.FreeList <DecayEntity>(ref list); }
//朝下运动 //朝下推动时返回最远距离的Gameobjt GameObject Downameobjet() { for (int i = mMapData.Distance; i < mMapData.MapHigh; i++) { if (mMapData.mapData[buttonObjectdown.X_axis, i] != null) { Vector2Int V = Vis.Floattoint(mMapData.mapData[buttonObjectdown.X_axis, i].transform.position); if (FindPostionDown(V, new Vector2Int(V.x, V.y - 1)) != V) { return(mMapData.mapData[buttonObjectdown.X_axis, i]); } } } return(null); }
//检查地图中目标位置是否都已经放置了目标 internal bool TargetCheck() { foreach (GameObject i in Target) { if (i != null) { Vector2Int T = Vis.Floattoint(i.transform.position); if (mapData[T.x, T.y] == null || mapData[T.x, T.y].tag != BoxTag.Box_Target.ToString()) { return(false); } } } return(true); }
//朝左推动时返回最远距离的Gameobjt GameObject LastGameobjet_Left() { for (int i = mMapData.MapWidth - mMapData.Distance; i < mMapData.MapWidth; i += 1) { if (mMapData.mapData[i, buttonObjectleft.Y_axis] != null) { Vector2Int V = Vis.Floattoint(mMapData.mapData[i, buttonObjectleft.Y_axis].transform.position); if (FindPostionLeft(V, new Vector2Int(V.x - 1, V.y)) != V) { return(mMapData.mapData[i, buttonObjectleft.Y_axis]); } } } return(null); }
//朝上运动 //朝上推动时返回最远距离的Gameobject GameObject UPGameobjet() { for (int i = mMapData.Distance - 1; i > -1; i--) { if (mMapData.mapData[buttonObjectup.X_axis, i] != null) { Vector2Int V = Vis.Floattoint(mMapData.mapData[buttonObjectup.X_axis, i].transform.position); if (FindPostionUP(V, new Vector2Int(V.x, V.y + 1)) != V) { return(mMapData.mapData[buttonObjectup.X_axis, i]); } } } return(null); }
public TypeDef(TypeDefTag type, Identifier name, Vis visibility, Lst <TypeRef> derivedFrom, Lst <SrcToken> members, bool isStatic, bool isPartial, bool isAbstract, bool isSealed, Option <Document> document, Lst <AttributeDef> attributes, Lst <Constraint> constraints) { Type = type; Name = name; IsStatic = isStatic; IsPartial = isPartial; IsAbstract = isAbstract; IsSealed = isSealed; Visibility = visibility; DerivedFrom = derivedFrom; Members = members; Document = document; Attributes = attributes; Constraints = constraints; }
//朝右推动时返回最远距离的Gameobject GameObject LastGameobjet() { for (int i = mMapData.Distance - 1; i > -1; i -= 1) { if (mMapData.mapData[i, buttonObjectright.Y_axis] != null) { Vector2Int V = Vis.Floattoint(mMapData.mapData[i, buttonObjectright.Y_axis].transform.position); if (FindPostion(V, new Vector2Int(V.x + 1, V.y)) != V) { return(mMapData.mapData[i, buttonObjectright.Y_axis]); } } } return(null); }
// Workaround for car chassis that won't die private void OnEntityDeath(ModularCar car, HitInfo hitinfo) { OutputRcon("Car died! Checking for associated parts..."); List <BaseEntity> ents = new List <BaseEntity>(); Vis.Entities(car.transform.position, 1f, ents); foreach (var ent in ents) { if (ent.name.Contains("module_car_spawned") && !ent.IsDestroyed) { OutputRcon($"Killing {ent.ShortPrefabName}"); ent.Kill(BaseNetworkable.DestroyMode.Gib); } } }
public static void RadialDecayTouch(Vector3 pos, float radius, int mask) { if (ConVar.Decay.upkeep) { return; } List <DecayEntity> list = Facepunch.Pool.GetList <DecayEntity>(); Vis.Entities <DecayEntity>(pos, radius, list, mask, QueryTriggerInteraction.Collide); for (int i = 0; i < list.Count; i++) { list[i].DecayTouch(); } Facepunch.Pool.FreeList <DecayEntity>(ref list); }
public void BuildingCheck() { List <DecayEntity> list = (List <DecayEntity>)Pool.GetList <DecayEntity>(); Vis.Entities <DecayEntity>(this.WorldSpaceBounds(), list, 2097152, (QueryTriggerInteraction)2); foreach (DecayEntity decayEntity in list) { if (decayEntity.isServer && decayEntity.IsAlive()) { decayEntity.Kill(BaseNetworkable.DestroyMode.Gib); } } // ISSUE: cast to a reference type Pool.FreeList <DecayEntity>((List <M0>&) ref list); }
private void Explode(BaseCombatEntity barrel, ConfigData.OBarrel config) { var position = barrel.transform.position; var radius = config.eRadius; var damage = config.eDamage; var effects = config.effects; if (barrel.health > 0) { try { barrel.Hurt(100f); } catch { // ignored } } foreach (var effect in effects) { var x = Core.Random.Range(-radius, radius); var y = Core.Random.Range(0, radius); var z = Core.Random.Range(-radius, radius); Effect.server.Run(effect, position + new Vector3(x, y, z)); } Effect.server.Run("assets/content/weapons/_gestures/effects/eat_1hand_celery.prefab", position); var entities = new List <BaseCombatEntity>(); Vis.Entities(position, radius, entities); foreach (var entity in entities.ToList()) { try { if (entity.health > 0) { entity.Hurt(damage, DamageType.Explosion); } } catch { // ignored } } }
public void Greeting() { List <BasePlayer> list = Pool.GetList <BasePlayer>(); Vis.Entities <BasePlayer>(base.transform.position, 10f, list, 131072, QueryTriggerInteraction.Collide); Vector3 vector3 = base.transform.position; BasePlayer basePlayer = null; foreach (BasePlayer basePlayer1 in list) { if (basePlayer1.isClient || basePlayer1.IsNpc || basePlayer1 == this || !basePlayer1.IsVisible(this.eyes.position, Single.PositiveInfinity) || basePlayer1 == this.lastWavedAtPlayer || Vector3.Dot(Vector3Ex.Direction2D(basePlayer1.eyes.position, this.eyes.position), this.initialFacingDir) < 0.2f) { continue; } basePlayer = basePlayer1; if (basePlayer == null && !list.Contains(this.lastWavedAtPlayer)) { this.lastWavedAtPlayer = null; } if (basePlayer == null) { this.SetAimDirection(this.initialFacingDir); } else { base.SignalBroadcast(BaseEntity.Signal.Gesture, "wave", null); this.SetAimDirection(Vector3Ex.Direction2D(basePlayer.eyes.position, this.eyes.position)); this.lastWavedAtPlayer = basePlayer; } Pool.FreeList <BasePlayer>(ref list); return; } if (basePlayer == null && !list.Contains(this.lastWavedAtPlayer)) { this.lastWavedAtPlayer = null; } if (basePlayer == null) { this.SetAimDirection(this.initialFacingDir); } else { base.SignalBroadcast(BaseEntity.Signal.Gesture, "wave", null); this.SetAimDirection(Vector3Ex.Direction2D(basePlayer.eyes.position, this.eyes.position)); this.lastWavedAtPlayer = basePlayer; } Pool.FreeList <BasePlayer>(ref list); }
public Context(Mpc m_Mpc) { this.m_Mpc = m_Mpc; Primary = new Vis(); Tracks = new Vis() { Empty = GridLength.Auto }; }
public bool GetMessage(Vis.Mask current, ref Vis.Mask previous, Vis.Mask other) { return false; }
public bool Pass(Vis.Mask self, Vis.Mask instigator) { if (!this.expanded) { int num = this.ruleCount; if (num <= 0) { return true; } this.rules = new Vis.Rule[num]; for (int i = 0; i < num; i++) { this.rules[i] = Vis.Rule.Decode(this.data, i * 4); } this.expanded = true; } for (int j = (int)this.rules.Length - 1; j >= 0; j--) { if (this.rules[j].Pass(self, instigator) != Vis.Rule.Failure.None) { return false; } } return true; }