public UnturnedResourceDamagingEvent(ResourceSpawnpoint resourceSpawnpoint, ushort damageAmount, EDamageOrigin damageOrigin,
                                      UnturnedPlayer?instigator, CSteamID instigatorId)
 {
     ResourceSpawnpoint = resourceSpawnpoint;
     DamageAmount       = damageAmount;
     DamageOrigin       = damageOrigin;
     Instigator         = instigator;
     InstigatorId       = instigatorId;
 }
Ejemplo n.º 2
0
        public static bool ResourceDamaged(ResourceSpawnpoint resource, ref ushort amount)
        {
            // TODO: causes?
            ResourceTag resourceTag = new ResourceTag(resource);

            if (amount >= resource.health)
            {
                ResourceDestroyedEventArgs deathevt = new ResourceDestroyedEventArgs();
                deathevt.Resource = resourceTag;
                deathevt.Amount   = new NumberTag(amount);
                UnturnedFreneticEvents.OnResourceDestroyed.Fire(deathevt);
                amount = (ushort)deathevt.Amount.Internal;
                return(deathevt.Cancelled || EntityDestroyed(resourceTag, ref amount));
            }
            ResourceDamagedEventArgs evt = new ResourceDamagedEventArgs();

            evt.Resource = resourceTag;
            evt.Amount   = new NumberTag(amount);
            UnturnedFreneticEvents.OnResourceDamaged.Fire(evt);
            amount = (ushort)evt.Amount.Internal;
            return(evt.Cancelled || EntityDamaged(resourceTag, ref amount));
        }
Ejemplo n.º 3
0
        private void OnDamageResourceRequested(CSteamID instigatorSteamId, Transform objectTransform, // lgtm [cs/too-many-ref-parameters]
                                               ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            if (!ResourceManager.tryGetRegion(objectTransform, out byte x, out byte y, out ushort index))
            {
                return;
            }

            List <ResourceSpawnpoint> tree       = LevelGround.trees[x, y];
            ResourceSpawnpoint        spawnpoint = tree[index];

            Player?        nativePlayer = PlayerTool.getPlayer(instigatorSteamId);
            UnturnedPlayer?player       = GetUnturnedPlayer(nativePlayer);

            var @event = new UnturnedResourceDamagingEvent(spawnpoint, pendingTotalDamage, damageOrigin, player, instigatorSteamId)
            {
                IsCancelled = !shouldAllow
            };

            Emit(@event);

            pendingTotalDamage = @event.DamageAmount;
            shouldAllow        = [email protected];
        }
Ejemplo n.º 4
0
 public ResourceTag(ResourceSpawnpoint resource)
 {
     Internal = resource;
 }
Ejemplo n.º 5
0
 public ResourceTag(ResourceSpawnpoint resource)
 {
     Internal = resource;
 }
Ejemplo n.º 6
0
        public static bool Prefix(UseableGun __instance, ref List <BulletInfo> ___bullets, ref int ___hitmarkerIndex, ref ParticleSystem ___tracerEmitter,
                                  ref Attachments ___thirdAttachments)
        {
            if (Global.AllOff || Hooks.askScreenshot.NeedingSpy)
            {
                ___tracerEmitter.startColor = Color.gray;
                return(true);
            }
            if (!Global.AimEnabled || (Global.AimSettings.RageBot && RageBot.FocusTarget != null && !Global.AimSettings.RBypassOne))
            {
                return(true);
            }

            if ((__instance.equippedGunAsset.projectile == null) && (___bullets != null))
            {
                if (__instance.channel.isOwner)
                {
                    RaycastInfo info2 = null;
                    float       dst   = 0f;

                    if (Global.AimSettings.RageBot)
                    {
                        if (RageBot.FocusTarget != null)
                        {
                            Vector3 AimAt = Aimbot.GetHitbox(RageBot.FocusTarget.player.transform, "Skull");

                            if (AimAt == Vector3.zero || RageBot.FocusTarget.player.stance.prone)
                            {
                                AimAt = RageBot.FocusTarget.player.transform.position + new Vector3(0, 0.005f, 0);
                            }

                            Ray prx = new Ray(Player.player.look.aim.position, (AimAt - Player.player.look.aim.position).normalized);
                            dst   = Vector3.Distance(AimAt, Player.player.look.aim.position);
                            info2 = DamageTool.raycast(prx,
                                                       dst,
                                                       RayMasks.ENEMY,
                                                       Player.player);
                        }
                    }


                    for (int i = 0; i < ___bullets.Count; i++)
                    {
                        BulletInfo info = ___bullets[i];
                        if (Global.AimSettings.RageBot && RageBot.FocusTarget != null && info2 != null && info2.player == RageBot.FocusTarget.player)
                        {
                            if (!((info.steps * __instance.equippedGunAsset.ballisticTravel) < dst))
                            {
                                Player.player.input.sendRaycast(info2);
                                Player.player.input.sendRaycast(info2);
                                info.steps = 254;
                                goto prx;
                            }
                        }

                        byte pellets = info.magazineAsset.pellets;
                        if (__instance.channel.isOwner)
                        {
                            EPlayerHit nONE = EPlayerHit.NONE;
                            if (pellets > 1)
                            {
                                ___hitmarkerIndex = info.pellet;
                            }
                            else if (OptionsSettings.hitmarker)
                            {
                                ___hitmarkerIndex++;
                                if (___hitmarkerIndex >= PlayerLifeUI.hitmarkers.Length)
                                {
                                    ___hitmarkerIndex = 0;
                                }
                            }
                            else
                            {
                                ___hitmarkerIndex = 0;
                            }

                            Ray ray = new Ray(info.pos, info.dir);
                            if (info2 == null)
                            {
                                info2 = DamageTool.raycast(ray,
                                                           !Provider.modeConfigData.Gameplay.Ballistics ? __instance.equippedGunAsset.range : __instance.equippedGunAsset.ballisticTravel,
                                                           RayMasks.DAMAGE_CLIENT,
                                                           __instance.player);
                            }

                            if (((info2.player != null) && (__instance.equippedGunAsset.playerDamageMultiplier.damage > 1f)) && (!__instance.player.quests.isMemberOfSameGroupAs(info2.player) && Provider.isPvP))
                            {
                                if (nONE != EPlayerHit.CRITICAL)
                                {
                                    nONE = (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL;
                                }
                                PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
                            }
                            else if (((info2.zombie != null) && (__instance.equippedGunAsset.zombieDamageMultiplier.damage > 1f)) || ((info2.animal != null) && (__instance.equippedGunAsset.animalDamageMultiplier.damage > 1f)))
                            {
                                if (nONE != EPlayerHit.CRITICAL)
                                {
                                    nONE = (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL;
                                }
                                PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, (info2.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
                            }
                            else if (((info2.transform != null) && info2.transform.CompareTag("Barricade")) && (__instance.equippedGunAsset.barricadeDamage > 1f))
                            {
                                ushort num3;
                                if (ushort.TryParse(info2.transform.name, NumberStyles.Any, CultureInfo.InvariantCulture, out num3))
                                {
                                    ItemBarricadeAsset asset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, num3);
                                    if ((asset != null) && (asset.isVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }
                            else if (((info2.transform != null) && info2.transform.CompareTag("Structure")) && (__instance.equippedGunAsset.structureDamage > 1f))
                            {
                                ushort num4;
                                if (ushort.TryParse(info2.transform.name, NumberStyles.Any, CultureInfo.InvariantCulture, out num4))
                                {
                                    ItemStructureAsset asset2 = (ItemStructureAsset)Assets.find(EAssetType.ITEM, num4);
                                    if ((asset2 != null) && (asset2.isVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }
                            else if (((info2.vehicle != null) && !info2.vehicle.isDead) && (__instance.equippedGunAsset.vehicleDamage > 1f))
                            {
                                if (((info2.vehicle.asset != null) && info2.vehicle.canBeDamaged) && (info2.vehicle.asset.isVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                {
                                    if (nONE == EPlayerHit.NONE)
                                    {
                                        nONE = EPlayerHit.BUILD;
                                    }
                                    PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                }
                            }
                            else if (((info2.transform != null) && info2.transform.CompareTag("Resource")) && (__instance.equippedGunAsset.resourceDamage > 1f))
                            {
                                byte   num5;
                                byte   num6;
                                ushort num7;
                                if (ResourceManager.tryGetRegion(info2.transform, out num5, out num6, out num7))
                                {
                                    ResourceSpawnpoint spawnpoint = ResourceManager.getResourceSpawnpoint(num5, num6, num7);
                                    if (((spawnpoint != null) && !spawnpoint.isDead) && (spawnpoint.asset.bladeID == ((ItemWeaponAsset)__instance.player.equipment.asset).bladeID))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }
                            else if ((info2.transform != null) && (__instance.equippedGunAsset.objectDamage > 1f))
                            {
                                InteractableObjectRubble componentInParent = info2.transform.GetComponentInParent <InteractableObjectRubble>();
                                if (componentInParent != null)
                                {
                                    info2.transform = componentInParent.transform;
                                    info2.section   = componentInParent.getSection(info2.collider.transform);
                                    if (!componentInParent.isSectionDead(info2.section) && (componentInParent.asset.rubbleIsVulnerable || ((ItemWeaponAsset)__instance.player.equipment.asset).isInvulnerable))
                                    {
                                        if (nONE == EPlayerHit.NONE)
                                        {
                                            nONE = EPlayerHit.BUILD;
                                        }
                                        PlayerUI.hitmark(___hitmarkerIndex, info2.point, pellets > 1, EPlayerHit.BUILD);
                                    }
                                }
                            }



                            if (Provider.modeConfigData.Gameplay.Ballistics)
                            {
                                if ((info.steps > 0) || (__instance.equippedGunAsset.ballisticSteps <= 1))
                                {
                                    if (__instance.equippedGunAsset.ballisticTravel < 32f)
                                    {
                                        trace(info.pos + ((Vector3)(info.dir * 32f)), info.dir, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                                    }
                                    else
                                    {
                                        trace(info.pos + ((Vector3)(info.dir * UnityEngine.Random.Range(32f, __instance.equippedGunAsset.ballisticTravel))), info.dir, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                                    }
                                }
                            }
                            else if (__instance.equippedGunAsset.range < 32f)
                            {
                                trace(ray.origin + ((Vector3)(ray.direction * 32f)), ray.direction, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                            }
                            else
                            {
                                trace(ray.origin + ((Vector3)(ray.direction * UnityEngine.Random.Range(32f, Mathf.Min(64f, __instance.equippedGunAsset.range)))), ray.direction, ref ___tracerEmitter, ref __instance, ref ___thirdAttachments);
                            }

                            float ballisticDrop = __instance.equippedGunAsset.ballisticDrop;
                            if (info.barrelAsset != null)
                            {
                                ballisticDrop *= info.barrelAsset.ballisticDrop;
                            }

                            info.pos += (Vector3)(info.dir * __instance.equippedGunAsset.ballisticTravel);
                            if (!Global.AimSettings.RageBot)
                            {
                                if (!Global.AimSettings.NoDrop)
                                {
                                    info.dir.y -= ballisticDrop;
                                }
                            }

                            info.dir.Normalize();

                            if (Global.AimSettings.RageBot && RageBot.FocusTarget != null)
                            {
                                goto prx;
                            }

                            if (!__instance.player.input.isRaycastInvalid(info2))
                            {
                                if (nONE != EPlayerHit.NONE)
                                {
                                    int num9;
                                    if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num9))
                                    {
                                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", (int)(num9 + 1));
                                    }
                                    if ((nONE == EPlayerHit.CRITICAL) && Provider.provider.statisticsService.userStatisticsService.getStatistic("Headshots", out num9))
                                    {
                                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Headshots", (int)(num9 + 1));
                                    }
                                }
                                __instance.player.input.sendRaycast(info2);
                                info.steps = 0xfe;
                            }
                        }
                    }
                }

prx:
                if (__instance.player.equipment.asset != null)
                {
                    if (Provider.modeConfigData.Gameplay.Ballistics)
                    {
                        for (int k = ___bullets.Count - 1; k >= 0; k--)
                        {
                            BulletInfo info5 = ___bullets[k];
                            info5.steps = (byte)(info5.steps + 1);
                            if (info5.steps >= __instance.equippedGunAsset.ballisticSteps)
                            {
                                ___bullets.RemoveAt(k);
                            }
                        }
                    }
                    else
                    {
                        ___bullets.Clear();
                    }
                }
            }
            return(false);
        }
        public static bool Prefix(InteractableSentry __instance)
        {
            RocketPlayer ownerPlayer = new RocketPlayer(__instance.owner.ToString());

            bool            hasWeapon    = (bool)hasWeaponField.GetValue(__instance);
            bool            isFiring     = (bool)isFiringField.GetValue(__instance);
            bool            isAiming     = (bool)isAimingField.GetValue(__instance);
            float           lastScan     = (float)lastScanField.GetValue(__instance);
            float           lastFire     = (float)lastFireField.GetValue(__instance);
            float           fireTime     = (float)fireTimeField.GetValue(__instance);
            float           lastAim      = (float)lastAimField.GetValue(__instance);
            ItemWeaponAsset displayAsset = displayAssetField.GetValue(__instance) as ItemWeaponAsset;
            Attachments     attachments  = attachmentsField.GetValue(__instance) as Attachments;

            bool interact = (bool)interactField.GetValue(__instance);

            var playersInRadius = (List <Player>)playersInRadiusField.GetValue(null);
            var zombiesInRadius = (List <Zombie>)zombiesInRadiusField.GetValue(null);
            var animalsInRadius = (List <Animal>)animalsInRadiusField.GetValue(null);

            var targetPlayer = targetPlayerField.GetValue(__instance) as Player;
            var targetZombie = targetZombieField.GetValue(__instance) as Zombie;
            var targetAnimal = targetAnimalField.GetValue(__instance) as Animal;
            var aimTransform = aimTransformField.GetValue(__instance) as Transform;

            if (__instance.isPowered)
            {
                Vector3 vector3_1 = __instance.transform.position + new Vector3(0.0f, 0.65f, 0.0f);
                Vector3 vector3_2;
                if ((double)Time.realtimeSinceStartup - (double)lastScan > 0.100000001490116)
                {
                    lastScanField.SetValue(__instance, Time.realtimeSinceStartup);

                    float a = 48f;
                    if (hasWeapon)
                    {
                        a = Mathf.Min(a, ((ItemWeaponAsset)displayAsset).range);
                    }
                    float  sqrRadius = a * a;
                    float  num       = sqrRadius;
                    Player player    = (Player)null;
                    Zombie zombie    = (Zombie)null;
                    Animal animal    = (Animal)null;
                    if (Provider.isPvP)
                    {
                        playersInRadius.Clear();
                        PlayerTool.getPlayersInRadius(vector3_1, sqrRadius, playersInRadius);
                        for (int index = 0; index < playersInRadius.Count; ++index)
                        {
                            Player playersInRadiu = playersInRadius[index];

                            var currentRocketPlayer = new RocketPlayer(playersInRadiu.channel.owner.playerID.steamID.ToString());

                            if (currentRocketPlayer.HasPermission(GodPermission))
                            {
                                continue;
                            }

                            if (!(playersInRadiu.channel.owner.playerID.steamID == __instance.owner) && !playersInRadiu.quests.isMemberOfGroup(__instance.group) && (!playersInRadiu.life.isDead && playersInRadiu.animator.gesture != EPlayerGesture.ARREST_START) && ((!playersInRadiu.movement.isSafe || !playersInRadiu.movement.isSafeInfo.noWeapons) && playersInRadiu.movement.canAddSimulationResultsToUpdates) && (!((UnityEngine.Object)player != (UnityEngine.Object)null) || playersInRadiu.animator.gesture != EPlayerGesture.SURRENDER_START) && (__instance.sentryMode != ESentryMode.FRIENDLY || (double)Time.realtimeSinceStartup - (double)playersInRadiu.equipment.lastPunching < 2.0 || playersInRadiu.equipment.isSelected && playersInRadiu.equipment.asset != null && playersInRadiu.equipment.asset.shouldFriendlySentryTargetUser))
                            {
                                vector3_2 = playersInRadiu.look.aim.position - vector3_1;
                                float sqrMagnitude = vector3_2.sqrMagnitude;
                                if ((double)sqrMagnitude <= (double)num)
                                {
                                    Vector3 vector3_3 = playersInRadiu.look.aim.position - vector3_1;
                                    float   magnitude = vector3_3.magnitude;
                                    Vector3 vector3_4 = vector3_3 / magnitude;
                                    if (!((UnityEngine.Object)playersInRadiu != (UnityEngine.Object)targetPlayer) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5)
                                    {
                                        if ((double)magnitude > 0.025000000372529)
                                        {
                                            RaycastHit hit;
                                            PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal);
                                            if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform))
                                            {
                                                PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal);
                                                if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)
                                                {
                                                    continue;
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        num    = sqrMagnitude;
                                        player = playersInRadiu;
                                    }
                                }
                            }
                        }
                    }
                    zombiesInRadius.Clear();
                    ZombieManager.getZombiesInRadius(vector3_1, sqrRadius, zombiesInRadius);
                    for (int index = 0; index < zombiesInRadius.Count; ++index)
                    {
                        Zombie zombiesInRadiu = zombiesInRadius[index];
                        if (!zombiesInRadiu.isDead && zombiesInRadiu.isHunting)
                        {
                            Vector3 position = zombiesInRadiu.transform.position;
                            switch (zombiesInRadiu.speciality)
                            {
                            case EZombieSpeciality.NORMAL:
                                position += new Vector3(0.0f, 1.75f, 0.0f);
                                break;

                            case EZombieSpeciality.MEGA:
                                position += new Vector3(0.0f, 2.625f, 0.0f);
                                break;

                            case EZombieSpeciality.CRAWLER:
                                position += new Vector3(0.0f, 0.25f, 0.0f);
                                break;

                            case EZombieSpeciality.SPRINTER:
                                position += new Vector3(0.0f, 1f, 0.0f);
                                break;
                            }
                            vector3_2 = position - vector3_1;
                            float sqrMagnitude = vector3_2.sqrMagnitude;
                            if ((double)sqrMagnitude <= (double)num)
                            {
                                Vector3 vector3_3 = position - vector3_1;
                                float   magnitude = vector3_3.magnitude;
                                Vector3 vector3_4 = vector3_3 / magnitude;
                                if (!((UnityEngine.Object)zombiesInRadiu != (UnityEngine.Object)targetZombie) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5)
                                {
                                    if ((double)magnitude > 0.025000000372529)
                                    {
                                        RaycastHit hit;
                                        PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal);
                                        if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform))
                                        {
                                            PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal);
                                            if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                    num    = sqrMagnitude;
                                    player = (Player)null;
                                    zombie = zombiesInRadiu;
                                }
                            }
                        }
                    }
                    animalsInRadius.Clear();
                    AnimalManager.getAnimalsInRadius(vector3_1, sqrRadius, animalsInRadius);
                    for (int index = 0; index < animalsInRadius.Count; ++index)
                    {
                        Animal animalsInRadiu = animalsInRadius[index];
                        if (!animalsInRadiu.isDead)
                        {
                            Vector3 position = animalsInRadiu.transform.position;
                            vector3_2 = position - vector3_1;
                            float sqrMagnitude = vector3_2.sqrMagnitude;
                            if ((double)sqrMagnitude <= (double)num)
                            {
                                Vector3 vector3_3 = position - vector3_1;
                                float   magnitude = vector3_3.magnitude;
                                Vector3 vector3_4 = vector3_3 / magnitude;
                                if (!((UnityEngine.Object)animalsInRadiu != (UnityEngine.Object)targetAnimal) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5)
                                {
                                    if ((double)magnitude > 0.025000000372529)
                                    {
                                        RaycastHit hit;
                                        PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal);
                                        if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform))
                                        {
                                            PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal);
                                            if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                    num    = sqrMagnitude;
                                    player = (Player)null;
                                    zombie = (Zombie)null;
                                    animal = animalsInRadiu;
                                }
                            }
                        }
                    }
                    if ((UnityEngine.Object)player != (UnityEngine.Object)targetPlayer || (UnityEngine.Object)zombie != (UnityEngine.Object)targetZombie || (UnityEngine.Object)animal != (UnityEngine.Object)targetAnimal)
                    {
                        targetPlayerField.SetValue(__instance, player);
                        targetZombieField.SetValue(__instance, zombie);
                        targetAnimalField.SetValue(__instance, animal);
                        lastFireField.SetValue(__instance, Time.realtimeSinceStartup + 0.1f);
                    }
                }
                if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                {
                    switch (__instance.sentryMode)
                    {
                    case ESentryMode.NEUTRAL:
                    case ESentryMode.FRIENDLY:
                        isFiringField.SetValue(__instance, targetPlayer.animator.gesture != EPlayerGesture.SURRENDER_START);
                        break;

                    case ESentryMode.HOSTILE:
                        isFiringField.SetValue(__instance, true);
                        break;
                    }
                    isAimingField.SetValue(__instance, true);
                }
                else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                {
                    isFiringField.SetValue(__instance, true);
                    isAimingField.SetValue(__instance, true);
                }
                else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                {
                    switch (__instance.sentryMode)
                    {
                    case ESentryMode.NEUTRAL:
                    case ESentryMode.FRIENDLY:
                        isFiringField.SetValue(__instance, targetAnimal.isHunting);
                        break;

                    case ESentryMode.HOSTILE:
                        isFiringField.SetValue(__instance, true);
                        break;
                    }
                    isAimingField.SetValue(__instance, true);
                }
                else
                {
                    isFiringField.SetValue(__instance, false);
                    isAimingField.SetValue(__instance, false);
                }
                if (isAiming && (double)Time.realtimeSinceStartup - (double)lastAim > (double)Provider.UPDATE_TIME)
                {
                    lastAimField.SetValue(__instance, Time.realtimeSinceStartup);
                    Transform transform = (Transform)null;
                    Vector3   vector3_3 = Vector3.zero;
                    if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                    {
                        transform = targetPlayer.transform;
                        vector3_3 = targetPlayer.look.aim.position;
                    }
                    else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                    {
                        transform = targetZombie.transform;
                        vector3_3 = targetZombie.transform.position;
                        switch (targetZombie.speciality)
                        {
                        case EZombieSpeciality.NORMAL:
                            vector3_3 += new Vector3(0.0f, 1.75f, 0.0f);
                            break;

                        case EZombieSpeciality.MEGA:
                            vector3_3 += new Vector3(0.0f, 2.625f, 0.0f);
                            break;

                        case EZombieSpeciality.CRAWLER:
                            vector3_3 += new Vector3(0.0f, 0.25f, 0.0f);
                            break;

                        case EZombieSpeciality.SPRINTER:
                            vector3_3 += new Vector3(0.0f, 1f, 0.0f);
                            break;
                        }
                    }
                    else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                    {
                        transform = targetAnimal.transform;
                        vector3_3 = targetAnimal.transform.position + Vector3.up;
                    }
                    if ((UnityEngine.Object)transform != (UnityEngine.Object)null)
                    {
                        float  yaw = Mathf.Atan2(vector3_3.x - vector3_1.x, vector3_3.z - vector3_1.z) * 57.29578f;
                        double num = (double)vector3_3.y - (double)vector3_1.y;
                        vector3_2 = vector3_3 - vector3_1;
                        double magnitude = (double)vector3_2.magnitude;
                        float  pitch     = Mathf.Sin((float)(num / magnitude)) * 57.29578f;
                        BarricadeManager.sendAlertSentry(__instance.transform, yaw, pitch);
                    }
                }
                if (isFiring && hasWeapon && (__instance.displayItem.state[10] > (byte)0 && !__instance.isOpen) && (double)Time.realtimeSinceStartup - (double)lastFire > (double)fireTime)
                {
                    lastFireField.SetValue(__instance, lastFire + fireTime);
                    if ((double)Time.realtimeSinceStartup - (double)lastFire > (double)fireTime)
                    {
                        lastFire = Time.realtimeSinceStartup;
                    }
                    float num1 = (float)__instance.displayItem.quality / 100f;
                    if (attachments.magazineAsset == null)
                    {
                        return(false);
                    }

                    if (!ownerPlayer.HasPermission(IgnoreAmmoPermission))
                    {
                        Console.WriteLine("Ammo reduction");
                        if ((__instance.sentryAsset.infiniteAmmo ? 1 : (((ItemGunAsset)displayAsset).infiniteAmmo ? 1 : 0)) == 0)
                        {
                            --__instance.displayItem.state[10];
                        }

                        if (!__instance.sentryAsset.infiniteQuality && Provider.modeConfigData.Items.Has_Durability && (__instance.displayItem.quality > (byte)0 && (double)UnityEngine.Random.value < (double)((ItemWeaponAsset)displayAsset).durability))
                        {
                            if ((int)__instance.displayItem.quality > (int)((ItemWeaponAsset)displayAsset).wear)
                            {
                                __instance.displayItem.quality -= ((ItemWeaponAsset)displayAsset).wear;
                            }
                            else
                            {
                                __instance.displayItem.quality = (byte)0;
                            }
                        }
                    }
                    if (attachments.barrelAsset == null || !attachments.barrelAsset.isSilenced || __instance.displayItem.state[16] == (byte)0)
                    {
                        AlertTool.alert(__instance.transform.position, 48f);
                    }

                    float num2 = ((ItemGunAsset)displayAsset).spreadAim * ((double)num1 < 0.5 ? (float)(1.0 + (1.0 - (double)num1 * 2.0)) : 1f);
                    if (attachments.tacticalAsset != null && interact)
                    {
                        num2 *= attachments.tacticalAsset.spread;
                    }
                    if (attachments.gripAsset != null)
                    {
                        num2 *= attachments.gripAsset.spread;
                    }
                    if (attachments.barrelAsset != null)
                    {
                        num2 *= attachments.barrelAsset.spread;
                    }
                    if (attachments.magazineAsset != null)
                    {
                        num2 *= attachments.magazineAsset.spread;
                    }


                    if ((UnityEngine.Object)((ItemGunAsset)displayAsset).projectile == (UnityEngine.Object)null)
                    {
                        BarricadeManager.sendShootSentry(__instance.transform);
                        byte pellets = attachments.magazineAsset.pellets;
                        for (byte index1 = 0; (int)index1 < (int)pellets; ++index1)
                        {
                            EPlayerKill kill      = EPlayerKill.NONE;
                            uint        xp        = 0;
                            float       times     = (float)(1.0 * ((double)num1 < 0.5 ? 0.5 + (double)num1 : 1.0));
                            Transform   transform = (Transform)null;
                            float       num3      = 0.0f;
                            if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                            {
                                transform = targetPlayer.transform;
                            }
                            else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                            {
                                transform = __instance.transform;
                            }
                            else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                            {
                                transform = targetAnimal.transform;
                            }
                            if ((UnityEngine.Object)transform != (UnityEngine.Object)null)
                            {
                                vector3_2 = transform.position - __instance.transform.position;
                                num3      = vector3_2.magnitude;
                            }
                            float num4 = (1f - num3 / ((ItemWeaponAsset)displayAsset).range) * (1f - ((ItemGunAsset)displayAsset).spreadHip) * 0.75f;
                            if ((UnityEngine.Object)transform == (UnityEngine.Object)null || (double)UnityEngine.Random.value > (double)num4)
                            {
                                Vector3 forward = aimTransform.forward;
                                forward += aimTransform.right * UnityEngine.Random.Range(-((ItemGunAsset)displayAsset).spreadHip, ((ItemGunAsset)displayAsset).spreadHip) * num2;
                                forward += aimTransform.up * UnityEngine.Random.Range(-((ItemGunAsset)displayAsset).spreadHip, ((ItemGunAsset)displayAsset).spreadHip) * num2;
                                forward.Normalize();
                                RaycastInfo raycastInfo = DamageTool.raycast(new Ray(aimTransform.position, forward), ((ItemWeaponAsset)displayAsset).range, RayMasks.DAMAGE_SERVER);
                                if (!((UnityEngine.Object)raycastInfo.transform == (UnityEngine.Object)null))
                                {
                                    DamageTool.impact(raycastInfo.point, raycastInfo.normal, raycastInfo.material, (UnityEngine.Object)raycastInfo.vehicle != (UnityEngine.Object)null || raycastInfo.transform.CompareTag("Barricade") || raycastInfo.transform.CompareTag("Structure") || raycastInfo.transform.CompareTag("Resource"));
                                    if ((UnityEngine.Object)raycastInfo.vehicle != (UnityEngine.Object)null)
                                    {
                                        DamageTool.damage(raycastInfo.vehicle, false, Vector3.zero, false, ((ItemWeaponAsset)displayAsset).vehicleDamage, times, true, out kill, new CSteamID(), EDamageOrigin.Sentry);
                                    }
                                    else if ((UnityEngine.Object)raycastInfo.transform != (UnityEngine.Object)null)
                                    {
                                        if (raycastInfo.transform.CompareTag("Barricade"))
                                        {
                                            ushort result;
                                            if (ushort.TryParse(raycastInfo.transform.name, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture, out result))
                                            {
                                                ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, result);
                                                if (itemBarricadeAsset != null && (itemBarricadeAsset.isVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable))
                                                {
                                                    DamageTool.damage(raycastInfo.transform, false, ((ItemWeaponAsset)displayAsset).barricadeDamage, times, out kill, new CSteamID(), EDamageOrigin.Sentry);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.transform.CompareTag("Structure"))
                                        {
                                            ushort result;
                                            if (ushort.TryParse(raycastInfo.transform.name, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture, out result))
                                            {
                                                ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, result);
                                                if (itemStructureAsset != null && (itemStructureAsset.isVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable))
                                                {
                                                    DamageTool.damage(raycastInfo.transform, false, raycastInfo.direction * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f), ((ItemWeaponAsset)displayAsset).structureDamage, times, out kill, new CSteamID(), EDamageOrigin.Sentry);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.transform.CompareTag("Resource"))
                                        {
                                            byte   x;
                                            byte   y;
                                            ushort index2;
                                            if (ResourceManager.tryGetRegion(raycastInfo.transform, out x, out y, out index2))
                                            {
                                                ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index2);
                                                if (resourceSpawnpoint != null && !resourceSpawnpoint.isDead && (int)resourceSpawnpoint.asset.bladeID == (int)((ItemWeaponAsset)displayAsset).bladeID)
                                                {
                                                    DamageTool.damage(raycastInfo.transform, raycastInfo.direction * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f), ((ItemWeaponAsset)displayAsset).resourceDamage, times, 1f, out kill, out xp, new CSteamID(), EDamageOrigin.Sentry);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.section < byte.MaxValue)
                                        {
                                            InteractableObjectRubble componentInParent = raycastInfo.transform.GetComponentInParent <InteractableObjectRubble>();
                                            if ((UnityEngine.Object)componentInParent != (UnityEngine.Object)null && !componentInParent.isSectionDead(raycastInfo.section) && (componentInParent.asset.rubbleIsVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable))
                                            {
                                                DamageTool.damage(componentInParent.transform, raycastInfo.direction, raycastInfo.section, ((ItemWeaponAsset)displayAsset).objectDamage, times, out kill, out xp, new CSteamID(), EDamageOrigin.Sentry);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Vector3 point = Vector3.zero;
                                if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                                {
                                    point = targetPlayer.look.aim.position;
                                }
                                else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                                {
                                    point = targetZombie.transform.position;
                                    switch (targetZombie.speciality)
                                    {
                                    case EZombieSpeciality.NORMAL:
                                        point += new Vector3(0.0f, 1.75f, 0.0f);
                                        break;

                                    case EZombieSpeciality.MEGA:
                                        point += new Vector3(0.0f, 2.625f, 0.0f);
                                        break;

                                    case EZombieSpeciality.CRAWLER:
                                        point += new Vector3(0.0f, 0.25f, 0.0f);
                                        break;

                                    case EZombieSpeciality.SPRINTER:
                                        point += new Vector3(0.0f, 1f, 0.0f);
                                        break;
                                    }
                                }
                                else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                                {
                                    point = targetAnimal.transform.position + Vector3.up;
                                }
                                DamageTool.impact(point, -aimTransform.forward, EPhysicsMaterial.FLESH_DYNAMIC, true);
                                Vector3 direction = aimTransform.forward * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f);
                                if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null)
                                {
                                    DamageTool.damage(targetPlayer, EDeathCause.SENTRY, ELimb.SPINE, __instance.owner, direction, (IDamageMultiplier)((ItemWeaponAsset)displayAsset).playerDamageMultiplier, times, true, out kill, true, ERagdollEffect.NONE);
                                }
                                else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null)
                                {
                                    IDamageMultiplier      damageMultiplier = ((ItemWeaponAsset)displayAsset).zombieOrPlayerDamageMultiplier;
                                    DamageZombieParameters parameters       = DamageZombieParameters.make(targetZombie, direction, damageMultiplier, ELimb.SPINE);
                                    parameters.times       = times;
                                    parameters.legacyArmor = true;
                                    parameters.instigator  = (object)__instance;
                                    DamageTool.damageZombie(parameters, out kill, out xp);
                                }
                                else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null)
                                {
                                    IDamageMultiplier      damageMultiplier = ((ItemWeaponAsset)displayAsset).animalOrPlayerDamageMultiplier;
                                    DamageAnimalParameters parameters       = DamageAnimalParameters.make(targetAnimal, direction, damageMultiplier, ELimb.SPINE);
                                    parameters.times      = times;
                                    parameters.instigator = (object)__instance;
                                    DamageTool.damageAnimal(parameters, out kill, out xp);
                                }
                            }
                        }
                    }
                    __instance.rebuildState();
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
 public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1));
         if (num.Internal < 0)
         {
             queue.HandleError(entry, "Must provide a non-negative number!");
             return;
         }
         EntityTag entity = EntityTag.For(entry.GetArgumentObject(queue, 0));
         if (entity == null)
         {
             queue.HandleError(entry, "Invalid entity!");
             return;
         }
         PlayerTag player;
         if (entity.TryGetPlayer(out player))
         {
             UFMHealthController healthController = player.Internal.player.gameObject.GetComponent <UFMHealthController>();
             uint amount = (uint)num.Internal;
             if (healthController != null)
             {
                 healthController.Heal(amount);
                 amount = (uint)(((double)amount / healthController.maxHealth) * 100.0);
             }
             PlayerLife life = player.Internal.player.life;
             life._health = healthController.Translate();
             life.channel.send("tellHealth", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 life.health
             });
             if (entry.ShouldShowGood(queue))
             {
                 uint finalHealth = healthController != null ? healthController.health : life.health;
                 entry.Good(queue, "Successfully healed a player to a new health value of " + finalHealth + "!");
             }
             return;
         }
         ZombieTag zombie;
         if (entity.TryGetZombie(out zombie))
         {
             Zombie inZomb = zombie.Internal;
             inZomb.health += (ushort)num.Internal;
             if (inZomb.health > inZomb.maxHealth)
             {
                 inZomb.health = inZomb.maxHealth;
             }
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully healed a zombie to a new health value of " + inZomb.health + "!");
             }
             return;
         }
         AnimalTag animal;
         if (entity.TryGetAnimal(out animal))
         {
             Animal inAnimal = animal.Internal;
             inAnimal.health += (ushort)num.Internal;
             if (inAnimal.health > inAnimal.asset.health)
             {
                 inAnimal.health = inAnimal.asset.health;
             }
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully healed an animal to a new health value of " + inAnimal.health + "!");
             }
             return;
         }
         BarricadeTag barricade;
         if (entity.TryGetBarricade(out barricade))
         {
             Barricade inBarricade = barricade.InternalData.barricade;
             inBarricade.health += (ushort)num.Internal;
             ushort max = ((ItemBarricadeAsset)Assets.find(EAssetType.ITEM, inBarricade.id)).health;
             if (inBarricade.health > max)
             {
                 inBarricade.health = max;
             }
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully healed a barricade to a new health value of " + inBarricade.health + "!");
             }
             return;
         }
         ResourceTag resource;
         if (entity.TryGetResource(out resource))
         {
             ResourceSpawnpoint inResource = resource.Internal;
             inResource.health += (ushort)num.Internal;
             ushort max = ((ResourceAsset)Assets.find(EAssetType.RESOURCE, inResource.id)).health;
             if (inResource.health > max)
             {
                 inResource.health = max;
             }
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully healed a resource to a new health value of " + inResource.health + "!");
             }
             return;
         }
         StructureTag structure;
         if (entity.TryGetStructure(out structure))
         {
             Structure inStructure = structure.InternalData.structure;
             inStructure.health += (ushort)num.Internal;
             ushort max = ((ItemStructureAsset)Assets.find(EAssetType.ITEM, inStructure.id)).health;
             if (inStructure.health > max)
             {
                 inStructure.health = max;
             }
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully healed a structure to a new health value of " + inStructure.health + "!");
             }
             return;
         }
         VehicleTag vehicle;
         if (entity.TryGetVehicle(out vehicle))
         {
             vehicle.Internal.askRepair((ushort)num.Internal);
             if (entry.ShouldShowGood(queue))
             {
                 entry.Good(queue, "Successfully healed a vehicle to a new health value of " + vehicle.Internal.health + "!");
             }
             return;
         }
         queue.HandleError(entry, "That entity can't be healed!");
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, ("Failed to heal entity: " + ex.ToString()));
     }
 }
Ejemplo n.º 9
0
        public virtual void update()
        {
            Ray        pointerToWorldRay = DevkitInput.pointerToWorldRay;
            RaycastHit raycastHit;

            this.isPointerOnWorld     = PhysicsUtility.raycast(pointerToWorldRay, out raycastHit, 8192f, (int)DevkitFoliageToolOptions.instance.surfaceMask, 0);
            this.pointerWorldPosition = raycastHit.point;
            this.previewSamples.Clear();
            if (!DevkitNavigation.isNavigating && DevkitInput.canEditorReceiveInput)
            {
                if (Input.GetKeyDown(113))
                {
                    this.mode = DevkitFoliageTool.EFoliageMode.PAINT;
                }
                if (Input.GetKeyDown(119))
                {
                    this.mode = DevkitFoliageTool.EFoliageMode.EXACT;
                }
                if (this.mode == DevkitFoliageTool.EFoliageMode.PAINT)
                {
                    if (Input.GetKeyDown(98))
                    {
                        this.isChangingBrushRadius = true;
                        this.beginChangeHotkeyTransaction();
                    }
                    if (Input.GetKeyDown(102))
                    {
                        this.isChangingBrushFalloff = true;
                        this.beginChangeHotkeyTransaction();
                    }
                    if (Input.GetKeyDown(118))
                    {
                        this.isChangingBrushStrength = true;
                        this.beginChangeHotkeyTransaction();
                    }
                }
            }
            if (Input.GetKeyUp(98))
            {
                this.isChangingBrushRadius = false;
                this.endChangeHotkeyTransaction();
            }
            if (Input.GetKeyUp(102))
            {
                this.isChangingBrushFalloff = false;
                this.endChangeHotkeyTransaction();
            }
            if (Input.GetKeyUp(118))
            {
                this.isChangingBrushStrength = false;
                this.endChangeHotkeyTransaction();
            }
            if (this.isChangingBrush)
            {
                Plane plane = default(Plane);
                plane.SetNormalAndPosition(Vector3.up, this.brushWorldPosition);
                float num;
                plane.Raycast(pointerToWorldRay, ref num);
                this.changePlanePosition = pointerToWorldRay.origin + pointerToWorldRay.direction * num;
                if (this.isChangingBrushRadius)
                {
                    this.brushRadius = (this.changePlanePosition - this.brushWorldPosition).magnitude;
                }
                if (this.isChangingBrushFalloff)
                {
                    this.brushFalloff = Mathf.Clamp01((this.changePlanePosition - this.brushWorldPosition).magnitude / this.brushRadius);
                }
                if (this.isChangingBrushStrength)
                {
                    this.brushStrength = (this.changePlanePosition - this.brushWorldPosition).magnitude / this.brushRadius;
                }
            }
            else
            {
                this.brushWorldPosition = this.pointerWorldPosition;
            }
            this.isBrushVisible = (this.isPointerOnWorld || this.isChangingBrush);
            if (!DevkitNavigation.isNavigating && DevkitInput.canEditorReceiveInput)
            {
                if (this.mode == DevkitFoliageTool.EFoliageMode.PAINT)
                {
                    Bounds worldBounds;
                    worldBounds..ctor(this.brushWorldPosition, new Vector3(this.brushRadius * 2f, 0f, this.brushRadius * 2f));
                    float num2 = this.brushRadius * this.brushRadius;
                    float num3 = num2 * this.brushFalloff * this.brushFalloff;
                    float num4 = 3.14159274f * this.brushRadius * this.brushRadius;
                    if (Input.GetKey(306) || Input.GetKey(304))
                    {
                        this.removeWeight += DevkitFoliageToolOptions.removeSensitivity * num4 * this.brushStrength * Time.deltaTime;
                        int num5 = 0;
                        if (this.removeWeight > 1f)
                        {
                            num5 = Mathf.FloorToInt(this.removeWeight);
                            this.removeWeight -= (float)num5;
                        }
                        FoliageBounds foliageBounds = new FoliageBounds(worldBounds);
                        for (int i = foliageBounds.min.x; i <= foliageBounds.max.x; i++)
                        {
                            for (int j = foliageBounds.min.y; j <= foliageBounds.max.y; j++)
                            {
                                FoliageCoord tileCoord = new FoliageCoord(i, j);
                                FoliageTile  tile      = FoliageSystem.getTile(tileCoord);
                                if (tile != null)
                                {
                                    if (!tile.hasInstances)
                                    {
                                        tile.readInstancesOnThread();
                                    }
                                    if (Input.GetKey(306))
                                    {
                                        if (DevkitFoliageTool.selectedInstanceAsset != null)
                                        {
                                            FoliageInstanceList list;
                                            if (tile.instances.TryGetValue(DevkitFoliageTool.selectedInstanceAsset.getReferenceTo <FoliageInstancedMeshInfoAsset>(), out list))
                                            {
                                                this.removeInstances(tile, list, num2, num3, ref num5);
                                            }
                                        }
                                        else if (DevkitFoliageTool.selectedCollectionAsset != null)
                                        {
                                            foreach (FoliageInfoCollectionAsset.FoliageInfoCollectionElement foliageInfoCollectionElement in DevkitFoliageTool.selectedCollectionAsset.elements)
                                            {
                                                FoliageInstancedMeshInfoAsset foliageInstancedMeshInfoAsset = Assets.find <FoliageInfoAsset>(foliageInfoCollectionElement.asset) as FoliageInstancedMeshInfoAsset;
                                                FoliageInstanceList           list2;
                                                if (foliageInstancedMeshInfoAsset != null && tile.instances.TryGetValue(foliageInstancedMeshInfoAsset.getReferenceTo <FoliageInstancedMeshInfoAsset>(), out list2))
                                                {
                                                    this.removeInstances(tile, list2, num2, num3, ref num5);
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        foreach (KeyValuePair <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> keyValuePair in tile.instances)
                                        {
                                            FoliageInstanceList value = keyValuePair.Value;
                                            this.removeInstances(tile, value, num2, num3, ref num5);
                                        }
                                    }
                                }
                            }
                        }
                        RegionBounds regionBounds = new RegionBounds(worldBounds);
                        for (byte b = regionBounds.min.x; b <= regionBounds.max.x; b += 1)
                        {
                            for (byte b2 = regionBounds.min.y; b2 <= regionBounds.max.y; b2 += 1)
                            {
                                List <ResourceSpawnpoint> list3 = LevelGround.trees[(int)b, (int)b2];
                                for (int k = list3.Count - 1; k >= 0; k--)
                                {
                                    ResourceSpawnpoint resourceSpawnpoint = list3[k];
                                    if (!resourceSpawnpoint.isGenerated)
                                    {
                                        if (Input.GetKey(306))
                                        {
                                            if (DevkitFoliageTool.selectedInstanceAsset != null)
                                            {
                                                FoliageResourceInfoAsset foliageResourceInfoAsset = DevkitFoliageTool.selectedInstanceAsset as FoliageResourceInfoAsset;
                                                if (foliageResourceInfoAsset == null || !foliageResourceInfoAsset.resource.isReferenceTo(resourceSpawnpoint.asset))
                                                {
                                                    goto IL_6BB;
                                                }
                                            }
                                            else if (DevkitFoliageTool.selectedCollectionAsset != null)
                                            {
                                                bool flag = false;
                                                foreach (FoliageInfoCollectionAsset.FoliageInfoCollectionElement foliageInfoCollectionElement2 in DevkitFoliageTool.selectedCollectionAsset.elements)
                                                {
                                                    FoliageResourceInfoAsset foliageResourceInfoAsset2 = Assets.find <FoliageInfoAsset>(foliageInfoCollectionElement2.asset) as FoliageResourceInfoAsset;
                                                    if (foliageResourceInfoAsset2 != null && foliageResourceInfoAsset2.resource.isReferenceTo(resourceSpawnpoint.asset))
                                                    {
                                                        flag = true;
                                                        break;
                                                    }
                                                }
                                                if (!flag)
                                                {
                                                    goto IL_6BB;
                                                }
                                            }
                                        }
                                        float sqrMagnitude = (resourceSpawnpoint.point - this.brushWorldPosition).sqrMagnitude;
                                        if (sqrMagnitude < num2)
                                        {
                                            bool flag2 = sqrMagnitude < num3;
                                            this.previewSamples.Add(new FoliagePreviewSample(resourceSpawnpoint.point, (!flag2) ? (Color.red / 2f) : Color.red));
                                            if (Input.GetKey(323) && flag2 && num5 > 0)
                                            {
                                                resourceSpawnpoint.destroy();
                                                list3.RemoveAt(k);
                                                num5--;
                                            }
                                        }
                                    }
                                    IL_6BB :;
                                }
                                List <LevelObject> list4 = LevelObjects.objects[(int)b, (int)b2];
                                for (int l = list4.Count - 1; l >= 0; l--)
                                {
                                    LevelObject levelObject = list4[l];
                                    if (levelObject.placementOrigin == ELevelObjectPlacementOrigin.PAINTED)
                                    {
                                        if (Input.GetKey(306))
                                        {
                                            if (DevkitFoliageTool.selectedInstanceAsset != null)
                                            {
                                                FoliageObjectInfoAsset foliageObjectInfoAsset = DevkitFoliageTool.selectedInstanceAsset as FoliageObjectInfoAsset;
                                                if (foliageObjectInfoAsset == null || !foliageObjectInfoAsset.obj.isReferenceTo(levelObject.asset))
                                                {
                                                    goto IL_888;
                                                }
                                            }
                                            else if (DevkitFoliageTool.selectedCollectionAsset != null)
                                            {
                                                bool flag3 = false;
                                                foreach (FoliageInfoCollectionAsset.FoliageInfoCollectionElement foliageInfoCollectionElement3 in DevkitFoliageTool.selectedCollectionAsset.elements)
                                                {
                                                    FoliageObjectInfoAsset foliageObjectInfoAsset2 = Assets.find <FoliageInfoAsset>(foliageInfoCollectionElement3.asset) as FoliageObjectInfoAsset;
                                                    if (foliageObjectInfoAsset2 != null && foliageObjectInfoAsset2.obj.isReferenceTo(levelObject.asset))
                                                    {
                                                        flag3 = true;
                                                        break;
                                                    }
                                                }
                                                if (!flag3)
                                                {
                                                    goto IL_888;
                                                }
                                            }
                                        }
                                        float sqrMagnitude2 = (levelObject.transform.position - this.brushWorldPosition).sqrMagnitude;
                                        if (sqrMagnitude2 < num2)
                                        {
                                            bool flag4 = sqrMagnitude2 < num3;
                                            this.previewSamples.Add(new FoliagePreviewSample(levelObject.transform.position, (!flag4) ? (Color.red / 2f) : Color.red));
                                            if (Input.GetKey(323) && flag4 && num5 > 0)
                                            {
                                                levelObject.destroy();
                                                list4.RemoveAt(l);
                                                num5--;
                                            }
                                        }
                                    }
                                    IL_888 :;
                                }
                            }
                        }
                    }
                    else if (DevkitFoliageTool.selectedInstanceAsset != null)
                    {
                        this.addFoliage(DevkitFoliageTool.selectedInstanceAsset, 1f);
                    }
                    else if (DevkitFoliageTool.selectedCollectionAsset != null)
                    {
                        foreach (FoliageInfoCollectionAsset.FoliageInfoCollectionElement foliageInfoCollectionElement4 in DevkitFoliageTool.selectedCollectionAsset.elements)
                        {
                            this.addFoliage(Assets.find <FoliageInfoAsset>(foliageInfoCollectionElement4.asset), foliageInfoCollectionElement4.weight);
                        }
                    }
                }
                else if (Input.GetKeyDown(323))
                {
                    if (DevkitFoliageTool.selectedInstanceAsset != null)
                    {
                        if (DevkitFoliageTool.selectedInstanceAsset != null)
                        {
                            DevkitFoliageTool.selectedInstanceAsset.addFoliageToSurface(raycastHit.point, raycastHit.normal, false, false);
                        }
                    }
                    else if (DevkitFoliageTool.selectedCollectionAsset != null)
                    {
                        FoliageInfoCollectionAsset.FoliageInfoCollectionElement foliageInfoCollectionElement5 = DevkitFoliageTool.selectedCollectionAsset.elements[Random.Range(0, DevkitFoliageTool.selectedCollectionAsset.elements.Count)];
                        FoliageInfoAsset foliageInfoAsset = Assets.find <FoliageInfoAsset>(foliageInfoCollectionElement5.asset);
                        if (foliageInfoAsset != null)
                        {
                            foliageInfoAsset.addFoliageToSurface(raycastHit.point, raycastHit.normal, false, false);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
    public static EPlayerHit CalcHitMarker(ItemGunAsset PAsset, ref RaycastInfo ri)
    {
        EPlayerHit eplayerHit = EPlayerHit.NONE;
        bool       flag       = ri == null || PAsset == null;
        EPlayerHit result;

        if (flag)
        {
            result = eplayerHit;
        }
        else
        {
            bool flag2 = ri.animal || ri.player || ri.zombie;
            if (flag2)
            {
                eplayerHit = EPlayerHit.ENTITIY;
                bool flag3 = ri.limb == ELimb.SKULL;
                if (flag3)
                {
                    eplayerHit = EPlayerHit.CRITICAL;
                }
            }
            else
            {
                bool flag4 = ri.transform;
                if (flag4)
                {
                    bool flag5 = ri.transform.CompareTag("Barricade") && PAsset.barricadeDamage > 1f;
                    if (flag5)
                    {
                        InteractableDoorHinge component = ri.transform.GetComponent <InteractableDoorHinge>();
                        bool flag6 = component != null;
                        if (flag6)
                        {
                            ri.transform = component.transform.parent.parent;
                        }
                        bool flag7 = !ushort.TryParse(ri.transform.name, out ushort id);
                        if (flag7)
                        {
                            return(eplayerHit);
                        }
                        ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                        bool flag8 = itemBarricadeAsset == null || (!itemBarricadeAsset.isVulnerable && !PAsset.isInvulnerable);
                        if (flag8)
                        {
                            return(eplayerHit);
                        }
                        bool flag9 = eplayerHit == EPlayerHit.NONE;
                        if (flag9)
                        {
                            eplayerHit = EPlayerHit.BUILD;
                        }
                    }
                    else
                    {
                        bool flag10 = ri.transform.CompareTag("Structure") && PAsset.structureDamage > 1f;
                        if (flag10)
                        {
                            bool flag11 = !ushort.TryParse(ri.transform.name, out ushort id2);
                            if (flag11)
                            {
                                return(eplayerHit);
                            }
                            ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                            bool flag12 = itemStructureAsset == null || (!itemStructureAsset.isVulnerable && !PAsset.isInvulnerable);
                            if (flag12)
                            {
                                return(eplayerHit);
                            }
                            bool flag13 = eplayerHit == EPlayerHit.NONE;
                            if (flag13)
                            {
                                eplayerHit = EPlayerHit.BUILD;
                            }
                        }
                        else
                        {
                            bool flag14 = ri.transform.CompareTag("Resource") && PAsset.resourceDamage > 1f;
                            if (flag14)
                            {
                                bool flag15 = !ResourceManager.tryGetRegion(ri.transform, out byte x, out byte y, out ushort index);
                                if (flag15)
                                {
                                    return(eplayerHit);
                                }
                                ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                                bool flag16 = resourceSpawnpoint == null || resourceSpawnpoint.isDead || !PAsset.hasBladeID(resourceSpawnpoint.asset.bladeID);
                                if (flag16)
                                {
                                    return(eplayerHit);
                                }
                                bool flag17 = eplayerHit == EPlayerHit.NONE;
                                if (flag17)
                                {
                                    eplayerHit = EPlayerHit.BUILD;
                                }
                            }
                            else
                            {
                                bool flag18 = PAsset.objectDamage > 1f;
                                if (flag18)
                                {
                                    InteractableObjectRubble component2 = ri.transform.GetComponent <InteractableObjectRubble>();
                                    bool flag19 = component2 == null;
                                    if (flag19)
                                    {
                                        return(eplayerHit);
                                    }
                                    ri.section = component2.getSection(ri.collider.transform);
                                    bool flag20 = component2.isSectionDead(ri.section) || (!component2.asset.rubbleIsVulnerable && !PAsset.isInvulnerable);
                                    if (flag20)
                                    {
                                        return(eplayerHit);
                                    }
                                    bool flag21 = eplayerHit == EPlayerHit.NONE;
                                    if (flag21)
                                    {
                                        eplayerHit = EPlayerHit.BUILD;
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    bool flag22 = ri.vehicle && !ri.vehicle.isDead && PAsset.vehicleDamage > 1f;
                    if (flag22)
                    {
                        bool flag23 = ri.vehicle.asset != null && (ri.vehicle.asset.isVulnerable || PAsset.isInvulnerable);
                        if (flag23)
                        {
                            bool flag24 = eplayerHit == EPlayerHit.NONE;
                            if (flag24)
                            {
                                eplayerHit = EPlayerHit.BUILD;
                            }
                        }
                    }
                }
            }
            result = eplayerHit;
        }
        return(result);
    }
        public static EPlayerHit CalcHitMarker(ItemGunAsset PAsset, ref RaycastInfo ri)
        {
            EPlayerHit eplayerhit = EPlayerHit.NONE;

            if (ri == null || PAsset == null)
            {
                return(eplayerhit);
            }

            if (ri.animal || ri.player || ri.zombie)
            {
                eplayerhit = EPlayerHit.ENTITIY;
                if (ri.limb == ELimb.SKULL)
                {
                    eplayerhit = EPlayerHit.CRITICAL;
                }
            }
            else if (ri.transform)
            {
                if (ri.transform.CompareTag("Barricade") && PAsset.barricadeDamage > 1f)
                {
                    InteractableDoorHinge component = ri.transform.GetComponent <InteractableDoorHinge>();
                    if (component != null)
                    {
                        ri.transform = component.transform.parent.parent;
                    }

                    if (!ushort.TryParse(ri.transform.name, out ushort id))
                    {
                        return(eplayerhit);
                    }

                    ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);

                    if (itemBarricadeAsset == null || !itemBarricadeAsset.isVulnerable && !PAsset.isInvulnerable)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
                else if (ri.transform.CompareTag("Structure") && PAsset.structureDamage > 1f)
                {
                    if (!ushort.TryParse(ri.transform.name, out ushort id2))
                    {
                        return(eplayerhit);
                    }

                    ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);

                    if (itemStructureAsset == null || !itemStructureAsset.isVulnerable && !PAsset.isInvulnerable)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
                else if (ri.transform.CompareTag("Resource") && PAsset.resourceDamage > 1f)
                {
                    if (!ResourceManager.tryGetRegion(ri.transform, out byte x, out byte y, out ushort index))
                    {
                        return(eplayerhit);
                    }

                    ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);

                    if (resourceSpawnpoint == null || resourceSpawnpoint.isDead ||
                        resourceSpawnpoint.asset.bladeID != PAsset.bladeID)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
                else if (PAsset.objectDamage > 1f)
                {
                    InteractableObjectRubble component2 = ri.transform.GetComponent <InteractableObjectRubble>();

                    if (component2 == null)
                    {
                        return(eplayerhit);
                    }

                    ri.section = component2.getSection(ri.collider.transform);

                    if (component2.isSectionDead(ri.section) ||
                        !component2.asset.rubbleIsVulnerable && !PAsset.isInvulnerable)
                    {
                        return(eplayerhit);
                    }

                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
            }
            else if (ri.vehicle && !ri.vehicle.isDead && PAsset.vehicleDamage > 1f)
            {
                if (ri.vehicle.asset != null && (ri.vehicle.asset.isVulnerable || PAsset.isInvulnerable))
                {
                    if (eplayerhit == EPlayerHit.NONE)
                    {
                        eplayerhit = EPlayerHit.BUILD;
                    }
                }
            }

            return(eplayerhit);
        }
 public static bool ResourceDamaged(ResourceSpawnpoint resource, ref ushort amount)
 {
     // TODO: causes?
     ResourceTag resourceTag = new ResourceTag(resource);
     if (amount >= resource.health)
     {
         ResourceDestroyedEventArgs deathevt = new ResourceDestroyedEventArgs();
         deathevt.Resource = resourceTag;
         deathevt.Amount = new NumberTag(amount);
         UnturnedFreneticEvents.OnResourceDestroyed.Fire(deathevt);
         amount = (ushort)deathevt.Amount.Internal;
         return deathevt.Cancelled || EntityDestroyed(resourceTag, ref amount);
     }
     ResourceDamagedEventArgs evt = new ResourceDamagedEventArgs();
     evt.Resource = resourceTag;
     evt.Amount = new NumberTag(amount);
     UnturnedFreneticEvents.OnResourceDamaged.Fire(evt);
     amount = (ushort)evt.Amount.Internal;
     return evt.Cancelled || EntityDamaged(resourceTag, ref amount);
 }
Ejemplo n.º 13
0
        // Token: 0x06000118 RID: 280 RVA: 0x0000B6FC File Offset: 0x000098FC
        public static EPlayerHit CalcHitMarker(ItemGunAsset PAsset, ref RaycastInfo ri)
        {
            EPlayerHit eplayerHit = EPlayerHit.NONE;
            bool       flag       = ri == null || PAsset == null;
            bool       flag2      = flag;
            EPlayerHit result;

            if (flag2)
            {
                result = eplayerHit;
            }
            else
            {
                bool flag3 = ri.animal || ri.player || ri.zombie;
                bool flag4 = flag3;
                if (flag4)
                {
                    eplayerHit = EPlayerHit.ENTITIY;
                    bool flag5 = ri.limb == ELimb.SKULL;
                    bool flag6 = flag5;
                    if (flag6)
                    {
                        eplayerHit = EPlayerHit.CRITICAL;
                    }
                }
                else
                {
                    bool flag7 = ri.transform;
                    bool flag8 = flag7;
                    if (flag8)
                    {
                        bool flag9  = ri.transform.CompareTag("Barricade") && PAsset.barricadeDamage > 1f;
                        bool flag10 = flag9;
                        if (flag10)
                        {
                            InteractableDoorHinge component = ri.transform.GetComponent <InteractableDoorHinge>();
                            bool flag11 = component != null;
                            bool flag12 = flag11;
                            if (flag12)
                            {
                                ri.transform = component.transform.parent.parent;
                            }
                            ushort id;
                            bool   flag13 = !ushort.TryParse(ri.transform.name, out id);
                            bool   flag14 = flag13;
                            if (flag14)
                            {
                                return(eplayerHit);
                            }
                            ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                            bool flag15 = itemBarricadeAsset == null || (!itemBarricadeAsset.isVulnerable && !PAsset.isInvulnerable);
                            bool flag16 = flag15;
                            if (flag16)
                            {
                                return(eplayerHit);
                            }
                            bool flag17 = eplayerHit == EPlayerHit.NONE;
                            bool flag18 = flag17;
                            if (flag18)
                            {
                                eplayerHit = EPlayerHit.BUILD;
                            }
                        }
                        else
                        {
                            bool flag19 = ri.transform.CompareTag("Structure") && PAsset.structureDamage > 1f;
                            bool flag20 = flag19;
                            if (flag20)
                            {
                                ushort id2;
                                bool   flag21 = !ushort.TryParse(ri.transform.name, out id2);
                                bool   flag22 = flag21;
                                if (flag22)
                                {
                                    return(eplayerHit);
                                }
                                ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                                bool flag23 = itemStructureAsset == null || (!itemStructureAsset.isVulnerable && !PAsset.isInvulnerable);
                                bool flag24 = flag23;
                                if (flag24)
                                {
                                    return(eplayerHit);
                                }
                                bool flag25 = eplayerHit == EPlayerHit.NONE;
                                bool flag26 = flag25;
                                if (flag26)
                                {
                                    eplayerHit = EPlayerHit.BUILD;
                                }
                            }
                            else
                            {
                                bool flag27 = ri.transform.CompareTag("Resource") && PAsset.resourceDamage > 1f;
                                bool flag28 = flag27;
                                if (flag28)
                                {
                                    byte   x;
                                    byte   y;
                                    ushort index;
                                    bool   flag29 = !ResourceManager.tryGetRegion(ri.transform, out x, out y, out index);
                                    bool   flag30 = flag29;
                                    if (flag30)
                                    {
                                        return(eplayerHit);
                                    }
                                    ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                                    bool flag31 = resourceSpawnpoint == null || resourceSpawnpoint.isDead || resourceSpawnpoint.asset.bladeID != PAsset.bladeID;
                                    bool flag32 = flag31;
                                    if (flag32)
                                    {
                                        return(eplayerHit);
                                    }
                                    bool flag33 = eplayerHit == EPlayerHit.NONE;
                                    bool flag34 = flag33;
                                    if (flag34)
                                    {
                                        eplayerHit = EPlayerHit.BUILD;
                                    }
                                }
                                else
                                {
                                    bool flag35 = PAsset.objectDamage > 1f;
                                    bool flag36 = flag35;
                                    if (flag36)
                                    {
                                        InteractableObjectRubble component2 = ri.transform.GetComponent <InteractableObjectRubble>();
                                        bool flag37 = component2 == null;
                                        bool flag38 = flag37;
                                        if (flag38)
                                        {
                                            return(eplayerHit);
                                        }
                                        ri.section = component2.getSection(ri.collider.transform);
                                        bool flag39 = component2.isSectionDead(ri.section) || (!component2.asset.rubbleIsVulnerable && !PAsset.isInvulnerable);
                                        bool flag40 = flag39;
                                        if (flag40)
                                        {
                                            return(eplayerHit);
                                        }
                                        bool flag41 = eplayerHit == EPlayerHit.NONE;
                                        bool flag42 = flag41;
                                        if (flag42)
                                        {
                                            eplayerHit = EPlayerHit.BUILD;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        bool flag43 = ri.vehicle && !ri.vehicle.isDead && PAsset.vehicleDamage > 1f;
                        bool flag44 = flag43;
                        if (flag44)
                        {
                            bool flag45 = ri.vehicle.asset != null && (ri.vehicle.asset.isVulnerable || PAsset.isInvulnerable);
                            bool flag46 = flag45;
                            if (flag46)
                            {
                                bool flag47 = eplayerHit == EPlayerHit.NONE;
                                bool flag48 = flag47;
                                if (flag48)
                                {
                                    eplayerHit = EPlayerHit.BUILD;
                                }
                            }
                        }
                    }
                }
                result = eplayerHit;
            }
            return(result);
        }
Ejemplo n.º 14
0
 public void punch(EPlayerPunch mode)
 {
     if (Player.player.channel.isOwner)
     {
         Player.player.playSound((AudioClip)Resources.Load("Sounds/General/Punch"));
         Ray         ray         = new Ray(Player.player.look.aim.position, Player.player.look.aim.forward);
         RaycastInfo raycastInfo = DamageTool.raycast(ray, MP_Player.farPunch ? 12f : 1.75f, RayMasks.DAMAGE_CLIENT); //1.75 default
         if (raycastInfo.player != null && DAMAGE_PLAYER_MULTIPLIER.damage > 1f && (Player.player.channel.owner.playerID.group == CSteamID.Nil || raycastInfo.player.channel.owner.playerID.group != Player.player.channel.owner.playerID.group) && Provider.isPvP)
         {
             PlayerUI.hitmark(0, raycastInfo.point, false, (raycastInfo.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
         }
         else if ((raycastInfo.zombie != null && DAMAGE_ZOMBIE_MULTIPLIER.damage > 1f) || (raycastInfo.animal != null && DAMAGE_ANIMAL_MULTIPLIER.damage > 1f))
         {
             PlayerUI.hitmark(0, raycastInfo.point, false, (raycastInfo.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
         }
         else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Barricade") && DAMAGE_BARRICADE > 1f)
         {
             InteractableDoorHinge component = raycastInfo.transform.GetComponent <InteractableDoorHinge>();
             if (component != null)
             {
                 raycastInfo.transform = component.transform.parent.parent;
             }
             ushort id;
             if (ushort.TryParse(raycastInfo.transform.name, out id))
             {
                 ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                 if (itemBarricadeAsset != null && itemBarricadeAsset.isVulnerable)
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Structure") && DAMAGE_STRUCTURE > 1f)
         {
             ushort id2;
             if (ushort.TryParse(raycastInfo.transform.name, out id2))
             {
                 ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                 if (itemStructureAsset != null && itemStructureAsset.isVulnerable)
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         else if (raycastInfo.vehicle != null && !raycastInfo.vehicle.isDead && DAMAGE_VEHICLE > 1f)
         {
             if (raycastInfo.vehicle.asset != null && raycastInfo.vehicle.asset.isVulnerable)
             {
                 PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
             }
         }
         else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Resource") && DAMAGE_RESOURCE > 1f)
         {
             byte   x;
             byte   y;
             ushort index;
             if (ResourceManager.tryGetRegion(raycastInfo.transform, out x, out y, out index))
             {
                 ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                 if (resourceSpawnpoint != null && !resourceSpawnpoint.isDead)
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         else if (raycastInfo.transform != null && DAMAGE_OBJECT > 1f)
         {
             InteractableObjectRubble component2 = raycastInfo.transform.GetComponent <InteractableObjectRubble>();
             if (component2 != null)
             {
                 raycastInfo.section = component2.getSection(raycastInfo.collider.transform);
                 if (!component2.isSectionDead(raycastInfo.section))
                 {
                     PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                 }
             }
         }
         Player.player.input.sendRaycast(raycastInfo);
     }
     if (mode == EPlayerPunch.LEFT)
     {
         Player.player.animator.play("Punch_Left", false);
         if (Provider.isServer)
         {
             Player.player.animator.sendGesture(EPlayerGesture.PUNCH_LEFT, false);
         }
     }
     else if (mode == EPlayerPunch.RIGHT)
     {
         Player.player.animator.play("Punch_Right", false);
         if (Provider.isServer)
         {
             Player.player.animator.sendGesture(EPlayerGesture.PUNCH_RIGHT, false);
         }
     }
     if (Provider.isServer)
     {
         if (!Player.player.input.hasInputs())
         {
             return;
         }
         InputInfo input = Player.player.input.getInput(true);
         if (input == null)
         {
             return;
         }
         if ((input.point - Player.player.look.aim.position).sqrMagnitude > 36f)
         {
             return;
         }
         DamageTool.impact(input.point, input.normal, input.material, input.type != ERaycastInfoType.NONE && input.type != ERaycastInfoType.OBJECT);
         EPlayerKill ePlayerKill = EPlayerKill.NONE;
         uint        num         = 0u;
         float       num2        = 1f;
         num2 *= 1f + Player.player.channel.owner.player.skills.mastery(0, 0) * 0.5f;
         if (input.type == ERaycastInfoType.PLAYER)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             if (input.player != null && (Player.player.channel.owner.playerID.group == CSteamID.Nil || input.player.channel.owner.playerID.group != Player.player.channel.owner.playerID.group) && Provider.isPvP)
             {
                 DamageTool.damage(input.player, EDeathCause.PUNCH, input.limb, Player.player.channel.owner.playerID.steamID, input.direction, DAMAGE_PLAYER_MULTIPLIER, num2, true, out ePlayerKill);
             }
         }
         else if (input.type == ERaycastInfoType.ZOMBIE)
         {
             if (input.zombie != null)
             {
                 DamageTool.damage(input.zombie, input.limb, input.direction, DAMAGE_ZOMBIE_MULTIPLIER, num2, true, out ePlayerKill, out num);
                 if (Player.player.movement.nav != 255)
                 {
                     input.zombie.alert(base.transform.position, true);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.ANIMAL)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             if (input.animal != null)
             {
                 DamageTool.damage(input.animal, input.limb, input.direction, DAMAGE_ANIMAL_MULTIPLIER, num2, out ePlayerKill, out num);
                 input.animal.alertPoint(base.transform.position, true);
             }
         }
         else if (input.type == ERaycastInfoType.VEHICLE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             if (input.vehicle != null && input.vehicle.asset != null && input.vehicle.asset.isVulnerable)
             {
                 DamageTool.damage(input.vehicle, false, DAMAGE_VEHICLE, num2, true, out ePlayerKill);
             }
         }
         else if (input.type == ERaycastInfoType.BARRICADE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             ushort id3;
             if (input.transform != null && input.transform.CompareTag("Barricade") && ushort.TryParse(input.transform.name, out id3))
             {
                 ItemBarricadeAsset itemBarricadeAsset2 = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id3);
                 if (itemBarricadeAsset2 != null && itemBarricadeAsset2.isVulnerable)
                 {
                     DamageTool.damage(input.transform, false, DAMAGE_BARRICADE, num2, out ePlayerKill);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.STRUCTURE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             ushort id4;
             if (input.transform != null && input.transform.CompareTag("Structure") && ushort.TryParse(input.transform.name, out id4))
             {
                 ItemStructureAsset itemStructureAsset2 = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id4);
                 if (itemStructureAsset2 != null && itemStructureAsset2.isVulnerable)
                 {
                     DamageTool.damage(input.transform, false, input.direction, DAMAGE_STRUCTURE, num2, out ePlayerKill);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.RESOURCE)
         {
             typeof(PlayerEquipment).GetField("lastPunching", BindingFlags.Instance | BindingFlags.Public).SetValue(null, Time.realtimeSinceStartup);
             byte   x2;
             byte   y2;
             ushort index2;
             if (input.transform != null && input.transform.CompareTag("Resource") && ResourceManager.tryGetRegion(input.transform, out x2, out y2, out index2))
             {
                 ResourceSpawnpoint resourceSpawnpoint2 = ResourceManager.getResourceSpawnpoint(x2, y2, index2);
                 if (resourceSpawnpoint2 != null && !resourceSpawnpoint2.isDead)
                 {
                     DamageTool.damage(input.transform, input.direction, DAMAGE_RESOURCE, num2, 1f, out ePlayerKill, out num);
                 }
             }
         }
         else if (input.type == ERaycastInfoType.OBJECT && input.transform != null && input.section < 255)
         {
             InteractableObjectRubble component3 = input.transform.GetComponent <InteractableObjectRubble>();
             if (component3 != null && !component3.isSectionDead(input.section))
             {
                 DamageTool.damage(input.transform, input.direction, input.section, DAMAGE_OBJECT, num2, out ePlayerKill, out num);
             }
         }
         if (Level.info.type == ELevelType.HORDE)
         {
             if (input.zombie != null)
             {
                 if (input.limb == ELimb.SKULL)
                 {
                     Player.player.skills.askPay(10u);
                 }
                 else
                 {
                     Player.player.skills.askPay(5u);
                 }
             }
             if (ePlayerKill == EPlayerKill.ZOMBIE)
             {
                 if (input.limb == ELimb.SKULL)
                 {
                     Player.player.skills.askPay(50u);
                 }
                 else
                 {
                     Player.player.skills.askPay(25u);
                 }
             }
         }
         else
         {
             if (ePlayerKill == EPlayerKill.PLAYER)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_PLAYERS);
                 if (Level.info.type == ELevelType.ARENA)
                 {
                     Player.player.skills.askPay(100u);
                 }
             }
             else if (ePlayerKill == EPlayerKill.ZOMBIE)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_ZOMBIES_NORMAL);
             }
             else if (ePlayerKill == EPlayerKill.MEGA)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_ZOMBIES_MEGA);
             }
             else if (ePlayerKill == EPlayerKill.ANIMAL)
             {
                 Player.player.sendStat(EPlayerStat.KILLS_ANIMALS);
             }
             else if (ePlayerKill == EPlayerKill.RESOURCE)
             {
                 Player.player.sendStat(EPlayerStat.FOUND_RESOURCES);
             }
             if (num > 0u)
             {
                 Player.player.skills.askPay(num);
             }
         }
     }
 }