Ejemplo n.º 1
0
 // Token: 0x06000E24 RID: 3620 RVA: 0x0003F15C File Offset: 0x0003D35C
 private void TeleportBody(CharacterBody characterBody)
 {
     if (!Util.HasEffectiveAuthority(characterBody.gameObject))
     {
         return;
     }
     if (!Physics.GetIgnoreLayerCollision(base.gameObject.layer, characterBody.gameObject.layer))
     {
         SpawnCard spawnCard = ScriptableObject.CreateInstance <SpawnCard>();
         spawnCard.hullSize      = characterBody.hullClassification;
         spawnCard.nodeGraphType = MapNodeGroup.GraphType.Ground;
         spawnCard.prefab        = Resources.Load <GameObject>("SpawnCards/HelperPrefab");
         GameObject gameObject = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(spawnCard, new DirectorPlacementRule
         {
             placementMode = DirectorPlacementRule.PlacementMode.NearestNode,
             position      = characterBody.transform.position
         }, RoR2Application.rng));
         if (gameObject)
         {
             Debug.Log("tp back");
             TeleportHelper.TeleportBody(characterBody, gameObject.transform.position);
             GameObject teleportEffectPrefab = Run.instance.GetTeleportEffectPrefab(characterBody.gameObject);
             if (teleportEffectPrefab)
             {
                 EffectManager.SimpleEffect(teleportEffectPrefab, gameObject.transform.position, Quaternion.identity, true);
             }
             UnityEngine.Object.Destroy(gameObject);
         }
         UnityEngine.Object.Destroy(spawnCard);
     }
 }
        private static void HandleTeleport(NetworkMessage netMsg)
        {
            if (Util.ConnectionIsLocal(netMsg.conn))
            {
                return;
            }
            netMsg.ReadMessage <TeleportHelper.TeleportMessage>(TeleportHelper.messageBuffer);
            if (!TeleportHelper.messageBuffer.gameObject)
            {
                return;
            }
            bool flag = Util.HasEffectiveAuthority(TeleportHelper.messageBuffer.gameObject);

            if (flag)
            {
                return;
            }
            TeleportHelper.TeleportGameObject(TeleportHelper.messageBuffer.gameObject, TeleportHelper.messageBuffer.newPosition, TeleportHelper.messageBuffer.delta, flag);
        }
 // Token: 0x06001AF6 RID: 6902 RVA: 0x0007265C File Offset: 0x0007085C
 private static void TeleportGameObject(GameObject gameObject, Vector3 newPosition, Vector3 delta, bool hasEffectiveAuthority)
 {
     TeleportHelper.OnTeleport(gameObject, newPosition, delta);
     if (NetworkServer.active || hasEffectiveAuthority)
     {
         TeleportHelper.TeleportMessage msg = new TeleportHelper.TeleportMessage
         {
             gameObject  = gameObject,
             newPosition = newPosition,
             delta       = delta
         };
         QosChannelIndex defaultReliable = QosChannelIndex.defaultReliable;
         if (NetworkServer.active)
         {
             NetworkServer.SendByChannelToAll(68, msg, defaultReliable.intVal);
             return;
         }
         NetworkManager.singleton.client.connection.SendByChannel(68, msg, defaultReliable.intVal);
     }
 }
        // Token: 0x06001AF8 RID: 6904 RVA: 0x00072754 File Offset: 0x00070954
        public static void TeleportBody(CharacterBody body, Vector3 targetFootPosition)
        {
            Vector3 b = body.footPosition - body.transform.position;

            TeleportHelper.TeleportGameObject(body.gameObject, targetFootPosition - b);
        }
        // Token: 0x06001AF5 RID: 6901 RVA: 0x0007262C File Offset: 0x0007082C
        public static void TeleportGameObject(GameObject gameObject, Vector3 newPosition)
        {
            bool hasEffectiveAuthority = Util.HasEffectiveAuthority(gameObject);

            TeleportHelper.TeleportGameObject(gameObject, newPosition, newPosition - gameObject.transform.position, hasEffectiveAuthority);
        }
        // Token: 0x0600155A RID: 5466 RVA: 0x0005B03C File Offset: 0x0005923C
        private void OnPassengerExit(GameObject passenger)
        {
            if (VehicleSeat.shouldLog)
            {
                Debug.Log("Releasing passenger.");
            }
            if (this.hidePassenger && this.passengerInfo.characterModel)
            {
                this.passengerInfo.characterModel.invisibilityCount--;
            }
            if (this.passengerInfo.body)
            {
                this.passengerInfo.body.currentVehicle = null;
            }
            if (this.passengerInfo.characterMotor)
            {
                if (this.disablePassengerMotor)
                {
                    this.passengerInfo.characterMotor.enabled = true;
                }
                else
                {
                    this.passengerInfo.characterMotor.onMovementHit -= this.OnPassengerMovementHit;
                }
                this.passengerInfo.characterMotor.velocity           = Vector3.zero;
                this.passengerInfo.characterMotor.rootMotion         = Vector3.zero;
                this.passengerInfo.characterMotor.Motor.BaseVelocity = Vector3.zero;
            }
            if (this.passengerInfo.collider && this.collider)
            {
                Physics.IgnoreCollision(this.collider, this.passengerInfo.collider, false);
            }
            if (this.passengerInfo.hasEffectiveAuthority)
            {
                if (this.passengerInfo.bodyStateMachine && this.passengerInfo.bodyStateMachine.CanInterruptState(InterruptPriority.Vehicle))
                {
                    this.passengerInfo.bodyStateMachine.SetNextStateToMain();
                }
                Vector3 newPosition = this.exitPosition ? this.exitPosition.position : this.seatPosition.position;
                TeleportHelper.TeleportGameObject(this.passengerInfo.transform.gameObject, newPosition);
            }
            if (this.passengerInfo.interactionDriver && this.passengerInfo.interactionDriver.interactableOverride == base.gameObject)
            {
                this.passengerInfo.interactionDriver.interactableOverride = null;
            }
            if (this.rigidbody && this.passengerInfo.characterMotor)
            {
                this.passengerInfo.characterMotor.velocity = this.rigidbody.velocity * this.exitVelocityFraction;
            }
            Action <GameObject> action = this.onPassengerExit;

            if (action != null)
            {
                action(this.passengerBodyObject);
            }
            UnityEvent unityEvent = this.onPassengerExitUnityEvent;

            if (unityEvent != null)
            {
                unityEvent.Invoke();
            }
            Action <VehicleSeat, GameObject> action2 = VehicleSeat.onPassengerExitGlobal;

            if (action2 == null)
            {
                return;
            }
            action2(this, this.passengerBodyObject);
        }