Esempio n. 1
0
    // Token: 0x06003317 RID: 13079 RVA: 0x000C0B7C File Offset: 0x000BED7C
    protected void WriteHitInfo(BitStream sendStream, ref Ray ray, bool didHit, ref RaycastHit2 hit)
    {
        global::NetEntityID hitView;
        bool hitNetworkView;

        if (didHit)
        {
            IDBase id = hit.id;
            if (id && id.idMain)
            {
                hitView        = global::NetEntityID.Get(id.idMain);
                hitNetworkView = !hitView.isUnassigned;
            }
            else
            {
                hitNetworkView = false;
                hitView        = global::NetEntityID.unassigned;
            }
        }
        else
        {
            hitView        = global::NetEntityID.unassigned;
            hitNetworkView = false;
        }
        this.WriteHitInfo(sendStream, ref ray, didHit, ref hit, hitNetworkView, hitView);
    }
Esempio n. 2
0
    protected void WriteHitInfo(BitStream sendStream, ref Ray ray, bool didHit, ref RaycastHit2 hit)
    {
        bool        flag;
        NetEntityID unassigned;

        if (didHit)
        {
            IDBase id = hit.id;
            if ((id != null) && (id.idMain != null))
            {
                unassigned = NetEntityID.Get((MonoBehaviour)id.idMain);
                flag       = !unassigned.isUnassigned;
            }
            else
            {
                flag       = false;
                unassigned = NetEntityID.unassigned;
            }
        }
        else
        {
            unassigned = NetEntityID.unassigned;
            flag       = false;
        }
        this.WriteHitInfo(sendStream, ref ray, didHit, ref hit, flag, unassigned);
    }
    // Token: 0x06000267 RID: 615 RVA: 0x0000CBF4 File Offset: 0x0000ADF4
    private void Update()
    {
        if (this.impacted)
        {
            return;
        }
        float num = Time.time - this.lastUpdateTime;

        this.lastUpdateTime = Time.time;
        RaycastHit  raycastHit = default(RaycastHit);
        RaycastHit2 invalid    = RaycastHit2.invalid;

        base.transform.Rotate(Vector3.right, this.dropDegreesPerSec * num);
        Ray ray;

        ray..ctor(base.transform.position, base.transform.forward);
        float num2 = this.speedPerSec * num;
        bool  flag = true;

        if (Physics2.Raycast2(ray, ref invalid, this.speedPerSec * num, this.layerMask))
        {
            Vector3    normal;
            Vector3    point;
            GameObject gameObject;
            Rigidbody  rigidbody;
            if (flag)
            {
                normal     = invalid.normal;
                point      = invalid.point;
                gameObject = invalid.gameObject;
                rigidbody  = invalid.rigidbody;
            }
            else
            {
                normal     = raycastHit.normal;
                point      = raycastHit.point;
                gameObject = raycastHit.collider.gameObject;
                rigidbody  = raycastHit.rigidbody;
            }
            Quaternion quaternion = Quaternion.LookRotation(normal);
            Vector3    vector     = Vector3.zero;
            int        layer      = gameObject.layer;
            if (rigidbody && !rigidbody.isKinematic && !rigidbody.CompareTag("Door"))
            {
                rigidbody.AddForceAtPosition(Vector3.up * 200f, point);
                rigidbody.AddForceAtPosition(ray.direction * 1000f, point);
            }
            if (layer != 17 && layer != 18 && layer != 27 && layer != 21)
            {
                vector = point + normal * 0.01f;
            }
            this.impacted           = true;
            base.transform.position = point;
            this.TryReportHit(gameObject);
            base.transform.parent = gameObject.transform;
            TrailRenderer component = base.GetComponent <TrailRenderer>();
            if (component)
            {
                component.enabled = false;
            }
            base.audio.enabled = false;
            if (gameObject)
            {
                global::SurfaceInfoObject surfaceInfoFor = global::SurfaceInfo.GetSurfaceInfoFor(gameObject, point);
                surfaceInfoFor.GetImpactEffect(global::SurfaceInfoObject.ImpactType.Bullet);
                Object @object = Object.Instantiate(surfaceInfoFor.GetImpactEffect(global::SurfaceInfoObject.ImpactType.Bullet), point, quaternion);
                Object.Destroy(@object, 1.5f);
                this.TryReportMiss();
            }
            Object.Destroy(base.gameObject, 20f);
        }
        else
        {
            base.transform.position += base.transform.forward * this.speedPerSec * num;
            this.distance           += this.speedPerSec * num;
        }
        if (this.distance > this.maxRange || Time.time - this.spawnTime > this.maxLifeTime)
        {
            Object.Destroy(base.gameObject);
        }
    }
Esempio n. 4
0
    private void Update()
    {
        float num = Time.time - this.lastUpdateTime;

        this.lastUpdateTime = Time.time;
        if (this.distance > this.fadeDistStart)
        {
            base.transform.localScale = Vector3.Lerp(base.transform.localScale, this.startScale, Mathf.Clamp((float)((this.distance - this.fadeDistStart) / this.fadeDistLength), (float)0f, (float)1f));
        }
        RaycastHit  hitInfo  = new RaycastHit();
        RaycastHit2 invalid  = RaycastHit2.invalid;
        Ray         ray      = new Ray(base.transform.position, base.transform.forward);
        float       distance = this.speedPerSec * num;
        bool        flag     = !((this.thereIsACollider && (this.colliderToHit != null)) && this.colliderToHit.enabled);

        if (!flag ? this.colliderToHit.Raycast(ray, out hitInfo, distance) : Physics2.Raycast2(ray, out invalid, this.speedPerSec * num, this.layerMask))
        {
            Vector3    point;
            Vector3    normal;
            GameObject gameObject;
            Rigidbody  rigidbody;
            if (Vector3.Distance(Camera.main.transform.position, base.transform.position) > 75f)
            {
                Object.Destroy(base.gameObject);
                return;
            }
            if (flag)
            {
                normal     = invalid.normal;
                point      = invalid.point;
                gameObject = invalid.gameObject;
                rigidbody  = invalid.rigidbody;
            }
            else
            {
                normal     = hitInfo.normal;
                point      = hitInfo.point;
                gameObject = hitInfo.collider.gameObject;
                rigidbody  = hitInfo.rigidbody;
            }
            Quaternion rotation     = Quaternion.LookRotation(normal);
            int        layer        = gameObject.layer;
            GameObject impactPrefab = this.impactPrefab;
            bool       flag2        = true;
            if (((rigidbody != null) && !rigidbody.isKinematic) && !rigidbody.CompareTag("Door"))
            {
                rigidbody.AddForceAtPosition((Vector3)(Vector3.up * 200f), point);
                rigidbody.AddForceAtPosition((Vector3)(ray.direction * 1000f), point);
            }
            SurfaceInfo.DoImpact(gameObject, SurfaceInfoObject.ImpactType.Bullet, point + ((Vector3)(normal * 0.01f)), rotation);
            switch (layer)
            {
            case 0x11:
            case 0x12:
            case 0x1b:
            case 0x15:
                flag2 = false;
                break;
            }
            Object.Destroy(base.gameObject);
            if (flag2)
            {
                this.impactSounds[Random.Range(0, this.impactSounds.Length)].Play(point, 1f, 2f, 15f, 180);
                GameObject obj4 = Object.Instantiate(this.decalPrefab, point + ((Vector3)(normal * Random.Range((float)0.01f, (float)0.03f))), rotation * Quaternion.Euler(0f, 0f, (float)Random.Range(-30, 30))) as GameObject;
                if (gameObject != null)
                {
                    obj4.transform.parent = gameObject.transform;
                }
                Object.Destroy(obj4, 15f);
            }
        }
        else
        {
            Transform transform = base.transform;
            transform.position += (Vector3)((base.transform.forward * this.speedPerSec) * num);
            this.distance      += this.speedPerSec * num;
        }
        if (this.distance > this.maxRange)
        {
            Object.Destroy(base.gameObject);
        }
    }
Esempio n. 5
0
    private void Update()
    {
        if (!this.impacted)
        {
            float num = Time.time - this.lastUpdateTime;
            this.lastUpdateTime = Time.time;
            RaycastHit  hit     = new RaycastHit();
            RaycastHit2 invalid = RaycastHit2.invalid;
            base.transform.Rotate(Vector3.right, (float)(this.dropDegreesPerSec * num));
            Ray   ray  = new Ray(base.transform.position, base.transform.forward);
            float num2 = this.speedPerSec * num;
            bool  flag = true;
            if (!Physics2.Raycast2(ray, out invalid, this.speedPerSec * num, this.layerMask))
            {
                Transform transform = base.transform;
                transform.position += (Vector3)((base.transform.forward * this.speedPerSec) * num);
                this.distance      += this.speedPerSec * num;
            }
            else
            {
                Vector3    point;
                Vector3    normal;
                GameObject gameObject;
                Rigidbody  rigidbody;
                if (flag)
                {
                    normal     = invalid.normal;
                    point      = invalid.point;
                    gameObject = invalid.gameObject;
                    rigidbody  = invalid.rigidbody;
                }
                else
                {
                    normal     = hit.normal;
                    point      = hit.point;
                    gameObject = hit.collider.gameObject;
                    rigidbody  = hit.rigidbody;
                }
                Quaternion rotation = Quaternion.LookRotation(normal);
                Vector3    zero     = Vector3.zero;
                int        layer    = gameObject.layer;
                bool       flag2    = true;
                if (((rigidbody != null) && !rigidbody.isKinematic) && !rigidbody.CompareTag("Door"))
                {
                    rigidbody.AddForceAtPosition((Vector3)(Vector3.up * 200f), point);
                    rigidbody.AddForceAtPosition((Vector3)(ray.direction * 1000f), point);
                }
                switch (layer)
                {
                case 0x11:
                case 0x12:
                case 0x1b:
                case 0x15:
                    flag2 = false;
                    break;

                default:
                    zero = point + ((Vector3)(normal * 0.01f));
                    break;
                }
                this.impacted           = true;
                base.transform.position = point;
                this.TryReportHit(gameObject);
                base.transform.parent = gameObject.transform;
                TrailRenderer component = base.GetComponent <TrailRenderer>();
                if (component != null)
                {
                    component.enabled = false;
                }
                base.audio.enabled = false;
                if (gameObject != null)
                {
                    SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(gameObject, point);
                    surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet);
                    Object.Destroy(Object.Instantiate(surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet), point, rotation), 1.5f);
                    this.TryReportMiss();
                }
                Object.Destroy(base.gameObject, 20f);
            }
            if ((this.distance > this.maxRange) || ((Time.time - this.spawnTime) > this.maxLifeTime))
            {
                Object.Destroy(base.gameObject);
            }
        }
    }
Esempio n. 6
0
    private void Update()
    {
        Vector3    vector3;
        Vector3    vector31;
        GameObject gameObject;
        Rigidbody  rigidbody;
        float      single = Time.time - this.lastUpdateTime;

        this.lastUpdateTime = Time.time;
        if (this.distance > this.fadeDistStart)
        {
            base.transform.localScale = Vector3.Lerp(base.transform.localScale, this.startScale, Mathf.Clamp((this.distance - this.fadeDistStart) / this.fadeDistLength, 0f, 1f));
        }
        RaycastHit  raycastHit  = new RaycastHit();
        RaycastHit2 raycastHit2 = RaycastHit2.invalid;
        Ray         ray         = new Ray(base.transform.position, base.transform.forward);
        float       single1     = this.speedPerSec * single;
        bool        flag        = (!this.thereIsACollider || !this.colliderToHit ? 0 : (int)this.colliderToHit.enabled) == 0;

        if ((!flag ? !this.colliderToHit.Raycast(ray, out raycastHit, single1) : !Physics2.Raycast2(ray, out raycastHit2, this.speedPerSec * single, this.layerMask)))
        {
            Transform transforms = base.transform;
            transforms.position = transforms.position + ((base.transform.forward * this.speedPerSec) * single);
            Tracer tracer = this;
            tracer.distance = tracer.distance + this.speedPerSec * single;
        }
        else
        {
            if (Vector3.Distance(Camera.main.transform.position, base.transform.position) > 75f)
            {
                UnityEngine.Object.Destroy(base.gameObject);
                return;
            }
            if (!flag)
            {
                vector31   = raycastHit.normal;
                vector3    = raycastHit.point;
                gameObject = raycastHit.collider.gameObject;
                rigidbody  = raycastHit.rigidbody;
            }
            else
            {
                vector31   = raycastHit2.normal;
                vector3    = raycastHit2.point;
                gameObject = raycastHit2.gameObject;
                rigidbody  = raycastHit2.rigidbody;
            }
            Quaternion quaternion  = Quaternion.LookRotation(vector31);
            int        num         = gameObject.layer;
            GameObject gameObject1 = this.impactPrefab;
            bool       flag1       = true;
            if (rigidbody && !rigidbody.isKinematic && !rigidbody.CompareTag("Door"))
            {
                rigidbody.AddForceAtPosition(Vector3.up * 200f, vector3);
                rigidbody.AddForceAtPosition(ray.direction * 1000f, vector3);
            }
            SurfaceInfo.DoImpact(gameObject, SurfaceInfoObject.ImpactType.Bullet, vector3 + (vector31 * 0.01f), quaternion);
            if (num == 17 || num == 18 || num == 27 || num == 21)
            {
                flag1 = false;
            }
            UnityEngine.Object.Destroy(base.gameObject);
            if (flag1)
            {
                this.impactSounds[UnityEngine.Random.Range(0, (int)this.impactSounds.Length)].Play(vector3, 1f, 2f, 15f, 180);
                GameObject gameObject2 = UnityEngine.Object.Instantiate(this.decalPrefab, vector3 + (vector31 * UnityEngine.Random.Range(0.01f, 0.03f)), quaternion * Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(-30, 30))) as GameObject;
                if (gameObject)
                {
                    gameObject2.transform.parent = gameObject.transform;
                }
                UnityEngine.Object.Destroy(gameObject2, 15f);
            }
        }
        if (this.distance > this.maxRange)
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
    }
    protected virtual void WriteHitInfo(uLink.BitStream sendStream, ref Ray ray, bool didHit, ref RaycastHit2 hit, bool hitNetworkView, NetEntityID hitView)
    {
        Vector3   point;
        Transform transforms;

        if (!didHit)
        {
            sendStream.WriteByte(255);
            point = ray.GetPoint(1000f);
        }
        else if (!hitNetworkView)
        {
            sendStream.WriteByte(255);
            point = hit.point;
        }
        else
        {
            IDRemoteBodyPart dRemoteBodyPart = hit.remoteBodyPart;
            if (!dRemoteBodyPart)
            {
                sendStream.WriteByte(254);
                transforms = hitView.transform;
            }
            else
            {
                sendStream.WriteByte((byte)dRemoteBodyPart.bodyPart);
                transforms = dRemoteBodyPart.transform;
            }
            sendStream.Write <NetEntityID>(hitView, new object[0]);
            point = transforms.InverseTransformPoint(hit.point);
        }
        sendStream.WriteVector3(point);
    }
    protected void WriteHitInfo(uLink.BitStream sendStream, ref Ray ray, bool didHit, ref RaycastHit2 hit)
    {
        bool        flag;
        NetEntityID netEntityID;

        if (!didHit)
        {
            netEntityID = NetEntityID.unassigned;
            flag        = false;
        }
        else
        {
            IDBase dBase = hit.id;
            if (!dBase || !dBase.idMain)
            {
                flag        = false;
                netEntityID = NetEntityID.unassigned;
            }
            else
            {
                netEntityID = NetEntityID.Get(dBase.idMain);
                flag        = !netEntityID.isUnassigned;
            }
        }
        this.WriteHitInfo(sendStream, ref ray, didHit, ref hit, flag, netEntityID);
    }
Esempio n. 9
0
    private void Update()
    {
        Vector3    vector3;
        Vector3    vector31;
        GameObject gameObject;
        Rigidbody  rigidbody;

        if (this.impacted)
        {
            return;
        }
        float single = Time.time - this.lastUpdateTime;

        this.lastUpdateTime = Time.time;
        RaycastHit  raycastHit  = new RaycastHit();
        RaycastHit2 raycastHit2 = RaycastHit2.invalid;

        base.transform.Rotate(Vector3.right, this.dropDegreesPerSec * single);
        Ray  ray  = new Ray(base.transform.position, base.transform.forward);
        bool flag = true;

        if (!Physics2.Raycast2(ray, out raycastHit2, this.speedPerSec * single, this.layerMask))
        {
            Transform transforms = base.transform;
            transforms.position = transforms.position + ((base.transform.forward * this.speedPerSec) * single);
            ArrowMovement arrowMovement = this;
            arrowMovement.distance = arrowMovement.distance + this.speedPerSec * single;
        }
        else
        {
            if (!flag)
            {
                vector31   = raycastHit.normal;
                vector3    = raycastHit.point;
                gameObject = raycastHit.collider.gameObject;
                rigidbody  = raycastHit.rigidbody;
            }
            else
            {
                vector31   = raycastHit2.normal;
                vector3    = raycastHit2.point;
                gameObject = raycastHit2.gameObject;
                rigidbody  = raycastHit2.rigidbody;
            }
            Quaternion quaternion = Quaternion.LookRotation(vector31);
            Vector3    vector32   = Vector3.zero;
            int        num        = gameObject.layer;
            bool       flag1      = true;
            if (rigidbody && !rigidbody.isKinematic && !rigidbody.CompareTag("Door"))
            {
                rigidbody.AddForceAtPosition(Vector3.up * 200f, vector3);
                rigidbody.AddForceAtPosition(ray.direction * 1000f, vector3);
            }
            if (num == 17 || num == 18 || num == 27 || num == 21)
            {
                flag1 = false;
            }
            else
            {
                vector32 = vector3 + (vector31 * 0.01f);
            }
            this.impacted           = true;
            base.transform.position = vector3;
            this.TryReportHit(gameObject);
            base.transform.parent = gameObject.transform;
            TrailRenderer component = base.GetComponent <TrailRenderer>();
            if (component)
            {
                component.enabled = false;
            }
            base.audio.enabled = false;
            if (gameObject)
            {
                SurfaceInfoObject surfaceInfoFor = SurfaceInfo.GetSurfaceInfoFor(gameObject, vector3);
                surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet);
                UnityEngine.Object obj = UnityEngine.Object.Instantiate(surfaceInfoFor.GetImpactEffect(SurfaceInfoObject.ImpactType.Bullet), vector3, quaternion);
                UnityEngine.Object.Destroy(obj, 1.5f);
                this.TryReportMiss();
            }
            UnityEngine.Object.Destroy(base.gameObject, 20f);
        }
        if (this.distance > this.maxRange || Time.time - this.spawnTime > this.maxLifeTime)
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
    }
Esempio n. 10
0
    // Token: 0x06003318 RID: 13080 RVA: 0x000C0BF0 File Offset: 0x000BEDF0
    protected virtual void WriteHitInfo(BitStream sendStream, ref Ray ray, bool didHit, ref RaycastHit2 hit, bool hitNetworkView, global::NetEntityID hitView)
    {
        Vector3 vector;

        if (didHit)
        {
            if (hitNetworkView)
            {
                IDRemoteBodyPart remoteBodyPart = hit.remoteBodyPart;
                Transform        transform;
                if (remoteBodyPart)
                {
                    sendStream.WriteByte(remoteBodyPart.bodyPart);
                    transform = remoteBodyPart.transform;
                }
                else
                {
                    sendStream.WriteByte(254);
                    transform = hitView.transform;
                }
                sendStream.Write <global::NetEntityID>(hitView, new object[0]);
                vector = transform.InverseTransformPoint(hit.point);
            }
            else
            {
                sendStream.WriteByte(byte.MaxValue);
                vector = hit.point;
            }
        }
        else
        {
            sendStream.WriteByte(byte.MaxValue);
            vector = ray.GetPoint(1000f);
        }
        sendStream.WriteVector3(vector);
    }
Esempio n. 11
0
    protected virtual void WriteHitInfo(BitStream sendStream, ref Ray ray, bool didHit, ref RaycastHit2 hit, bool hitNetworkView, NetEntityID hitView)
    {
        Vector3 point;

        if (didHit)
        {
            if (hitNetworkView)
            {
                Transform        transform;
                IDRemoteBodyPart remoteBodyPart = hit.remoteBodyPart;
                if (remoteBodyPart != null)
                {
                    sendStream.WriteByte((byte)remoteBodyPart.bodyPart);
                    transform = remoteBodyPart.transform;
                }
                else
                {
                    sendStream.WriteByte(0xfe);
                    transform = hitView.transform;
                }
                sendStream.Write <NetEntityID>(hitView, new object[0]);
                point = transform.InverseTransformPoint(hit.point);
            }
            else
            {
                sendStream.WriteByte(0xff);
                point = hit.point;
            }
        }
        else
        {
            sendStream.WriteByte(0xff);
            point = ray.GetPoint(1000f);
        }
        sendStream.WriteVector3(point);
    }
Esempio n. 12
0
    // Token: 0x06002DB5 RID: 11701 RVA: 0x000AC314 File Offset: 0x000AA514
    private void Update()
    {
        float num = Time.time - this.lastUpdateTime;

        this.lastUpdateTime = Time.time;
        if (this.distance > this.fadeDistStart)
        {
            base.transform.localScale = Vector3.Lerp(base.transform.localScale, this.startScale, Mathf.Clamp((this.distance - this.fadeDistStart) / this.fadeDistLength, 0f, 1f));
        }
        RaycastHit  raycastHit = default(RaycastHit);
        RaycastHit2 invalid    = RaycastHit2.invalid;
        Ray         ray;

        ray..ctor(base.transform.position, base.transform.forward);
        float num2 = this.speedPerSec * num;
        bool  flag = !this.thereIsACollider || !this.colliderToHit || !this.colliderToHit.enabled;

        if ((!flag) ? this.colliderToHit.Raycast(ray, ref raycastHit, num2) : Physics2.Raycast2(ray, ref invalid, this.speedPerSec * num, this.layerMask))
        {
            float num3 = Vector3.Distance(Camera.main.transform.position, base.transform.position);
            if (num3 > 75f)
            {
                Object.Destroy(base.gameObject);
                return;
            }
            Vector3    normal;
            Vector3    point;
            GameObject gameObject;
            Rigidbody  rigidbody;
            if (flag)
            {
                normal     = invalid.normal;
                point      = invalid.point;
                gameObject = invalid.gameObject;
                rigidbody  = invalid.rigidbody;
            }
            else
            {
                normal     = raycastHit.normal;
                point      = raycastHit.point;
                gameObject = raycastHit.collider.gameObject;
                rigidbody  = raycastHit.rigidbody;
            }
            Quaternion quaternion  = Quaternion.LookRotation(normal);
            int        layer       = gameObject.layer;
            GameObject gameObject2 = this.impactPrefab;
            bool       flag2       = true;
            if (rigidbody && !rigidbody.isKinematic && !rigidbody.CompareTag("Door"))
            {
                rigidbody.AddForceAtPosition(Vector3.up * 200f, point);
                rigidbody.AddForceAtPosition(ray.direction * 1000f, point);
            }
            global::SurfaceInfo.DoImpact(gameObject, global::SurfaceInfoObject.ImpactType.Bullet, point + normal * 0.01f, quaternion);
            if (layer == 17 || layer == 18 || layer == 27 || layer == 21)
            {
                flag2 = false;
            }
            Object.Destroy(base.gameObject);
            if (flag2)
            {
                this.impactSounds[Random.Range(0, this.impactSounds.Length)].Play(point, 1f, 2f, 15f, 180);
                GameObject gameObject3 = Object.Instantiate(this.decalPrefab, point + normal * Random.Range(0.01f, 0.03f), quaternion * Quaternion.Euler(0f, 0f, (float)Random.Range(-30, 30))) as GameObject;
                if (gameObject)
                {
                    gameObject3.transform.parent = gameObject.transform;
                }
                Object.Destroy(gameObject3, 15f);
            }
        }
        else
        {
            base.transform.position += base.transform.forward * this.speedPerSec * num;
            this.distance           += this.speedPerSec * num;
        }
        if (this.distance > this.maxRange)
        {
            Object.Destroy(base.gameObject);
        }
    }