Beispiel #1
0
 private void SendMixed()
 {
     DoMix();
     if (NetGame.isServer || ReplayRecorder.isRecording)
     {
         NetStream netStream = identity.BeginEvent(evtMixed);
         identity.EndEvent();
     }
 }
 protected override void Update()
 {
     if (ReplayRecorder.isPlaying || NetGame.isClient)
     {
         return;
     }
     if (wall.shattered)
     {
         if (mainPlayer != null)
         {
             mainPlayer.Trigger();
         }
         else
         {
             Trigger();
         }
         if ((bool)identity)
         {
             identity.BeginEvent(evtCollision);
             identity.EndEvent();
         }
         base.enabled = false;
     }
     base.Update();
 }
Beispiel #3
0
    private void SendCrack(Vector3 adjustedImpulse, Vector3 maxImpactPoint)
    {
        NetStream stream = identity.BeginEvent(evtCrack);

        NetVector3.Quantize(maxImpactPoint - base.transform.position, 100f, 16).Write(stream, 6);
        NetVector3.Quantize(adjustedImpulse / breakTreshold, 10f, 16).Write(stream, 6);
        identity.EndEvent();
    }
Beispiel #4
0
 private void FailStart()
 {
     if (!ReplayRecorder.isPlaying && !NetGame.isClient)
     {
         NetStream netStream = identity.BeginEvent(evtFail);
         identity.EndEvent();
     }
     failSound.PlayOneShot();
     StartCoroutine(EmitBurst());
 }
Beispiel #5
0
 private void OnTriggerEnter(Collider other)
 {
     if (!NetGame.isClient && !ReplayRecorder.isPlaying && !(other.tag != "Player") && !(timeToCool > 0f) && trainGearbox.gear > 0)
     {
         timeToCool = cooldown;
         NetStream netStream = identity.BeginEvent(evtBeep);
         identity.EndEvent();
         OnBeep(null);
     }
 }
Beispiel #6
0
 private void HandGrab(bool left)
 {
     grab.PlayOneShot((!left) ? rightHand.position : leftHand.position, Random.Range(0.5f, 1.5f), Random.Range(0.95f, 1.05f));
     if (NetGame.isServer || ReplayRecorder.isRecording)
     {
         NetStream netStream = identity.BeginEvent(evtHandGrab);
         netStream.Write(left);
         identity.EndEvent();
     }
 }
Beispiel #7
0
 private void PlayBubble(float drownPhase)
 {
     humanAudio.underwaterBubble.PlayOneShot(base.transform.position, 1f, 0.9f + 0.2f * drownPhase);
     if (!ReplayRecorder.isPlaying || !NetGame.isClient)
     {
         NetStream stream = identity.BeginEvent(evtBubble);
         NetSignal.encoder.CollectState(stream, drownPhase);
         identity.EndEvent();
     }
 }
 private void SendPlug(PlugEventType type)
 {
     PlayPlug(type);
     if (NetGame.isServer || ReplayRecorder.isRecording)
     {
         NetStream netStream = identity.BeginEvent(evtPlug);
         netStream.Write((uint)type, 3);
         identity.EndEvent();
     }
 }
Beispiel #9
0
 private void SendHit(HitType type, Vector3 position)
 {
     DoHit(type, position);
     if (NetGame.isServer || ReplayRecorder.isRecording)
     {
         NetStream netStream = identity.BeginEvent(evtHit);
         netStream.Write((uint)type, 1);
         posEncoder.CollectState(netStream, position);
         identity.EndEvent();
     }
 }
Beispiel #10
0
 private void Update()
 {
     if (!ReplayRecorder.isPlaying && !NetGame.isClient && !wasPlayed && inside && Time.time > enterTime + triggerDelay)
     {
         Play();
         if ((bool)identity)
         {
             identity.BeginEvent(evtCollision);
             identity.EndEvent();
         }
     }
 }
Beispiel #11
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.contacts.Length != 0 && bag.ReportCollision(collision.impulse.magnitude, collision.contacts[0].point) && (NetGame.isServer || ReplayRecorder.isRecording))
     {
         NetStream netStream = identity.BeginEvent(evtCollision);
         int       x         = NetFloat.Quantize(collision.impulse.magnitude, 10000f, 11);
         netStream.Write(x, 10);
         Vector3 vec = collision.contacts[0].point - base.transform.position;
         NetVector3.Quantize(vec, 100f, 10).Write(netStream, 3);
         identity.EndEvent();
     }
 }
 private void FailStart()
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Failed Start ");
     }
     if (!ReplayRecorder.isPlaying && !NetGame.isClient)
     {
         NetStream netStream = identity.BeginEvent(evtFail);
         identity.EndEvent();
     }
     StartCoroutine(EmitBurst());
 }
Beispiel #13
0
    private void Update()
    {
        if (ReplayRecorder.isPlaying || NetGame.isClient)
        {
            return;
        }
        if (timeToCool > 0f)
        {
            timeToCool -= Time.deltaTime;
            return;
        }
        bool flag = false;

        for (int i = 0; i < Human.all.Count; i++)
        {
            Human   human   = Human.all[i];
            Ragdoll ragdoll = human.ragdoll;
            if ((toGrab == null || ragdoll.partLeftHand.sensor.grabObject == toGrab) && (dist == 0f || (ragdoll.partLeftHand.transform.position - base.transform.position).magnitude < dist))
            {
                flag = true;
            }
            if ((toGrab == null || ragdoll.partRightHand.sensor.grabObject == toGrab) && (dist == 0f || (ragdoll.partRightHand.transform.position - base.transform.position).magnitude < dist))
            {
                flag = true;
            }
        }
        if (flag)
        {
            timeGrabbed += Time.deltaTime;
            if (timeGrabbed > time)
            {
                if ((bool)audioSource)
                {
                    audioSource.Play();
                }
                if ((bool)identity)
                {
                    identity.BeginEvent(evtCollision);
                    identity.EndEvent();
                }
                timeToCool  = 240f;
                timeGrabbed = 0f;
            }
        }
        else
        {
            timeGrabbed = 0f;
        }
    }
Beispiel #14
0
        private void BroadcastImpact(float impact)
        {
            if (showDebug)
            {
                Debug.Log(base.name + " Broadcast impact ");
            }
            float num = AudioUtils.ValueToDB(impact) + 32f;

            if (!(num < -64f))
            {
                NetStream netStream = identity.BeginEvent(evtImpact);
                netStream.Write(NetFloat.Quantize(num, 64f, 6), 6);
                identity.EndEvent();
            }
        }
Beispiel #15
0
 public void OnTriggerEnter(Collider other)
 {
     if (!ReplayRecorder.isPlaying && !NetGame.isClient && other.gameObject.tag == "Player")
     {
         if (mainPlayer != null)
         {
             mainPlayer.Trigger();
         }
         else
         {
             Trigger();
         }
         if ((bool)identity)
         {
             identity.BeginEvent(evtCollision);
             identity.EndEvent();
         }
     }
 }
        public void BroadcastCollisionAudio(CollisionAudioHitConfig config, AudioChannel channel, Vector3 pos, float rms, float pitch)
        {
            if (showDebug)
            {
                Debug.Log(base.name + " Broadcast Collision Audio ");
            }
            float num = AudioUtils.ValueToDB(rms) + 32f;

            if (num < -64f)
            {
                return;
            }
            if (identity == null)
            {
                Debug.LogErrorFormat(this, "No NetIdentity for {0}", base.name);
                return;
            }
            NetStream netStream = identity.BeginEvent(evtCollisionAudio);

            netStream.Write(config.netId, 8);
            if (channel == AudioChannel.Footsteps)
            {
                netStream.Write(v: true);
            }
            else
            {
                netStream.Write(v: false);
                if (channel == AudioChannel.Body)
                {
                    netStream.Write(v: true);
                }
                else
                {
                    netStream.Write(v: false);
                }
            }
            Vector3 vec = pos - base.transform.position;

            NetVector3.Quantize(vec, 100f, 10).Write(netStream, 3);
            netStream.Write(NetFloat.Quantize(AudioUtils.ValueToDB(rms) + 32f, 64f, 6), 6);
            netStream.Write(NetFloat.Quantize(AudioUtils.RatioToCents(pitch), 4800f, 8), 3, 8);
            identity.EndEvent();
        }
Beispiel #17
0
    public void Update()
    {
        if (ReplayRecorder.isPlaying || NetGame.isClient)
        {
            return;
        }
        if (timeToCool > 0f)
        {
            timeToCool -= Time.deltaTime;
            return;
        }
        bool flag = false;

        if ((bool)humanInside)
        {
            flag = true;
        }
        if (flag)
        {
            timeGrabbed += Time.deltaTime;
            if (timeGrabbed > time)
            {
                if ((bool)audioSource)
                {
                    audioSource.Play();
                }
                if ((bool)identity)
                {
                    identity.BeginEvent(evtCollision);
                    identity.EndEvent();
                }
                timeToCool  = 60f;
                humanInside = null;
                timeGrabbed = 0f;
            }
        }
        else
        {
            timeGrabbed = 0f;
        }
    }
Beispiel #18
0
 private void Scroll(Vector3 scroll)
 {
     if (!NetGame.isClient && !ReplayRecorder.isPlaying)
     {
         base.transform.position += scroll;
     }
     if (player.isLocalPlayer)
     {
         CloudSystem.instance.Scroll(scroll);
         player.cameraController.Scroll(scroll);
         for (int i = 0; i < CloudBox.all.Count; i++)
         {
             CloudBox.all[i].FadeIn(1f);
         }
     }
     if (identity != null && (NetGame.isServer || ReplayRecorder.isRecording))
     {
         NetStream stream = identity.BeginEvent(evtScroll);
         NetVector3.Quantize(scroll, 500f, 12).Write(stream);
         identity.EndEvent();
     }
 }
    public void FixedUpdate()
    {
        if (joint == null || NetGame.isClient || ReplayRecorder.isPlaying)
        {
            return;
        }
        Vector3 vector = axis.TransformPoint(Vector3.forward);
        float   num    = (vector - anchor).magnitude - 0.1f;

        if (!(num > 0f))
        {
            return;
        }
        totalTravel += num / (breakAngleTravel * ((float)Math.PI / 180f));
        anchor       = Vector3.MoveTowards(anchor, vector, num);
        if (totalTravel > 1f)
        {
            NetStream netStream = identity.BeginEvent(evtPull);
            identity.EndEvent();
            OnPull(null);
            UnityEngine.Object.Destroy(joint);
            GetComponent <Rigidbody>().angularDrag = 0.05f;
            GetComponent <Rigidbody>().useGravity  = true;
            if (groundedIgnoreCollider != null)
            {
                IgnoreCollision.Unignore(base.transform, groundedIgnoreCollider);
            }
        }
        else
        {
            joint.angularYZDrive = new JointDrive
            {
                positionSpring = 0f,
                positionDamper = holdDamper * (1f - totalTravel),
                maximumForce   = float.PositiveInfinity
            };
        }
    }
    public void OnTriggerEnter(Collider other)
    {
        if (ReplayRecorder.isPlaying || NetGame.isClient || timeToCool > 0f)
        {
            return;
        }
        bool flag = false;

        if (acceptedCollider == null)
        {
            foreach (Human item in Human.all)
            {
                if (item.GetComponent <Collider>() == other)
                {
                    flag = true;
                }
            }
        }
        else if (other == acceptedCollider)
        {
            flag = true;
        }
        if (flag)
        {
            if ((bool)audioSource)
            {
                audioSource.Play();
            }
            if ((bool)identity)
            {
                identity.BeginEvent(evtCollision);
                identity.EndEvent();
            }
            timeToCool = 60f;
        }
    }