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 static void TraceAll(HitTest test, List <TraceInfo> traces, int layerMask = -5) { if (CFG.Setting.grass12) { layerMask &= CFG.Setting.grass ? -1073741825 : -5; } layerMask &= CFG.Setting.grass ? -8388609 : -5; layerMask &= CFG.Setting.grass ? -65537 : -5; if (CFG.Setting.grass ? test.HitMaterial != "Flesh" : true) { List <RaycastHit> list = Facepunch.Pool.GetList <RaycastHit>(); Vector3 origin = test.AttackRay.origin; Vector3 direction = test.AttackRay.direction; float maxDistance = test.MaxDistance; float radius = test.Radius; if ((layerMask & 16384) != 0) { layerMask &= -16385; GamePhysics.TraceAllUnordered(new Ray(origin - direction * 5f, direction), radius, list, maxDistance + 5f, 16384, QueryTriggerInteraction.UseGlobal); for (int i = 0; i < list.Count; i++) { RaycastHit raycastHit = list[i]; raycastHit.distance -= 5f; list[i] = raycastHit; } } GamePhysics.TraceAllUnordered(new Ray(origin, direction), radius, list, maxDistance, layerMask, QueryTriggerInteraction.UseGlobal); for (int j = 0; j < list.Count; j++) { RaycastHit hit = list[j]; Collider collider = hit.GetCollider(); if (!collider.isTrigger) { ColliderInfo component = collider.GetComponent <ColliderInfo>(); if (!component || component.Filter(test)) { BaseCollision component2 = collider.GetComponent <BaseCollision>(); if (component2 != null) { component2.TraceTest(test, traces); } else if (hit.distance > 0f) { TraceInfo traceInfo = default(TraceInfo); traceInfo.valid = true; traceInfo.distance = hit.distance; traceInfo.partID = 0U; traceInfo.point = hit.point; traceInfo.normal = hit.normal; traceInfo.collider = collider; traceInfo.material = collider.GetMaterialAt(hit.point); traceInfo.entity = collider.gameObject.ToBaseEntity(); traceInfo.bone = Model.GetTransform(collider.transform, hit.point, traceInfo.entity); if (!traceInfo.entity || (traceInfo.entity.isClient && traceInfo.entity != test.ignoreEntity)) { traces.Add(traceInfo); } } } } } traces.Sort((TraceInfo a, TraceInfo b) => a.distance.CompareTo(b.distance)); Facepunch.Pool.FreeList <RaycastHit>(ref list); } }