Пример #1
0
    public virtual void Update()
    {
        if (!this.activated)
        {
            return;
        }
        if (!this.particlesTurnedOn)
        {
            var headEmissionModule  = head.emission;
            var trailEmissionModule = trail.emission;
            headEmissionModule.enabled  = true;
            trailEmissionModule.enabled = true;
            this.particlesTurnedOn      = true;
        }


        float distance = this.velocity.magnitude * Time.deltaTime;

        if (this.lineRenderer)
        {
            this.lineVerteces++;
            this.lineRenderer.SetVertexCount(this.lineVerteces);
            this.lineRenderer.SetPosition(this.lineVerteces - 1, this.transform.position);
        }
        if (this.lineRenderer && (this.type == 3))
        {
            this.lineVerteces++;
            this.lineRenderer.SetVertexCount(this.lineVerteces);
            this.lineRenderer.SetPosition(this.lineVerteces - 1, this.transform.position + (((this.transform.right * (Random.value - 0.5f)) * (Status.zoomed ? 0.5f : 170)) * 0.05f));
        }
        RaycastHit[] hits = null;
        hits = Physics.RaycastAll(this.transform.position, this.velocity, distance);
        foreach (RaycastHit hit in hits)
        {
            Atom          atom  = null;
            NucleusObject nuc   = null;
            GameObject    other = null;
            if (hit.collider)
            {
                other = hit.collider.transform.root.gameObject;
                atom  = (Atom)other.GetComponent(typeof(Atom));
                nuc   = (NucleusObject)hit.collider.GetComponent(typeof(NucleusObject));
            }
            if ((((!Status.zoomed && !this.reacted) && !this.ignoreCollisions) && (distance > 0f)) && other)
            {
                if (atom)
                {
                    if (!hit.collider.isTrigger)
                    {
                        this.reacted = true;
                    }
                    this.React(atom, hit.point);
                }
                else
                {
                    this.transform.position = hit.point;
                    this.StartCoroutine(this.Done());
                }
            }
            else
            {
                if (((((((!this.reacted && Status.zoomed) && (distance > 0f)) && other) && nuc) && (atom != null)) && (atom.neutrons != 0)) && (atom.neutrons < 9))
                {
                    float rv = Random.value;
                    this.reacted = true;
                    if ((((rv > 0.8f) && (this.energy < 200)) || ((rv > 0.95f) && (this.energy < 2000))) && (this.type == 1))
                    {
                        atom.AbsorbNeut(hit.point + (hit.normal * 0.1f));
                        this.transform.position = hit.point;
                        this.StartCoroutine(this.Done());
                    }
                }
            }
        }
        this.transform.position = this.transform.position + (this.velocity * Time.deltaTime);
        this.traveled           = this.traveled + distance;
        if (this.lineRenderer)
        {
            {
                float   _6 = Vector3.Distance(this.transform.position, this.origin) * this.lineStretch;
                Vector2 _7 = this.lineRenderer.material.mainTextureScale;
                _7.x = _6;
                this.lineRenderer.material.mainTextureScale = _7;
            }
        }
        if ((this.traveled >= this.range) && (!this.noTimeOut || !Status.zoomed))
        {
            this.StartCoroutine(this.Done());
        }
    }