示例#1
0
    // Token: 0x06003AD1 RID: 15057 RVA: 0x000CE300 File Offset: 0x000CC500
    private static void UpdateBeam(ref global::LaserBeam.FrameData frame, global::LaserBeam beam)
    {
        Transform transform = beam.transform;

        frame.origin    = transform.position;
        frame.direction = transform.forward;
        frame.direction.Normalize();
        int        num = beam.beamLayers;
        RaycastHit raycastHit2;

        if (num == 0)
        {
            frame.hit = false;
        }
        else if (beam.isViewModel)
        {
            RaycastHit2 raycastHit;
            if (frame.hit = Physics2.Raycast2(frame.origin, frame.direction, ref raycastHit, beam.beamMaxDistance, num))
            {
                frame.hitPoint  = raycastHit.point;
                frame.hitNormal = raycastHit.normal;
            }
        }
        else if (frame.hit = Physics.Raycast(frame.origin, frame.direction, ref raycastHit2, beam.beamMaxDistance, num))
        {
            frame.hitPoint  = raycastHit2.point;
            frame.hitNormal = raycastHit2.normal;
        }
        if (!frame.hit)
        {
            frame.didHit           = false;
            frame.point.x          = frame.origin.x + frame.direction.x * beam.beamMaxDistance;
            frame.point.y          = frame.origin.y + frame.direction.y * beam.beamMaxDistance;
            frame.point.z          = frame.origin.z + frame.direction.z * beam.beamMaxDistance;
            frame.distance         = beam.beamMaxDistance;
            frame.distanceFraction = 1f;
            frame.pointWidth       = beam.beamWidthEnd;
        }
        else
        {
            frame.point            = frame.hitPoint;
            frame.didHit           = true;
            frame.distance         = frame.direction.x * frame.point.x + frame.direction.y * frame.point.y + frame.direction.z * frame.point.z - (frame.direction.x * frame.origin.x + frame.direction.y * frame.origin.y + frame.direction.z * frame.origin.z);
            frame.distanceFraction = frame.distance / beam.beamMaxDistance;
            frame.pointWidth       = Mathf.Lerp(beam.beamWidthStart, beam.beamWidthEnd, frame.distanceFraction);
            frame.dotRadius        = Mathf.Lerp(beam.dotRadiusStart, beam.dotRadiusEnd, frame.distanceFraction);
        }
        frame.originWidth = beam.beamWidthStart;
        Vector3 vector;

        vector.x     = (vector.y = (vector.z = frame.originWidth));
        frame.bounds = new Bounds(frame.origin, vector);
        vector.x     = (vector.y = (vector.z = frame.pointWidth));
        frame.bounds.Encapsulate(new Bounds(frame.point, vector));
        frame.beamsLayer = 1 << beam.gameObject.layer;
        global::LaserGraphics.allBeamsMask |= frame.beamsLayer;
    }
 // Token: 0x06003A65 RID: 14949 RVA: 0x000CD0D4 File Offset: 0x000CB2D4
 private void PlaySound(global::LaserBeam anyBeam, AudioClip clip)
 {
     if (anyBeam)
     {
         clip.PlayLocal(anyBeam.transform, Vector3.zero, 1f, 0, 1f, 4f);
     }
     else
     {
         clip.PlayLocal(base.itemRep.transform, Vector3.zero, 1f, 0, 1f, 4f);
     }
 }
    // Token: 0x06003A63 RID: 14947 RVA: 0x000CD060 File Offset: 0x000CB260
    protected override void DisableMod(global::ItemModRepresentation.Reason reason)
    {
        global::LaserBeam anyBeam = null;

        foreach (global::LaserBeam laserBeam in this.beams)
        {
            if (laserBeam)
            {
                anyBeam           = laserBeam;
                laserBeam.enabled = false;
            }
        }
        if (reason == global::ItemModRepresentation.Reason.Explicit)
        {
            this.PlaySound(anyBeam, base.modDataBlock.offSound);
        }
    }
    // Token: 0x06003A62 RID: 14946 RVA: 0x000CCFF0 File Offset: 0x000CB1F0
    protected override void EnableMod(global::ItemModRepresentation.Reason reason)
    {
        global::LaserBeam anyBeam = null;

        foreach (global::LaserBeam laserBeam in this.beams)
        {
            if (laserBeam)
            {
                anyBeam           = laserBeam;
                laserBeam.enabled = (this.is_vm || global::LaserModRep.allow_3rd_lasers);
            }
        }
        if (reason == global::ItemModRepresentation.Reason.Explicit)
        {
            this.PlaySound(anyBeam, base.modDataBlock.onSound);
        }
    }
示例#5
0
    // Token: 0x06003AD6 RID: 15062 RVA: 0x000CF9AC File Offset: 0x000CDBAC
    private static void RenderBeam(Plane[] frustum, Camera camera, global::LaserBeam beam, ref global::LaserBeam.FrameData frame)
    {
        Vector3 vector  = global::LaserGraphics.world2Cam.MultiplyPoint(frame.origin);
        Vector3 vector2 = global::LaserGraphics.world2Cam.MultiplyPoint(frame.point);
        Vector3 vector3 = vector2 - vector;

        vector3.Normalize();
        float      num         = 1f - (1f - Mathf.Abs(vector3.z)) * beam.beamOutput;
        Quaternion quaternion  = Quaternion.LookRotation(vector3, vector2);
        Quaternion quaternion2 = Quaternion.LookRotation(vector3, vector);
        Vector3    vector4     = quaternion2 * new Vector3(frame.originWidth, 0f, 0f);
        Vector3    vector5     = quaternion * new Vector3(frame.pointWidth, 0f, 0f);

        frame.beamVertices.m0  = global::LaserGraphics.cam2World.MultiplyPoint(vector4 * 0.5f + vector);
        frame.beamVertices.m2  = global::LaserGraphics.cam2World.MultiplyPoint(vector5 * 0.5f + vector2);
        frame.beamVertices.m1  = global::LaserGraphics.cam2World.MultiplyPoint(vector4 * -0.5f + vector);
        frame.beamVertices.m3  = global::LaserGraphics.cam2World.MultiplyPoint(vector5 * -0.5f + vector2);
        frame.beamNormals.m0.x = frame.originWidth;
        frame.beamNormals.m2.x = frame.pointWidth;
        frame.beamNormals.m1.x = -frame.originWidth;
        frame.beamNormals.m3.x = -frame.pointWidth;
        frame.beamNormals.m0.y = -frame.distance;
        frame.beamNormals.m1.y = -frame.distance;
        frame.beamNormals.m2.y = -frame.distance;
        frame.beamNormals.m3.y = -frame.distance;
        frame.beamNormals.m0.z = (frame.beamNormals.m1.z = 0f);
        frame.beamNormals.m2.z = (frame.beamNormals.m3.z = frame.distanceFraction);
        frame.beamColor.m0     = (frame.beamColor.m1 = (frame.beamColor.m2 = (frame.beamColor.m3 = global::LaserGraphics.RangeBeamColor(beam.beamColor * num))));
        frame.beamUVs.m0       = global::LaserGraphics.uv[0];
        frame.beamUVs.m0.x     = frame.beamUVs.m0.x * frame.distanceFraction;
        frame.beamUVs.m1       = global::LaserGraphics.uv[1];
        frame.beamUVs.m1.x     = frame.beamUVs.m1.x * frame.distanceFraction;
        frame.beamUVs.m2       = global::LaserGraphics.uv[2];
        frame.beamUVs.m2.x     = frame.beamUVs.m2.x * frame.distanceFraction;
        frame.beamUVs.m3       = global::LaserGraphics.uv[3];
        frame.beamUVs.m3.x     = frame.beamUVs.m3.x * frame.distanceFraction;
        frame.bufBeam          = global::LaserGraphics.MeshBuffer.ForBeamMaterial(beam.beamMaterial);
        if (global::LaserGraphics.Computation.beams.Add(frame.bufBeam))
        {
            frame.bufBeam.measureSize = 1;
        }
        else
        {
            frame.bufBeam.measureSize++;
        }
        frame.bufBeam.beams.Add(beam);
        if (frame.didHit)
        {
            Vector3 vector6 = global::LaserGraphics.world2Cam.MultiplyVector(-frame.hitNormal);
            if (vector6.z < 0f)
            {
                Vector3 vector7 = global::LaserGraphics.cam2World.MultiplyPoint(Vector3.zero);
                if (!Physics.Linecast(vector7, Vector3.Lerp(vector7, frame.point, 0.95f), beam.cullLayers))
                {
                    Vector3    vector8     = global::LaserGraphics.world2Cam.MultiplyPoint(frame.point);
                    Quaternion quaternion3 = Quaternion.LookRotation(vector8, Vector3.up);
                    frame.dotVertices1.m0 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(frame.dotRadius, -frame.dotRadius, 0f));
                    frame.dotVertices1.m1 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(frame.dotRadius, frame.dotRadius, 0f));
                    frame.dotVertices1.m2 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(-frame.dotRadius, -frame.dotRadius, 0f));
                    frame.dotVertices1.m3 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(-frame.dotRadius, frame.dotRadius, 0f));
                    quaternion3           = Quaternion.LookRotation(vector6, Vector3.up);
                    frame.dotVertices2.m0 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(frame.dotRadius, -frame.dotRadius, -0.01f));
                    frame.dotVertices2.m1 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(frame.dotRadius, frame.dotRadius, -0.01f));
                    frame.dotVertices2.m2 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(-frame.dotRadius, -frame.dotRadius, -0.01f));
                    frame.dotVertices2.m3 = global::LaserGraphics.cam2World.MultiplyPoint(vector8 + quaternion3 * new Vector3(-frame.dotRadius, frame.dotRadius, -0.01f));
                    frame.dotColor1.m0    = (frame.dotColor1.m1 = (frame.dotColor1.m2 = (frame.dotColor1.m3 = (frame.dotColor2.m0 = (frame.dotColor2.m1 = (frame.dotColor2.m2 = (frame.dotColor2.m3 = global::LaserGraphics.RangeDotColor(beam.dotColor))))))));
                    frame.bufDot          = global::LaserGraphics.MeshBuffer.ForDotMaterial(beam.dotMaterial);
                    if (global::LaserGraphics.Computation.dots.Add(frame.bufDot))
                    {
                        frame.bufDot.measureSize = 2;
                    }
                    else
                    {
                        frame.bufDot.measureSize += 2;
                    }
                    frame.bufDot.beams.Add(beam);
                    frame.drawDot = true;
                }
                else
                {
                    frame.bufDot  = null;
                    frame.drawDot = false;
                }
            }
            else
            {
                frame.bufDot  = null;
                frame.drawDot = false;
            }
        }
        else
        {
            frame.bufDot  = null;
            frame.drawDot = false;
        }
    }