Пример #1
0
        public static void save()
        {
            River river = new River(Level.info.path + "/Environment/Roads.dat", false);

            river.writeByte(LevelRoads.SAVEDATA_ROADS_VERSION);
            river.writeByte((byte)LevelRoads.materials.Length);
            byte b = 0;

            while ((int)b < LevelRoads.materials.Length)
            {
                river.writeSingle(LevelRoads.materials[(int)b].width);
                river.writeSingle(LevelRoads.materials[(int)b].height);
                river.writeSingle(LevelRoads.materials[(int)b].depth);
                river.writeSingle(LevelRoads.materials[(int)b].offset);
                river.writeBoolean(LevelRoads.materials[(int)b].isConcrete);
                b += 1;
            }
            river.closeRiver();
            river = new River(Level.info.path + "/Environment/Paths.dat", false);
            river.writeByte(LevelRoads.SAVEDATA_PATHS_VERSION);
            ushort num  = 0;
            ushort num2 = 0;

            while ((int)num2 < LevelRoads.roads.Count)
            {
                if (LevelRoads.roads[(int)num2].joints.Count > 1)
                {
                    num += 1;
                }
                num2 += 1;
            }
            river.writeUInt16(num);
            byte b2 = 0;

            while ((int)b2 < LevelRoads.roads.Count)
            {
                List <RoadJoint> joints = LevelRoads.roads[(int)b2].joints;
                if (joints.Count > 1)
                {
                    river.writeUInt16((ushort)joints.Count);
                    river.writeByte(LevelRoads.roads[(int)b2].material);
                    river.writeBoolean(LevelRoads.roads[(int)b2].isLoop);
                    ushort num3 = 0;
                    while ((int)num3 < joints.Count)
                    {
                        RoadJoint roadJoint = joints[(int)num3];
                        river.writeSingleVector3(roadJoint.vertex);
                        river.writeSingleVector3(roadJoint.getTangent(0));
                        river.writeSingleVector3(roadJoint.getTangent(1));
                        river.writeByte((byte)roadJoint.mode);
                        river.writeSingle(roadJoint.offset);
                        river.writeBoolean(roadJoint.ignoreTerrain);
                        num3 += 1;
                    }
                }
                b2 += 1;
            }
            river.closeRiver();
        }
Пример #2
0
        public float getLength(int index)
        {
            index = Mathf.Clamp(index, 0, this.joints.Count - 1);
            RoadJoint roadJoint = this.joints[index];
            RoadJoint roadJoint2;

            if (index == this.joints.Count - 1)
            {
                roadJoint2 = this.joints[0];
            }
            else
            {
                roadJoint2 = this.joints[index + 1];
            }
            return(BezierTool.getLength(roadJoint.vertex, roadJoint.vertex + roadJoint.getTangent(1), roadJoint2.vertex + roadJoint2.getTangent(0), roadJoint2.vertex));
        }
Пример #3
0
        // Token: 0x0600266B RID: 9835 RVA: 0x000E1CC0 File Offset: 0x000E00C0
        public Vector3 getVelocity(int index, float t)
        {
            index = Mathf.Clamp(index, 0, this.joints.Count - 1);
            t     = Mathf.Clamp01(t);
            RoadJoint roadJoint = this.joints[index];
            RoadJoint roadJoint2;

            if (index == this.joints.Count - 1)
            {
                roadJoint2 = this.joints[0];
            }
            else
            {
                roadJoint2 = this.joints[index + 1];
            }
            return(BezierTool.getVelocity(roadJoint.vertex, roadJoint.vertex + roadJoint.getTangent(1), roadJoint2.vertex + roadJoint2.getTangent(0), roadJoint2.vertex, t));
        }
Пример #4
0
        // Token: 0x0600266D RID: 9837 RVA: 0x000E1DBC File Offset: 0x000E01BC
        public float getLengthEstimate(int index)
        {
            index = Mathf.Clamp(index, 0, this.joints.Count - 1);
            RoadJoint roadJoint = this.joints[index];
            RoadJoint roadJoint2;

            if (index == this.joints.Count - 1)
            {
                roadJoint2 = this.joints[0];
            }
            else
            {
                roadJoint2 = this.joints[index + 1];
            }
            Vector3 tangent  = roadJoint.getTangent(1);
            Vector3 tangent2 = roadJoint2.getTangent(0);

            if (Vector3.Dot(tangent.normalized, tangent2.normalized) < -0.999f)
            {
                return((roadJoint2.vertex - roadJoint.vertex).magnitude);
            }
            return(BezierTool.getLengthEstimate(roadJoint.vertex, roadJoint.vertex + tangent, roadJoint2.vertex + tangent2, roadJoint2.vertex));
        }
Пример #5
0
        // Token: 0x06002669 RID: 9833 RVA: 0x000E1B74 File Offset: 0x000DFF74
        public Vector3 getPosition(int index, float t)
        {
            index = Mathf.Clamp(index, 0, this.joints.Count - 1);
            t     = Mathf.Clamp01(t);
            RoadJoint roadJoint = this.joints[index];
            RoadJoint roadJoint2;

            if (index == this.joints.Count - 1)
            {
                roadJoint2 = this.joints[0];
            }
            else
            {
                roadJoint2 = this.joints[index + 1];
            }
            Vector3 tangent  = roadJoint.getTangent(1);
            Vector3 tangent2 = roadJoint2.getTangent(0);

            if (Vector3.Dot(tangent.normalized, tangent2.normalized) < -0.999f)
            {
                return(Vector3.Lerp(roadJoint.vertex, roadJoint2.vertex, t));
            }
            return(BezierTool.getPosition(roadJoint.vertex, roadJoint.vertex + tangent, roadJoint2.vertex + tangent2, roadJoint2.vertex, t));
        }