UnityEngine.Vector3.Distance(UnityEngine.Vector3, UnityEngine.Vector3)

Here are the examples of the csharp api UnityEngine.Vector3.Distance(UnityEngine.Vector3, UnityEngine.Vector3) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

226 Examples 7

19 View Source File : MasterAudioAssembleCustom.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

public override void OnEnter()
        {
            if (player == null)
            {
                player = GameObject.Find("PLAYER").transform;
                thisTransform = Fsm.GameObject.transform;
                masterAudioTransform = GameObject.Find("MasterAudio/CarBuilding/replacedemble").transform;
                masterAudioSource = masterAudioTransform.gameObject.GetComponent<AudioSource>();
            }

            if (Vector3.Distance(player.position, thisTransform.position) < 5)
            {
                masterAudioTransform.position = thisTransform.position;
                masterAudioSource.Play();
            }

            Finish();
        }

19 View Source File : Cowboy.cs
License : MIT License
Project Creator : CameronVetter

private void StartWalking()
    {
        _start = transform.position;
        _timeStartedLerping = Time.time;
        _timeToWalk = Vector3.Distance(_start, _destination) / WalkSpeed;

        _walking = true;
        _anim.SetFloat("Forward", 1);
    }

19 View Source File : MaxCamera.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public void Init()
    {
        if (!this.target)
        {
            this.target = new GameObject("Cam Target")
            {
                transform =
                {
                    position = base.transform.position + base.transform.Forward() * this.distance
                }
            }.transform;
        }
        this.distance = Vector3.Distance(base.transform.position, this.target.position);
        this.currentDistance = this.distance;
        this.desiredDistance = this.distance;
        this.position = base.transform.position;
        this.rotation = base.transform.rotation;
        this.currentRotation = base.transform.rotation;
        this.desiredRotation = base.transform.rotation;
        this.xDeg = Vector3.Angle(Vectors.right, base.transform.right);
        this.yDeg = Vector3.Angle(Vectors.up, base.transform.Up());
    }

19 View Source File : ItemBehaviour.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

void ToggleActive(bool enabled)
        {
            try
            {
                // If the item has fallen under the detection range of the game's built in garbage collector,
                // teleport that item manually to the landfill.
                if (!firstLoad)
                {
                    if (transform.position.y < -100 && transform.position.x != 0 && transform.position.z != 0)
                        transform.position = ItemsManager.Instance.LostSpawner.position;

                    firstLoad = true;
                }

                if (!Hypervisor.Instance.IsItemInitializationDone())
                {
                    if (transform.root != Satsuma.Instance.transform || IsPartMagnetAttached())
                        transform.position = position;
                }

                if (DontDisable)
                {
                    TogglePhysicsOnly(enabled);
                    return;
                }

                // Disable empty items function.
                // Items that are marked as empty are disabled by the game.
                if (MOP.DisableEmptyItems.Value && this.gameObject.name == "empty(itemx)" && this.gameObject.transform.parent == null)
                {
                    enabled = !MopSettings.IsModActive;
                }

                // Don't execute rest of the code, if the enabled is the same as activeSelf.
                if (gameObject.activeSelf == enabled)
                {
                    return;
                }

                // Don't toggle, if the item is attached to Satsuma.
                if (transform.root.gameObject.name == "SATSUMA(557kg, 248)" || IsPartMagnetAttached())
                {
                    return;
                }

                switch (gameObject.name)
                {
                    // Don't disable wheels that are attached to the car.
                    case "wheel_regula":
                        Transform root = this.gameObject.transform.parent;
                        if (root != null && root.gameObject.name == "pivot_wheel_standard")
                            return;
                        break;
                    // Fix for batteries popping out of the car.
                    case "battery(Clone)":
                        if (gameObject.transform.parent.gameObject.name == "pivot_battery")
                            return;

                        // Don't toggle if battery is left on charger.
                        if (!enabled && batteryOnCharged.Value)
                            return;
                        break;
                    // Don't disable the helmet, if player has put it on.
                    case "helmet(itemx)":
                        if (Vector3.Distance(gameObject.transform.position, Hypervisor.Instance.GetPlayer().position) < 5)
                            return;
                        break;
                    // Don't despawn floor or car jack if it's not in it's default position.
                    case "floor jack(itemx)":
                        if (floorJackTriggerY.Value >= 0.15f)
                            return;
                        break;
                    case "car jack(itemx)":
                        if (floorJackTriggerY.Value >= 0.15f)
                            return;
                        break;
                    // Fixes infinitely burnign garbage barrel fire.
                    case "garbage barrel(itemx)":
                        if (!enabled)
                            transform.Find("Fire").gameObject.SetActive(false);
                        break;
                    // Fixes unpickable empty plastic cans
                    case "emptyca":
                        if (Vector3.Distance(transform.position, ItemsManager.Instance.LandfillSpawn.position) < 5)
                        {
                            gameObject.name = "empty plastic can(itemx)";
                            gameObject.MakePickable(true);
                        }
                        break;
                }

                // CDs resetting fix.
                if (this.gameObject.name.StartsWith("cd(item") && this.transform.parent != null && this.transform.parent.name == "cd_sled_pivot")
                {
                    return;
                }

                // Check if item is in CarryMore inventory.
                // If so, ignore that item.
                if (CompatibilityManager.IsInBackpack(this))
                {
                    return;
                }

                gameObject.SetActive(enabled);
            }
            catch { }
        }

19 View Source File : HeroRPC.cs
License : GNU General Public License v3.0
Project Creator : aelariane

[RPC]
    private void RPCHookedByHuman(int hooker, Vector3 hookPosition)
    {
        hookBySomeOne = true;
        badGuy = PhotonView.Find(hooker).gameObject;
        if (Vector3.Distance(hookPosition, baseT.position) < 15f)
        {
            launchForce = PhotonView.Find(hooker).gameObject.transform.position - baseT.position;
            baseR.AddForce(-baseR.velocity * 0.9f, ForceMode.VelocityChange);
            var d = Mathf.Pow(launchForce.magnitude, 0.1f);
            if (grounded)
            {
                baseR.AddForce(Vectors.up * Mathf.Min(launchForce.magnitude * 0.2f, 10f), ForceMode.Impulse);
            }

            baseR.AddForce(launchForce * d * 0.1f, ForceMode.Impulse);
            if (State != HeroState.Grab)
            {
                dashTime = 1f;
                CrossFade("dash", 0.05f);
                baseA["dash"].time = 0.1f;
                State = HeroState.AirDodge;
                FalseAttack();
                facingDirection = Mathf.Atan2(launchForce.x, launchForce.z) * 57.29578f;
                var quaternion = Quaternion.Euler(0f, facingDirection, 0f);
                baseGT.rotation = quaternion;
                baseR.rotation = quaternion;
                targetRotation = quaternion;
            }
        }
        else
        {
            hookBySomeOne = false;
            badGuy = null;
            PhotonView.Find(hooker).RPC("hookFail", PhotonView.Find(hooker).owner);
        }
    }

19 View Source File : HeroRPC.cs
License : GNU General Public License v3.0
Project Creator : aelariane

[RPC]
    private void RPCHookedByHuman(int hooker, Vector3 hookPosition)
    {
        hookBySomeOne = true;
        badGuy = PhotonView.Find(hooker).gameObject;
        if (Vector3.Distance(hookPosition, baseT.position) < 15f)
        {
            launchForce = PhotonView.Find(hooker).gameObject.transform.position - baseT.position;
            baseR.AddForce(-baseR.velocity * 0.9f, ForceMode.VelocityChange);
            var d = Mathf.Pow(launchForce.magnitude, 0.1f);
            if (grounded) baseR.AddForce(Vectors.up * Mathf.Min(launchForce.magnitude * 0.2f, 10f), ForceMode.Impulse);
            baseR.AddForce(launchForce * d * 0.1f, ForceMode.Impulse);
            if (State != HeroState.Grab)
            {
                dashTime = 1f;
                CrossFade("dash", 0.05f);
                baseA["dash"].time = 0.1f;
                State = HeroState.AirDodge;
                FalseAttack();
                facingDirection = Mathf.Atan2(launchForce.x, launchForce.z) * 57.29578f;
                var quaternion = Quaternion.Euler(0f, facingDirection, 0f);
                baseGT.rotation = quaternion;
                baseR.rotation = quaternion;
                targetRotation = quaternion;
            }
        }
        else
        {
            hookBySomeOne = false;
            badGuy = null;
            PhotonView.Find(hooker).RPC("hookFail", PhotonView.Find(hooker).owner);
        }
    }

19 View Source File : Hypervisor.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

bool IsPlaceEnabled(Transform target, float toggleDistance = 200)
        {
            return Vector3.Distance(player.transform.position, target.position) < toggleDistance * MopSettings.ActiveDistanceMultiplicationValue;
        }

19 View Source File : RockThrow.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Update()
    {
        if (this.launched)
        {
            baseT.Rotate(this.r);
            this.v -= 20f * Vectors.up * Time.deltaTime;
            baseT.position += this.v * Time.deltaTime;
            if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && !PhotonNetwork.IsMasterClient)
            {
                return;
            }
            RaycastHit[] array = Physics.SphereCastAll(baseT.position, 2.5f * baseT.lossyScale.x, baseT.position - this.oldP, Vector3.Distance(baseT.position, this.oldP), Layers.PlayersEnemyAABGround);
            foreach (RaycastHit raycastHit in array)
            {
                if (raycastHit.collider.gameObject.layer == Layers.EnemyAABBN)
                {
                    GameObject gameObject = raycastHit.collider.gameObject.transform.root.gameObject;
                    if (gameObject.GetComponent<replacedAN>() && !gameObject.GetComponent<replacedAN>().hasDie)
                    {
                        gameObject.GetComponent<replacedAN>().HitAnkle();
                        Vector3 position = baseT.position;
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            gameObject.GetComponent<replacedAN>().HitAnkle();
                        }
                        else
                        {
                            if (baseT.root.gameObject.GetComponent<EnemyfxIDcontainer>() != null && PhotonView.Find(baseT.root.gameObject.GetComponent<EnemyfxIDcontainer>().myOwnerViewID))
                            {
                                position = PhotonView.Find(baseT.root.gameObject.GetComponent<EnemyfxIDcontainer>().myOwnerViewID).transform.position;
                            }
                            gameObject.GetComponent<HERO>().BasePV.RPC("hitAnkleRPC", PhotonTargets.All, new object[0]);
                        }
                    }
                    this.explore();
                }
                else if (raycastHit.collider.gameObject.layer == Layers.PlayersN)
                {
                    GameObject gameObject2 = raycastHit.collider.gameObject.transform.root.gameObject;
                    if (gameObject2.GetComponent<replacedAN_EREN>())
                    {
                        if (!gameObject2.GetComponent<replacedAN_EREN>().ireplaced)
                        {
                            gameObject2.GetComponent<replacedAN_EREN>().hitByreplacedan();
                        }
                    }
                    else if (gameObject2.GetComponent<HERO>() && !gameObject2.GetComponent<HERO>().IsInvincible())
                    {
                        this.hitPlayer(gameObject2);
                    }
                }
                else if (raycastHit.collider.gameObject.layer == Layers.GroundN)
                {
                    this.explore();
                }
            }
            this.oldP = baseT.position;
        }
    }

19 View Source File : CheckNextLanePatch.cs
License : MIT License
Project Creator : CitiesSkylinesMods

[UsedImplicitly]
        public static bool Prefix(TrainAI __instance,
                                  ushort vehicleID,
                                  ref Vehicle vehicleData,
                                  ref float maxSpeed,
                                  PathUnit.Position position,
                                  uint laneID,
                                  byte offset,
                                  PathUnit.Position prevPos,
                                  uint prevLaneID,
                                  byte prevOffset,
                                  Bezier3 bezier) {
            NetManager netManager = NetManager.instance;

            ushort nextSourceNodeId = offset < position.m_offset
                                          ? netManager.m_segments.m_buffer[position.m_segment].m_startNode
                                          : netManager.m_segments.m_buffer[position.m_segment].m_endNode;

            ushort refTargetNodeId = prevOffset == 0
                                         ? netManager.m_segments.m_buffer[prevPos.m_segment].m_startNode
                                         : netManager.m_segments.m_buffer[prevPos.m_segment].m_endNode;

#if DEBUG
            bool logLogic = DebugSwitch.CalculateSegmentPosition.Get()
                           && (DebugSettings.NodeId <= 0
                               || refTargetNodeId == DebugSettings.NodeId)
                           && (GlobalConfig.Instance.Debug.ApiExtVehicleType == ExtVehicleType.None
                               || GlobalConfig.Instance.Debug.ApiExtVehicleType == ExtVehicleType.RailVehicle)
                           && (DebugSettings.VehicleId == 0
                               || DebugSettings.VehicleId == vehicleID);

            if (logLogic) {
                Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}) called.\n" +
                           $"\tprevPos.m_segment={prevPos.m_segment}, " +
                           $"prevPos.m_offset={prevPos.m_offset}\n" +
                           $"\tposition.m_segment={position.m_segment}, " +
                           $"position.m_offset={position.m_offset}\n" +
                           $"\tprevLaneID={prevLaneID}, prevOffset={prevOffset}\n" +
                           $"\tprevLaneId={laneID}, prevOffset={offset}\n" +
                           $"\tnextSourceNodeId={nextSourceNodeId}\n" +
                           $"\trefTargetNodeId={refTargetNodeId}, " +
                           $"refTargetNodeId={refTargetNodeId}");
            }
#endif

            Vehicle.Frame lastFrameData = vehicleData.GetLastFrameData();

            Vector3 lastPosPlusRot = lastFrameData.m_position;
            Vector3 lastPosMinusRot = lastFrameData.m_position;
            Vector3 rotationAdd = lastFrameData.m_rotation
                              * new Vector3(0f, 0f, __instance.m_info.m_generatedInfo.m_wheelBase * 0.5f);
            lastPosPlusRot += rotationAdd;
            lastPosMinusRot -= rotationAdd;
            float breakingDist = 0.5f * lastFrameData.m_velocity.sqrMagnitude / __instance.m_info.m_braking;
            float distToTargetAfterRot = Vector3.Distance(lastPosPlusRot, bezier.a);
            float distToTargetBeforeRot = Vector3.Distance(lastPosMinusRot, bezier.a);

#if DEBUG
            if (logLogic) {
                Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                           $"lastPos={lastFrameData.m_position} " +
                           $"lastPosMinusRot={lastPosMinusRot} " +
                           $"lastPosPlusRot={lastPosPlusRot} " +
                           $"rotationAdd={rotationAdd} " +
                           $"breakingDist={breakingDist} " +
                           $"distToTargetAfterRot={distToTargetAfterRot} " +
                           $"distToTargetBeforeRot={distToTargetBeforeRot}");
            }
#endif

            if (Mathf.Min(distToTargetAfterRot, distToTargetBeforeRot) >= breakingDist - 5f) {
                /*VehicleManager vehMan = Singleton<VehicleManager>.instance;
                ushort firstVehicleId = vehicleData.GetFirstVehicle(vehicleID);
                if (VehicleBehaviorManager.Instance.MayDespawn(ref vehMan.m_vehicles.m_buffer[firstVehicleId]) || vehMan.m_vehicles.m_buffer[firstVehicleId].m_blockCounter < 100) {*/ // NON-STOCK CODE
#if DEBUG
                if (logLogic) {
                    Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                               $"Checking for free space on lane {laneID}.");
                }
#endif

                if (!netManager.m_lanes.m_buffer[laneID].CheckSpace(1000f, vehicleID)) {
#if DEBUG
                    if (logLogic) {
                        Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                                   $"No space available on lane {laneID}. ABORT.");
                    }
#endif
                    vehicleData.m_flags2 |= Vehicle.Flags2.Yielding;
                    vehicleData.m_waitCounter = 0;
                    maxSpeed = 0f;
                    return false;
                }

                Vector3 bezierMiddlePoint = bezier.Position(0.5f);

                Segment3 segment = Vector3.SqrMagnitude(vehicleData.m_segment.a - bezierMiddlePoint) <
                              Vector3.SqrMagnitude(bezier.a - bezierMiddlePoint)
                                  ? new Segment3(vehicleData.m_segment.a, bezierMiddlePoint)
                                  : new Segment3(bezier.a, bezierMiddlePoint);

#if DEBUG
                if (logLogic) {
                    Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                               $"Checking for overlap (1). segment.a={segment.a} segment.b={segment.b}");
                }
#endif
                if (segment.LengthSqr() >= 3f) {
                    segment.a += (segment.b - segment.a).normalized * 2.5f;

                    if (CheckOverlap(vehicleID, ref vehicleData, segment, vehicleID)) {
#if DEBUG
                        if (logLogic) {
                            Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                                       $"Overlap detected (1). segment.LengthSqr()={segment.LengthSqr()} " +
                                       $"segment.a={segment.a} ABORT.");
                        }
#endif
                        vehicleData.m_flags2 |= Vehicle.Flags2.Yielding;
                        vehicleData.m_waitCounter = 0;
                        maxSpeed = 0f;
                        return false;
                    }
                }

                segment = new Segment3(bezierMiddlePoint, bezier.d);
#if DEBUG
                if (logLogic) {
                    Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                               $"Checking for overlap (2). segment.a={segment.a} segment.b={segment.b}");
                }
#endif
                if (segment.LengthSqr() >= 1f
                    && CheckOverlap(vehicleID, ref vehicleData, segment, vehicleID)) {
#if DEBUG
                    if (logLogic) {
                        Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                                   $"Overlap detected (2). ABORT.");
                    }
#endif
                    vehicleData.m_flags2 |= Vehicle.Flags2.Yielding;
                    vehicleData.m_waitCounter = 0;
                    maxSpeed = 0f;
                    return false;
                }

                // } // NON-STOCK CODE
                // if (this.m_info.m_vehicleType != VehicleInfo.VehicleType.Monorail) { // NON-STOCK CODE
                if (nextSourceNodeId != refTargetNodeId) {
                    return false;
                }
#if DEBUG
                if (logLogic) {
                    Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                               $"Checking if vehicle is allowed to change segment.");
                }
#endif
                float oldMaxSpeed = maxSpeed;
                if (!VehicleBehaviorManager.Instance.MayChangeSegment(
                        vehicleID,
                        ref vehicleData,
                        lastFrameData.m_velocity.sqrMagnitude,
                        ref prevPos,
                        ref netManager.m_segments.m_buffer[prevPos.m_segment],
                        refTargetNodeId,
                        prevLaneID,
                        ref position,
                        refTargetNodeId,
                        ref netManager.m_nodes.m_buffer[refTargetNodeId],
                        laneID,
                        out maxSpeed)) {
#if DEBUG
                    if (logLogic) {
                        Log._Debug($"CustomTrainAI.CustomCheckNextLane({vehicleID}): " +
                                   $"Vehicle is NOT allowed to change segment. ABORT.");
                    }
#endif
                    maxSpeed = 0;
                    return false;
                }

                ExtVehicleManager.Instance.UpdateVehiclePosition(
                        vehicleID,
                        ref vehicleData);
                maxSpeed = oldMaxSpeed;

                // NON-STOCK CODE
            }
            return false;
        }

19 View Source File : RockScript.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Update()
    {
        if (this.disable)
        {
            return;
        }
        this.vv += -Vectors.up * this.g * Time.deltaTime;
        base.transform.position += this.vv * Time.deltaTime;
        base.transform.position += this.vh * Time.deltaTime;
        if (Vector3.Distance(this.desPt, base.transform.position) < 20f || base.transform.position.y < 0f)
        {
            base.transform.position = this.desPt;
            if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && PhotonNetwork.IsMasterClient)
            {
                if (FengGameManagerMKII.LAN)
                {
                    Network.Instantiate(CacheResources.Load("FX/boom1_CT_KICK"), base.transform.position + Vectors.up * 30f, Quaternion.Euler(270f, 0f, 0f), 0);
                }
                else
                {
                    Optimization.Caching.Pool.NetworkEnable("FX/boom1_CT_KICK", base.transform.position + Vectors.up * 30f, Quaternion.Euler(270f, 0f, 0f), 0);
                }
            }
            else
            {
                Pool.Enable("FX/boom1_CT_KICK", base.transform.position + Vectors.up * 30f, Quaternion.Euler(270f, 0f, 0f));//UnityEngine.Object.Instantiate(CacheResources.Load("FX/boom1_CT_KICK"), base.transform.position + Vectors.up * 30f, Quaternion.Euler(270f, 0f, 0f));
            }
            this.disable = true;
        }
    }

19 View Source File : CannonBall.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public void destroyMe()
    {
        bool flag = !this.disabled;
        if (flag)
        {
            this.disabled = true;
            GameObject gameObject = Pool.NetworkEnable("FX/boom4", base.transform.position, base.transform.rotation, 0);
            foreach (EnemyCheckCollider enemyCheckCollider in gameObject.GetComponentsInChildren<EnemyCheckCollider>())
            {
                enemyCheckCollider.dmg = 0;
            }
            bool flag2 = GameModes.CannonsKillHumans.Enabled;
            if (flag2)
            {
                foreach (HERO hero in FengGameManagerMKII.Heroes)
                {
                    bool flag3 = hero != null && Vector3.Distance(hero.transform.position, base.transform.position) <= 20f && !hero.BasePV.IsMine;
                    if (flag3)
                    {
                        GameObject gameObject2 = hero.gameObject;
                        PhotonPlayer owner = gameObject2.GetPhotonView().owner;

                        bool flag4 = GameModes.TeamMode.Enabled;
                        if (flag4)
                        {
                            int num = PhotonNetwork.player.RCteam;
                            int num2 = owner.RCteam; ;
                            bool flag5 = num == 0 || num != num2;
                            if (flag5)
                            {
                                gameObject2.GetComponent<HERO>().MarkDie();
                                gameObject2.GetComponent<HERO>().BasePV.RPC("netDie2", PhotonTargets.All, new object[]
                                {
                                    -1,
                                    PhotonNetwork.player.UIName + " "
                                });
                                FengGameManagerMKII.FGM.PlayerKillInfoUpdate(PhotonNetwork.player, 0);
                            }
                        }
                        else
                        {
                            gameObject2.GetComponent<HERO>().MarkDie();
                            gameObject2.GetComponent<HERO>().BasePV.RPC("netDie2", PhotonTargets.All, new object[]
                            {
                                -1,
                               PhotonNetwork.player.UIName + " "
                            });
                            FengGameManagerMKII.FGM.PlayerKillInfoUpdate(PhotonNetwork.player, 0);
                        }
                    }
                }
            }
            bool flag6 = this.myreplacedanTriggers != null;
            if (flag6)
            {
                for (int j = 0; j < this.myreplacedanTriggers.Count; j++)
                {
                    bool flag7 = this.myreplacedanTriggers[j] != null;
                    if (flag7)
                    {
                        this.myreplacedanTriggers[j].IsCollide = false;
                    }
                }
            }
            PhotonNetwork.Destroy(base.gameObject);
        }
    }

19 View Source File : CubeCollector.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Update()
    {
        if (GameObject.FindGameObjectWithTag("Player") == null)
        {
            return;
        }
        GameObject gameObject = GameObject.FindGameObjectWithTag("Player");
        if (Vector3.Distance(gameObject.transform.position, base.transform.position) < 8f)
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
    }

19 View Source File : HeroRPC.cs
License : GNU General Public License v3.0
Project Creator : aelariane

[RPC]
    private void netlaughAttack()
    {
        var array = GameObject.FindGameObjectsWithTag("replacedan");
        foreach (var gameObject in array)
            if (Vector3.Distance(gameObject.transform.position, baseT.position) < 50f &&
                Vector3.Angle(gameObject.transform.Forward(), baseT.position - gameObject.transform.position) < 90f &&
                gameObject.GetComponent<replacedAN>())
                gameObject.GetComponent<replacedAN>().BeLaughAttacked();
    }

19 View Source File : Yard.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

public bool IsItemInFridge(GameObject item)
        {
            if (fridgeRunning == null)
                return false;

            if (!fridgeRunning.Value)
                return false;

            return Vector3.Distance(item.transform.position, chillPoint.position) < ChillDistance;
        }

19 View Source File : COLOSSAL_TITAN.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private RaycastHit[] checkHitCapsule(Vector3 start, Vector3 end, float r)
    {
        return Physics.SphereCastAll(start, r, end - start, Vector3.Distance(start, end));
    }

19 View Source File : Hypervisor.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

bool IsEnabled(Transform target, float toggleDistance = 200)
        {
            if (inSectorMode)
                toggleDistance *= MOP.ActiveDistance.Value == 0 ? 0.5f : 0.1f;

            return Vector3.Distance(player.transform.position, target.position) < toggleDistance * MopSettings.ActiveDistanceMultiplicationValue;
        }

19 View Source File : PVPcheckPoint.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void checkIfBeingCapture()
    {
        this.playerOn = false;
        this.replacedanOn = false;
        GameObject[] array = GameObject.FindGameObjectsWithTag("Player");
        GameObject[] array2 = GameObject.FindGameObjectsWithTag("replacedan");
        for (int i = 0; i < array.Length; i++)
        {
            if (Vector3.Distance(array[i].transform.position, base.transform.position) < this.hitTestR)
            {
                this.playerOn = true;
                if (this.state == CheckPointState.Human && array[i].GetPhotonView().IsMine)
                {
                    if (FengGameManagerMKII.FGM.checkpoint != base.gameObject)
                    {
                        FengGameManagerMKII.FGM.checkpoint = base.gameObject;
                        Chat.Add("<color=#A8FF24>Respawn point changed to point" + this.id + "</color>");
                    }
                    break;
                }
            }
        }
        for (int i = 0; i < array2.Length; i++)
        {
            if (Vector3.Distance(array2[i].transform.position, base.transform.position) < this.hitTestR + 5f)
            {
                if (!array2[i].GetComponent<replacedAN>() || !array2[i].GetComponent<replacedAN>().hasDie)
                {
                    this.replacedanOn = true;
                    if (this.state == CheckPointState.replacedan && array2[i].GetPhotonView().IsMine && array2[i].GetComponent<replacedAN>() && array2[i].GetComponent<replacedAN>().nonAI)
                    {
                        if (FengGameManagerMKII.FGM.checkpoint != base.gameObject)
                        {
                            FengGameManagerMKII.FGM.checkpoint = base.gameObject;
                            Chat.Add("<color=#A8FF24>Respawn point changed to point" + this.id + "</color>");
                        }
                        break;
                    }
                }
            }
        }
    }

19 View Source File : World.cs
License : MIT License
Project Creator : BrunoS3D

void Update() {
        if (randomize) {
            noiseScale = Random.Range(32, 128);
            noiseOffset = Random.insideUnitSphere * noiseScale * noiseScale;
            for (int idx = 0; idx < chunkMap.Count; idx++) {
                Chunk chunk = chunkMap[idx];
                StartCoroutine(chunk.GenerateChunk());
            }
            randomize = false;
            return;
        }

        Vector3 ppos = player.position;
        t_chunckUpdateTime += Time.deltaTime;

        for (int idx = 0; idx < chunkMap.Count; idx++) {
            Chunk chunk = chunkMap[idx];
            CloudsChunk cloudsChunk = cloudsChunkMap[idx];

            Vector2 biPlayerPos = new Vector2(player.position.x, player.position.z);
            Vector2 biChunkPos = new Vector2(chunk.transform.position.x, chunk.transform.position.z);

            bool activeChunk = Vector3.Distance(biPlayerPos, biChunkPos) <= playerFOV.magnitude;

            chunk.gameObject.SetActive(activeChunk);

            if (activeChunk) {
                chunk.gameObject.SetActive(true);
            } else {
                if (chunk.CoroutinesRunning == 0) {
                    chunk.gameObject.SetActive(false);
                }
            }

            // utopia
            if (activeChunk && t_chunckUpdateTime >= chunckUpdateTime && chunk.CoroutinesRunning == 0) {
                StartCoroutine(chunk.RefreshMap());
            }
        }

        if (t_chunckUpdateTime >= chunckUpdateTime) {
            Chunk chunk = TryGetChunk(ppos);
            if (chunk != null) {
                StartCoroutine(chunk.RefreshMap());
            }
            t_chunckUpdateTime = 0.0f;
        }

        for (float x = ppos.x - playerFOV.x; x < ppos.x + playerFOV.x; x += chunkSize.x) {
            for (float z = ppos.z - playerFOV.y; z < ppos.z + playerFOV.y; z += chunkSize.z) {
                Vector3 idxpos = new Vector3(x, 0, z);

                Chunk chunk = TryGetChunk(idxpos);
                CloudsChunk cloudsChunk = TryGetCloudsChunk(idxpos);

                if (chunk == null) {
                    int xGridCoord = Mathf.FloorToInt(x / chunkSize.x) * chunkSize.x;
                    int zGridCoord = Mathf.FloorToInt(z / chunkSize.z) * chunkSize.z;

                    var instance = Instantiate(chunkPrefab, new Vector3(xGridCoord, 0, zGridCoord), Quaternion.idenreplacedy).GetComponent<Chunk>();

                    instance.transform.SetParent(transform);
                    chunkMap.Add(instance);
                }

                if (cloudsChunk == null) {
                    int xGridCoord = Mathf.FloorToInt(x / chunkSize.x) * chunkSize.x;
                    int zGridCoord = Mathf.FloorToInt(z / chunkSize.z) * chunkSize.z;

                    var instance = Instantiate(cloudsChunkPrefab, new Vector3(xGridCoord, cloudsHeight, zGridCoord), Quaternion.idenreplacedy).GetComponent<CloudsChunk>();

                    instance.transform.SetParent(transform);
                    cloudsChunkMap.Add(instance);
                }
            }
        }
    }

19 View Source File : MovingScript.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Initialize()
        {
            areaMultipliers = new float[Areas.Count];
            for(int i = 0; i < areaMultipliers.Length; i++)
            {
                areaMultipliers[i] = Areas[i].Speed / Vector3.Distance(Areas[i].StartPosition, Areas[i].TargetPosition);
            }
            lowerBorder = 0f;
            upperBorder = 1f;
            stage = 1;
            path = 0f;
            pathMultiplier = 1f;
            movementPercentage = 0f;

            MovingScriptArea area = Areas[0];

            cachedTransform.position = area.StartPosition;
            cachedTransform.rotation = area.StartRotation;
            currentBeginPoint = area.StartPosition;
            currentTargetPoint = area.TargetPosition;
            currentBeginRotation = area.StartRotation;
            currentTargetRotation = area.TargetRotation;
            movementMultiplier = areaMultipliers[0];
            waitTime = area.Delay;
        }

19 View Source File : CalculateSegmentPositionPatch2.cs
License : MIT License
Project Creator : CitiesSkylinesMods

[UsedImplicitly]
        public static bool Prefix(CarAI __instance,
                                  ushort vehicleID,
                                  ref Vehicle vehicleData,
                                  PathUnit.Position nextPosition,
                                  PathUnit.Position position,
                                  uint laneID,
                                  byte offset,
                                  PathUnit.Position prevPos,
                                  uint prevLaneID,
                                  byte prevOffset,
                                  int index,
                                  out Vector3 pos,
                                  out Vector3 dir,
                                  out float maxSpeed) {
            NetManager netManager = Singleton<NetManager>.instance;
            ushort nextSourceNodeId;
            ushort nextTargetNodeId;
            NetSegment[] segmentsBuffer = netManager.m_segments.m_buffer;

            if (offset < position.m_offset) {
                nextSourceNodeId = segmentsBuffer[position.m_segment].m_startNode;
                nextTargetNodeId = segmentsBuffer[position.m_segment].m_endNode;
            } else {
                nextSourceNodeId = segmentsBuffer[position.m_segment].m_endNode;
                nextTargetNodeId = segmentsBuffer[position.m_segment].m_startNode;
            }

            ushort curTargetNodeId;
            curTargetNodeId = prevOffset == 0
                                  ? segmentsBuffer[prevPos.m_segment].m_startNode
                                  : segmentsBuffer[prevPos.m_segment].m_endNode;

#if DEBUG
            bool logCalculation = DebugSwitch.CalculateSegmentPosition.Get()
                        && (DebugSettings.NodeId <= 0
                            || curTargetNodeId == DebugSettings.NodeId)
                        && (GlobalConfig.Instance.Debug.ApiExtVehicleType == ExtVehicleType.None
                            || GlobalConfig.Instance.Debug.ApiExtVehicleType == ExtVehicleType.RoadVehicle)
                        && (DebugSettings.VehicleId == 0
                            || DebugSettings.VehicleId == vehicleID);

            if (logCalculation) {
                Log._Debug($"CustomCarAI.CustomCalculateSegmentPosition({vehicleID}) called.\n" +
                           $"\tcurPosition.m_segment={prevPos.m_segment}, " +
                           $"curPosition.m_offset={prevPos.m_offset}\n" +
                           $"\tposition.m_segment={position.m_segment}, " +
                           $"position.m_offset={position.m_offset}\n" +
                           $"\tnextNextPosition.m_segment={nextPosition.m_segment}, " +
                           $"nextNextPosition.m_offset={nextPosition.m_offset}\n" +
                           $"\tcurLaneId={prevLaneID}, prevOffset={prevOffset}\n" +
                           $"\tnextLaneId={laneID}, nextOffset={offset}\n" +
                           $"\tnextSourceNodeId={nextSourceNodeId}, nextTargetNodeId={nextTargetNodeId}\n" +
                           $"\tcurTargetNodeId={curTargetNodeId}, curTargetNodeId={curTargetNodeId}\n" +
                           $"\tindex={index}");
            }
#endif

            Vehicle.Frame lastFrameData = vehicleData.GetLastFrameData();
            Vector3 lastFrameVehiclePos = lastFrameData.m_position;
            float sqrVelocity = lastFrameData.m_velocity.sqrMagnitude;
            netManager.m_lanes.m_buffer[laneID].CalculatePositionAndDirection(
                Constants.ByteToFloat(offset),
                out pos,
                out dir);

            float braking = __instance.m_info.m_braking;
            if ((vehicleData.m_flags & Vehicle.Flags.Emergency2) != 0) {
                braking *= 2f;
            }

            // car position on the Bezier curve of the lane
            Vector3 refVehiclePosOnBezier = netManager.m_lanes.m_buffer[prevLaneID]
                                                      .CalculatePosition(
                                                          Constants.ByteToFloat(prevOffset));

            // ushort currentSegmentId = netManager.m_lanes.m_buffer[prevLaneID].m_segment;
            // this seems to be like the required braking force in order to stop the vehicle within its half length.
            float crazyValue = (0.5f * sqrVelocity / braking) +
                               (__instance.m_info.m_generatedInfo.m_size.z * 0.5f);
            float d = Vector3.Distance(lastFrameVehiclePos, refVehiclePosOnBezier);
            bool withinBrakingDistance = d >= crazyValue - 1f;

            if (nextSourceNodeId == curTargetNodeId
                && withinBrakingDistance) {
                // NON-STOCK CODE START (stock code replaced)
                if (!VehicleBehaviorManager.Instance.MayChangeSegment(
                        vehicleID,
                        ref vehicleData,
                        sqrVelocity,
                        ref prevPos,
                        ref segmentsBuffer[prevPos.m_segment],
                        curTargetNodeId,
                        prevLaneID,
                        ref position,
                        nextSourceNodeId,
                        ref netManager.m_nodes.m_buffer[nextSourceNodeId],
                        laneID,
                        ref nextPosition,
                        nextTargetNodeId,
                        out maxSpeed)) {
                    // NON-STOCK CODE
                    return false;
                }

                ExtVehicleManager.Instance.UpdateVehiclePosition(
                    vehicleID,
                    ref vehicleData /*, lastFrameData.m_velocity.magnitude*/);

                // NON-STOCK CODE END
            }

            NetInfo prevSegmentInfo = segmentsBuffer[position.m_segment].Info;
            // NON-STOCK CODE START (stock code replaced)
            VehicleAICommons.CustomCalculateTargetSpeed(
                __instance,
                vehicleID,
                ref vehicleData,
                position,
                laneID,
                prevSegmentInfo,
                out maxSpeed);

            maxSpeed = Constants.ManagerFactory.VehicleBehaviorManager.CalcMaxSpeed(
                vehicleID,
                ref Constants.ManagerFactory.ExtVehicleManager.ExtVehicles[vehicleID],
                __instance.m_info,
                position,
                ref segmentsBuffer[position.m_segment],
                pos,
                maxSpeed,
                false);

            // NON-STOCK CODE END
            return false;
        }

19 View Source File : HeroRPC.cs
License : GNU General Public License v3.0
Project Creator : aelariane

[RPC]
    private void netlaughAttack()
    {
        var array = GameObject.FindGameObjectsWithTag("replacedan");
        foreach (var gameObject in array)
        {
            if (Vector3.Distance(gameObject.transform.position, baseT.position) < 50f &&
                Vector3.Angle(gameObject.transform.Forward(), baseT.position - gameObject.transform.position) < 90f &&
                gameObject.GetComponent<replacedAN>())
            {
                gameObject.GetComponent<replacedAN>().BeLaughAttacked();
            }
        }
    }

19 View Source File : HeroRPC.cs
License : GNU General Public License v3.0
Project Creator : aelariane

[RPC]
    private void netTauntAttack(float tauntTime, float distance = 100f)
    {
        foreach (var replaced in FengGameManagerMKII.replacedans)
        {
            if (replaced != null && !replaced.hasDie && Vector3.Distance(replaced.baseGT.position, baseT.position) < distance)
            {
                replaced.BeTauntedBy(baseG, tauntTime);
            }
        }
    }

19 View Source File : AHSSShotGunCollider.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void OnTriggerStay(Collider other)
    {
        if (!isLocal)
        {
            return;
        }

        if (this.active_me)
        {
            switch (other.gameObject.tag)
            {
                case "playerHitbox":
                    if (!FengGameManagerMKII.Level.PVPEnabled)
                    {
                        return;
                    }
                    float num = 1f - Vector3.Distance(other.gameObject.transform.position, baseT.position) * 0.05f;
                    num = Mathf.Min(1f, num);
                    HitBox component = other.gameObject.GetComponent<HitBox>();
                    if (component != null && component.transform.root != null)
                    {
                        if (component.transform.root.GetComponent<HERO>().myTeam == this.myTeam)
                        {
                            return;
                        }
                        if (!component.transform.root.GetComponent<HERO>().IsInvincible())
                        {
                            if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                            {
                                if (!component.transform.root.GetComponent<HERO>().IsGrabbed)
                                {
                                    component.transform.root.GetComponent<HERO>().Die((component.transform.root.transform.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f, false);
                                }
                            }
                            else if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && !component.transform.root.GetComponent<HERO>().HasDied() && !component.transform.root.GetComponent<HERO>().IsGrabbed)
                            {
                                component.transform.root.GetComponent<HERO>().MarkDie();
                                component.transform.root.GetComponent<HERO>().BasePV.RPC("netDie", PhotonTargets.All, new object[]
                                {
                                (component.transform.root.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f,
                                false,
                                this.viewID,
                                this.ownerName,
                                false
                                });
                            }
                        }
                    }
                    break;

                case "replacedanneck":
                    HitBox component2 = other.gameObject.GetComponent<HitBox>();
                    if (component2 != null && this.checkIfBehind(component2.transform.root.gameObject) && !this.currentHits.Contains(component2))
                    {
                        component2.hitPosition = (baseT.position + component2.transform.position) * 0.5f;
                        this.currentHits.Add(component2);
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (component2.transform.root.GetComponent<replacedAN>() && !component2.transform.root.GetComponent<replacedAN>().hasDie)
                            {
                                int num2 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num2 = Mathf.Max(10, num2);
                                FengGameManagerMKII.FGM.netShowDamage(num2);
                                if ((float)num2 > component2.transform.root.GetComponent<replacedAN>().myLevel * 100f)
                                {
                                    component2.transform.root.GetComponent<replacedAN>().Die();
                                    if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num2)
                                    {
                                        IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num2, component2.transform.root.gameObject, 0.02f);
                                    }
                                    FengGameManagerMKII.FGM.PlayerKillInfoSingleUpdate(num2);
                                }
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient || !component2.transform.root.GetComponent<PhotonView>().BasePV.IsMine)
                        {
                            if (component2.transform.root.GetComponent<replacedAN>())
                            {
                                if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                                {
                                    int num3 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                    num3 = Mathf.Max(10, num3);
                                    if ((float)num3 > component2.transform.root.GetComponent<replacedAN>().myLevel * 100f)
                                    {
                                        if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num3)
                                        {
                                            IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num3, component2.transform.root.gameObject, 0.02f);
                                            component2.transform.root.GetComponent<replacedAN>().asClientLookTarget = false;
                                        }
                                        component2.transform.root.GetComponent<replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<replacedAN>().BasePV.owner, new object[]
                                        {
                                        baseT.root.gameObject.GetPhotonView().viewID,
                                        num3
                                        });
                                    }
                                }
                            }
                            else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                            {
                                int num4 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num4 = Mathf.Max(10, num4);
                                if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.owner, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num4
                                    });
                                }
                            }
                            else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>() && !component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                            {
                                int num5 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num5 = Mathf.Max(10, num5);
                                component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.owner, new object[]
                                {
                                baseT.root.gameObject.GetPhotonView().viewID,
                                num5
                                });
                            }
                        }
                        else if (component2.transform.root.GetComponent<replacedAN>())
                        {
                            if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                            {
                                int num6 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num6 = Mathf.Max(10, num6);
                                if ((float)num6 > component2.transform.root.GetComponent<replacedAN>().myLevel * 100f)
                                {
                                    if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num6)
                                    {
                                        IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num6, component2.transform.root.gameObject, 0.02f);
                                    }
                                    component2.transform.root.GetComponent<replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num6);
                                }
                            }
                        }
                        else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                        {
                            if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                int num7 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num7 = Mathf.Max(10, num7);
                                if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num7)
                                {
                                    IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num7, null, 0.02f);
                                }
                                component2.transform.root.GetComponent<FEMALE_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num7);
                            }
                        }
                        else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>() && !component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                        {
                            int num8 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num8 = Mathf.Max(10, num8);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num8)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num8, null, 0.02f);
                            }
                            component2.transform.root.GetComponent<COLOSSAL_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num8);
                        }
                        this.showCriticalHitFX(other.gameObject.transform.position);
                    }
                    break;

                case "erenHitbox":
                    if (this.dmg > 0 && !other.gameObject.transform.root.gameObject.GetComponent<replacedAN_EREN>().ireplaced)
                    {
                        other.gameObject.transform.root.gameObject.GetComponent<replacedAN_EREN>().hitByreplacedan();
                    }
                    break;

                case "replacedaneye":
                    if (!this.currentHits.Contains(other.gameObject))
                    {
                        this.currentHits.Add(other.gameObject);
                        GameObject gameObject = other.gameObject.transform.root.gameObject;
                        if (gameObject.GetComponent<FEMALE_replacedAN>())
                        {
                            if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                            {
                                if (!gameObject.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<FEMALE_replacedAN>().hitEye();
                                }
                            }
                            else if (!PhotonNetwork.IsMasterClient || !gameObject.GetPhotonView().IsMine)
                            {
                                if (!gameObject.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                    });
                                }
                            }
                            else if (!gameObject.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject.GetComponent<FEMALE_replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                            }
                        }
                        else if (gameObject.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                        {
                            if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                            {
                                if (!gameObject.GetComponent<replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<replacedAN>().HitEye();
                                }
                            }
                            else if (!PhotonNetwork.IsMasterClient || !gameObject.GetPhotonView().IsMine)
                            {
                                if (!gameObject.GetComponent<replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                    });
                                }
                            }
                            else if (!gameObject.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject.GetComponent<replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                            }
                            this.showCriticalHitFX(other.gameObject.transform.position);
                        }
                    }
                    break;

                case "replacedanankle":
                    if (currentHits.Contains(other.gameObject))
                    {
                        return;
                    }

                    this.currentHits.Add(other.gameObject);
                    GameObject gameObject2 = other.gameObject.transform.root.gameObject;
                    int num9 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - gameObject2.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                    num9 = Mathf.Max(10, num9);
                    if (gameObject2.GetComponent<replacedAN>() && gameObject2.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().HitAnkle();
                            }
                        }
                        else
                        {
                            if (!PhotonNetwork.IsMasterClient || !gameObject2.GetPhotonView().IsMine)
                            {
                                if (!gameObject2.GetComponent<replacedAN>().hasDie)
                                {
                                    gameObject2.GetComponent<replacedAN>().BasePV.RPC("hitAnkleRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                    });
                                }
                            }
                            else if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().HitAnkle();
                            }
                            this.showCriticalHitFX(other.gameObject.transform.position);
                        }
                    }
                    else if (gameObject2.GetComponent<FEMALE_replacedAN>())
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (other.gameObject.name == "ankleR")
                            {
                                if (gameObject2.GetComponent<FEMALE_replacedAN>() && !gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleR(num9);
                                }
                            }
                            else if (gameObject2.GetComponent<FEMALE_replacedAN>() && !gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleL(num9);
                            }
                        }
                        else if (other.gameObject.name == "ankleR")
                        {
                            if (!PhotonNetwork.IsMasterClient)
                            {
                                if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject2.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleRRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num9
                                    });
                                }
                            }
                            else if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleRRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient)
                        {
                            if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleLRPC", PhotonTargets.MasterClient, new object[]
                                {
                                baseT.root.gameObject.GetPhotonView().viewID,
                                num9
                                });
                            }
                        }
                        else if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleLRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                        }
                        this.showCriticalHitFX(other.gameObject.transform.position);
                    }
                    break;
            }
        }
    }

19 View Source File : AHSSShotGunCollider.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void OnTriggerStay(Collider other)
    {
        if (!isLocal)
            return;
        if (this.active_me)
        {
            switch (other.gameObject.tag)
            {
                case "playerHitbox":
                    if (!FengGameManagerMKII.Level.PVPEnabled)
                    {
                        return;
                    }
                    float num = 1f - Vector3.Distance(other.gameObject.transform.position, baseT.position) * 0.05f;
                    num = Mathf.Min(1f, num);
                    HitBox component = other.gameObject.GetComponent<HitBox>();
                    if (component != null && component.transform.root != null)
                    {
                        if (component.transform.root.GetComponent<HERO>().myTeam == this.myTeam)
                        {
                            return;
                        }
                        if (!component.transform.root.GetComponent<HERO>().IsInvincible())
                        {
                            if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                            {
                                if (!component.transform.root.GetComponent<HERO>().IsGrabbed)
                                {
                                    component.transform.root.GetComponent<HERO>().Die((component.transform.root.transform.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f, false);
                                }
                            }
                            else if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && !component.transform.root.GetComponent<HERO>().HasDied() && !component.transform.root.GetComponent<HERO>().IsGrabbed)
                            {
                                component.transform.root.GetComponent<HERO>().MarkDie();
                                component.transform.root.GetComponent<HERO>().BasePV.RPC("netDie", PhotonTargets.All, new object[]
                                {
                                (component.transform.root.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f,
                                false,
                                this.viewID,
                                this.ownerName,
                                false
                                });
                            }
                        }
                    }
                    break;

                case "replacedanneck":
                    HitBox component2 = other.gameObject.GetComponent<HitBox>();
                    if (component2 != null && this.checkIfBehind(component2.transform.root.gameObject) && !this.currentHits.Contains(component2))
                    {
                        component2.hitPosition = (baseT.position + component2.transform.position) * 0.5f;
                        this.currentHits.Add(component2);
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (component2.transform.root.GetComponent<replacedAN>() && !component2.transform.root.GetComponent<replacedAN>().hasDie)
                            {
                                int num2 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num2 = Mathf.Max(10, num2);
                                FengGameManagerMKII.FGM.netShowDamage(num2);
                                if ((float)num2 > component2.transform.root.GetComponent<replacedAN>().myLevel * 100f)
                                {
                                    component2.transform.root.GetComponent<replacedAN>().Die();
                                    if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num2)
                                    {
                                        IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num2, component2.transform.root.gameObject, 0.02f);
                                    }
                                    FengGameManagerMKII.FGM.PlayerKillInfoSingleUpdate(num2);
                                }
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient || !component2.transform.root.GetComponent<PhotonView>().BasePV.IsMine)
                        {
                            if (component2.transform.root.GetComponent<replacedAN>())
                            {
                                if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                                {
                                    int num3 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                    num3 = Mathf.Max(10, num3);
                                    if ((float)num3 > component2.transform.root.GetComponent<replacedAN>().myLevel * 100f)
                                    {
                                        if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num3)
                                        {
                                            IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num3, component2.transform.root.gameObject, 0.02f);
                                            component2.transform.root.GetComponent<replacedAN>().asClientLookTarget = false;
                                        }
                                        component2.transform.root.GetComponent<replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<replacedAN>().BasePV.owner, new object[]
                                        {
                                        baseT.root.gameObject.GetPhotonView().viewID,
                                        num3
                                        });
                                    }
                                }
                            }
                            else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                            {
                                int num4 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num4 = Mathf.Max(10, num4);
                                if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.owner, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num4
                                    });
                                }
                            }
                            else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>() && !component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                            {
                                int num5 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num5 = Mathf.Max(10, num5);
                                component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.owner, new object[]
                                {
                                baseT.root.gameObject.GetPhotonView().viewID,
                                num5
                                });
                            }
                        }
                        else if (component2.transform.root.GetComponent<replacedAN>())
                        {
                            if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                            {
                                int num6 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num6 = Mathf.Max(10, num6);
                                if ((float)num6 > component2.transform.root.GetComponent<replacedAN>().myLevel * 100f)
                                {
                                    if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num6)
                                    {
                                        IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num6, component2.transform.root.gameObject, 0.02f);
                                    }
                                    component2.transform.root.GetComponent<replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num6);
                                }
                            }
                        }
                        else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                        {
                            if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                int num7 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num7 = Mathf.Max(10, num7);
                                if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num7)
                                {
                                    IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num7, null, 0.02f);
                                }
                                component2.transform.root.GetComponent<FEMALE_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num7);
                            }
                        }
                        else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>() && !component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                        {
                            int num8 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num8 = Mathf.Max(10, num8);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num8)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num8, null, 0.02f);
                            }
                            component2.transform.root.GetComponent<COLOSSAL_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num8);
                        }
                        this.showCriticalHitFX(other.gameObject.transform.position);
                    }
                    break;

                case "erenHitbox":
                    if (this.dmg > 0 && !other.gameObject.transform.root.gameObject.GetComponent<replacedAN_EREN>().ireplaced)
                    {
                        other.gameObject.transform.root.gameObject.GetComponent<replacedAN_EREN>().hitByreplacedan();
                    }
                    break;

                case "replacedaneye":
                    if (!this.currentHits.Contains(other.gameObject))
                    {
                        this.currentHits.Add(other.gameObject);
                        GameObject gameObject = other.gameObject.transform.root.gameObject;
                        if (gameObject.GetComponent<FEMALE_replacedAN>())
                        {
                            if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                            {
                                if (!gameObject.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<FEMALE_replacedAN>().hitEye();
                                }
                            }
                            else if (!PhotonNetwork.IsMasterClient || !gameObject.GetPhotonView().IsMine)
                            {
                                if (!gameObject.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                    });
                                }
                            }
                            else if (!gameObject.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject.GetComponent<FEMALE_replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                            }
                        }
                        else if (gameObject.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                        {
                            if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                            {
                                if (!gameObject.GetComponent<replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<replacedAN>().HitEye();
                                }
                            }
                            else if (!PhotonNetwork.IsMasterClient || !gameObject.GetPhotonView().IsMine)
                            {
                                if (!gameObject.GetComponent<replacedAN>().hasDie)
                                {
                                    gameObject.GetComponent<replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                    });
                                }
                            }
                            else if (!gameObject.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject.GetComponent<replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                            }
                            this.showCriticalHitFX(other.gameObject.transform.position);
                        }
                    }
                    break;

                case "replacedanankle":
                    if (currentHits.Contains(other.gameObject)) return;
                    this.currentHits.Add(other.gameObject);
                    GameObject gameObject2 = other.gameObject.transform.root.gameObject;
                    int num9 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - gameObject2.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                    num9 = Mathf.Max(10, num9);
                    if (gameObject2.GetComponent<replacedAN>() && gameObject2.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().HitAnkle();
                            }
                        }
                        else
                        {
                            if (!PhotonNetwork.IsMasterClient || !gameObject2.GetPhotonView().IsMine)
                            {
                                if (!gameObject2.GetComponent<replacedAN>().hasDie)
                                {
                                    gameObject2.GetComponent<replacedAN>().BasePV.RPC("hitAnkleRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                    });
                                }
                            }
                            else if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().HitAnkle();
                            }
                            this.showCriticalHitFX(other.gameObject.transform.position);
                        }
                    }
                    else if (gameObject2.GetComponent<FEMALE_replacedAN>())
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (other.gameObject.name == "ankleR")
                            {
                                if (gameObject2.GetComponent<FEMALE_replacedAN>() && !gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleR(num9);
                                }
                            }
                            else if (gameObject2.GetComponent<FEMALE_replacedAN>() && !gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleL(num9);
                            }
                        }
                        else if (other.gameObject.name == "ankleR")
                        {
                            if (!PhotonNetwork.IsMasterClient)
                            {
                                if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                                {
                                    gameObject2.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleRRPC", PhotonTargets.MasterClient, new object[]
                                    {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num9
                                    });
                                }
                            }
                            else if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleRRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient)
                        {
                            if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleLRPC", PhotonTargets.MasterClient, new object[]
                                {
                                baseT.root.gameObject.GetPhotonView().viewID,
                                num9
                                });
                            }
                        }
                        else if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject2.GetComponent<FEMALE_replacedAN>().hitAnkleLRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                        }
                        this.showCriticalHitFX(other.gameObject.transform.position);
                    }
                    break;
            }
        }
    }

19 View Source File : Horse.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void LateUpdate()
    {
        if (Owner == null && BasePV.IsMine)
        {
            PhotonNetwork.Destroy(gameObject);
            return;
        }

        switch (State)
        {
            case HorseState.Mounted:
                {
                    if (this.Owner == null)
                    {
                        this.Unmounted();
                        return;
                    }

                    Owner.baseT.position = baseT.position + heroOffsetVector;
                    Owner.baseT.rotation = baseR.rotation;
                    Owner.baseR.velocity = baseR.velocity;

                    if (controller.targetDirection == -874f)
                    {
                        this.ToIdleAnimation();
                        if (baseR.velocity.magnitude > 15f)
                        {
                            if (!Owner.baseA.IsPlaying("horse_run"))
                            {
                                Owner.CrossFade("horse_run", 0.1f);
                            }
                        }
                        else if (!Owner.baseA.IsPlaying("horse_idle"))
                        {
                            Owner.CrossFade("horse_idle", 0.1f);
                        }
                    }
                    else
                    {
                        base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, this.controller.targetDirection, 0f), 100f * Time.deltaTime / (base.rigidbody.velocity.magnitude + 20f));
                        if (this.controller.isWALKDown)
                        {
                            baseR.AddForce(baseT.Forward() * this.speed * 0.6f, ForceMode.Acceleration);
                            if (baseR.velocity.magnitude >= this.speed * 0.6f)
                            {
                                baseR.AddForce(-this.speed * 0.6f * baseR.velocity.normalized, ForceMode.Acceleration);
                            }
                        }
                        else
                        {
                            baseR.AddForce(baseT.Forward() * this.speed, ForceMode.Acceleration);
                            if (baseR.velocity.magnitude >= this.speed)
                            {
                                baseR.AddForce(-this.speed * baseR.velocity.normalized, ForceMode.Acceleration);
                            }
                        }
                        if (baseR.velocity.magnitude > 8f)
                        {
                            if (!baseA.IsPlaying("horse_Run"))
                            {
                                this.CrossFade("horse_Run", 0.1f);
                            }
                            if (!this.Owner.baseA.IsPlaying("horse_run"))
                            {
                                this.Owner.CrossFade("horse_run", 0.1f);
                            }
                            if (!this.dustParticle.enableEmission)
                            {
                                this.dustParticle.enableEmission = true;
                                BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                                {
                        true
                                });
                            }
                        }
                        else
                        {
                            if (!baseA.IsPlaying("horse_WALK"))
                            {
                                this.CrossFade("horse_WALK", 0.1f);
                            }
                            if (!this.Owner.baseA.IsPlaying("horse_idle"))
                            {
                                this.Owner.baseA.CrossFade("horse_idle", 0.1f);
                            }
                            if (this.dustParticle.enableEmission)
                            {
                                this.dustParticle.enableEmission = false;
                                BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                                {
                                    false
                                });
                            }
                        }
                    }

                    if ((this.controller.isAttackDown || this.controller.isAttackIIDown) && this.IsGrounded())
                    {
                        baseR.AddForce(Vectors.up * 25f, ForceMode.VelocityChange);
                    }
                }
                break;

            case HorseState.Follow:
                {
                    if (this.Owner == null)
                    {
                        this.Unmounted();
                        return;
                    }

                    if (baseR.velocity.magnitude > 8f)
                    {
                        if (!baseA.IsPlaying("horse_Run"))
                        {
                            this.CrossFade("horse_Run", 0.1f);
                        }
                        if (!this.dustParticle.enableEmission)
                        {
                            this.dustParticle.enableEmission = true;
                            BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                            {
                        true
                            });
                        }
                    }
                    else
                    {
                        if (!baseA.IsPlaying("horse_WALK"))
                        {
                            this.CrossFade("horse_WALK", 0.1f);
                        }
                        if (this.dustParticle.enableEmission)
                        {
                            this.dustParticle.enableEmission = false;
                            BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                            {
                                false
                            });
                        }
                    }

                    float num = -Mathf.DeltaAngle(FengMath.GetHorizontalAngle(baseT.position, this.setPoint), base.gameObject.transform.rotation.eulerAngles.y - 90f);
                    base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, base.gameObject.transform.rotation.eulerAngles.y + num, 0f), 200f * Time.deltaTime / (baseR.velocity.magnitude + 20f));
                    if (Vector3.Distance(this.setPoint, baseT.position) < 20f)
                    {
                        baseR.AddForce(baseT.Forward() * this.speed * 0.7f, ForceMode.Acceleration);
                        if (baseR.velocity.magnitude >= this.speed)
                        {
                            baseR.AddForce(-this.speed * 0.7f * baseR.velocity.normalized, ForceMode.Acceleration);
                        }
                    }
                    else
                    {
                        baseR.AddForce(base.transform.Forward() * this.speed, ForceMode.Acceleration);
                        if (baseR.velocity.magnitude >= this.speed)
                        {
                            baseR.AddForce(-this.speed * baseR.velocity.normalized, ForceMode.Acceleration);
                        }
                    }
                    this.timeElapsed += Time.deltaTime;
                    if (this.timeElapsed > 0.6f)
                    {
                        this.timeElapsed = 0f;
                        if (Vector3.Distance(this.Owner.baseT.position, this.setPoint) > 20f)
                        {
                            this.Followed();
                        }
                    }
                    if (Vector3.Distance(this.Owner.baseT.position, baseT.position) < 5f)
                    {
                        this.Unmounted();
                    }
                    if (Vector3.Distance(this.setPoint, baseT.position) < 5f)
                    {
                        this.Unmounted();
                    }
                    this.awayTimer += Time.deltaTime;
                    if (this.awayTimer > 6f)
                    {
                        this.awayTimer = 0f;
                        if (Physics.Linecast(baseT.position + Vectors.up, this.Owner.baseT.position + Vectors.up, Layers.Ground.value))
                        {
                            baseT.position = new Vector3(this.Owner.baseT.position.x, this.GetHeight(this.Owner.baseT.position + Vectors.up * 5f), this.Owner.baseT.position.z);
                        }
                    }
                }
                break;

            case HorseState.Idle:
                {
                    this.ToIdleAnimation();
                    if (this.Owner != null && Vector3.Distance(this.Owner.baseT.position, baseT.position) > 20f)
                    {
                        this.Followed();
                    }
                }
                break;
        }
        baseR.AddForce(new Vector3(0f, -50f * baseR.mreplaced, 0f));
    }

19 View Source File : Bomb.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public void Explode(float radius)
    {
        this.disabled = true;
        this.baseR.velocity = Vectors.zero;
        this.myExplosion = Pool.NetworkEnable("RCreplacedet/BombExplodeMain", this.baseT.position, Quaternion.Euler(0f, 0f, 0f), 0).GetComponent<BombExplode>();
        foreach (HERO hero in FengGameManagerMKII.Heroes)
        {
            if (Vector3.Distance(hero.baseT.position, this.baseT.position) < radius && !hero.BasePV.IsMine && !hero.BombImmune)
            {
                PhotonPlayer owner = hero.BasePV.owner;
                if (PhotonNetwork.player.RCteam > 0)
                {
                    int num = PhotonNetwork.player.RCteam;
                    int num2 = owner.RCteam;
                    if (num == 0 || num != num2)
                    {
                        hero.MarkDie();
                        hero.BasePV.RPC("netDie2", PhotonTargets.All, new object[]
                        {
                            -1,
                            BombName
                        }); ;
                        FengGameManagerMKII.FGM.PlayerKillInfoUpdate(PhotonNetwork.player, 0);
                    }
                }
                else
                {
                    hero.MarkDie();
                    hero.BasePV.RPC("netDie2", PhotonTargets.All, new object[]
                    {
                        -1,
                       BombName
                    });
                    FengGameManagerMKII.FGM.PlayerKillInfoUpdate(PhotonNetwork.player, 0);
                }
            }
        }
        base.StartCoroutine(this.WaitAndFade(1.5f));
    }

19 View Source File : IN_GAME_MAIN_CAMERA.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public void snapShot2(int index)
    {
        this.snapShotCamera.transform.position = ((!(Head != null)) ? MainT.position : Head.position);
        this.snapShotCamera.transform.position += Vectors.up * this.heightMulti;
        this.snapShotCamera.transform.position -= Vectors.up * 1.1f;
        Vector3 vector;
        Vector3 b = vector = this.snapShotCamera.transform.position;
        Vector3 vector2 = (vector + this.snapShotTargetPosition) * 0.5f;
        this.snapShotCamera.transform.position = vector2;
        vector = vector2;
        this.snapShotCamera.transform.LookAt(this.snapShotTargetPosition);
        if (index == 3)
        {
            this.snapShotCamera.transform.RotateAround(BaseT.position, Vectors.up, UnityEngine.Random.Range(-180f, 180f));
        }
        else
        {
            this.snapShotCamera.transform.RotateAround(BaseT.position, Vectors.up, UnityEngine.Random.Range(-20f, 20f));
        }
        this.snapShotCamera.transform.LookAt(vector);
        this.snapShotCamera.transform.RotateAround(vector, BaseT.right, UnityEngine.Random.Range(-20f, 20f));
        float num = Vector3.Distance(this.snapShotTargetPosition, b);
        if (this.snapShotTarget != null && this.snapShotTarget.GetComponent<replacedAN>())
        {
            num += (float)(index - 1) * this.snapShotTarget.transform.localScale.x * 10f;
        }
        this.snapShotCamera.transform.position -= this.snapShotCamera.transform.Forward() * UnityEngine.Random.Range(num + 3f, num + 10f);
        this.snapShotCamera.transform.LookAt(vector);
        this.snapShotCamera.transform.RotateAround(vector, BaseT.forward, UnityEngine.Random.Range(-30f, 30f));
        Vector3 vector3 = (!(Head != null)) ? MainT.position : Head.position;
        Vector3 vector4 = ((!(Head != null)) ? MainT.position : Head.position) - this.snapShotCamera.transform.position;
        vector3 -= vector4;
        RaycastHit raycastHit;
        if (Head != null)
        {
            if (Physics.Linecast(Head.position, vector3, out raycastHit, Layers.Ground))
            {
                this.snapShotCamera.transform.position = raycastHit.point;
            }
            else if (Physics.Linecast(Head.position - vector4 * this.distanceMulti * 3f, vector3, out raycastHit, Layers.EnemyGround))
            {
                this.snapShotCamera.transform.position = raycastHit.point;
            }
        }
        else if (Physics.Linecast(MainT.position + Vectors.up, vector3, out raycastHit, Layers.EnemyGround))
        {
            this.snapShotCamera.transform.position = raycastHit.point;
        }
        switch (index)
        {
            case 1:
                this.snapshot1 = this.RTImage(this.snapShotCamera.GetComponent<Camera>());
                SnapShotSaves.addIMG(this.snapshot1, this.snapShotDmg);
                break;

            case 2:
                this.snapshot2 = this.RTImage(this.snapShotCamera.GetComponent<Camera>());
                SnapShotSaves.addIMG(this.snapshot2, this.snapShotDmg);
                break;

            case 3:
                this.snapshot3 = this.RTImage(this.snapShotCamera.GetComponent<Camera>());
                SnapShotSaves.addIMG(this.snapshot3, this.snapShotDmg);
                break;
        }
        this.snapShotCount = index;
        this.hreplacednapShot = true;
        this.snapShotCountDown = 2f;
        if (index == 1)
        {
            FengGameManagerMKII.UIRefer.panels[0].transform.Find("snapshot1").GetComponent<UITexture>().mainTexture = this.snapshot1;
            FengGameManagerMKII.UIRefer.panels[0].transform.Find("snapshot1").GetComponent<UITexture>().transform.localScale = new Vector3((float)Screen.width * 0.4f, (float)Screen.height * 0.4f, 1f);
            FengGameManagerMKII.UIRefer.panels[0].transform.Find("snapshot1").GetComponent<UITexture>().transform.localPosition = new Vector3((float)(-(float)Screen.width) * 0.225f, (float)Screen.height * 0.225f, 0f);
            FengGameManagerMKII.UIRefer.panels[0].transform.Find("snapshot1").GetComponent<UITexture>().transform.rotation = Quaternion.Euler(0f, 0f, 10f);
            if (Settings.SnapshotsInGame.Value)
            {
                FengGameManagerMKII.UIRefer.panels[0].transform.Find("snapshot1").GetComponent<UITexture>().enabled = true;
            }
            else
            {
                FengGameManagerMKII.UIRefer.panels[0].transform.Find("snapshot1").GetComponent<UITexture>().enabled = false;
            }
        }
    }

19 View Source File : IN_GAME_MAIN_CAMERA.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public GameObject SetMainObject(object obj, bool resetRotation = true, bool lockAngle = false)
    {
        if (obj == null)
        {
            Head = null;
            this.distanceMulti = this.heightMulti = 1f;
        }
        else if (obj is HERO)
        {
            usingreplacedan = false;
            MainHERO = (HERO)obj;
            MainreplacedAN = null;
            MainObject = (obj as HERO).baseG;
            Head = ((HERO)obj).baseT.Find("Amarture/Controller_Body/hip/spine/chest/neck/head");
            if (Interpolation.Value)
            {
                MainHERO.rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
            }
            this.distanceMulti = this.heightMulti = 0.64f;
            if (resetRotation)
            {
                BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
            }
        }
        else if (obj is replacedAN)
        {
            usingreplacedan = true;
            MainreplacedAN = obj as replacedAN;
            MainHERO = null;
            MainEREN = null;
            MainObject = MainreplacedAN.baseG;
            Head = MainT.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck/head");
            this.distanceMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.4f) : 1f;
            this.heightMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.45f) : 1f;
            if (resetRotation)
            {
                BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
            }
        }
        else if (obj is replacedAN_EREN)
        {
            MainEREN = obj as replacedAN_EREN;
            MainreplacedAN = null;
            MainObject = MainEREN.gameObject;
            Head = MainT.transform.Find("Amarture/Core/Controller_Body/hip/spine/chest/neck/head");
            this.distanceMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.2f) : 1f;
            this.heightMulti = (Head != null) ? (Vector3.Distance(Head.position, MainT.position) * 0.33f) : 1f;
            if (resetRotation)
            {
                BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
            }
        }
        else
        {
            Head = null;
            this.distanceMulti = this.heightMulti = 1f;
            if (resetRotation)
            {
                BaseT.rotation = Quaternion.Euler(0f, 0f, 0f);
            }
            if (obj is GameObject obje)
            {
                MainObject = obje;
            }
        }
        this.lockAngle = lockAngle;
        VideoSettings.Apply();
        return MainObject;
    }

19 View Source File : NavToColliderEditor.cs
License : MIT License
Project Creator : akof1314

void DrawScaleHandle()
    {
        float s = Vector3.Distance(Camera.current.transform.position, regionCenter) / 5.0f;
        regionSize = Handles.ScaleHandle(regionSize, regionCenter, Quaternion.idenreplacedy, s);
    }

19 View Source File : EnemyCheckCollider.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void OnTriggerStay(Collider other)
    {
        if ((IN_GAME_MAIN_CAMERA.GameType == GameType.Single || base.transform.root.gameObject.GetPhotonView().IsMine) && this.active_me)
        {
            if (other.gameObject.tag == "playerHitbox")
            {
                float b = 1f - Vector3.Distance(other.gameObject.transform.position, base.transform.position) * 0.05f;
                b = Mathf.Min(1f, b);
                HitBox component = other.gameObject.GetComponent<HitBox>();
                if (component != null && component.transform.root != null)
                {
                    if (this.dmg == 0)
                    {
                        Vector3 vector = component.transform.root.transform.position - base.transform.position;
                        float num2 = 0f;
                        if (base.gameObject.GetComponent<SphereCollider>() != null)
                        {
                            num2 = base.transform.localScale.x * base.gameObject.GetComponent<SphereCollider>().radius;
                        }
                        if (base.gameObject.GetComponent<CapsuleCollider>() != null)
                        {
                            num2 = base.transform.localScale.x * base.gameObject.GetComponent<CapsuleCollider>().height;
                        }
                        float num3 = 5f;
                        if (num2 > 0f)
                        {
                            num3 = Mathf.Max(5f, num2 - vector.magnitude);
                        }
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            component.transform.root.GetComponent<HERO>().blowAway(vector.normalized * num3 + Vector3.up * 1f);
                            return;
                        }
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
                        {
                            object[] parameters = new object[]
                            {
                                vector.normalized * num3 + Vector3.up * 1f
                            };
                            component.transform.root.GetComponent<HERO>().BasePV.RPC("blowAway", PhotonTargets.All, parameters);
                            return;
                        }
                    }
                    else if (!component.transform.root.GetComponent<HERO>().IsInvincible())
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!component.transform.root.GetComponent<HERO>().IsGrabbed)
                            {
                                Vector3 vector2 = component.transform.root.transform.position - base.transform.position;
                                component.transform.root.GetComponent<HERO>().Die(vector2.normalized * b * 1000f + Vector3.up * 50f, this.isThisBite);
                                return;
                            }
                        }
                        else if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && !component.transform.root.GetComponent<HERO>().HasDied() && !component.transform.root.GetComponent<HERO>().IsGrabbed)
                        {
                            component.transform.root.GetComponent<HERO>().MarkDie();
                            int myOwnerViewID = -1;
                            string replacedanName = string.Empty;
                            if (base.transform.root.gameObject.GetComponent<EnemyfxIDcontainer>() != null)
                            {
                                myOwnerViewID = base.transform.root.gameObject.GetComponent<EnemyfxIDcontainer>().myOwnerViewID;
                                replacedanName = base.transform.root.gameObject.GetComponent<EnemyfxIDcontainer>().replacedanName;
                            }
                            object[] objArray2 = new object[]
                            {
                                (component.transform.root.position - base.transform.position).normalized * b * 1000f + Vector3.up * 50f,
                                this.isThisBite,
                                myOwnerViewID,
                                replacedanName,
                                true
                            };
                            component.transform.root.GetComponent<HERO>().BasePV.RPC("netDie", PhotonTargets.All, objArray2);
                            return;
                        }
                    }
                }
            }
            else if (other.gameObject.tag == "erenHitbox" && this.dmg > 0 && !other.gameObject.transform.root.gameObject.GetComponent<replacedAN_EREN>().ireplaced)
            {
                other.gameObject.transform.root.gameObject.GetComponent<replacedAN_EREN>().hitByreplacedan();
            }
        }
    }

19 View Source File : ItemBehaviour.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

internal void ResetKiljuContainer()
        {
            if (!gameObject.name.ContainsAny("empty plastic can", "kilju", "emptyca")) return;
           
            gameObject.MakePickable(true);
            gameObject.tag = "ITEM";

            if (ItemsManager.Instance.GetCanTrigger())
            {
                if (Vector3.Distance(transform.position, ItemsManager.Instance.GetCanTrigger().transform.position) < 10)
                {
                    transform.position = ItemsManager.Instance.LostSpawner.position;
                    kiljuInitialReset = false;

                    PlayMakerFSM fsm = gameObject.GetPlayMakerFSM("Use");
                    if (fsm)
                    {
                        fsm.FsmVariables.GetFsmBool("ContainsKilju").Value = false;
                    }
                    gameObject.name = "empty plastic can(itemx)";
                    return; 
                }
            }

            if (ItemsManager.Instance.LandfillSpawn)
            {
                if (Vector3.Distance(transform.position, ItemsManager.Instance.LandfillSpawn.position) < 5)
                {
                    transform.position = ItemsManager.Instance.LandfillSpawn.position;

                    PlayMakerFSM fsm = gameObject.GetPlayMakerFSM("Use");
                    if (fsm)
                    {
                        fsm.FsmVariables.GetFsmBool("ContainsKilju").Value = false;
                    }
                    gameObject.name = "empty plastic can(itemx)";
                }
            }
        }

19 View Source File : HeroRPC.cs
License : GNU General Public License v3.0
Project Creator : aelariane

[RPC]
    private void netTauntAttack(float tauntTime, float distance = 100f)
    {
        foreach (var replaced in FengGameManagerMKII.replacedans)
            if (replaced != null && !replaced.hasDie && Vector3.Distance(replaced.baseGT.position, baseT.position) < distance)
                replaced.BeTauntedBy(baseG, tauntTime);
    }

19 View Source File : CompatibilityManager.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

public static bool IsInBackpack(ItemBehaviour behaviour)
        {
            if (CarryMore)
            {
                return behaviour.transform.position.y < -900;
            }
            else if (AdvancedBackpack)
            {
                return Vector3.Distance(behaviour.transform.position, AdvancedBackpackPosition) < AdvancedBackpackDistance;
            }

            return false;
        }

19 View Source File : RacingMovingObject.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Update()
        {
            if(isLaunched == false)
            {
                return;
            }
            if (toEnd)
            {
                CachedTransform.position = Vector3.MoveTowards(CachedTransform.position, endPosition, Speed * Time.deltaTime);
                if (Vector3.Distance(CachedTransform.position, endPosition) < 2f)
                {
                    this.toEnd = false;
                }
            }
            else
            {
                CachedTransform.position = Vector3.MoveTowards(CachedTransform.position, startPosition, Speed * Time.deltaTime);
                if (Vector3.Distance(CachedTransform.position, startPosition) < 2f)
                {
                    this.toEnd = true;
                }
            }
        }

19 View Source File : BusRollFix.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

IEnumerator PositionFixRoutine()
        {
            while (MopSettings.IsModActive)
            {
                yield return new WaitForSeconds(5);
                if (transform.localEulerAngles.z > 20 && transform.localEulerAngles.z < 340)
                {
                    // Bus won't be flipped back, if player's too close.
                    if (Vector3.Distance(Hypervisor.Instance.GetPlayer().position, transform.position) < 300) 
                        continue;

                    Vector3 fixedPosition = transform.localEulerAngles;
                    fixedPosition.z = 0;
                    transform.localEulerAngles = fixedPosition;
                }
            }
        }

19 View Source File : MovementUpdate.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Update()
    {
        if (this.disabled)
        {
            return;
        }
        if (Network.peerType == NetworkPeerType.Disconnected)
        {
            return;
        }
        if (Network.peerType == NetworkPeerType.Connecting)
        {
            return;
        }
        if (base.networkView.isMine)
        {
            if (Vector3.Distance(base.transform.position, this.lastPosition) >= 0.5f)
            {
                this.lastPosition = base.transform.position;
                base.networkView.RPC("updateMovement", RPCMode.Others, new object[]
                {
                    base.transform.position,
                    base.transform.rotation,
                    base.transform.localScale,
                    base.rigidbody.velocity
                });
            }
            else if (Vector3.Distance(base.transform.rigidbody.velocity, this.lastVelocity) >= 0.1f)
            {
                this.lastVelocity = base.transform.rigidbody.velocity;
                base.networkView.RPC("updateMovement", RPCMode.Others, new object[]
                {
                    base.transform.position,
                    base.transform.rotation,
                    base.transform.localScale,
                    base.rigidbody.velocity
                });
            }
            else if (Quaternion.Angle(base.transform.rotation, this.lastRotation) >= 1f)
            {
                this.lastRotation = base.transform.rotation;
                base.networkView.RPC("updateMovement", RPCMode.Others, new object[]
                {
                    base.transform.position,
                    base.transform.rotation,
                    base.transform.localScale,
                    base.rigidbody.velocity
                });
            }
        }
        else
        {
            base.transform.position = Vector3.Slerp(base.transform.position, this.targetPosition, Time.deltaTime * 2f);
        }
    }

19 View Source File : Hypervisor.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

IEnumerator LoopRoutine()
        {
            MopSettings.IsModActive = true;

            FramerateRecorder rec = gameObject.AddComponent<FramerateRecorder>();
            rec.Initialize();

            while (MopSettings.IsModActive)
            {
                // Ticks make sure that MOP is still up and running.
                // If the ticks didn't update, that means this routine stopped.
                ++ticks;

                if (!itemInitializationDelayDone)
                {
                    // We are slightly delaying the initialization, so all items have chance to set in place, because replaced MSC and its physics.
                    waitTime++;
                    if (waitTime >= WaitDone)
                    {
                        FinishLoading();
                    }
                }

                isPlayerAtYard = MOP.ActiveDistance.Value == 0 ? Vector3.Distance(player.position, placeManager[0].transform.position) < 100
                    : Vector3.Distance(player.position, placeManager[0].transform.position) < 100 * MopSettings.ActiveDistanceMultiplicationValue;

                // When player is in any of the sectors, MOP will act like the player is at yard.
                if (SectorManager.Instance.IsPlayerInSector())
                {
                    inSectorMode = true;
                    isPlayerAtYard = true;
                }
                else
                {
                    inSectorMode = false;
                }

                yield return null;

                int i;
                long half = worldObjectManager.Count >> 1;
                // World Objects.
                for (i = 0; i < worldObjectManager.Count; ++i)
                {
                    if (i == half)
                        yield return null;

                    try
                    {
                        GenericObject worldObject = worldObjectManager[i];

                        // Check if object was destroyed (mostly intended for AI pedastrians).
                        if (worldObject.GameObject == null)
                        {
                            worldObjectManager.Remove(worldObject);
                            continue;
                        }

                        if (SectorManager.Instance.IsPlayerInSector() && SectorManager.Instance.SectorRulesContains(worldObject.GameObject.name))
                        {
                            worldObject.GameObject.SetActive(true);
                            continue;
                        }

                        // Should the object be disabled when the player leaves the house?
                        if (worldObject.DisableOn.HasFlag(DisableOn.PlayerAwayFromHome) || worldObject.DisableOn.HasFlag(DisableOn.PlayerInHome))
                        {
                            if (worldObject.GameObject.name == "NPC_CARS" && inSectorMode)
                                continue;

                            if (worldObject.GameObject.name == "COMPUTER" && worldObject.GameObject.transform.Find("SYSTEM").gameObject.activeSelf)
                                continue;

                            worldObject.Toggle(worldObject.DisableOn.HasFlag(DisableOn.PlayerAwayFromHome) ? isPlayerAtYard : !isPlayerAtYard);
                        }
                        else if (worldObject.DisableOn.HasFlag(DisableOn.Distance))
                        {
                            // The object will be disabled, if the player is in the range of that object.
                            worldObject.Toggle(IsEnabled(worldObject.transform, worldObject.Distance));
                        }
                    }
                    catch (Exception ex)
                    {
                        ExceptionManager.New(ex, false, "WORLD_OBJECT_TOGGLE_ERROR");
                    }
                }

                // Safe mode prevents toggling elemenets that MAY case some issues (vehicles, items, etc.)
                if (MopSettings.Mode == PerformanceMode.Safe)
                {
                    yield return new WaitForSeconds(.7f);
                    continue;
                }

                // So we create two separate lists - one is meant to enable, and second is ment to disable them,
                // Why?
                // If we enable items before enabling vehicle inside of which these items are supposed to be, they'll fall through to ground.
                // And the opposite happens if we disable vehicles before disabling items.
                // So if we are disabling items, we need to do that BEFORE we disable vehicles.
                // And we need to enable items AFTER we enable vehicles.
                itemsToEnable.Clear();
                itemsToDisable.Clear();
                half = ItemsManager.Instance.Count >> 1;
                for (i = 0; i < ItemsManager.Instance.Count; ++i)
                {
                    if (i == half)
                        yield return null;

                    // Safe check if somehow the i gets bigger than array length.
                    if (i >= ItemsManager.Instance.Count) break;

                    try
                    {

                        ItemBehaviour item = ItemsManager.Instance[i];

                        if (item == null || item.gameObject == null)
                        {
                            itemsToRemove.Add(item);
                            continue;
                        }

                        // Check the mode in what MOP is supposed to run and adjust to it.
                        bool toEnable = true;
                        if (MopSettings.Mode == 0)
                            toEnable = IsEnabled(item.transform, FsmManager.IsPlayerInCar() && !isPlayerAtYard ? 20 : 150);
                        else
                            toEnable = IsEnabled(item.transform, 150);

                        if (toEnable)
                        {
                            item.ToggleChangeFix();
                            if (item.ActiveSelf) continue;
                            itemsToEnable.Add(item);
                        }
                        else
                        {
                            if (!item.ActiveSelf) continue;
                            itemsToDisable.Add(item);
                        }

                        if (item.rb != null && item.rb.IsSleeping())
                        {
                            if (item.IsPartMagnetAttached()) continue;
                            if (CompatibilityManager.IsInBackpack(item)) continue;
                            item.rb.isKinematic = true;
                        }
                        
                    }
                    catch (Exception ex)
                    {
                        ExceptionManager.New(ex, false, "ITEM_TOGGLE_GATHER_ERROR");
                    }
                }

                // Items To Disable
                int full = itemsToDisable.Count;
                if (full > 0)
                {
                    half = itemsToDisable.Count >> 1;
                    for (i = 0; i < full; ++i)
                    {
                        if (half != 0 && i == half)
                            yield return null;

                        try
                        {
                            itemsToDisable[i].Toggle(false);
                        }
                        catch (Exception ex)
                        {
                            ExceptionManager.New(ex, false, "ITEM_TOGGLE_DISABLE_ERROR - " + itemsToDisable[i] != null ? itemsToDisable[i].gameObject.name : "null");
                        }
                    }
                }

                // Vehicles (new)
                half = vehicleManager.Count >> 1;
                for (i = 0; i < vehicleManager.Count; ++i)
                {
                    if (half != 0 && i == half) yield return null;

                    try
                    {
                        if (vehicleManager[i] == null)
                        {
                            vehicleManager.RemoveAt(i);
                            continue;
                        }

                        float distance = Vector3.Distance(player.transform.position, vehicleManager[i].transform.position);
                        float toggleDistance = MOP.ActiveDistance.Value == 0
                            ? MopSettings.UnityCarActiveDistance : MopSettings.UnityCarActiveDistance * MopSettings.ActiveDistanceMultiplicationValue;

                        switch (vehicleManager[i].VehicleType)
                        {
                            case VehiclesTypes.Satsuma:
                                Satsuma.Instance.ToggleElements(distance);
                                vehicleManager[i].ToggleEventSounds(distance < 3);
                                break;
                            case VehiclesTypes.Jonnez:
                                vehicleManager[i].ToggleEventSounds(distance < 2);
                                break;
                        }

                        vehicleManager[i].ToggleUnityCar(IsVehiclePhysicsEnabled(distance, toggleDistance));
                        vehicleManager[i].Toggle(IsVehicleEnabled(distance));
                    }
                    catch (Exception ex)
                    {
                        ExceptionManager.New(ex, false, $"VEHICLE_TOGGLE_ERROR_{i}");
                    }
                }

                // Items To Enable
                full = itemsToEnable.Count;
                if (full > 0)
                {
                    half = full >> 1;
                    for (i = 0; i < full; ++i)
                    {
                        if (half != 0 && i == half) yield return null;

                        try
                        {
                            itemsToEnable[i].Toggle(true);
                        }
                        catch (Exception ex)
                        {
                            ExceptionManager.New(ex, false, "ITEM_TOGGLE_ENABLE_ERROR - " + itemsToEnable[i] != null ? itemsToDisable[i].gameObject.name : "null");
                        }
                    }
                }

                // Places (New)
                full = placeManager.Count;
                half = full >> 1;
                for (i = 0; i < full; ++i)
                {
                    if (i == half)
                        yield return null;

                    try
                    {
                        if (SectorManager.Instance.IsPlayerInSector() && SectorManager.Instance.SectorRulesContains(placeManager[i].GetName()))
                        {
                            continue;
                        }

                        placeManager[i].ToggleActive(IsPlaceEnabled(placeManager[i].transform, placeManager[i].GetToggleDistance()));
                    }
                    catch (Exception ex)
                    {
                        ExceptionManager.New(ex, false, $"PLACE_TOGGLE_ERROR_{i}");
                    }
                }

                // Remove items that don't exist anymore.
                if (itemsToRemove.Count > 0)
                {
                    for (i = itemsToRemove.Count - 1; i >= 0; --i)
                    {
                        ItemsManager.Instance.RemoveAt(i);
                    }

                    itemsToRemove.Clear();
                }

                yield return new WaitForSeconds(.7f);

                if (retries > 0 && !restartSucceedMessaged)
                {
                    restartSucceedMessaged = true;
                    ModConsole.Log("<color=green>[MOP] Restart succeeded!</color>");
                }
            }
        }

19 View Source File : RockThrow.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void explore()
    {
        GameObject gameObject;
        if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && PhotonNetwork.IsMasterClient)
        {
            gameObject = Pool.NetworkEnable("FX/boom6", baseT.position, baseT.rotation, 0);
            if (baseT.root.gameObject.GetComponent<EnemyfxIDcontainer>() != null)
            {
                gameObject.GetComponent<EnemyfxIDcontainer>().myOwnerViewID = baseT.root.gameObject.GetComponent<EnemyfxIDcontainer>().myOwnerViewID;
                gameObject.GetComponent<EnemyfxIDcontainer>().replacedanName = baseT.root.gameObject.GetComponent<EnemyfxIDcontainer>().replacedanName;
            }
        }
        else
        {
            gameObject = Pool.Enable("FX/boom6", baseT.position, baseT.rotation);//(GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("FX/boom6"), baseT.position, baseT.rotation);
        }
        gameObject.transform.localScale = baseT.localScale;
        float num = 1f - Vector3.Distance(IN_GAME_MAIN_CAMERA.BaseCamera.transform.position, gameObject.transform.position) * 0.05f;
        num = Mathf.Min(1f, num);
        IN_GAME_MAIN_CAMERA.MainCamera.startShake(num, num, 0.95f);
        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
        {
            Pool.Disable(gameObject);
        }
        else
        {
            PhotonNetwork.Destroy(BasePV);
        }
    }

19 View Source File : SaveManager.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

public static void VerifySave()
        {
            if (!File.Exists(SavePath))
                return;

            // Preplacedenger bucket seat.
            // Check if driver bucket seat is bought and check the same for preplacedenger one.
            // If they do not match, fix it.
            try
            {
                saveBugs = new List<SaveBugs>();

                bool bucketPreplacedengerSeat = ES2.Load<bool>(SavePath + "?tag=bucket seat preplacedenger(Clone)Purchased", setting);
                bool bucketDriverSeat = ES2.Load<bool>(SavePath + "?tag=bucket seat driver(Clone)Purchased", setting);
                if (bucketDriverSeat != bucketPreplacedengerSeat)
                {
                    saveBugs.Add(SaveBugs.New("Bucket Seats", "One bucket seat is present in the game world, while the other isn't - both should be in game world.", () =>
                    {
                        ES2.Save(true, SavePath + "?tag=bucket seat preplacedenger(Clone)Purchased");
                        ES2.Save(true, SavePath + "?tag=bucket seat driver(Clone)Purchased");
                    }));
                }
            }
            catch (Exception e)
            {
                ExceptionManager.New(e, false, "VERIFY_SAVE_BUCKET_SEAT");
            }

            try
            {
                bool tractorTrailerAttached = ES2.Load<bool>(SavePath + "?tag=TractorTrailerAttached", setting);
                Transform flatbedTransform = ES2.Load<Transform>(SavePath + "?tag=FlatbedTransform", setting);
                Transform kekmetTransform = ES2.Load<Transform>(SavePath + "?tag=TractorTransform", setting);
                if (tractorTrailerAttached && Vector3.Distance(flatbedTransform.position, kekmetTransform.position) > 5.5f)
                {
                    saveBugs.Add(SaveBugs.New("Flatbed Trailer Attached", "Trailer and tractor are too far apart from each other - impossible for them to be attached.", () =>
                    {
                        ES2.Save(false, SavePath + "?tag=TractorTrailerAttached", setting);
                    }));
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.New(ex, false, "VERIFY_SAVE_FLATBED");
            }

            try
            {
                // This one applies fix quietly, as it happens so often,
                // it would be annoying to nag player about that error.
                if (SaveFileExists)
                {
                    MopSaveData save = ModSave.Load<MopSaveData>(mopSavePath);

                    if (save.version == MOP.ModVersion)
                    {
                        bool bumperRearInstalled = ES2.Load<bool>(SavePath + "?tag=bumper rear(Clone)Installed", setting);
                        float bumperTightness = ES2.Load<float>(SavePath + "?tag=Bumper_RearTightness", setting);
                        if (bumperRearInstalled && bumperTightness != save.rearBumperTightness)
                        {
                            ES2.Save(save.rearBumperTightness, SavePath + "?tag=Bumper_RearTightness");
                            ES2.Save(save.rearBumperBolts, SavePath + "?tag=Bumper_RearBolts");
                        }

                        bool halfshaft_FLInstalled = ES2.Load<bool>(SavePath + "?tag=halfshaft_flInstalled", setting);
                        float halfshaft_FLTightness = ES2.Load<float>(SavePath + "?tag=Halfshaft_FLTightness", setting);
                        if (halfshaft_FLInstalled && halfshaft_FLTightness != save.halfshaft_FLTightness)
                        {
                            saveBugs.Add(SaveBugs.New("Halfshaft (FL) Missmateched Bolt Stages", "Bolt stages in Halfshaft (FL) aren't correct.", () =>
                            {
                                ES2.Save(save.halfshaft_FLTightness, SavePath + "?tag=Halfshaft_FLTightness");
                                ES2.Save(save.halfshaft_FLBolts, SavePath + "?tag=Halfshaft_FLBolts");
                            }));
                        }

                        bool halfshaft_FRInstalled = ES2.Load<bool>(SavePath + "?tag=halfshaft_frInstalled", setting);
                        float halfshaft_FRTightness = ES2.Load<float>(SavePath + "?tag=Halfshaft_FRTightness", setting);
                        if (halfshaft_FRInstalled && halfshaft_FRTightness != save.halfshaft_FRTightness)
                        {
                            saveBugs.Add(SaveBugs.New("Halfshaft (FR) Missmateched Bolt Stages", "Bolt stages in Halfshaft (FR) aren't correct.", () =>
                            {
                                ES2.Save(save.halfshaft_FRTightness, SavePath + "?tag=Halfshaft_FRTightness");
                                ES2.Save(save.halfshaft_FRBolts, SavePath + "?tag=Halfshaft_FRBolts");
                            }));
                        }

                        bool wiringBatteryMinusInstalled = ES2.Load<bool>(SavePath + "?tag=battery_terminal_minus(xxxxx)Installed", setting);
                        float wiringBatteryMinusTightness = ES2.Load<float>(SavePath + "?tag=WiringBatteryMinusTightness", setting);
                        if (wiringBatteryMinusInstalled && wiringBatteryMinusTightness != save.wiringBatteryMinusTightness)
                        {
                            saveBugs.Add(SaveBugs.New("Battery terminal minus bolt is not tightened.", "Incorrect bolt tightness of battery minus terminal.", () =>
                            {
                                ES2.Save(save.wiringBatteryMinusTightness, SavePath + "?tag=WiringBatteryMinusTightness");
                                ES2.Save(save.wiringBatteryMinusBolts, SavePath + "?tag=WiringBatteryMinusBolts");
                            }));
                        }
                    }
                    else
                    {
                        ReleaseSave();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.New(ex, false, "VERIFY_BUMPER_REAR");
            }

            if (saveBugs.Count > 0)
            {
                ModPrompt.CreateYesNoPrompt($"MOP found <color=yellow>{saveBugs.Count}</color> problem{(saveBugs.Count > 1 ? "s" : "")} with your save:\n\n" +
                                            $"<color=yellow>{string.Join(", ", saveBugs.Select(f => f.BugName).ToArray())}</color>\n\n" +
                                            $"Would you like MOP to try and fix {((saveBugs.Count > 1) ? "them" : "it")}?", "MOP - Save Integrity Verification", FixAllProblems);
            }
            else
            {
                ModConsole.Log("[MOP] MOP didn't find any problems with your save :)");
            }
        }

19 View Source File : supplyCheck.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Update()
    {
        this.elapsedTime += Time.deltaTime;
        if (this.elapsedTime > this.stepTime)
        {
            this.elapsedTime -= this.stepTime;
            foreach (HERO hero in FengGameManagerMKII.Heroes)
            {
                if (hero != null && hero.IsLocal && Vector3.Distance(hero.baseT.position, baseT.position) < 1.5f)
                {
                    hero.GetSupply();
                }
            }
        }
    }

19 View Source File : WorldInteractor.cs
License : MIT License
Project Creator : BrunoS3D

void Update() {
        if (Input.mouseScrollDelta.y > 0) {
            placeBlock++;
        }
        if (Input.mouseScrollDelta.y < 0) {
            placeBlock--;
        }
        placeBlock = Mathf.Max(placeBlock, 1);
        placeBlock = Mathf.Min(placeBlock, World.currentWorld.blockDefs.Count - 1);

        if (Input.GetMouseButton(0) || Input.GetMouseButton(1)) {
            // increase time
            t_timeToInteractDelta += Time.deltaTime;

        } else {
            // reset time
            t_timeToInteractDelta = 0.0f;
        }

        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) {
            t_timeToInteractDelta = timeToInteract;
        }

        d_timeToInteractDelta = t_timeToInteractDelta;

        RaycastHit hit;
        var ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        int cookerDef = World.currentWorld.FindBlockDefByName("Cooker");
        int cookerActiveDef = World.currentWorld.FindBlockDefByName("CookerActive");
        // int craftTableDef = World.currentWorld.FindBlockDefByName("CraftTable");

        int targetBlock = -1;

        d_targetBlock = targetBlock;
        d_targetNewBlockDistance = -1.0f;
        d_targetExistingBlockDistance = -1.0f;

        if (Physics.Raycast(ray, out hit)) {
            if (hit.transform && hit.transform.GetComponent<Chunk>()) {
                Vector3 mid = new Vector3(0.5f, 0.5f, 0.5f);

                Chunk chunk = hit.transform.GetComponent<Chunk>();

                Vector3 chunkPosition = chunk.transform.position;
                d_chunkPosition = chunkPosition;

                Vector3 worldHitPoint = hit.point + hit.normal / 2;
                worldHitPoint = Vector3Int.FloorToInt(worldHitPoint);

                d_worldHitPoint = worldHitPoint;

                Vector3 worldBlockPoint = hit.point - hit.normal / 2;
                worldBlockPoint = Vector3Int.FloorToInt(worldBlockPoint);

                d_worldBlockPoint = worldBlockPoint;

                Vector3 chunkHitPoint = worldHitPoint - chunkPosition;
                Vector3 chunkBlockPoint = worldBlockPoint - chunkPosition;

                d_chunkHitPoint = chunkHitPoint;
                d_chunkBlockPoint = chunkBlockPoint;

                float targetNewBlockDistance = Vector3.Distance(transform.position, worldHitPoint + mid);
                float targetExistingBlockDistance = Vector3.Distance(transform.position, worldBlockPoint + mid);

                d_targetNewBlockDistance = targetNewBlockDistance;
                d_targetExistingBlockDistance = targetExistingBlockDistance;

                targetBlock = chunk.GetBlockAt(chunkBlockPoint);
                d_targetBlock = targetBlock;

                if (t_timeToInteractDelta >= timeToInteract) {
                    // reset time
                    t_timeToInteractDelta = 0.0f;
                    d_timeToInteractDelta = t_timeToInteractDelta;

                    if (Input.GetMouseButton(0)) {
                        chunk.RemoveBlockAt(chunkBlockPoint);
                        World.currentWorld.InsertBlockParticlesAt(worldBlockPoint, targetBlock);
                        // Debug.Log($"Removido bloco {World.currentWorld.blockDefs[targetBlock].name} na posicao {chunkBlockPoint}");
                    } else if (Input.GetMouseButton(1)) {
                        if (targetBlock == cookerDef) {
                            chunk.SetBlockAt(chunkBlockPoint, cookerActiveDef);
                            // Debug.Log($"Bloco {World.currentWorld.blockDefs[targetBlock].name} alterado para {World.currentWorld.blockDefs[cookerActiveDef].name} na posicao {chunkBlockPoint}");
                            return;
                        }
                        if (targetBlock == cookerActiveDef) {
                            chunk.SetBlockAt(chunkBlockPoint, cookerDef);
                            // Debug.Log($"Bloco {World.currentWorld.blockDefs[targetBlock].name} alterado para {World.currentWorld.blockDefs[cookerDef].name} na posicao {chunkBlockPoint}");
                            return;
                        }
                        if (targetNewBlockDistance >= minNewBlockDistance && targetExistingBlockDistance >= minExistingBlockDistance) {
                            chunk.InsertBlockAt(chunkHitPoint, placeBlock);
                            // Debug.Log($"Adicionado bloco {World.currentWorld.blockDefs[placeBlock].name} na posicao {chunkHitPoint}");
                            return;
                        }
                    }
                }
            }
        }
    }

19 View Source File : GraphLineCurver.cs
License : Apache License 2.0
Project Creator : activey

void Start()
		{

			LineRenderer line = GetComponent<LineRenderer> ();
			if (line == null) {
				return;
			}
			Vector3 startPosition = line.GetPosition (0);
			Vector3 endPosition = line.GetPosition (1);

			float distance = Vector3.Distance (startPosition, endPosition);

			Vector3 middlePosition = Vector3.MoveTowards (startPosition, endPosition, distance / 4);
			//middlePosition.y = middlePosition.y + 20;

			Vector3[] arrayToCurve = new Vector3[3]{startPosition, middlePosition, endPosition};

			/*List<Vector3> points;
			List<Vector3> curvedPoints;
			int pointsLength = 0;
			int curvedLength = 0;

			if(smoothness < 1.0f) smoothness = 1.0f;

			pointsLength = arrayToCurve.Length;

			curvedLength = (pointsLength*Mathf.RoundToInt(smoothness))-1;
			curvedPoints = new List<Vector3>(curvedLength);

			float t = 0.0f;
			for(int pointInTimeOnCurve = 0;pointInTimeOnCurve < curvedLength+1;pointInTimeOnCurve++){
				t = Mathf.InverseLerp(0,curvedLength,pointInTimeOnCurve);

				points = new List<Vector3>(arrayToCurve);

				for(int j = pointsLength-1; j > 0; j--){
					for (int i = 0; i < j; i++){
						points[i] = (1-t)*points[i] + t*points[i+1];
					}
				}

				curvedPoints.Add(points[0]);
			}

			line.numPositions = curvedPoints.Count;
			for (int index = 0; index < curvedPoints.Count; index++) {
				line.SetPosition (index, curvedPoints [index]);
			}*/

			for (int index = 0; index < arrayToCurve.Length; index++) {
				line.SetPosition (index, arrayToCurve [index]);
			}
		}

19 View Source File : ICameraHandler.cs
License : MIT License
Project Creator : CitiesSkylinesMultiplayer

public static void Postfix(CameraController __instance, Camera ___m_camera)
        {
            // Make sure the camera object is defined, this should always happen but for some strange reason it didnt (look bellow)
            // This is not happening if i test it localy. (debug using AllocConsole in CSM.cs)
            // https://github.com/DominicMaas/Tango/issues/155
            if (___m_camera && MultiplayerManager.Instance.CurrentRole != MultiplayerRole.None)
            {
                // Get camera rotation, angle and position
                Transform transform = ___m_camera.transform;
                Quaternion _rotation = transform.rotation;
                Vector3 _position = transform.position;

                // Update the player camera position every time the camera moves OR rotates
                // This should not be that demanding on the server (might be demanding if you are playing with a lot of players
                // We could also make the server update the player locations every x seconds by storing all the info on the server and send it to all clients every 1 second?
                if (Vector3.Distance(_position, playerCameraPosition_last) > 1 || playerCameraRotation_last != _rotation)
                {
                    // Store camera rotation and position
                    playerCameraPosition_last = _position;
                    playerCameraRotation_last = _rotation;


                    // Set the correct playerName if our currentRole is SERVER, else use the CurrentClient Username
                    string playerName;
                    if (MultiplayerManager.Instance.CurrentRole == MultiplayerRole.Server)
                    {
                        playerName = MultiplayerManager.Instance.CurrentServer.Config.Username;
                    }
                    else
                    {
                        playerName = MultiplayerManager.Instance.CurrentClient.Config.Username;
                    }

                    // Send info to all clients
                    Command.SendToAll(new PlayerLocationCommand
                    {
                        PlayerName = playerName,
                        PlayerCameraPosition = _position,
                        PlayerCameraRotation = _rotation,
                        PlayerCameraHeight = __instance.m_currentHeight,
                        PlayerColor = JoinGamePanel.playerColor
                    });
                }
            }
        }

19 View Source File : TriggerColliderWeapon.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void OnTriggerStay(Collider other)
    {
        //if (this.ActiveMe)
        //{
        if (!this.currentHitsII.Contains(other.gameObject))
        {
            this.currentHitsII.Add(other.gameObject);
            IN_GAME_MAIN_CAMERA.MainCamera.startShake(0.1f, 0.1f, 0.95f);
            if (other.gameObject.transform.root.gameObject.CompareTag("replacedan"))
            {
                IN_GAME_MAIN_CAMERA.MainHERO.slashHit.Play();
                if (IN_GAME_MAIN_CAMERA.GameType != GameType.Single)
                {
                    Optimization.Caching.Pool.NetworkEnable("hitMeat", baseT.position, Quaternion.Euler(270f, 0f, 0f), 0);
                }
                else
                {
                    Pool.Enable("hitMeat", baseT.position, Quaternion.Euler(270f, 0f, 0f));//(GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("hitMeat"));
                }
                //gameObject.transform.position = baseT.position;
                baseT.root.GetComponent<HERO>().useBlade(0);
            }
        }
        switch (other.gameObject.tag)
        {
            case "playerHitbox":
                if (!FengGameManagerMKII.Level.PVPEnabled)
                {
                    return;
                }
                float num = 1f - Vector3.Distance(other.gameObject.transform.position, baseT.position) * 0.05f;
                num = Mathf.Min(1f, num);
                HitBox component = other.gameObject.GetComponent<HitBox>();
                if (component != null && component.transform.root != null)
                {
                    if (component.transform.root.GetComponent<HERO>().myTeam == this.myTeam)
                    {
                        return;
                    }
                    if (!component.transform.root.GetComponent<HERO>().IsInvincible())
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!component.transform.root.GetComponent<HERO>().IsGrabbed)
                            {
                                component.transform.root.GetComponent<HERO>().Die((component.transform.root.transform.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f, false);
                            }
                        }
                        else if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && !component.transform.root.GetComponent<HERO>().HasDied() && !component.transform.root.GetComponent<HERO>().IsGrabbed)
                        {
                            component.transform.root.GetComponent<HERO>().MarkDie();
                            component.transform.root.GetComponent<HERO>().BasePV.RPC("netDie", PhotonTargets.All, new object[]
                            {
                                (component.transform.root.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f,
                                false,
                                baseT.root.gameObject.GetPhotonView().viewID,
                                PhotonView.Find(baseT.root.gameObject.GetPhotonView().viewID).owner.Properties[PhotonPlayerProperty.name],
                                false
                            });
                        }
                    }
                }
                break;

            case "replacedanneck":
                HitBox component2 = other.gameObject.GetComponent<HitBox>();
                if (component2 != null && this.checkIfBehind(component2.transform.root.gameObject) && !this.currentHits.Contains(component2))
                {
                    component2.hitPosition = (baseT.position + component2.transform.position) * 0.5f;
                    this.currentHits.Add(component2);
                    this.meatDie.Play();
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                    {
                        if (component2.transform.root.GetComponent<replacedAN>() && !component2.transform.root.GetComponent<replacedAN>().hasDie)
                        {
                            int num2 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num2 = Mathf.Max(10, num2);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num2)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num2, component2.transform.root.gameObject, 0.02f);
                            }
                            component2.transform.root.GetComponent<replacedAN>().Die();
                            this.napeMeat(IN_GAME_MAIN_CAMERA.MainR.velocity, component2.transform.root);
                            FengGameManagerMKII.FGM.netShowDamage(num2);
                            FengGameManagerMKII.FGM.PlayerKillInfoSingleUpdate(num2);
                        }
                    }
                    else if (!PhotonNetwork.IsMasterClient || !component2.transform.root.gameObject.GetPhotonView().IsMine)
                    {
                        if (component2.transform.root.GetComponent<replacedAN>())
                        {
                            if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                            {
                                int num3 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num3 = Mathf.Max(10, num3);
                                if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num3)
                                {
                                    IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num3, component2.transform.root.gameObject, 0.02f);
                                    component2.transform.root.GetComponent<replacedAN>().asClientLookTarget = false;
                                }
                                component2.transform.root.GetComponent<replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<replacedAN>().BasePV.owner, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num3
                                });
                            }
                        }
                        else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                        {
                            baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                            int num4 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num4 = Mathf.Max(10, num4);
                            if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.owner, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num4
                                });
                            }
                        }
                        else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>())
                        {
                            baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                            if (!component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                            {
                                int num5 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num5 = Mathf.Max(10, num5);
                                component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.owner, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num5
                                });
                            }
                        }
                    }
                    else if (component2.transform.root.GetComponent<replacedAN>())
                    {
                        if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                        {
                            int num6 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num6 = Mathf.Max(10, num6);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num6)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num6, component2.transform.root.gameObject, 0.02f);
                            }
                            component2.transform.root.GetComponent<replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num6);
                        }
                    }
                    else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                    {
                        baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                        if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            int num7 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num7 = Mathf.Max(10, num7);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num7)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num7, null, 0.02f);
                            }
                            component2.transform.root.GetComponent<FEMALE_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num7);
                        }
                    }
                    else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>())
                    {
                        baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                        if (!component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                        {
                            int num8 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num8 = Mathf.Max(10, num8);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num8)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num8, null, 0.02f);
                            }
                            component2.transform.root.GetComponent<COLOSSAL_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num8);
                        }
                    }
                    this.showCriticalHitFX();
                }
                break;

            case "replacedaneye":
                if (!this.currentHits.Contains(other.gameObject))
                {
                    this.currentHits.Add(other.gameObject);
                    GameObject gameObject2 = other.gameObject.transform.root.gameObject;
                    if (gameObject2.GetComponent<FEMALE_replacedAN>())
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().hitEye();
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient)
                        {
                            if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                });
                            }
                        }
                        else if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject2.GetComponent<FEMALE_replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                        }
                    }
                    else if (gameObject2.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().HitEye();
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient || !gameObject2.GetPhotonView().IsMine)
                        {
                            if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                });
                            }
                        }
                        else if (!gameObject2.GetComponent<replacedAN>().hasDie)
                        {
                            gameObject2.GetComponent<replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                        }
                        this.showCriticalHitFX();
                    }
                }
                break;

            case "replacedanankle":
                if (currentHits.Contains(other.gameObject))
                {
                    return;
                }

                this.currentHits.Add(other.gameObject);
                GameObject gameObject3 = other.gameObject.transform.root.gameObject;
                int num9 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - gameObject3.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                num9 = Mathf.Max(10, num9);
                if (gameObject3.GetComponent<replacedAN>() && gameObject3.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                {
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                    {
                        if (!gameObject3.GetComponent<replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<replacedAN>().HitAnkle();
                        }
                    }
                    else
                    {
                        if (!PhotonNetwork.IsMasterClient || !gameObject3.GetPhotonView().IsMine)
                        {
                            if (!gameObject3.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject3.GetComponent<replacedAN>().BasePV.RPC("hitAnkleRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                });
                            }
                        }
                        else if (!gameObject3.GetComponent<replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<replacedAN>().HitAnkle();
                        }
                        this.showCriticalHitFX();
                    }
                }
                else if (gameObject3.GetComponent<FEMALE_replacedAN>())
                {
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                    {
                        if (other.gameObject.name == "ankleR")
                        {
                            if (gameObject3.GetComponent<FEMALE_replacedAN>() && !gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleR(num9);
                            }
                        }
                        else if (gameObject3.GetComponent<FEMALE_replacedAN>() && !gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleL(num9);
                        }
                    }
                    else if (other.gameObject.name == "ankleR")
                    {
                        if (!PhotonNetwork.IsMasterClient)
                        {
                            if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject3.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleRRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num9
                                });
                            }
                        }
                        else if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleRRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                        }
                    }
                    else if (!PhotonNetwork.IsMasterClient)
                    {
                        if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleLRPC", PhotonTargets.MasterClient, new object[]
                            {
                                baseT.root.gameObject.GetPhotonView().viewID,
                                num9
                            });
                        }
                    }
                    else if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                    {
                        gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleLRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                    }
                    this.showCriticalHitFX();
                }
                break;
        }
        //}
    }

19 View Source File : TriggerColliderWeapon.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void OnTriggerStay(Collider other)
    {
        //if (this.ActiveMe)
        //{
        if (!this.currentHitsII.Contains(other.gameObject))
        {
            this.currentHitsII.Add(other.gameObject);
            IN_GAME_MAIN_CAMERA.MainCamera.startShake(0.1f, 0.1f, 0.95f);
            if (other.gameObject.transform.root.gameObject.CompareTag("replacedan"))
            {
                IN_GAME_MAIN_CAMERA.MainHERO.slashHit.Play();
                if (IN_GAME_MAIN_CAMERA.GameType != GameType.Single)
                {
                    Optimization.Caching.Pool.NetworkEnable("hitMeat", baseT.position, Quaternion.Euler(270f, 0f, 0f), 0);
                }
                else
                {
                    Pool.Enable("hitMeat", baseT.position, Quaternion.Euler(270f, 0f, 0f));//(GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("hitMeat"));
                }
                //gameObject.transform.position = baseT.position;
                baseT.root.GetComponent<HERO>().useBlade(0);
            }
        }
        switch (other.gameObject.tag)
        {
            case "playerHitbox":
                if (!FengGameManagerMKII.Level.PVPEnabled)
                {
                    return;
                }
                float num = 1f - Vector3.Distance(other.gameObject.transform.position, baseT.position) * 0.05f;
                num = Mathf.Min(1f, num);
                HitBox component = other.gameObject.GetComponent<HitBox>();
                if (component != null && component.transform.root != null)
                {
                    if (component.transform.root.GetComponent<HERO>().myTeam == this.myTeam)
                    {
                        return;
                    }
                    if (!component.transform.root.GetComponent<HERO>().IsInvincible())
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!component.transform.root.GetComponent<HERO>().IsGrabbed)
                            {
                                component.transform.root.GetComponent<HERO>().Die((component.transform.root.transform.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f, false);
                            }
                        }
                        else if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && !component.transform.root.GetComponent<HERO>().HasDied() && !component.transform.root.GetComponent<HERO>().IsGrabbed)
                        {
                            component.transform.root.GetComponent<HERO>().MarkDie();
                            component.transform.root.GetComponent<HERO>().BasePV.RPC("netDie", PhotonTargets.All, new object[]
                            {
                                (component.transform.root.position - baseT.position).normalized * num * 1000f + Vectors.up * 50f,
                                false,
                                baseT.root.gameObject.GetPhotonView().viewID,
                                PhotonView.Find(baseT.root.gameObject.GetPhotonView().viewID).owner.Properties[PhotonPlayerProperty.name],
                                false
                            });
                        }
                    }
                }
                break;

            case "replacedanneck":
                HitBox component2 = other.gameObject.GetComponent<HitBox>();
                if (component2 != null && this.checkIfBehind(component2.transform.root.gameObject) && !this.currentHits.Contains(component2))
                {
                    component2.hitPosition = (baseT.position + component2.transform.position) * 0.5f;
                    this.currentHits.Add(component2);
                    this.meatDie.Play();
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                    {
                        if (component2.transform.root.GetComponent<replacedAN>() && !component2.transform.root.GetComponent<replacedAN>().hasDie)
                        {
                            int num2 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num2 = Mathf.Max(10, num2);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num2)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num2, component2.transform.root.gameObject, 0.02f);
                            }
                            component2.transform.root.GetComponent<replacedAN>().Die();
                            this.napeMeat(IN_GAME_MAIN_CAMERA.MainR.velocity, component2.transform.root);
                            FengGameManagerMKII.FGM.netShowDamage(num2);
                            FengGameManagerMKII.FGM.PlayerKillInfoSingleUpdate(num2);
                        }
                    }
                    else if (!PhotonNetwork.IsMasterClient || !component2.transform.root.gameObject.GetPhotonView().IsMine)
                    {
                        if (component2.transform.root.GetComponent<replacedAN>())
                        {
                            if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                            {
                                int num3 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num3 = Mathf.Max(10, num3);
                                if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num3)
                                {
                                    IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num3, component2.transform.root.gameObject, 0.02f);
                                    component2.transform.root.GetComponent<replacedAN>().asClientLookTarget = false;
                                }
                                component2.transform.root.GetComponent<replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<replacedAN>().BasePV.owner, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num3
                                });
                            }
                        }
                        else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                        {
                            baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                            int num4 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num4 = Mathf.Max(10, num4);
                            if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<FEMALE_replacedAN>().BasePV.owner, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num4
                                });
                            }
                        }
                        else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>())
                        {
                            baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                            if (!component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                            {
                                int num5 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                                num5 = Mathf.Max(10, num5);
                                component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.RPC("replacedanGetHit", component2.transform.root.GetComponent<COLOSSAL_replacedAN>().BasePV.owner, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num5
                                });
                            }
                        }
                    }
                    else if (component2.transform.root.GetComponent<replacedAN>())
                    {
                        if (!component2.transform.root.GetComponent<replacedAN>().hasDie)
                        {
                            int num6 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num6 = Mathf.Max(10, num6);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num6)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num6, component2.transform.root.gameObject, 0.02f);
                            }
                            component2.transform.root.GetComponent<replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num6);
                        }
                    }
                    else if (component2.transform.root.GetComponent<FEMALE_replacedAN>())
                    {
                        baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                        if (!component2.transform.root.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            int num7 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num7 = Mathf.Max(10, num7);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num7)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num7, null, 0.02f);
                            }
                            component2.transform.root.GetComponent<FEMALE_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num7);
                        }
                    }
                    else if (component2.transform.root.GetComponent<COLOSSAL_replacedAN>())
                    {
                        baseT.root.GetComponent<HERO>().useBlade(int.MaxValue);
                        if (!component2.transform.root.GetComponent<COLOSSAL_replacedAN>().hasDie)
                        {
                            int num8 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - component2.transform.root.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                            num8 = Mathf.Max(10, num8);
                            if (Settings.Snapshots.ToValue() && Settings.SnapshotsDamage.Value <= num8)
                            {
                                IN_GAME_MAIN_CAMERA.MainCamera.startSnapShot(component2.transform.position, num8, null, 0.02f);
                            }
                            component2.transform.root.GetComponent<COLOSSAL_replacedAN>().replacedanGetHit(baseT.root.gameObject.GetPhotonView().viewID, num8);
                        }
                    }
                    this.showCriticalHitFX();
                }
                break;

            case "replacedaneye":
                if (!this.currentHits.Contains(other.gameObject))
                {
                    this.currentHits.Add(other.gameObject);
                    GameObject gameObject2 = other.gameObject.transform.root.gameObject;
                    if (gameObject2.GetComponent<FEMALE_replacedAN>())
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().hitEye();
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient)
                        {
                            if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                });
                            }
                        }
                        else if (!gameObject2.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject2.GetComponent<FEMALE_replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                        }
                    }
                    else if (gameObject2.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().HitEye();
                            }
                        }
                        else if (!PhotonNetwork.IsMasterClient || !gameObject2.GetPhotonView().IsMine)
                        {
                            if (!gameObject2.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject2.GetComponent<replacedAN>().BasePV.RPC("hitEyeRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                });
                            }
                        }
                        else if (!gameObject2.GetComponent<replacedAN>().hasDie)
                        {
                            gameObject2.GetComponent<replacedAN>().hitEyeRPC(baseT.root.gameObject.GetPhotonView().viewID);
                        }
                        this.showCriticalHitFX();
                    }
                }
                break;

            case "replacedanankle":
                if (currentHits.Contains(other.gameObject)) return;
                this.currentHits.Add(other.gameObject);
                GameObject gameObject3 = other.gameObject.transform.root.gameObject;
                int num9 = (int)((IN_GAME_MAIN_CAMERA.MainR.velocity - gameObject3.rigidbody.velocity).magnitude * 10f * this.scoreMulti);
                num9 = Mathf.Max(10, num9);
                if (gameObject3.GetComponent<replacedAN>() && gameObject3.GetComponent<replacedAN>().abnormalType != AbnormalType.Crawler)
                {
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                    {
                        if (!gameObject3.GetComponent<replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<replacedAN>().HitAnkle();
                        }
                    }
                    else
                    {
                        if (!PhotonNetwork.IsMasterClient || !gameObject3.GetPhotonView().IsMine)
                        {
                            if (!gameObject3.GetComponent<replacedAN>().hasDie)
                            {
                                gameObject3.GetComponent<replacedAN>().BasePV.RPC("hitAnkleRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID
                                });
                            }
                        }
                        else if (!gameObject3.GetComponent<replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<replacedAN>().HitAnkle();
                        }
                        this.showCriticalHitFX();
                    }
                }
                else if (gameObject3.GetComponent<FEMALE_replacedAN>())
                {
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                    {
                        if (other.gameObject.name == "ankleR")
                        {
                            if (gameObject3.GetComponent<FEMALE_replacedAN>() && !gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleR(num9);
                            }
                        }
                        else if (gameObject3.GetComponent<FEMALE_replacedAN>() && !gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleL(num9);
                        }
                    }
                    else if (other.gameObject.name == "ankleR")
                    {
                        if (!PhotonNetwork.IsMasterClient)
                        {
                            if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                            {
                                gameObject3.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleRRPC", PhotonTargets.MasterClient, new object[]
                                {
                                    baseT.root.gameObject.GetPhotonView().viewID,
                                    num9
                                });
                            }
                        }
                        else if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleRRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                        }
                    }
                    else if (!PhotonNetwork.IsMasterClient)
                    {
                        if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                        {
                            gameObject3.GetComponent<FEMALE_replacedAN>().BasePV.RPC("hitAnkleLRPC", PhotonTargets.MasterClient, new object[]
                            {
                                baseT.root.gameObject.GetPhotonView().viewID,
                                num9
                            });
                        }
                    }
                    else if (!gameObject3.GetComponent<FEMALE_replacedAN>().hasDie)
                    {
                        gameObject3.GetComponent<FEMALE_replacedAN>().hitAnkleLRPC(baseT.root.gameObject.GetPhotonView().viewID, num9);
                    }
                    this.showCriticalHitFX();
                }
                break;
        }
        //}
    }

19 View Source File : SpringLayout.cs
License : Apache License 2.0
Project Creator : activey

private void CalculateRepulsion(GraphSceneComponents sceneComponents)
		{
			sceneComponents.AcceptNode (v => {
				SpringLayoutData layoutData = GetLayoutData (v);

				double dx = 0;
				double dy = 0;
				double dz = 0;

				sceneComponents.AcceptNode (v2 => {
					float vx = v.GetPosition().x - v2.GetPosition().x;
					float vy = v.GetPosition().y - v2.GetPosition().y;
					float vz = v.GetPosition().z - v2.GetPosition().z;

					double distanceSq = Mathf.Sqrt(Vector3.Distance(v.GetPosition(), v2.GetPosition()));
					if (distanceSq == 0) {
						System.Random random = new System.Random();
						dx += random.NextDouble();
						dy += random.NextDouble();
						dz += random.NextDouble();
					} else if (distanceSq < repulsion_range_sq) {
						float factor = 0.1F;
						dx += factor * vx / distanceSq;
						dy += factor * vy / distanceSq;
						dz += factor * vz / distanceSq;
					}
				});

				double dlen = dx*dx + dy*dy + dz*dz;
				if (dlen > 0) {
					dlen = System.Math.Sqrt(dlen) / 20;
					layoutData.xRepulsion += dx / dlen;
					layoutData.yRepulsion += dy / dlen;
					layoutData.zRepulsion += dz / dlen;
				}
			});
		}

19 View Source File : RacingMovingObject.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public override void Launch()
        {
            IsActive = true;

            //Explanation by Sadico
            //we execute the Distance function just one to initialize the moltiplier and don't need to do the calculation anymore
            //instead we do a more simple math calculation, get_perc at each frame that just cap and cycle a counter
            time_moltiplier = this.Speed / Vector3.Distance(this.startPosition, this.endPosition);
            percentage_position = 0;
        }

19 View Source File : COLOSSAL_TITAN.cs
License : GNU General Public License v3.0
Project Creator : aelariane

public void Update()
    {
        this.healthTime -= Time.deltaTime;
        UpdateLabel();
        if (this.state == "null")
        {
            return;
        }
        if (this.state == "wait")
        {
            this.waitTime -= Time.deltaTime;
            if (this.waitTime <= 0f)
            {
                baseT.position = new Vector3(30f, 0f, 784f);
                //UnityEngine.Object.Instantiate(CacheResources.Load("FX/ThunderCT"), baseT.position + Vectors.up * 350f, Quaternion.Euler(270f, 0f, 0f));
                Pool.Enable("FX/ThunderCT", baseT.position + Vectors.up * 350f, Quaternion.Euler(270f, 0f, 0f));
                IN_GAME_MAIN_CAMERA.MainCamera.flashBlind();
                if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                {
                    this.idle();
                }
                else if ((!FengGameManagerMKII.LAN) ? BasePV.IsMine : base.networkView.isMine)
                {
                    this.idle();
                }
                else
                {
                    this.state = "null";
                }
            }
        }
        else
        {
            if (this.state == "idle")
            {
                if (this.attackPattern == -1)
                {
                    this.slap("r1");
                    this.attackPattern++;
                }
                else if (this.attackPattern == 0)
                {
                    this.attack_sweep(string.Empty);
                    this.attackPattern++;
                }
                else if (this.attackPattern == 1)
                {
                    this.steam();
                    this.attackPattern++;
                }
                else if (this.attackPattern == 2)
                {
                    this.kick();
                    this.attackPattern++;
                }
                else
                {
                    if (this.isSteamNeed || this.hasDie)
                    {
                        this.steam();
                        this.isSteamNeed = false;
                        return;
                    }
                    if (this.myHero == null)
                    {
                        this.findNearestHero();
                    }
                    else
                    {
                        Vector3 vector = this.myHero.transform.position - baseT.position;
                        float current = -Mathf.Atan2(vector.z, vector.x) * 57.29578f;
                        float f = -Mathf.DeltaAngle(current, baseGT.rotation.eulerAngles.y - 90f);
                        this.myDistance = Mathf.Sqrt((this.myHero.transform.position.x - baseT.position.x) * (this.myHero.transform.position.x - baseT.position.x) + (this.myHero.transform.position.z - baseT.position.z) * (this.myHero.transform.position.z - baseT.position.z));
                        float num = this.myHero.transform.position.y - baseT.position.y;
                        if (this.myDistance < 85f && UnityEngine.Random.Range(0, 100) < 5)
                        {
                            this.steam();
                            return;
                        }
                        if (num > 310f && num < 350f)
                        {
                            if (Vector3.Distance(this.myHero.transform.position, baseT.Find("APL1").position) < 40f)
                            {
                                this.slap("l1");
                                return;
                            }
                            if (Vector3.Distance(this.myHero.transform.position, baseT.Find("APL2").position) < 40f)
                            {
                                this.slap("l2");
                                return;
                            }
                            if (Vector3.Distance(this.myHero.transform.position, baseT.Find("APR1").position) < 40f)
                            {
                                this.slap("r1");
                                return;
                            }
                            if (Vector3.Distance(this.myHero.transform.position, baseT.Find("APR2").position) < 40f)
                            {
                                this.slap("r2");
                                return;
                            }
                            if (this.myDistance < 150f && Mathf.Abs(f) < 80f)
                            {
                                this.attack_sweep(string.Empty);
                                return;
                            }
                        }
                        if (num < 300f && Mathf.Abs(f) < 80f && this.myDistance < 85f)
                        {
                            this.attack_sweep("_vertical");
                            return;
                        }
                        int num2 = UnityEngine.Random.Range(0, 7);
                        if (num2 == 0)
                        {
                            this.slap("l1");
                        }
                        else if (num2 == 1)
                        {
                            this.slap("l2");
                        }
                        else if (num2 == 2)
                        {
                            this.slap("r1");
                        }
                        else if (num2 == 3)
                        {
                            this.slap("r2");
                        }
                        else if (num2 == 4)
                        {
                            this.attack_sweep(string.Empty);
                        }
                        else if (num2 == 5)
                        {
                            this.attack_sweep("_vertical");
                        }
                        else if (num2 == 6)
                        {
                            this.steam();
                        }
                    }
                }
                return;
            }
            if (this.state == "attack_sweep")
            {
                if (this.attackCheckTimeA != 0f && ((base.animation["attack_" + this.attackAnimation].normalizedTime >= this.attackCheckTimeA && base.animation["attack_" + this.attackAnimation].normalizedTime <= this.attackCheckTimeB) || (!this.attackChkOnce && base.animation["attack_" + this.attackAnimation].normalizedTime >= this.attackCheckTimeA)))
                {
                    if (!this.attackChkOnce)
                    {
                        this.attackChkOnce = true;
                    }
                    foreach (RaycastHit raycastHit in this.checkHitCapsule(this.checkHitCapsuleStart.position, this.checkHitCapsuleEnd.position, this.checkHitCapsuleR))
                    {
                        GameObject gameObject = raycastHit.collider.gameObject;
                        if (gameObject.CompareTag("Player"))
                        {
                            this.killPlayer(gameObject);
                        }
                        if (gameObject.CompareTag("erenHitbox") && this.attackAnimation == "combo_3" && IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && ((!FengGameManagerMKII.LAN) ? PhotonNetwork.IsMasterClient : Network.isServer))
                        {
                            gameObject.transform.root.gameObject.GetComponent<replacedAN_EREN>().hitByFTByServer(3);
                        }
                    }
                    foreach (RaycastHit raycastHit2 in this.checkHitCapsule(this.checkHitCapsuleEndOld, this.checkHitCapsuleEnd.position, this.checkHitCapsuleR))
                    {
                        GameObject gameObject2 = raycastHit2.collider.gameObject;
                        if (gameObject2.CompareTag("Player"))
                        {
                            this.killPlayer(gameObject2);
                        }
                    }
                    this.checkHitCapsuleEndOld = this.checkHitCapsuleEnd.position;
                }
                if (base.animation["attack_" + this.attackAnimation].normalizedTime >= 1f)
                {
                    this.sweepSmokeObject.GetComponent<ParticleSystem>().enableEmission = false;
                    this.sweepSmokeObject.GetComponent<ParticleSystem>().Stop();
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
                    {
                        if (!FengGameManagerMKII.LAN)
                        {
                            BasePV.RPC("stopSweepSmoke", PhotonTargets.Others, new object[0]);
                        }
                    }
                    this.findNearestHero();
                    this.idle();
                    this.playAnimation("idle");
                }
            }
            else if (this.state == "kick")
            {
                if (!this.attackChkOnce && base.animation[this.actionName].normalizedTime >= this.attackCheckTime)
                {
                    this.attackChkOnce = true;
                    this.door_broken.SetActive(true);
                    this.door_closed.SetActive(false);
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
                    {
                        if (!FengGameManagerMKII.LAN)
                        {
                            BasePV.RPC("changeDoor", PhotonTargets.OthersBuffered, new object[0]);
                        }
                    }
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
                    {
                        if (FengGameManagerMKII.LAN)
                        {
                            Network.Instantiate(CacheResources.Load("FX/boom1_CT_KICK"), baseT.position + baseT.Forward() * 120f + baseT.right * 30f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Network.Instantiate(CacheResources.Load("rock"), baseT.position + baseT.Forward() * 120f + baseT.right * 30f, Quaternion.Euler(0f, 0f, 0f), 0);
                        }
                        else
                        {
                            Optimization.Caching.Pool.NetworkEnable("FX/boom1_CT_KICK", baseT.position + baseT.Forward() * 120f + baseT.right * 30f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Optimization.Caching.Pool.NetworkEnable("rock", baseT.position + baseT.Forward() * 120f + baseT.right * 30f, Quaternion.Euler(0f, 0f, 0f), 0);
                        }
                    }
                    else
                    {
                        Pool.Enable("FX/boom1_CT_KICK", baseT.position + baseT.Forward() * 120f + baseT.right * 30f, Quaternion.Euler(270f, 0f, 0f));
                        //UnityEngine.Object.Instantiate(CacheResources.Load("FX/boom1_CT_KICK"), baseT.position + baseT.Forward() * 120f + baseT.right * 30f, Quaternion.Euler(270f, 0f, 0f));
                        Pool.Enable("rock", baseT.position + baseT.Forward() * 120f + baseT.right * 30f, Quaternion.Euler(0f, 0f, 0f));
                    }
                }
                if (base.animation[this.actionName].normalizedTime >= 1f)
                {
                    this.findNearestHero();
                    this.idle();
                    this.playAnimation("idle");
                }
            }
            else if (this.state == "slap")
            {
                if (!this.attackChkOnce && base.animation["attack_slap_" + this.attackAnimation].normalizedTime >= this.attackCheckTime)
                {
                    this.attackChkOnce = true;
                    GameObject gameObject3;
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
                    {
                        if (FengGameManagerMKII.LAN)
                        {
                            gameObject3 = (GameObject)Network.Instantiate(CacheResources.Load("FX/boom1"), this.checkHitCapsuleStart.position, Quaternion.Euler(270f, 0f, 0f), 0);
                        }
                        else
                        {
                            gameObject3 = Optimization.Caching.Pool.NetworkEnable("FX/boom1", this.checkHitCapsuleStart.position, Quaternion.Euler(270f, 0f, 0f), 0);
                        }
                        if (gameObject3.GetComponent<EnemyfxIDcontainer>())
                        {
                            gameObject3.GetComponent<EnemyfxIDcontainer>().replacedanName = base.name;
                        }
                    }
                    else
                    {
                        gameObject3 = Pool.Enable("FX/boom1", this.checkHitCapsuleStart.position, Quaternion.Euler(270f, 0f, 0f));//(GameObject)UnityEngine.Object.Instantiate(CacheResources.Load("FX/boom1"), this.checkHitCapsuleStart.position, Quaternion.Euler(270f, 0f, 0f));
                    }
                    gameObject3.transform.localScale = new Vector3(5f, 5f, 5f);
                }
                if (base.animation["attack_slap_" + this.attackAnimation].normalizedTime >= 1f)
                {
                    this.findNearestHero();
                    this.idle();
                    this.playAnimation("idle");
                }
            }
            else if (this.state == "steam")
            {
                if (!this.attackChkOnce && base.animation[this.actionName].normalizedTime >= this.attackCheckTime)
                {
                    this.attackChkOnce = true;
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
                    {
                        if (FengGameManagerMKII.LAN)
                        {
                            Network.Instantiate(CacheResources.Load("FX/colossal_steam"), baseT.position + baseT.Up() * 185f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Network.Instantiate(CacheResources.Load("FX/colossal_steam"), baseT.position + baseT.Up() * 303f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Network.Instantiate(CacheResources.Load("FX/colossal_steam"), baseT.position + baseT.Up() * 50f, Quaternion.Euler(270f, 0f, 0f), 0);
                        }
                        else
                        {
                            Optimization.Caching.Pool.NetworkEnable("FX/colossal_steam", baseT.position + baseT.Up() * 185f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Optimization.Caching.Pool.NetworkEnable("FX/colossal_steam", baseT.position + baseT.Up() * 303f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Optimization.Caching.Pool.NetworkEnable("FX/colossal_steam", baseT.position + baseT.Up() * 50f, Quaternion.Euler(270f, 0f, 0f), 0);
                        }
                    }
                    else
                    {
                        Pool.Enable("FX/colossal_steam", baseT.position + baseT.Forward() * 185f, Quaternion.Euler(270f, 0f, 0f));
                        Pool.Enable("FX/colossal_steam", baseT.position + baseT.Forward() * 303f, Quaternion.Euler(270f, 0f, 0f));
                        Pool.Enable("FX/colossal_steam", baseT.position + baseT.Forward() * 50f, Quaternion.Euler(270f, 0f, 0f));
                        //UnityEngine.Object.Instantiate(CacheResources.Load("FX/colossal_steam"), baseT.position + baseT.Forward() * 185f, Quaternion.Euler(270f, 0f, 0f));
                        //UnityEngine.Object.Instantiate(CacheResources.Load("FX/colossal_steam"), baseT.position + baseT.Forward() * 303f, Quaternion.Euler(270f, 0f, 0f));
                        //UnityEngine.Object.Instantiate(CacheResources.Load("FX/colossal_steam"), baseT.position + baseT.Forward() * 50f, Quaternion.Euler(270f, 0f, 0f));
                    }
                }
                if (base.animation[this.actionName].normalizedTime >= 1f)
                {
                    if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
                    {
                        if (FengGameManagerMKII.LAN)
                        {
                            Network.Instantiate(CacheResources.Load("FX/colossal_steam_dmg"), baseT.position + baseT.Up() * 185f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Network.Instantiate(CacheResources.Load("FX/colossal_steam_dmg"), baseT.position + baseT.Up() * 303f, Quaternion.Euler(270f, 0f, 0f), 0);
                            Network.Instantiate(CacheResources.Load("FX/colossal_steam_dmg"), baseT.position + baseT.Up() * 50f, Quaternion.Euler(270f, 0f, 0f), 0);
                        }
                        else
                        {
                            GameObject gameObject4 = Optimization.Caching.Pool.NetworkEnable("FX/colossal_steam_dmg", baseT.position + baseT.Up() * 185f, Quaternion.Euler(270f, 0f, 0f), 0);
                            if (gameObject4.GetComponent<EnemyfxIDcontainer>())
                            {
                                gameObject4.GetComponent<EnemyfxIDcontainer>().replacedanName = base.name;
                            }
                            gameObject4 = Optimization.Caching.Pool.NetworkEnable("FX/colossal_steam_dmg", baseT.position + baseT.Up() * 303f, Quaternion.Euler(270f, 0f, 0f), 0);
                            if (gameObject4.GetComponent<EnemyfxIDcontainer>())
                            {
                                gameObject4.GetComponent<EnemyfxIDcontainer>().replacedanName = base.name;
                            }
                            gameObject4 = Optimization.Caching.Pool.NetworkEnable("FX/colossal_steam_dmg", baseT.position + baseT.Up() * 50f, Quaternion.Euler(270f, 0f, 0f), 0);
                            if (gameObject4.GetComponent<EnemyfxIDcontainer>())
                            {
                                gameObject4.GetComponent<EnemyfxIDcontainer>().replacedanName = base.name;
                            }
                        }
                    }
                    else
                    {
                        Pool.Enable("FX/colossal_steam_dmg", baseT.position + baseT.Forward() * 185f, Quaternion.Euler(270f, 0f, 0f));
                        Pool.Enable("FX/colossal_steam_dmg", baseT.position + baseT.Forward() * 303f, Quaternion.Euler(270f, 0f, 0f));
                        Pool.Enable("FX/colossal_steam_dmg", baseT.position + baseT.Forward() * 50f, Quaternion.Euler(270f, 0f, 0f));
                        //UnityEngine.Object.Instantiate(CacheResources.Load("FX/colossal_steam_dmg"), baseT.position + baseT.Forward() * 185f, Quaternion.Euler(270f, 0f, 0f));
                        //UnityEngine.Object.Instantiate(CacheResources.Load("FX/colossal_steam_dmg"), baseT.position + baseT.Forward() * 303f, Quaternion.Euler(270f, 0f, 0f));
                        //UnityEngine.Object.Instantiate(CacheResources.Load("FX/colossal_steam_dmg"), baseT.position + baseT.Forward() * 50f, Quaternion.Euler(270f, 0f, 0f));
                    }
                    if (this.hasDie)
                    {
                        if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single)
                        {
                            UnityEngine.Object.Destroy(baseG);
                        }
                        else if (FengGameManagerMKII.LAN)
                        {
                            if (base.networkView.isMine)
                            {
                            }
                        }
                        else if (PhotonNetwork.IsMasterClient)
                        {
                            PhotonNetwork.Destroy(BasePV);
                        }
                        FengGameManagerMKII.FGM.GameWin();
                    }
                    this.findNearestHero();
                    this.idle();
                    this.playAnimation("idle");
                }
            }
            else if (this.state == string.Empty)
            {
            }
        }
    }

19 View Source File : Horse.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void LateUpdate()
    {
        if (Owner == null && BasePV.IsMine)
        {
            PhotonNetwork.Destroy(gameObject);
            return;
        }

        switch (State)
        {
            case HorseState.Mounted:
                {
                    if (this.Owner == null)
                    {
                        this.Unmounted();
                        return;
                    }

                    Owner.baseT.position = baseT.position + heroOffsetVector;
                    Owner.baseT.rotation = baseR.rotation;
                    Owner.baseR.velocity = baseR.velocity;

                    if (controller.targetDirection == -874f)
                    {
                        this.ToIdleAnimation();
                        if (baseR.velocity.magnitude > 15f)
                        {
                            if (!Owner.baseA.IsPlaying("horse_run"))
                            {
                                Owner.CrossFade("horse_run", 0.1f);
                            }
                        }
                        else if (!Owner.baseA.IsPlaying("horse_idle"))
                        {
                            Owner.CrossFade("horse_idle", 0.1f);
                        }
                    }
                    else
                    {
                        base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, this.controller.targetDirection, 0f), 100f * Time.deltaTime / (base.rigidbody.velocity.magnitude + 20f));
                        if (this.controller.isWALKDown)
                        {
                            baseR.AddForce(baseT.Forward() * this.speed * 0.6f, ForceMode.Acceleration);
                            if (baseR.velocity.magnitude >= this.speed * 0.6f)
                            {
                                baseR.AddForce(-this.speed * 0.6f * baseR.velocity.normalized, ForceMode.Acceleration);
                            }
                        }
                        else
                        {
                            baseR.AddForce(baseT.Forward() * this.speed, ForceMode.Acceleration);
                            if (baseR.velocity.magnitude >= this.speed)
                            {
                                baseR.AddForce(-this.speed * baseR.velocity.normalized, ForceMode.Acceleration);
                            }
                        }
                        if (baseR.velocity.magnitude > 8f)
                        {
                            if (!baseA.IsPlaying("horse_Run"))
                            {
                                this.CrossFade("horse_Run", 0.1f);
                            }
                            if (!this.Owner.baseA.IsPlaying("horse_run"))
                            {
                                this.Owner.CrossFade("horse_run", 0.1f);
                            }
                            if (!this.dustParticle.enableEmission)
                            {
                                this.dustParticle.enableEmission = true;
                                BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                                {
                        true
                                });
                            }
                        }
                        else
                        {
                            if (!baseA.IsPlaying("horse_WALK"))
                            {
                                this.CrossFade("horse_WALK", 0.1f);
                            }
                            if (!this.Owner.baseA.IsPlaying("horse_idle"))
                            {
                                this.Owner.baseA.CrossFade("horse_idle", 0.1f);
                            }
                            if (this.dustParticle.enableEmission)
                            {
                                this.dustParticle.enableEmission = false;
                                BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                                {
                                    false
                                });
                            }
                        }
                    }

                    if ((this.controller.isAttackDown || this.controller.isAttackIIDown) && this.IsGrounded())
                    {
                        baseR.AddForce(Vectors.up * 25f, ForceMode.VelocityChange);
                    }
                }
                break;

            case HorseState.Follow:
                {
                    if (this.Owner == null)
                    {
                        this.Unmounted();
                        return;
                    }

                    if (baseR.velocity.magnitude > 8f)
                    {
                        if (!baseA.IsPlaying("horse_Run"))
                        {
                            this.CrossFade("horse_Run", 0.1f);
                        }
                        if (!this.dustParticle.enableEmission)
                        {
                            this.dustParticle.enableEmission = true;
                            BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                            {
                        true
                            });
                        }
                    }
                    else
                    {
                        if (!baseA.IsPlaying("horse_WALK"))
                        {
                            this.CrossFade("horse_WALK", 0.1f);
                        }
                        if (this.dustParticle.enableEmission)
                        {
                            this.dustParticle.enableEmission = false;
                            BasePV.RPC("setDust", PhotonTargets.Others, new object[]
                            {
                                false
                            });
                        }
                    }

                    float num = -Mathf.DeltaAngle(FengMath.GetHorizontalAngle(baseT.position, this.setPoint), base.gameObject.transform.rotation.eulerAngles.y - 90f);
                    base.gameObject.transform.rotation = Quaternion.Lerp(base.gameObject.transform.rotation, Quaternion.Euler(0f, base.gameObject.transform.rotation.eulerAngles.y + num, 0f), 200f * Time.deltaTime / (baseR.velocity.magnitude + 20f));
                    if (Vector3.Distance(this.setPoint, baseT.position) < 20f)
                    {
                        baseR.AddForce(baseT.Forward() * this.speed * 0.7f, ForceMode.Acceleration);
                        if (baseR.velocity.magnitude >= this.speed)
                        {
                            baseR.AddForce(-this.speed * 0.7f * baseR.velocity.normalized, ForceMode.Acceleration);
                        }
                    }
                    else
                    {
                        baseR.AddForce(base.transform.Forward() * this.speed, ForceMode.Acceleration);
                        if (baseR.velocity.magnitude >= this.speed)
                        {
                            baseR.AddForce(-this.speed * baseR.velocity.normalized, ForceMode.Acceleration);
                        }
                    }
                    this.timeElapsed += Time.deltaTime;
                    if (this.timeElapsed > 0.6f)
                    {
                        this.timeElapsed = 0f;
                        if (Vector3.Distance(this.Owner.baseT.position, this.setPoint) > 20f)
                        {
                            this.Followed();
                        }
                    }
                    if (Vector3.Distance(this.Owner.baseT.position, baseT.position) < 5f)
                    {
                        this.Unmounted();
                    }
                    if (Vector3.Distance(this.setPoint, baseT.position) < 5f)
                    {
                        this.Unmounted();
                    }
                    this.awayTimer += Time.deltaTime;
                    if (this.awayTimer > 6f)
                    {
                        this.awayTimer = 0f;
                        if (Physics.Linecast(baseT.position + Vectors.up, this.Owner.baseT.position + Vectors.up, Layers.Ground.value))
                        {
                            baseT.position = new Vector3(this.Owner.baseT.position.x, this.GetHeight(this.Owner.baseT.position + Vectors.up * 5f), this.Owner.baseT.position.z);
                        }
                    }
                }
                break;

            case HorseState.Idle:
                {
                    this.ToIdleAnimation();
                    if (this.Owner != null && Vector3.Distance(this.Owner.baseT.position, baseT.position) > 20f)
                    {
                        this.Followed();
                    }
                }
                break;
        }
        baseR.AddForce(new Vector3(0f, -50f * baseR.mreplaced, 0f));
    }

19 View Source File : LevelMovingBrick.cs
License : GNU General Public License v3.0
Project Creator : aelariane

private void Update()
    {
        if (this.towardsA)
        {
            base.transform.position = Vector3.MoveTowards(base.transform.position, this.pointA, this.speed * Time.deltaTime);
            if (Vector3.Distance(base.transform.position, this.pointA) < 2f)
            {
                this.towardsA = false;
            }
        }
        else
        {
            base.transform.position = Vector3.MoveTowards(base.transform.position, this.pointB, this.speed * Time.deltaTime);
            if (Vector3.Distance(base.transform.position, this.pointB) < 2f)
            {
                this.towardsA = true;
            }
        }
    }

See More Examples