void FixedUpdate() { if (player == null || player.IsSleeping() || !player.IsConnected) { Destroy(); return; } float currentTime = UnityEngine.Time.realtimeSinceStartup; if (currentTime - lastUpdate >= 0.5f) { bool flag1 = Physics.Raycast(player.eyes.HeadRay(), out RayHit, 3f, colliderRemovable); ent = flag1 ? RayHit.GetEntity() : null; lastUpdate = currentTime; } if (player.serverInput.IsDown(BUTTON.FIRE_PRIMARY)) { if (currentTime - lastRemove >= 0.5f) { Remove(player); lastRemove = currentTime; } } }
private void cmdChatClone(BasePlayer player, string cmd, string[] args) { String[] perms = permission.GetPermissions(); // foreach (var perm in perms) // { // Debug.Log(perm); // } //var player = (BasePlayer)caller.Object; //Debug.Log(player.userID); //ply stmid //Debug.Log(permission.UserHasPermission(player.UserIDString, this.Title +".admin")); var layers = LayerMask.GetMask("Construction", "Default", "Deployed", "Resource", "Terrain", "Water", "World", "Player (Server)", "AI", "Deployed", "Terrain", "World"); //var playerLayer = LayerMask.GetMask("Player (Server)"); //var targetLayer = LayerMask.GetMask("Player (Server)", "AI", "Deployed", "Construction"); //var groundLayer = LayerMask.GetMask("Construction", "Terrain", "World"); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(player.eyes.HeadRay(), out hit, float.MaxValue, layers)) { var entity = hit.GetEntity(); if (entity != null) { PrintToChat(player, $"Cloned entity: {entity.PrefabName}"); this.spawnTarget = entity.PrefabName; } } }
public void FireBullet() { float damageAmount = 10f; Vector3 vector3 = Vector3.op_Subtraction(((Component)this.muzzlePos).get_transform().get_position(), Vector3.op_Multiply(this.muzzlePos.get_forward(), 0.25f)); Vector3 aimConeDirection = AimConeUtil.GetModifiedAimConeDirection((float)this.aimCone, ((Component)this.muzzlePos).get_transform().get_forward(), true); this.ClientRPC <Vector3>((Connection)null, "CLIENT_FireGun", Vector3.op_Addition(vector3, Vector3.op_Multiply(aimConeDirection, 300f))); List <RaycastHit> list = (List <RaycastHit>)Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(vector3, aimConeDirection), 0.1f, list, 300f, 1219701521, (QueryTriggerInteraction)0); for (int index = 0; index < list.Count; ++index) { RaycastHit hit = list[index]; BaseEntity entity = hit.GetEntity(); if (!Object.op_Inequality((Object)entity, (Object)null) || !Object.op_Equality((Object)entity, (Object)this) && !entity.EqualNetID((BaseNetworkable)this)) { if (Object.op_Inequality((Object)(entity as BaseCombatEntity), (Object)null)) { HitInfo info = new HitInfo((BaseEntity)this, entity, DamageType.Bullet, damageAmount, ((RaycastHit) ref hit).get_point()); entity.OnAttacked(info); if (entity is BasePlayer || entity is BaseNpc) { Effect.server.ImpactEffect(new HitInfo() { HitPositionWorld = ((RaycastHit) ref hit).get_point(), HitNormalWorld = Vector3.op_UnaryNegation(((RaycastHit) ref hit).get_normal()), HitMaterial = StringPool.Get("Flesh") });
private void GetTargetEntity(BasePlayer player) { bool flag = Physics.Raycast(player.eyes.HeadRay(), out raycastHit, 2f, Rust.Layers.Solid); if (!flag) { return; } BaseEntity entity; try { entity = raycastHit.GetEntity(); } catch (NullReferenceException nre) { return; } if (entity == null) { return; } MiniCopter mini = ((entity is MiniCopter) ? entity : entity.GetParentEntity()) as MiniCopter; if (mini != null) { PushMini(player, mini); return; } SendReply(player, GetMsg("Err - Can only push minicopter"), GetEnglishName(entity.ShortPrefabName)); }
public void FireGun(Vector3 targetPos, float aimCone, bool isCoax) { Transform transforms = (isCoax ? this.coaxMuzzle : this.topTurretMuzzle); Vector3 vector3 = transforms.transform.position - (transforms.forward * 0.25f); Vector3 vector31 = targetPos - vector3; Vector3 modifiedAimConeDirection = AimConeUtil.GetModifiedAimConeDirection(aimCone, vector31.normalized, true); targetPos = vector3 + (modifiedAimConeDirection * 300f); List <RaycastHit> list = Facepunch.Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(vector3, modifiedAimConeDirection), 0f, list, 300f, 1219701521, QueryTriggerInteraction.UseGlobal); for (int i = 0; i < list.Count; i++) { RaycastHit item = list[i]; BaseEntity entity = item.GetEntity(); if (!(entity != null) || !(entity == this) && !entity.EqualNetID(this)) { BaseCombatEntity baseCombatEntity = entity as BaseCombatEntity; if (baseCombatEntity != null) { this.ApplyDamage(baseCombatEntity, item.point, modifiedAimConeDirection); } if (!(entity != null) || entity.ShouldBlockProjectiles()) { targetPos = item.point; break; } } } base.ClientRPC <bool, Vector3>(null, "CLIENT_FireGun", isCoax, targetPos); Facepunch.Pool.FreeList <RaycastHit>(ref list); }
void FixedUpdate() { if (!player.IsConnected) { OnDestroy(); return; } if (player.IsSleeping()) { return; } float currentTime = UnityEngine.Time.realtimeSinceStartup; if ((currentTime - lastUpdate >= refreshTime) && player.GetActiveItem()?.GetHeldEntity() is Hammer) { bool flag1 = Physics.Raycast(player.eyes.HeadRay(), out RayHit, distance, 2097152); TargetEntity = flag1 ? RayHit.GetEntity() : null; lastUpdate = currentTime; } if ((currentTime - lastHit >= refreshTime) && (state.IsDown(BUTTON.FIRE_PRIMARY) || state.WasJustPressed(BUTTON.FIRE_PRIMARY) || state.WasJustReleased(BUTTON.FIRE_PRIMARY))) { if (TargetEntity != null && TargetEntity is BuildingBlock && player.GetActiveItem()?.GetHeldEntity() is Hammer) { eh.CheckInput(TargetEntity, player); } lastHit = currentTime; } }
private void customClear(BasePlayer player, string command, string[] args) { if (args.Length >= 1) { RaycastHit hit = new RaycastHit(); if (Physics.Raycast(player.eyes.HeadRay(), out hit, float.MaxValue)) { var entity = hit.GetEntity(); if (entity.GetBuildingPrivilege().authorizedPlayers.Any(x => x.userid == player.userID)) { if (entity is SamSite) { String ID = entity.GetInstanceID().ToString(); //removing msgs DynamicConfigFile warnings = Interface.Oxide.DataFileSystem.GetDatafile("warningMsgs"); DynamicConfigFile firings = Interface.Oxide.DataFileSystem.GetDatafile("firingMsgs"); warnings.Remove(ID); firings.Remove(ID); player.ChatMessage("custom Messages removed"); } else { player.ChatMessage("you are not looking at a SAM Site!"); } } else { player.ChatMessage("you are not authorized here!"); } } } }
private void CustomFiring(BasePlayer player, string command, string[] args) { if (args.Length >= 1) { RaycastHit hit = new RaycastHit(); if (Physics.Raycast(player.eyes.HeadRay(), out hit, float.MaxValue)) { var entity = hit.GetEntity(); if (entity.GetBuildingPrivilege().authorizedPlayers.Any(x => x.userid == player.userID)) { if (entity is SamSite) { setCustomMsg(true, entity.GetInstanceID(), args[0]); player.ChatMessage("custom Message saved"); } else { player.ChatMessage("you are not looking at a SAM Site!"); } } else { player.ChatMessage("you are not authorized here!"); } } } }
void EntKillProcess(BasePlayer player) { bool flag1 = Physics.Raycast(player.eyes.HeadRay(), out RayHit, 10f, layermask); baseEntity = flag1 ? RayHit.GetEntity() : null; if (baseEntity == null) { return; } if (baseEntity is BasePlayer) { return; } if (EntKillOwnOnly && player.userID != baseEntity.OwnerID) { return; } baseEntity.Kill(BaseNetworkable.DestroyMode.Gib); }
public void ServerUse_Strike() { BasePlayer ownerPlayer = base.GetOwnerPlayer(); if (ownerPlayer == null) { return; } Vector3 vector3 = ownerPlayer.eyes.position; Vector3 vector31 = ownerPlayer.eyes.BodyForward(); for (int i = 0; i < 2; i++) { List <RaycastHit> list = Facepunch.Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(vector3 - (vector31 * (i == 0 ? 0f : 0.2f)), vector31), (i == 0 ? 0f : this.attackRadius), list, this.effectiveRange + 0.2f, 1219701521, QueryTriggerInteraction.UseGlobal); bool flag = false; for (int j = 0; j < list.Count; j++) { RaycastHit item = list[j]; BaseEntity entity = item.GetEntity(); if (!(entity == null) && (!(entity != null) || !(entity == ownerPlayer) && !entity.EqualNetID(ownerPlayer)) && (!(entity != null) || !entity.isClient) && !(entity.Categorize() == ownerPlayer.Categorize())) { float single = 0f; foreach (DamageTypeEntry damageType in this.damageTypes) { single += damageType.amount; } entity.OnAttacked(new HitInfo(ownerPlayer, entity, DamageType.Slash, single * this.npcDamageScale)); HitInfo hitInfo = Facepunch.Pool.Get <HitInfo>(); hitInfo.HitPositionWorld = item.point; hitInfo.HitNormalWorld = -vector31; if (entity is BaseNpc || entity is BasePlayer) { hitInfo.HitMaterial = StringPool.Get("Flesh"); } else { hitInfo.HitMaterial = StringPool.Get((item.GetCollider().sharedMaterial != null ? item.GetCollider().sharedMaterial.GetName() : "generic")); } Effect.server.ImpactEffect(hitInfo); Facepunch.Pool.Free <HitInfo>(ref hitInfo); flag = true; if (!(entity != null) || entity.ShouldBlockProjectiles()) { break; } } } Facepunch.Pool.FreeList <RaycastHit>(ref list); if (flag) { break; } } }
public void ServerUse_Strike() { BasePlayer ownerPlayer = this.GetOwnerPlayer(); if (Object.op_Equality((Object)ownerPlayer, (Object)null)) { return; } Vector3 position = ownerPlayer.eyes.position; Vector3 vector3 = ownerPlayer.eyes.BodyForward(); for (int index1 = 0; index1 < 2; ++index1) { List <RaycastHit> list = (List <RaycastHit>)Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(Vector3.op_Subtraction(position, Vector3.op_Multiply(vector3, index1 == 0 ? 0.0f : 0.2f)), vector3), index1 == 0 ? 0.0f : this.attackRadius, list, this.effectiveRange + 0.2f, 1219701521, (QueryTriggerInteraction)0); bool flag = false; for (int index2 = 0; index2 < list.Count; ++index2) { RaycastHit hit = list[index2]; BaseEntity entity = hit.GetEntity(); if (!Object.op_Equality((Object)entity, (Object)null) && (!Object.op_Inequality((Object)entity, (Object)null) || !Object.op_Equality((Object)entity, (Object)ownerPlayer) && !entity.EqualNetID((BaseNetworkable)ownerPlayer)) && ((!Object.op_Inequality((Object)entity, (Object)null) || !entity.isClient) && !(entity.Categorize() == ownerPlayer.Categorize()))) { float num = 0.0f; foreach (DamageTypeEntry damageType in this.damageTypes) { num += damageType.amount; } entity.OnAttacked(new HitInfo((BaseEntity)ownerPlayer, entity, DamageType.Slash, num * this.npcDamageScale)); HitInfo info = (HitInfo)Pool.Get <HitInfo>(); info.HitPositionWorld = ((RaycastHit) ref hit).get_point(); info.HitNormalWorld = Vector3.op_UnaryNegation(vector3); info.HitMaterial = entity is BaseNpc || entity is BasePlayer?StringPool.Get("Flesh") : StringPool.Get(Object.op_Inequality((Object)hit.GetCollider().get_sharedMaterial(), (Object)null) ? hit.GetCollider().get_sharedMaterial().GetName() : "generic"); Effect.server.ImpactEffect(info); // ISSUE: cast to a reference type Pool.Free <HitInfo>((M0&)ref info); flag = true; if (!Object.op_Inequality((Object)entity, (Object)null) || entity.ShouldBlockProjectiles()) { break; } } } // ISSUE: cast to a reference type Pool.FreeList <RaycastHit>((List <M0>&) ref list); if (flag) { break; } } }
public virtual void FireGun( Vector3 targetPos, float aimCone, Transform muzzleToUse = null, BaseCombatEntity target = null) { if (this.IsOffline()) { return; } if (Object.op_Equality((Object)muzzleToUse, (Object)null)) { muzzleToUse = this.muzzlePos; } Vector3 vector3_1 = Vector3.op_Subtraction(((Component)this.GetCenterMuzzle()).get_transform().get_position(), Vector3.op_Multiply(this.GetCenterMuzzle().get_forward(), 0.25f)); Vector3 forward = ((Component)this.GetCenterMuzzle()).get_transform().get_forward(); Vector3 aimConeDirection = AimConeUtil.GetModifiedAimConeDirection(aimCone, forward, true); targetPos = Vector3.op_Addition(vector3_1, Vector3.op_Multiply(aimConeDirection, 300f)); List <RaycastHit> list = (List <RaycastHit>)Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(vector3_1, aimConeDirection), 0.0f, list, 300f, 1219701521, (QueryTriggerInteraction)0); for (int index = 0; index < list.Count; ++index) { RaycastHit hit = list[index]; BaseEntity entity1 = hit.GetEntity(); if ((!Object.op_Inequality((Object)entity1, (Object)null) || !Object.op_Equality((Object)entity1, (Object)this) && !entity1.EqualNetID((BaseNetworkable)this)) && (!Object.op_Inequality((Object)target, (Object)null) || !Object.op_Inequality((Object)entity1, (Object)null) || (!Object.op_Inequality((Object)((Component)entity1).GetComponent <BasePlayer>(), (Object)null) || entity1.EqualNetID((BaseNetworkable)target)))) { BaseCombatEntity entity2 = entity1 as BaseCombatEntity; if (Object.op_Inequality((Object)entity2, (Object)null)) { this.ApplyDamage(entity2, ((RaycastHit) ref hit).get_point(), aimConeDirection); } if (!Object.op_Inequality((Object)entity1, (Object)null) || entity1.ShouldBlockProjectiles()) { targetPos = ((RaycastHit) ref hit).get_point(); Vector3 vector3_2 = Vector3.op_Subtraction(targetPos, vector3_1); ((Vector3) ref vector3_2).get_normalized(); break; } } } this.ClientRPC <uint, Vector3>((Connection)null, "CLIENT_FireGun", StringPool.Get(((Object)((Component)muzzleToUse).get_gameObject()).get_name()), targetPos); // ISSUE: cast to a reference type Pool.FreeList <RaycastHit>((List <M0>&) ref list); }
private void cmdChatDespawn(BasePlayer player, string cmd, string[] args) { var layers = LayerMask.GetMask("Construction", "Default", "Deployed", "Resource", "Terrain", "Water", "World", "Player (Server)", "AI", "Deployed", "Terrain", "World"); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(player.eyes.HeadRay(), out hit, float.MaxValue, layers)) { var entity = hit.GetEntity(); if (entity != null && entity.IsDestroyed == false) { PrintToChat(player, $"Despawned entity: {entity.PrefabName}"); entity.Kill(); } } Puts("spawned"); }
public void FireBullet() { float single = 10f; Vector3 vector3 = this.muzzlePos.transform.position - (this.muzzlePos.forward * 0.25f); Vector3 vector31 = this.muzzlePos.transform.forward; Vector3 modifiedAimConeDirection = AimConeUtil.GetModifiedAimConeDirection((float)this.aimCone, vector31, true); Vector3 vector32 = vector3 + (modifiedAimConeDirection * 300f); base.ClientRPC <Vector3>(null, "CLIENT_FireGun", vector32); List <RaycastHit> list = Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(vector3, modifiedAimConeDirection), 0.1f, list, 300f, 1219701521, QueryTriggerInteraction.UseGlobal); for (int i = 0; i < list.Count; i++) { RaycastHit item = list[i]; BaseEntity entity = item.GetEntity(); if (!(entity != null) || !(entity == this) && !entity.EqualNetID(this)) { if (entity is BaseCombatEntity) { HitInfo hitInfo = new HitInfo(this, entity, DamageType.Bullet, single, item.point); entity.OnAttacked(hitInfo); if (entity is BasePlayer || entity is BaseNpc) { Effect.server.ImpactEffect(new HitInfo() { HitPositionWorld = item.point, HitNormalWorld = -item.normal, HitMaterial = StringPool.Get("Flesh") }); } } if (!(entity != null) || entity.ShouldBlockProjectiles()) { vector32 = item.point; return; } } } }
public virtual void FireGun(Vector3 targetPos, float aimCone, Transform muzzleToUse = null, BaseCombatEntity target = null) { if (this.IsOffline()) { return; } if (muzzleToUse == null) { muzzleToUse = this.muzzlePos; } Vector3 centerMuzzle = this.GetCenterMuzzle().transform.position - (this.GetCenterMuzzle().forward * 0.25f); Vector3 vector3 = this.GetCenterMuzzle().transform.forward; Vector3 modifiedAimConeDirection = AimConeUtil.GetModifiedAimConeDirection(aimCone, vector3, true); targetPos = centerMuzzle + (modifiedAimConeDirection * 300f); List <RaycastHit> list = Facepunch.Pool.GetList <RaycastHit>(); GamePhysics.TraceAll(new Ray(centerMuzzle, modifiedAimConeDirection), 0f, list, 300f, 1219701521, QueryTriggerInteraction.UseGlobal); for (int i = 0; i < list.Count; i++) { RaycastHit item = list[i]; BaseEntity entity = item.GetEntity(); if ((!(entity != null) || !(entity == this) && !entity.EqualNetID(this)) && (!(target != null) || !(entity != null) || !(entity.GetComponent <BasePlayer>() != null) || entity.EqualNetID(target))) { BaseCombatEntity baseCombatEntity = entity as BaseCombatEntity; if (baseCombatEntity != null) { this.ApplyDamage(baseCombatEntity, item.point, modifiedAimConeDirection); } if (!(entity != null) || entity.ShouldBlockProjectiles()) { targetPos = item.point; vector3 = (targetPos - centerMuzzle).normalized; break; } } } base.ClientRPC <uint, Vector3>(null, "CLIENT_FireGun", StringPool.Get(muzzleToUse.gameObject.name), targetPos); Facepunch.Pool.FreeList <RaycastHit>(ref list); }