static void Postfix(ushort nodeID, ref RenderManager.Instance data, ref Vector3 centerPos)
        {
            if (NodeManager.Instance.buffer[nodeID] is not NodeData blendData)
            {
                return;
            }

            centerPos = blendData.GetPosition(); // fix center pos.

            if (blendData.ShouldRenderCenteralCrossingTexture())
            {
                data.m_dataVector1.w = 0.01f; // puts crossings in the center.
            }
            if (blendData.NodeType == NodeTypeT.Stretch)
            {
                ushort segmentID  = nodeID.ToNode().GetSegment(data.m_dataInt0 & 7);
                var    invert     = segmentID.ToSegment().m_flags.IsFlagSet(NetSegment.Flags.Invert);
                var    startNode  = NetUtil.IsStartNode(segmentId: segmentID, nodeId: nodeID);
                bool   turnAround = (startNode == !invert);
                if (turnAround)
                {
                    // for segments it works like this:
                    // 1- data.m_dataVector0.x *= -1 (can't do this for nodes)
                    // 2- data.m_dataVector0.y *= -1 (can do this for nodes)

                    // 1- data.m_dataVector0.x *= -1 does not work for node shader. so we do the equivalent of swapping left/right matrices:
                    Helpers.Swap(ref data.m_dataMatrix0, ref data.m_dataMatrix1);
                    Helpers.Swap(ref data.m_extraData.m_dataMatrix2, ref data.m_extraData.m_dataMatrix3);

                    // 2-
                    data.m_dataVector0.y *= -1;
                }
            }
        }
Exemplo n.º 2
0
 public override void Draw(RenderManager.CameraInfo cameraInfo, RenderManager.Instance data)
 {
     foreach (var item in Items)
     {
         TreeInstance.RenderInstance(cameraInfo, Info, item.Position, item.Scale, 1f, new Vector4());
     }
 }
        public static bool ShouldConnectMedian(
            ushort nodeId,
            int nodeInfoIDX,
            ref RenderManager.Instance data)
        {
            ushort sourceSegmentID  = nodeId.ToNode().GetSegment(data.m_dataInt0 & 7);
            int    targetSegmentIDX = data.m_dataInt0 >> 4;
            ushort targetSegmentID  = nodeId.ToNode().GetSegment(targetSegmentIDX);

            NetInfo.Node nodeInfo = sourceSegmentID.ToSegment().Info.m_nodes[nodeInfoIDX];
            if (!DirectConnectUtil.IsMedian(nodeInfo, nodeId.ToNode().Info))
            {
                Log.Debug($"not a median: node:{nodeId} connect_group:{nodeInfo.m_connectGroup} vehcileTypes:{nodeId.ToNode().Info.m_vehicleTypes}");
                return(true); // ignore.
            }

            return(!DirectConnectUtil.OpenMedian(sourceSegmentID, targetSegmentID));

            if (TMPE_Exists_)
            {
                try {
                    return(!DirectConnectUtil.OpenMedian(sourceSegmentID, targetSegmentID));
                }
                catch {
                    TMPE_Exists_ = false;
                }
            }
            return(true); // ignore
        }
Exemplo n.º 4
0
 static void Enqueue(
     ushort nodeID, ref RenderManager.Instance renderData,
     bool isBendNode = false, bool turnAround = false)
 {
     int     segmentIndex  = renderData.m_dataInt0 & 7;
     int     segmentIndex2 = renderData.m_dataInt0 >> 4;
     ref var node          = ref nodeID.ToNode();
Exemplo n.º 5
0
 public static void OnAfterDrawMesh(
     ushort nodeID,
     ref RenderManager.Instance renderData,
     NetInfo.Node nodeInfo)
 {
     if (nodeInfo == Overlay.HoveredInfo)
     {
         Enqueue(nodeID, ref renderData);
     }
 }
Exemplo n.º 6
0
        public override void Draw(RenderManager.CameraInfo cameraInfo, RenderManager.Instance data)
        {
            var instance = new InstanceID()
            {
            };

            foreach (var item in Items)
            {
                PropInstance.RenderInstance(cameraInfo, Info, instance, item.Position, item.Scale, item.Angle, item.Color, new Vector4(), true);
            }
        }
        public static bool ShouldConnectTracks(
            ushort nodeId,
            int nodeInfoIDX,
            ref RenderManager.Instance data)
        {
            ushort sourceSegmentID  = nodeId.ToNode().GetSegment(data.m_dataInt0 & 7);
            int    targetSegmentIDX = data.m_dataInt0 >> 4;

            return(SegmentEnd.GetShouldConnectTracks(
                       sourceSegmentID,
                       targetSegmentIDX,
                       nodeId,
                       nodeInfoIDX));
        }
Exemplo n.º 8
0
        public void Draw(RenderManager.Instance data)
        {
            var instance = Singleton <NetManager> .instance;

            instance.m_materialBlock.Clear();

            instance.m_materialBlock.SetMatrix(instance.ID_LeftMatrix, Left);
            instance.m_materialBlock.SetMatrix(instance.ID_RightMatrix, Right);
            instance.m_materialBlock.SetVector(instance.ID_MeshScale, Scale);

            instance.m_materialBlock.SetTexture(instance.ID_SurfaceTexA, RenderHelper.SurfaceTexture);

            Graphics.DrawMesh(Mesh, Position, Quaternion.identity, RenderHelper.MaterialLib[MaterialType], 0, null, 0, instance.m_materialBlock);
        }
Exemplo n.º 9
0
        public override void Draw(RenderManager.CameraInfo cameraInfo, RenderManager.Instance renderData)
        {
            var instance = Singleton <NetManager> .instance;

            foreach (var data in Datas)
            {
                if (cameraInfo.CheckRenderDistance(renderData.m_position, data.segment.m_lodRenderDistance))
                {
                    instance.m_materialBlock.Clear();
                    instance.m_materialBlock.SetMatrix(instance.ID_LeftMatrix, data.left);
                    instance.m_materialBlock.SetMatrix(instance.ID_RightMatrix, data.right);
                    instance.m_materialBlock.SetVector(instance.ID_MeshScale, Scale);
                    if (data.segment.m_requireHeightMap)
                    {
                        instance.m_materialBlock.SetTexture(instance.ID_HeightMap, data.heightMap);
                        instance.m_materialBlock.SetVector(instance.ID_HeightMapping, data.heightMapping);
                        instance.m_materialBlock.SetVector(instance.ID_SurfaceMapping, data.surfaceMapping);
                    }

                    instance.m_drawCallData.m_defaultCalls++;
                    Graphics.DrawMesh(data.segment.m_segmentMesh, data.position, Quaternion.identity, data.segment.m_segmentMaterial, 0, null, 0, instance.m_materialBlock);
                }
                else if (data.segment.m_combinedLod is NetInfo.LodValue combinedLod)
                {
                    if (data.segment.m_requireHeightMap && data.heightMap != combinedLod.m_heightMap)
                    {
                        if (combinedLod.m_lodCount != 0)
                        {
                            NetSegment.RenderLod(cameraInfo, combinedLod);
                        }

                        combinedLod.m_heightMap      = data.heightMap;
                        combinedLod.m_heightMapping  = data.heightMapping;
                        combinedLod.m_surfaceMapping = data.surfaceMapping;
                    }

                    combinedLod.m_leftMatrices[combinedLod.m_lodCount]  = data.left;
                    combinedLod.m_rightMatrices[combinedLod.m_lodCount] = data.right;
                    combinedLod.m_meshScales[combinedLod.m_lodCount]    = Scale;
                    combinedLod.m_meshLocations[combinedLod.m_lodCount] = data.position;
                    combinedLod.m_lodMin = Vector3.Min(combinedLod.m_lodMin, data.position);
                    combinedLod.m_lodMax = Vector3.Max(combinedLod.m_lodMax, data.position);

                    if (++combinedLod.m_lodCount == combinedLod.m_leftMatrices.Length)
                    {
                        NetSegment.RenderLod(cameraInfo, combinedLod);
                    }
                }
            }
        }
        static void Postfix(ref NetNode __instance, ref RenderManager.Instance data)
        {
            ushort   nodeID    = NetUtil.GetID(__instance);
            NodeData blendData = NodeManager.Instance.buffer[nodeID];

            if (blendData == null)
            {
                return;
            }

            if (blendData.ShouldRenderCenteralCrossingTexture())
            {
                // puts crossings in the center.
                data.m_dataVector1.w = 0.01f;
            }
#if false
            if (blendData.NodeType == NodeTypeT.Stretch)
            {
                // should data vectors be inverted?
                ushort segmentID = __instance.GetSegment(data.m_dataInt0 & 7);
                var    invert    = segmentID.ToSegment().m_flags.IsFlagSet(NetSegment.Flags.Invert);
                var    startNode = NetUtil.IsStartNode(segmentId: segmentID, nodeId: nodeID);
                bool   flip      = startNode == !invert; // tested works.
                if (flip)                                // flip across x axis
                {
                    data.m_dataVector0.x = -data.m_dataVector0.x;
                    //data.m_dataVector0.z = -data.m_dataVector0.z;
                    data.m_dataVector0.y = -data.m_dataVector0.y;
                    //data.m_dataVector0.w = -data.m_dataVector0.w;

                    //data.m_dataVector2.x = -data.m_dataVector2.x;
                    //data.m_dataVector2.z = -data.m_dataVector2.z;
                    data.m_dataVector2.y = -data.m_dataVector2.y;
                    //data.m_dataVector2.w = -data.m_dataVector2.w;

                    //data.m_dataVector1.x = -data.m_dataVector1.x;
                    //data.m_dataVector1.z = -data.m_dataVector1.z;
                    //data.m_dataVector1.y = -data.m_dataVector1.y;
                    //data.m_dataVector1.w = -data.m_dataVector1.w;

                    //data.m_dataVector3.z = -data.m_dataVector3.z;
                    //data.m_dataVector3.y = -data.m_dataVector3.y;
                    //data.m_dataVector3.x = -data.m_dataVector3.x;
                    //data.m_dataVector3.w = -data.m_dataVector3.w;
                }
            }
#endif
        }
Exemplo n.º 11
0
        public void Draw(RenderManager.CameraInfo cameraInfo, RenderManager.Instance data)
        {
            var instance      = Singleton <PropManager> .instance;
            var materialBlock = instance.m_materialBlock;

            materialBlock.Clear();

            materialBlock.SetVectorArray(instance.ID_PropLocation, Locations);
            materialBlock.SetVectorArray(instance.ID_PropObjectIndex, Indices);
            materialBlock.SetVectorArray(instance.ID_PropColor, Colors);
            materialBlock.SetVector(RenderHelper.ID_DecalSize, Size);

            var mesh     = Mesh;
            var material = RenderHelper.MaterialLib[MaterialType];

            Graphics.DrawMesh(mesh, Matrix4x4.identity, material, 9, null, 0, materialBlock);
        }
Exemplo n.º 12
0
        public override void Draw(RenderManager.CameraInfo cameraInfo, RenderManager.Instance data)
        {
            var instance = Singleton <NetManager> .instance;

            for (var i = 0; i < Meshes.Length && i < MaterialTypes.Length; i += 1)
            {
                var materialType = MaterialTypes[i];
                instance.m_materialBlock.Clear();

                instance.m_materialBlock.SetMatrix(instance.ID_LeftMatrix, Left);
                instance.m_materialBlock.SetMatrix(instance.ID_RightMatrix, Right);
                instance.m_materialBlock.SetVector(instance.ID_MeshScale, Scale);

                instance.m_materialBlock.SetTexture(instance.ID_SurfaceTexA, RenderHelper.SurfaceALib[materialType]);
                instance.m_materialBlock.SetTexture(instance.ID_SurfaceTexB, RenderHelper.SurfaceBLib[materialType]);

                Graphics.DrawMesh(Meshes[i], Position, Quaternion.identity, RenderHelper.MaterialLib[materialType], 0, null, 0, instance.m_materialBlock, CastShadow, ReceiveShadow);
            }
        }
Exemplo n.º 13
0
        //private void NetNode.RefreshEndData
        //  (ushort nodeID, NetInfo info, uint instanceIndex, ref RenderManager.Instance data)
        static void Postfix(ushort nodeID, NetInfo info, ref RenderManager.Instance data)
        {
            var net = info.GetMetaData();

            if (net == null)
            {
                return;
            }
            float pwL = info.m_pavementWidth;
            float pwR = net.PavementWidthRight;

            if (pwL == pwR)
            {
                return;
            }

            float w = info.m_halfWidth * 2;

            float pwM = pwR; // TODO calculate
            float r   = pwM / w;

            ref var segment = ref nodeID.ToNode().GetFirstSegment().ToSegment();
Exemplo n.º 14
0
        /// <summary>
        /// determines if DC node should be rendered modifying it if necessary.
        /// </summary>
        /// <param name="nodeInfo">node to be rendered. some inputs are post modified if necessary</param>
        /// <param name="dataVector0">data vectors. they are reversed if necessary.</param>
        /// <returns>if node should be rendered</returns>
        public static bool ShouldConnectTracks(
            ushort nodeId,
            ref RenderManager.Instance data,
            ref NetInfo.Node nodeInfo,
            ref Vector4 dataVector0)
        {
            ushort sourceSegmentID  = nodeId.ToNode().GetSegment(data.m_dataInt0 & 7);
            int    targetSegmentIDX = data.m_dataInt0 >> 4;
            ushort targetSegmentID  = nodeId.ToNode().GetSegment(targetSegmentIDX);

            if (TMPEUTILS.exists)
            {
                try {
                    bool ret = DirectConnectUtil.DetermineDirectConnect(
                        sourceSegmentID,
                        targetSegmentID,
                        nodeId,
                        ref nodeInfo,
                        out bool flipMesh);

                    if (flipMesh)
                    {
                        dataVector0.x = -dataVector0.x;
                        dataVector0.y = -dataVector0.y;
                    }

                    return(ret);
                }
                catch (Exception e) {
                    Log.Error(e.Message);
                    TMPEUTILS.exists = false;
                    throw;
                }
            }
            return(true);
        }
Exemplo n.º 15
0
        public static bool RenderDestroyedPropsPrefix(BuildingAI __instance, RenderManager.CameraInfo cameraInfo, ushort buildingID, ref Building data, int layerMask, ref RenderManager.Instance instance, bool renderFixed, bool renderNonfixed)
        {
            if (__instance.m_info.m_props == null || !cameraInfo.CheckRenderDistance(instance.m_position, __instance.m_info.m_maxPropDistance + 72f))
            {
                return(false);
            }
            int                length          = data.Length;
            Texture            _HeightMap      = null;
            Vector4            _HeightMapping  = Vector4.zero;
            Vector4            _SurfaceMapping = Vector4.zero;
            BuildingProperties properties      = Singleton <BuildingManager> .instance.m_properties;

            Building.Frame lastFrameData = data.GetLastFrameData();
            float          num           = (float)Mathf.Max(0, lastFrameData.m_fireDamage - 127) * 0.0078125f;

            for (int i = 0; i < __instance.m_info.m_props.Length; i++)
            {
                BuildingInfo.Prop prop = __instance.m_info.m_props[i];
                Randomizer        r    = new Randomizer((buildingID << 6) | prop.m_index);
                Randomizer        r2   = new Randomizer((buildingID << 6) | prop.m_index);
                if (r.Int32(100u) >= prop.m_probability || length < prop.m_requiredLength)
                {
                    continue;
                }
                PropInfo finalProp = prop.m_finalProp;
                if (!(finalProp != null))
                {
                    continue;
                }
                finalProp = finalProp.GetVariation(ref r);
                float scale = finalProp.m_minScale + (float)r.Int32(10000u) * (finalProp.m_maxScale - finalProp.m_minScale) * 0.0001f;
                Color color = finalProp.GetColor(ref r);
                if (!finalProp.m_isDecal)
                {
                    finalProp = Singleton <PropManager> .instance.GetRandomPropInfo(ref r2, ItemClass.Service.Disaster);

                    finalProp = finalProp.GetVariation(ref r2);
                    scale     = finalProp.m_minScale + (float)r2.Int32(10000u) * (finalProp.m_maxScale - finalProp.m_minScale) * 0.0001f;
                    color     = finalProp.GetColor(ref r2);
                    if (properties != null && num != 0f)
                    {
                        color = Color.Lerp(color, properties.m_burnedColor, num);
                    }
                }
                if ((layerMask & (1 << finalProp.m_prefabDataLayer)) == 0 && !finalProp.m_hasEffects)
                {
                    continue;
                }
                Vector3 vector = instance.m_dataMatrix1.MultiplyPoint(prop.m_position);
                if (!prop.m_fixedHeight || __instance.m_info.m_requireHeightMap)
                {
                    vector.y = (float)(int)instance.m_extraData.GetUShort(i) * 0.015625f;
                }
                if (!cameraInfo.CheckRenderDistance(vector, finalProp.m_maxRenderDistance) || !((!prop.m_fixedHeight) ? renderNonfixed : renderFixed))
                {
                    continue;
                }
                InstanceID propRenderID = GetPropRenderIDReverse(__instance, buildingID, 0, ref data);
                Vector4    dataVector   = instance.m_dataVector3;
                if (!prop.m_fixedHeight && (!__instance.m_info.m_colorizeEverything || finalProp.m_isDecal))
                {
                    dataVector.z = 0f;
                }
                if (finalProp.m_requireWaterMap)
                {
                    if (_HeightMap == null)
                    {
                        Singleton <TerrainManager> .instance.GetWaterMapping(data.m_position, out _HeightMap, out _HeightMapping, out _SurfaceMapping);
                    }
#if UseTask
                    var localData     = data;
                    var localInstance = instance;
                    Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID, vector, scale, localData.m_angle + prop.m_radAngle, color, dataVector, (localData.m_flags & Building.Flags.Active) != 0, localInstance.m_dataTexture0, localInstance.m_dataVector1, localInstance.m_dataVector2, _HeightMap, _HeightMapping, _SurfaceMapping));
#else
                    PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID, vector, scale, data.m_angle + prop.m_radAngle, color, dataVector, (data.m_flags & Building.Flags.Active) != 0, instance.m_dataTexture0, instance.m_dataVector1, instance.m_dataVector2, _HeightMap, _HeightMapping, _SurfaceMapping);
#endif
                }
                else if (finalProp.m_requireHeightMap)
                {
#if UseTask
                    var localData     = data;
                    var localInstance = instance;
                    Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID, vector, scale, localData.m_angle + prop.m_radAngle, color, dataVector, (localData.m_flags & Building.Flags.Active) != 0, localInstance.m_dataTexture0, localInstance.m_dataVector1, localInstance.m_dataVector2));
#else
                    PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID, vector, scale, data.m_angle + prop.m_radAngle, color, dataVector, (data.m_flags & Building.Flags.Active) != 0, instance.m_dataTexture0, instance.m_dataVector1, instance.m_dataVector2);
#endif
                }
                else
                {
#if UseTask
                    var localData = data;
                    Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID, vector, scale, localData.m_angle + prop.m_radAngle, color, dataVector, (localData.m_flags & Building.Flags.Active) != 0));
#else
                    PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID, vector, scale, data.m_angle + prop.m_radAngle, color, dataVector, (data.m_flags & Building.Flags.Active) != 0);
#endif
                }
            }

            return(false);
        }
Exemplo n.º 16
0
 public abstract void Draw(RenderManager.CameraInfo cameraInfo, RenderManager.Instance data);
Exemplo n.º 17
0
        public static bool RenderPropsPrefix(BuildingAI __instance, RenderManager.CameraInfo cameraInfo, ushort buildingID, ref Building data, int layerMask, ref RenderManager.Instance instance, bool renderFixed, bool renderNonfixed, bool isActive)
        {
            if (__instance.m_info.m_props == null || ((layerMask & __instance.m_info.m_treeLayers) == 0 && !cameraInfo.CheckRenderDistance(instance.m_position, __instance.m_info.m_maxPropDistance + 72f)))
            {
                return(false);
            }
            int             length          = data.Length;
            Texture         _HeightMap      = null;
            Vector4         _HeightMapping  = Vector4.zero;
            Vector4         _SurfaceMapping = Vector4.zero;
            Matrix4x4       lhs             = Matrix4x4.zero;
            bool            flag            = false;
            DistrictManager instance2       = Singleton <DistrictManager> .instance;
            byte            district        = instance2.GetDistrict(data.m_position);
            Vector3         position        = data.m_position;
            ushort          num             = Building.FindParentBuilding(buildingID);

            if (num != 0)
            {
                position = Singleton <BuildingManager> .instance.m_buildings.m_buffer[num].m_position;
            }
            byte park = instance2.GetPark(position);

            for (int i = 0; i < __instance.m_info.m_props.Length; i++)
            {
                BuildingInfo.Prop prop = __instance.m_info.m_props[i];
                Randomizer        r    = new Randomizer((buildingID << 6) | prop.m_index);
                if (r.Int32(100u) >= prop.m_probability || length < prop.m_requiredLength)
                {
                    continue;
                }
                PropInfo finalProp = prop.m_finalProp;
                TreeInfo finalTree = prop.m_finalTree;
                if (finalProp != null)
                {
                    finalProp = finalProp.GetVariation(ref r, ref instance2.m_districts.m_buffer[district], park);
                    float num2  = finalProp.m_minScale + (float)r.Int32(10000u) * (finalProp.m_maxScale - finalProp.m_minScale) * 0.0001f;
                    Color color = finalProp.GetColor(ref r);
                    if ((layerMask & (1 << finalProp.m_prefabDataLayer)) == 0 && !finalProp.m_hasEffects)
                    {
                        continue;
                    }
                    Vector4 dataVector = instance.m_dataVector3;
                    Vector3 vector;
                    if (prop.m_fixedHeight)
                    {
                        if (!renderFixed)
                        {
                            continue;
                        }
                        if (__instance.m_info.m_isFloating)
                        {
                            if (!flag)
                            {
                                Singleton <TerrainManager> .instance.HeightMap_sampleWaterHeightAndNormal(instance.m_position, 0.15f, out float h, out Vector3 normal);

                                Vector3 position2 = instance.m_position;
                                position2.y = h;
                                Quaternion q = Quaternion.FromToRotation(Vector3.up, normal) * instance.m_rotation;
                                lhs  = Matrix4x4.TRS(position2, q, Vector3.one);
                                flag = true;
                            }
                            Matrix4x4 rhs = default(Matrix4x4);
                            rhs.SetTRS(prop.m_position, Quaternion.AngleAxis(prop.m_radAngle * 57.29578f, Vector3.down), new Vector3(num2, num2, num2));
                            rhs    = lhs * rhs;
                            vector = rhs.MultiplyPoint(Vector3.zero);
                            if (cameraInfo.CheckRenderDistance(vector, finalProp.m_maxRenderDistance))
                            {
                                InstanceID propRenderID = GetPropRenderIDReverse(__instance, buildingID, i, ref data);
                                PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID, rhs, vector, num2, data.m_angle + prop.m_radAngle, color, dataVector, isActive);
                                continue;
                            }
                        }
                        else
                        {
                            vector = instance.m_dataMatrix1.MultiplyPoint(prop.m_position);
                            if (__instance.m_info.m_requireHeightMap)
                            {
                                vector.y = (float)(int)instance.m_extraData.GetUShort(i) * 0.015625f;
                            }
                        }
                    }
                    else
                    {
                        if (!renderNonfixed)
                        {
                            continue;
                        }
                        vector = instance.m_dataMatrix1.MultiplyPoint(prop.m_position);
                        if (!__instance.m_info.m_isFloating)
                        {
                            vector.y = (float)(int)instance.m_extraData.GetUShort(i) * 0.015625f;
                        }
                        if (!__instance.m_info.m_colorizeEverything || finalProp.m_isDecal)
                        {
                            dataVector.z = 0f;
                        }
                    }
                    if (!cameraInfo.CheckRenderDistance(vector, finalProp.m_maxRenderDistance))
                    {
                        continue;
                    }
                    InstanceID propRenderID2 = GetPropRenderIDReverse(__instance, buildingID, i, ref data);
                    if (finalProp.m_requireWaterMap)
                    {
                        if (_HeightMap == null)
                        {
                            Singleton <TerrainManager> .instance.GetWaterMapping(data.m_position, out _HeightMap, out _HeightMapping, out _SurfaceMapping);
                        }
#if UseTask
                        var localData     = data;
                        var localInstance = instance;
                        Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID2, vector, num2, localData.m_angle + prop.m_radAngle, color, dataVector, isActive, localInstance.m_dataTexture0, localInstance.m_dataVector1, localInstance.m_dataVector2, _HeightMap, _HeightMapping, _SurfaceMapping));
#else
                        PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID2, vector, num2, data.m_angle + prop.m_radAngle, color, dataVector, isActive, instance.m_dataTexture0, instance.m_dataVector1, instance.m_dataVector2, _HeightMap, _HeightMapping, _SurfaceMapping);
#endif
                    }
                    else if (finalProp.m_requireHeightMap)
                    {
#if UseTask
                        var localData     = data;
                        var localInstance = instance;
                        Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID2, vector, num2, localData.m_angle + prop.m_radAngle, color, dataVector, isActive, localInstance.m_dataTexture0, localInstance.m_dataVector1, localInstance.m_dataVector2));
#else
                        PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID2, vector, num2, data.m_angle + prop.m_radAngle, color, dataVector, isActive, instance.m_dataTexture0, instance.m_dataVector1, instance.m_dataVector2);
#endif
                    }
                    else
                    {
#if UseTask
                        var localData     = data;
                        var localInstance = instance;
                        Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID2, vector, num2, localData.m_angle + prop.m_radAngle, color, dataVector, isActive));
#else
                        PropInstance.RenderInstance(cameraInfo, finalProp, propRenderID2, vector, num2, data.m_angle + prop.m_radAngle, color, dataVector, isActive);
#endif
                    }
                }
                else
                {
                    if (!(finalTree != null))
                    {
                        continue;
                    }
                    finalTree = finalTree.GetVariation(ref r);
                    float scale      = finalTree.m_minScale + (float)r.Int32(10000u) * (finalTree.m_maxScale - finalTree.m_minScale) * 0.0001f;
                    float brightness = finalTree.m_minBrightness + (float)r.Int32(10000u) * (finalTree.m_maxBrightness - finalTree.m_minBrightness) * 0.0001f;
                    if ((layerMask & (1 << finalTree.m_prefabDataLayer)) != 0 && ((!prop.m_fixedHeight) ? renderNonfixed : renderFixed))
                    {
                        Vector3 position3 = instance.m_dataMatrix1.MultiplyPoint(prop.m_position);
                        if (!prop.m_fixedHeight || __instance.m_info.m_requireHeightMap)
                        {
                            position3.y = (float)(int)instance.m_extraData.GetUShort(i) * 0.015625f;
                        }
                        Vector4 dataVector2 = instance.m_dataVector3;
                        if (!__instance.m_info.m_colorizeEverything)
                        {
                            dataVector2.z = 0f;
                        }
#if UseTask
                        var localData     = data;
                        var localInstance = instance;
                        Patcher.Dispatcher.Add(() => TreeInstance.RenderInstance(cameraInfo, finalTree, position3, scale, brightness, dataVector2));
#else
                        TreeInstance.RenderInstance(cameraInfo, finalTree, position3, scale, brightness, dataVector2);
#endif
                    }
                }
            }

            return(false);
        }
Exemplo n.º 18
0
    // NetNode
    // Token: 0x060034C6 RID: 13510 RVA: 0x0023D1EC File Offset: 0x0023B5EC

    /// <param name="centerPos">position between left corner and right corner of segmentID (or something like that).</param>
    private static void RefreshJunctionData(ref NetNode This, ushort nodeID, int segmentIndex, ushort SegmentID, Vector3 centerPos, ref uint instanceIndex, ref RenderManager.Instance data)
    {
        Vector3 cornerPos_right = Vector3.zero, cornerDir_right = Vector3.zero, cornerPos_left = Vector3.zero, cornerDir_left = Vector3.zero,
                cornerPosA_right = Vector3.zero, cornerDirA_right = Vector3.zero, cornerPosA_left = Vector3.zero, cornerDirA_left = Vector3.zero,
                cornerPosB_right = Vector3.zero, cornerDirB_right = Vector3.zero, cornerPosB_left = Vector3.zero, cornerDirB_left = Vector3.zero;

        NetManager instance = Singleton <NetManager> .instance;

        data.m_position    = This.m_position;
        data.m_rotation    = Quaternion.identity;
        data.m_initialized = true;
        NetSegment segment         = SegmentID.ToSegment();
        NetInfo    info            = segment.Info;
        float      vscale          = info.m_netAI.GetVScale();
        ItemClass  connectionClass = info.GetConnectionClass();
        bool       bStartNode      = nodeID == segment.m_startNode;
        Vector3    dir             = !bStartNode ? segment.m_endDirection : segment.m_startDirection;
        float      dot_A           = -4f;
        float      dot_B           = -4f;
        ushort     segmentID_A     = 0;
        ushort     segmentID_B     = 0;

        for (int i = 0; i < 8; i++)
        {
            ushort segmentID2 = This.GetSegment(i);
            if (segmentID2 != 0 && segmentID2 != SegmentID)
            {
                NetInfo   info2            = instance.m_segments.m_buffer[(int)segmentID2].Info;
                ItemClass connectionClass2 = info2.GetConnectionClass();
                if (connectionClass.m_service == connectionClass2.m_service)
                {
                    NetSegment segment2    = segmentID2.ToSegment();
                    bool       bStartNode2 = nodeID != segment2.m_startNode;
                    Vector3    dir2        = !bStartNode2 ? segment2.m_endDirection : segment2.m_startDirection;
                    float      dot         = dir.x * dir2.x + dir.z * dir2.z;
                    float      determinent = dir2.z * dir.x - dir2.x * dir.z;
                    bool       bRight      = determinent > 0;
                    bool       bWide       = dot < 0;
                    // 180 -> det=0 dot=-1
                    if (!bRight)
                    {
                        if (dot > dot_A) // most accute
                        {
                            dot_A       = dot;
                            segmentID_A = segmentID2;
                        }
                        dot = -2f - dot;
                        if (dot > dot_B) // widest
                        {
                            dot_B       = dot;
                            segmentID_B = segmentID2;
                        }
                    }
                    else
                    {
                        if (dot > dot_B) // most accute
                        {
                            dot_B       = dot;
                            segmentID_B = segmentID2;
                        }
                        dot = -2f - dot;
                        if (dot > dot_A) // widest
                        {
                            dot_A       = dot;
                            segmentID_A = segmentID2;
                        }
                    }
                }
            }
        }
        segment.CalculateCorner(SegmentID, true, bStartNode, false, out cornerPos_right, out cornerDir_right, out _);
        segment.CalculateCorner(SegmentID, true, bStartNode, true, out cornerPos_left, out cornerDir_left, out _);
        if (segmentID_A != 0 && segmentID_B != 0)
        {
            float pavementRatio_avgA = info.m_pavementWidth / info.m_halfWidth * 0.5f;
            float averageWidthA      = 1f;
            if (segmentID_A != 0)
            {
                NetSegment segment_A = instance.m_segments.m_buffer[(int)segmentID_A];
                NetInfo    infoA     = segment_A.Info;
                bStartNode = (segment_A.m_startNode == nodeID);
                segment_A.CalculateCorner(segmentID_A, true, bStartNode, true, out cornerPosA_right, out cornerDirA_right, out _);
                segment_A.CalculateCorner(segmentID_A, true, bStartNode, false, out cornerPosA_left, out cornerDirA_left, out _);
                float pavementRatioA = infoA.m_pavementWidth / infoA.m_halfWidth * 0.5f;
                pavementRatio_avgA = (pavementRatio_avgA + pavementRatioA) * 0.5f;
                averageWidthA      = 2f * info.m_halfWidth / (info.m_halfWidth + infoA.m_halfWidth);
            }
            float pavementRatio_avgB = info.m_pavementWidth / info.m_halfWidth * 0.5f;
            float averageWithB       = 1f;
            if (segmentID_B != 0)
            {
                NetSegment segment_B = instance.m_segments.m_buffer[(int)segmentID_B];
                NetInfo    infoB     = segment_B.Info;
                bStartNode = (segment_B.m_startNode == nodeID);
                segment_B.CalculateCorner(segmentID_B, true, bStartNode, true, out cornerPosB_right, out cornerDirB_right, out _);
                segment_B.CalculateCorner(segmentID_B, true, bStartNode, false, out cornerPosB_left, out cornerDirB_left, out _);
                float pavementRatioB = infoB.m_pavementWidth / infoB.m_halfWidth * 0.5f;
                pavementRatio_avgB = (pavementRatio_avgB + pavementRatioB) * 0.5f;
                averageWithB       = 2f * info.m_halfWidth / (info.m_halfWidth + infoB.m_halfWidth);
            }

            Bezier3 bezierA_right = new Bezier3
            {
                a = cornerPos_right,
                d = cornerPosA_right,
            };

            NetSegment.CalculateMiddlePoints(bezierA_right.a, -cornerDir_right, bezierA_right.d, -cornerDirA_right, true, true, out bezierA_right.b, out bezierA_right.c);
            NetSegment.CalculateMiddlePoints(cornerPos_left, -cornerDir_left, cornerPosA_left, -cornerDirA_left, true, true, out var cpoint2_Aleft, out var cpoint3_Aleft);
            NetSegment.CalculateMiddlePoints(cornerPos_right, -cornerDir_right, cornerPosB_right, -cornerDirB_right, true, true, out var cpoint2_Bright, out var cpoint3_Bright);
            NetSegment.CalculateMiddlePoints(cornerPos_left, -cornerDir_left, cornerPosB_left, -cornerDirB_left, true, true, out var cpoint2_Bleft, out var cpoint3_Bleft);

            data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(bezierA_right.a, bezierA_right.b, bezierA_right.c, bezierA_right.d, bezierA_right.a, bezierA_right.b, bezierA_right.c, bezierA_right.d, This.m_position, vscale);
            data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(cornerPos_left, cpoint2_Aleft, cpoint3_Aleft, cornerPosA_left, cornerPos_left, cpoint2_Aleft, cpoint3_Aleft, cornerPosA_left, This.m_position, vscale);
            data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(cornerPos_right, cpoint2_Bright, cpoint3_Bright, cornerPosB_right, cornerPos_right, cpoint2_Bright, cpoint3_Bright, cornerPosB_right, This.m_position, vscale);
            data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(cornerPos_left, cpoint2_Bleft, cpoint3_Bleft, cornerPosB_left, cornerPos_left, cpoint2_Bleft, cpoint3_Bleft, cornerPosB_left, This.m_position, vscale);

            // Vector4(1/width | 1/length | 0.5 - pavement/width | pavement/width )
            data.m_dataVector0   = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
            data.m_dataVector1   = centerPos - data.m_position;
            data.m_dataVector1.w = (data.m_dataMatrix0.m31 + data.m_dataMatrix0.m32 + data.m_extraData.m_dataMatrix2.m31 + data.m_extraData.m_dataMatrix2.m32 + data.m_extraData.m_dataMatrix3.m31 + data.m_extraData.m_dataMatrix3.m32 + data.m_dataMatrix1.m31 + data.m_dataMatrix1.m32) * 0.125f;
            data.m_dataVector2   = new Vector4(pavementRatio_avgA, averageWidthA, pavementRatio_avgB, averageWithB);
        }
        else
        {
            centerPos.x = (cornerPos_right.x + cornerPos_left.x) * 0.5f;
            centerPos.z = (cornerPos_right.z + cornerPos_left.z) * 0.5f;
            var cornerPos_left_prev  = cornerPos_left;
            var cornerPos_right_prev = cornerPos_right;
            cornerDirB_right = cornerDir_left;
            cornerDirB_left  = cornerDir_right;
            float   d        = info.m_netAI.GetEndRadius() * 1.33333337f;
            Vector3 vector13 = cornerPos_right - cornerDir_right * d;
            Vector3 vector14 = cornerPos_left_prev - cornerDirB_right * d;
            Vector3 vector15 = cornerPos_left - cornerDir_left * d;
            Vector3 vector16 = cornerPos_right_prev - cornerDirB_left * d;
            Vector3 vector17 = cornerPos_right + cornerDir_right * d;
            Vector3 vector18 = cornerPos_left_prev + cornerDirB_right * d;
            Vector3 vector19 = cornerPos_left + cornerDir_left * d;
            Vector3 vector20 = cornerPos_right_prev + cornerDirB_left * d;
            data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(cornerPos_right, vector13, vector14, cornerPos_left_prev, cornerPos_right, vector13, vector14, cornerPos_left_prev, This.m_position, vscale);
            data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(cornerPos_left, vector19, vector20, cornerPos_right_prev, cornerPos_left, vector19, vector20, cornerPos_right_prev, This.m_position, vscale);
            data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(cornerPos_right, vector17, vector18, cornerPos_left_prev, cornerPos_right, vector17, vector18, cornerPos_left_prev, This.m_position, vscale);
            data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(cornerPos_left, vector15, vector16, cornerPos_right_prev, cornerPos_left, vector15, vector16, cornerPos_right_prev, This.m_position, vscale);
            data.m_dataMatrix0.SetRow(3, data.m_dataMatrix0.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_extraData.m_dataMatrix2.SetRow(3, data.m_extraData.m_dataMatrix2.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_extraData.m_dataMatrix3.SetRow(3, data.m_extraData.m_dataMatrix3.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_dataMatrix1.SetRow(3, data.m_dataMatrix1.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
            data.m_dataVector0   = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
            data.m_dataVector1   = centerPos - data.m_position;
            data.m_dataVector1.w = (data.m_dataMatrix0.m31 + data.m_dataMatrix0.m32 + data.m_extraData.m_dataMatrix2.m31 + data.m_extraData.m_dataMatrix2.m32 + data.m_extraData.m_dataMatrix3.m31 + data.m_extraData.m_dataMatrix3.m32 + data.m_dataMatrix1.m31 + data.m_dataMatrix1.m32) * 0.125f;
            data.m_dataVector2   = new Vector4(info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f, info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f);
        }
        Vector4 colorLocation;
        Vector4 vector21;

        if (NetNode.BlendJunction(nodeID))
        {
            colorLocation = RenderManager.GetColorLocation(86016u + (uint)nodeID);
            vector21      = colorLocation;
        }
        else
        {
            colorLocation = RenderManager.GetColorLocation((uint)(49152 + SegmentID));
            vector21      = RenderManager.GetColorLocation(86016u + (uint)nodeID);
        }
        data.m_extraData.m_dataVector4 = new Vector4(colorLocation.x, colorLocation.y, vector21.x, vector21.y);
        data.m_dataInt0     = segmentIndex;
        data.m_dataColor0   = info.m_color;
        data.m_dataColor0.a = 0f;
        data.m_dataFloat0   = Singleton <WeatherManager> .instance.GetWindSpeed(data.m_position);

        if (info.m_requireSurfaceMaps)
        {
            Singleton <TerrainManager> .instance.GetSurfaceMapping(data.m_position, out data.m_dataTexture0, out data.m_dataTexture1, out data.m_dataVector3);
        }
        instanceIndex = (uint)data.m_nextInstance;
    }
Exemplo n.º 19
0
        public static bool RenderInstancePowerPoleAIPrefix(PowerPoleAI __instance, RenderManager.CameraInfo cameraInfo, ushort buildingID, ref Building data, int layerMask, ref RenderManager.Instance instance)
        {
#if UseTask
            var localData     = data;
            var localInstance = instance;
            Patcher.Dispatcher.Add(() => __instance.RenderMeshes(cameraInfo, buildingID, ref localData, layerMask, ref localInstance));
#else
            __instance.RenderMeshes(cameraInfo, buildingID, ref data, layerMask, ref instance);
#endif
            __instance.RenderProps(cameraInfo, buildingID, ref data, layerMask, ref instance, (data.m_flags & Building.Flags.Collapsed) == 0, renderNonfixed: true);

            return(false);
        }
Exemplo n.º 20
0
        public static bool RenderDestroyedInstancePrefix(NetLane __instance, RenderManager.CameraInfo cameraInfo, ushort segmentID, uint laneID, NetInfo netInfo, NetInfo.Lane laneInfo, NetNode.Flags startFlags, NetNode.Flags endFlags, Color startColor, Color endColor, float startAngle, float endAngle, bool invert, int layerMask, Vector4 objectIndex1, Vector4 objectIndex2, ref RenderManager.Instance data, ref int propIndex)
        {
            NetLaneProps laneProps = laneInfo.m_laneProps;

            if (laneProps != null && laneProps.m_props != null)
            {
                bool flag  = (laneInfo.m_finalDirection & NetInfo.Direction.Both) == NetInfo.Direction.Backward || (laneInfo.m_finalDirection & NetInfo.Direction.AvoidBoth) == NetInfo.Direction.AvoidForward;
                bool flag2 = flag != invert;
                if (flag)
                {
                    NetNode.Flags flags = startFlags;
                    startFlags = endFlags;
                    endFlags   = flags;
                }
                int num = laneProps.m_props.Length;
                for (int i = 0; i < num; i++)
                {
                    NetLaneProps.Prop prop = laneProps.m_props[i];
                    if (__instance.m_length < prop.m_minLength)
                    {
                        continue;
                    }
                    int num2 = 2;
                    if (prop.m_repeatDistance > 1f)
                    {
                        num2 *= Mathf.Max(1, Mathf.RoundToInt(__instance.m_length / prop.m_repeatDistance));
                    }
                    int num3 = propIndex;
                    if (propIndex != -1)
                    {
                        propIndex = num3 + (num2 + 1 >> 1);
                    }
                    if (!prop.CheckFlags((NetLane.Flags)__instance.m_flags, startFlags, endFlags))
                    {
                        continue;
                    }
                    float num4 = prop.m_segmentOffset * 0.5f;
                    if (__instance.m_length != 0f)
                    {
                        num4 = Mathf.Clamp(num4 + prop.m_position.z / __instance.m_length, -0.5f, 0.5f);
                    }
                    if (flag2)
                    {
                        num4 = 0f - num4;
                    }
                    PropInfo finalProp = prop.m_finalProp;
                    if (!(finalProp != null) || (layerMask & (1 << finalProp.m_prefabDataLayer)) == 0)
                    {
                        continue;
                    }
                    Color      color = (prop.m_colorMode != NetLaneProps.ColorMode.EndState) ? startColor : endColor;
                    Randomizer r     = new Randomizer((int)laneID + i);
                    for (int j = 1; j <= num2; j += 2)
                    {
                        if (r.Int32(100u) >= prop.m_probability)
                        {
                            continue;
                        }
                        float    num5      = num4 + (float)j / (float)num2;
                        PropInfo variation = finalProp.GetVariation(ref r);
                        float    scale     = variation.m_minScale + (float)r.Int32(10000u) * (variation.m_maxScale - variation.m_minScale) * 0.0001f;
                        if (prop.m_colorMode == NetLaneProps.ColorMode.Default)
                        {
                            color = variation.GetColor(ref r);
                        }
                        if (!variation.m_isDecal && !variation.m_surviveCollapse)
                        {
                            continue;
                        }
                        Vector3 vector = __instance.m_bezier.Position(num5);
                        if (propIndex != -1)
                        {
                            vector.y = (float)(int)data.m_extraData.GetUShort(num3++) * 0.015625f;
                        }
                        vector.y += prop.m_position.y;
                        if (!cameraInfo.CheckRenderDistance(vector, variation.m_maxRenderDistance))
                        {
                            continue;
                        }
                        Vector3 vector2 = __instance.m_bezier.Tangent(num5);
                        if (!(vector2 != Vector3.zero))
                        {
                            continue;
                        }
                        if (flag2)
                        {
                            vector2 = -vector2;
                        }
                        vector2.y = 0f;
                        if (prop.m_position.x != 0f)
                        {
                            vector2   = Vector3.Normalize(vector2);
                            vector.x += vector2.z * prop.m_position.x;
                            vector.z -= vector2.x * prop.m_position.x;
                        }
                        float num6 = Mathf.Atan2(vector2.x, 0f - vector2.z);
                        if (prop.m_cornerAngle != 0f || prop.m_position.x != 0f)
                        {
                            float num7 = endAngle - startAngle;
                            if (num7 > (float)Math.PI)
                            {
                                num7 -= (float)Math.PI * 2f;
                            }
                            if (num7 < -(float)Math.PI)
                            {
                                num7 += (float)Math.PI * 2f;
                            }
                            float num8 = startAngle + num7 * num5;
                            num7 = num8 - num6;
                            if (num7 > (float)Math.PI)
                            {
                                num7 -= (float)Math.PI * 2f;
                            }
                            if (num7 < -(float)Math.PI)
                            {
                                num7 += (float)Math.PI * 2f;
                            }
                            num6 += num7 * prop.m_cornerAngle;
                            if (num7 != 0f && prop.m_position.x != 0f)
                            {
                                float num9 = Mathf.Tan(num7);
                                vector.x += vector2.x * num9 * prop.m_position.x;
                                vector.z += vector2.z * num9 * prop.m_position.x;
                            }
                        }
                        Vector4 objectIndex3 = (!(num5 > 0.5f)) ? objectIndex1 : objectIndex2;
                        num6 += prop.m_angle * ((float)Math.PI / 180f);
                        InstanceID id = default(InstanceID);
                        id.NetSegment = segmentID;
#if UseTask
                        Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, variation, id, vector, scale, num6, color, objectIndex3, active: true));
#else
                        PropInstance.RenderInstance(cameraInfo, variation, id, vector, scale, num6, color, objectIndex3, active: true);
#endif
                    }
                }
            }
            if ((laneInfo.m_laneType & (NetInfo.LaneType.Vehicle | NetInfo.LaneType.Parking | NetInfo.LaneType.CargoVehicle | NetInfo.LaneType.TransportVehicle)) == 0 && ((laneInfo.m_laneType & NetInfo.LaneType.Pedestrian) == 0 || netInfo.m_vehicleTypes != 0))
            {
                return(false);
            }
            bool       flag3 = (laneInfo.m_vehicleType & ~VehicleInfo.VehicleType.Bicycle) == 0 || laneInfo.m_verticalOffset >= 0.5f;
            Randomizer r2    = new Randomizer(laneID);
            int        num10 = Mathf.RoundToInt(__instance.m_length * 0.07f);
            for (int k = 0; k < num10; k++)
            {
                PropInfo randomPropInfo = Singleton <PropManager> .instance.GetRandomPropInfo(ref r2, ItemClass.Service.Road);

                randomPropInfo = randomPropInfo.GetVariation(ref r2);
                float num11  = randomPropInfo.m_minScale + (float)r2.Int32(10000u) * (randomPropInfo.m_maxScale - randomPropInfo.m_minScale) * 0.0001f;
                Color color2 = randomPropInfo.GetColor(ref r2);
                float num12  = (float)r2.Int32(1000u) * 0.001f;
                float angle  = (float)r2.Int32(1000u) * 0.006283186f;
                if (!randomPropInfo.m_isDecal)
                {
                    if (flag3)
                    {
                        continue;
                    }
                    if (netInfo.m_netAI.IsOverground())
                    {
                        float num13 = netInfo.m_halfWidth - Mathf.Abs(laneInfo.m_position);
                        float num14 = Mathf.Max(randomPropInfo.m_generatedInfo.m_size.x, randomPropInfo.m_generatedInfo.m_size.z) * num11 * 0.5f - 0.5f;
                        if (num13 < num14)
                        {
                            continue;
                        }
                    }
                }
                Vector3    position     = __instance.m_bezier.Position(num12);
                Vector4    objectIndex4 = (!(num12 > 0.5f)) ? objectIndex1 : objectIndex2;
                InstanceID id2          = default(InstanceID);
                id2.NetSegment = segmentID;
                if (!randomPropInfo.m_requireHeightMap)
                {
#if UseTask
                    Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, randomPropInfo, id2, position, num11, angle, color2, objectIndex4, active: true));
#else
                    PropInstance.RenderInstance(cameraInfo, randomPropInfo, id2, position, num11, angle, color2, objectIndex4, active: true);
#endif
                }
            }

            return(false);
        }
Exemplo n.º 21
0
        public static bool RenderInstancePrefix(NetLane __instance, RenderManager.CameraInfo cameraInfo, ushort segmentID, uint laneID, NetInfo.Lane laneInfo, NetNode.Flags startFlags, NetNode.Flags endFlags, Color startColor, Color endColor, float startAngle, float endAngle, bool invert, int layerMask, Vector4 objectIndex1, Vector4 objectIndex2, ref RenderManager.Instance data, ref int propIndex)
        {
            NetLaneProps laneProps = laneInfo.m_laneProps;

            if (!(laneProps != null) || laneProps.m_props == null)
            {
                return(false);
            }
            bool flag  = (laneInfo.m_finalDirection & NetInfo.Direction.Both) == NetInfo.Direction.Backward || (laneInfo.m_finalDirection & NetInfo.Direction.AvoidBoth) == NetInfo.Direction.AvoidForward;
            bool flag2 = flag != invert;

            if (flag)
            {
                NetNode.Flags flags = startFlags;
                startFlags = endFlags;
                endFlags   = flags;
            }
            Texture _HeightMap       = null;
            Vector4 _HeightMapping   = Vector4.zero;
            Vector4 _SurfaceMapping  = Vector4.zero;
            Texture _HeightMap2      = null;
            Vector4 _HeightMapping2  = Vector4.zero;
            Vector4 _SurfaceMapping2 = Vector4.zero;
            int     num = laneProps.m_props.Length;

            for (int i = 0; i < num; i++)
            {
                NetLaneProps.Prop prop = laneProps.m_props[i];
                if (__instance.m_length < prop.m_minLength)
                {
                    continue;
                }
                int num2 = 2;
                if (prop.m_repeatDistance > 1f)
                {
                    num2 *= Mathf.Max(1, Mathf.RoundToInt(__instance.m_length / prop.m_repeatDistance));
                }
                int num3 = propIndex;
                if (propIndex != -1)
                {
                    propIndex = num3 + (num2 + 1 >> 1);
                }
                if (!prop.CheckFlags((NetLane.Flags)__instance.m_flags, startFlags, endFlags))
                {
                    continue;
                }
                float num4 = prop.m_segmentOffset * 0.5f;
                if (__instance.m_length != 0f)
                {
                    num4 = Mathf.Clamp(num4 + prop.m_position.z / __instance.m_length, -0.5f, 0.5f);
                }
                if (flag2)
                {
                    num4 = 0f - num4;
                }
                PropInfo finalProp = prop.m_finalProp;
                if (finalProp != null && (layerMask & (1 << finalProp.m_prefabDataLayer)) != 0)
                {
                    Color      color = (prop.m_colorMode != NetLaneProps.ColorMode.EndState) ? startColor : endColor;
                    Randomizer r     = new Randomizer((int)laneID + i);
                    for (int j = 1; j <= num2; j += 2)
                    {
                        if (r.Int32(100u) >= prop.m_probability)
                        {
                            continue;
                        }
                        float    num5      = num4 + (float)j / (float)num2;
                        PropInfo variation = finalProp.GetVariation(ref r);
                        float    scale     = variation.m_minScale + (float)r.Int32(10000u) * (variation.m_maxScale - variation.m_minScale) * 0.0001f;
                        if (prop.m_colorMode == NetLaneProps.ColorMode.Default)
                        {
                            color = variation.GetColor(ref r);
                        }
                        Vector3 vector = __instance.m_bezier.Position(num5);
                        if (propIndex != -1)
                        {
                            vector.y = (float)(int)data.m_extraData.GetUShort(num3++) * 0.015625f;
                        }
                        vector.y += prop.m_position.y;
                        if (!cameraInfo.CheckRenderDistance(vector, variation.m_maxRenderDistance))
                        {
                            continue;
                        }
                        Vector3 vector2 = __instance.m_bezier.Tangent(num5);
                        if (!(vector2 != Vector3.zero))
                        {
                            continue;
                        }
                        if (flag2)
                        {
                            vector2 = -vector2;
                        }
                        vector2.y = 0f;
                        if (prop.m_position.x != 0f)
                        {
                            vector2   = Vector3.Normalize(vector2);
                            vector.x += vector2.z * prop.m_position.x;
                            vector.z -= vector2.x * prop.m_position.x;
                        }
                        float num6 = Mathf.Atan2(vector2.x, 0f - vector2.z);
                        if (prop.m_cornerAngle != 0f || prop.m_position.x != 0f)
                        {
                            float num7 = endAngle - startAngle;
                            if (num7 > (float)Math.PI)
                            {
                                num7 -= (float)Math.PI * 2f;
                            }
                            if (num7 < -(float)Math.PI)
                            {
                                num7 += (float)Math.PI * 2f;
                            }
                            float num8 = startAngle + num7 * num5;
                            num7 = num8 - num6;
                            if (num7 > (float)Math.PI)
                            {
                                num7 -= (float)Math.PI * 2f;
                            }
                            if (num7 < -(float)Math.PI)
                            {
                                num7 += (float)Math.PI * 2f;
                            }
                            num6 += num7 * prop.m_cornerAngle;
                            if (num7 != 0f && prop.m_position.x != 0f)
                            {
                                float num9 = Mathf.Tan(num7);
                                vector.x += vector2.x * num9 * prop.m_position.x;
                                vector.z += vector2.z * num9 * prop.m_position.x;
                            }
                        }
                        Vector4 objectIndex3 = (!(num5 > 0.5f)) ? objectIndex1 : objectIndex2;
                        num6 += prop.m_angle * ((float)Math.PI / 180f);
                        InstanceID id = default(InstanceID);
                        id.NetSegment = segmentID;
                        if (variation.m_requireWaterMap)
                        {
                            if (_HeightMap == null)
                            {
                                Singleton <TerrainManager> .instance.GetHeightMapping(Singleton <NetManager> .instance.m_segments.m_buffer[segmentID].m_middlePosition, out _HeightMap, out _HeightMapping, out _SurfaceMapping);
                            }
                            if (_HeightMap2 == null)
                            {
                                Singleton <TerrainManager> .instance.GetWaterMapping(Singleton <NetManager> .instance.m_segments.m_buffer[segmentID].m_middlePosition, out _HeightMap2, out _HeightMapping2, out _SurfaceMapping2);
                            }
#if UseTask
                            Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, variation, id, vector, scale, num6, color, objectIndex3, active: true, _HeightMap, _HeightMapping, _SurfaceMapping, _HeightMap2, _HeightMapping2, _SurfaceMapping2));
#else
                            PropInstance.RenderInstance(cameraInfo, variation, id, vector, scale, num6, color, objectIndex3, active: true, _HeightMap, _HeightMapping, _SurfaceMapping, _HeightMap2, _HeightMapping2, _SurfaceMapping2);
#endif
                        }
                        else if (!variation.m_requireHeightMap)
                        {
#if UseTask
                            Patcher.Dispatcher.Add(() => PropInstance.RenderInstance(cameraInfo, variation, id, vector, scale, num6, color, objectIndex3, active: true));
#else
                            PropInstance.RenderInstance(cameraInfo, variation, id, vector, scale, num6, color, objectIndex3, active: true);
#endif
                        }
                    }
                }
                TreeInfo finalTree = prop.m_finalTree;
                if (!(finalTree != null) || (layerMask & (1 << finalTree.m_prefabDataLayer)) == 0)
                {
                    continue;
                }
                Randomizer r2 = new Randomizer((int)laneID + i);
                for (int k = 1; k <= num2; k += 2)
                {
                    if (r2.Int32(100u) >= prop.m_probability)
                    {
                        continue;
                    }
                    float    t          = num4 + (float)k / (float)num2;
                    TreeInfo variation2 = finalTree.GetVariation(ref r2);
                    float    scale2     = variation2.m_minScale + (float)r2.Int32(10000u) * (variation2.m_maxScale - variation2.m_minScale) * 0.0001f;
                    float    brightness = variation2.m_minBrightness + (float)r2.Int32(10000u) * (variation2.m_maxBrightness - variation2.m_minBrightness) * 0.0001f;
                    Vector3  position   = __instance.m_bezier.Position(t);
                    if (propIndex != -1)
                    {
                        position.y = (float)(int)data.m_extraData.GetUShort(num3++) * 0.015625f;
                    }
                    position.y += prop.m_position.y;
                    if (prop.m_position.x != 0f)
                    {
                        Vector3 vector3 = __instance.m_bezier.Tangent(t);
                        if (flag2)
                        {
                            vector3 = -vector3;
                        }
                        vector3.y   = 0f;
                        vector3     = Vector3.Normalize(vector3);
                        position.x += vector3.z * prop.m_position.x;
                        position.z -= vector3.x * prop.m_position.x;
                    }
#if UseTask
                    Patcher.Dispatcher.Add(() => TreeInstance.RenderInstance(cameraInfo, variation2, position, scale2, brightness, RenderManager.DefaultColorLocation));
#else
                    TreeInstance.RenderInstance(cameraInfo, variation2, position, scale2, brightness, RenderManager.DefaultColorLocation);
#endif
                }
            }
            return(false);
        }
Exemplo n.º 22
0
        public static void NetNodeRenderInstancePostfix(RenderManager.CameraInfo cameraInfo, ushort nodeID, ref RenderManager.Instance data)
        {
            if (data.m_nextInstance != ushort.MaxValue)
            {
                return;
            }

            if (!TryGetMarkup(nodeID, out Markup markup))
            {
                return;
            }

            if ((cameraInfo.m_layerMask & (3 << 24)) == 0)
            {
                return;
            }

            if (!cameraInfo.CheckRenderDistance(data.m_position, UI.Settings.RenderDistance))
            {
                return;
            }

            if (markup.NeedRecalculateBatches)
            {
                markup.NeedRecalculateBatches = false;
                markup.RecalculateBatches();
            }

            var instance      = PropManager;
            var materialBlock = instance.m_materialBlock;

            var renderBatches = markup.RenderBatches;

            foreach (var batch in renderBatches)
            {
                materialBlock.Clear();
                materialBlock.SetVectorArray(instance.ID_PropLocation, batch.Locations);
                materialBlock.SetVectorArray(instance.ID_PropObjectIndex, batch.Indices);
                materialBlock.SetVectorArray(instance.ID_PropColor, batch.Colors);
                materialBlock.SetVector(RenderHelper.ID_DecalSize, batch.Size);

                var mesh     = batch.Mesh;
                var material = Material;

                Graphics.DrawMesh(mesh, Matrix4x4.identity, material, 10, null, 0, materialBlock);
            }
        }
Exemplo n.º 23
0
 public static bool Prefix(BuildingAI __instance, RenderManager.CameraInfo cameraInfo, ushort buildingID, ref Building data, int layerMask, ref RenderManager.Instance instance)
 {
     __instance.m_info.m_rendered = true;
     if (__instance.m_info.m_mesh != null)
     {
         BuildingAI.RenderMesh(cameraInfo, buildingID, ref data, __instance.m_info, ref instance);
     }
     if (__instance.m_info.m_subMeshes != null)
     {
         for (int i = 0; i < __instance.m_info.m_subMeshes.Length; i++)
         {
             BuildingInfo.MeshInfo meshInfo = __instance.m_info.m_subMeshes[i];
             if (((meshInfo.m_flagsRequired | meshInfo.m_flagsForbidden) & data.m_flags) == meshInfo.m_flagsRequired)
             {
                 BuildingInfoSub buildingInfoSub = meshInfo.m_subInfo as BuildingInfoSub;
                 buildingInfoSub.m_rendered = true;
                 if (buildingInfoSub.m_subMeshes != null && buildingInfoSub.m_subMeshes.Length != 0)
                 {
                     for (int j = 0; j < buildingInfoSub.m_subMeshes.Length; j++)
                     {
                         BuildingInfo.MeshInfo meshInfo2 = buildingInfoSub.m_subMeshes[j];
                         if (((meshInfo2.m_flagsRequired | meshInfo2.m_flagsForbidden) & data.m_flags) == meshInfo2.m_flagsRequired)
                         {
                             BuildingInfoSub buildingInfoSub2 = meshInfo2.m_subInfo as BuildingInfoSub;
                             buildingInfoSub2.m_rendered = true;
                             BuildingAI.RenderMesh(cameraInfo, __instance.m_info, buildingInfoSub2, meshInfo.m_matrix, ref instance);
                         }
                     }
                 }
                 else
                 {
                     BuildingAI.RenderMesh(cameraInfo, __instance.m_info, buildingInfoSub, meshInfo.m_matrix, ref instance);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 24
0
        public void RefreshJunctionData(ushort nodeID, int segmentIndex, ushort nodeSegment, Vector3 centerPos, ref uint instanceIndex, ref RenderManager.Instance data)
        {
            NetNode    thisNode = NetManager.instance.m_nodes.m_buffer[nodeID];
            NetManager instance = Singleton <NetManager> .instance;

            data.m_position    = thisNode.m_position;
            data.m_rotation    = Quaternion.identity;
            data.m_initialized = true;
            float      vScale          = 0.05f;
            Vector3    zero            = Vector3.zero;
            Vector3    zero2           = Vector3.zero;
            Vector3    zero3           = Vector3.zero;
            Vector3    zero4           = Vector3.zero;
            Vector3    vector          = Vector3.zero;
            Vector3    vector2         = Vector3.zero;
            Vector3    a               = Vector3.zero;
            Vector3    a2              = Vector3.zero;
            Vector3    zero5           = Vector3.zero;
            Vector3    zero6           = Vector3.zero;
            Vector3    zero7           = Vector3.zero;
            Vector3    zero8           = Vector3.zero;
            NetSegment netSegment      = instance.m_segments.m_buffer[(int)nodeSegment];
            NetInfo    info            = netSegment.Info;
            ItemClass  connectionClass = info.GetConnectionClass();
            Vector3    vector3         = (nodeID != netSegment.m_startNode) ? netSegment.m_endDirection : netSegment.m_startDirection;
            float      num             = -4f;
            float      num2            = -4f;
            ushort     num3            = 0;
            ushort     num4            = 0;

            for (int i = 0; i < 8; i++)
            {
                ushort segment = thisNode.GetSegment(i);
                if (segment != 0 && segment != nodeSegment)
                {
                    NetInfo   info2            = instance.m_segments.m_buffer[(int)segment].Info;
                    ItemClass connectionClass2 = info2.GetConnectionClass();
                    if (connectionClass.m_service == connectionClass2.m_service)
                    {
                        NetSegment netSegment2 = instance.m_segments.m_buffer[(int)segment];
                        Vector3    vector4     = (nodeID != netSegment2.m_startNode) ? netSegment2.m_endDirection : netSegment2.m_startDirection;
                        float      num5        = vector3.x * vector4.x + vector3.z * vector4.z;
                        if (vector4.z * vector3.x - vector4.x * vector3.z < 0f)
                        {
                            if (num5 > num)
                            {
                                num  = num5;
                                num3 = segment;
                            }
                            num5 = -2f - num5;
                            if (num5 > num2)
                            {
                                num2 = num5;
                                num4 = segment;
                            }
                        }
                        else
                        {
                            if (num5 > num2)
                            {
                                num2 = num5;
                                num4 = segment;
                            }
                            num5 = -2f - num5;
                            if (num5 > num)
                            {
                                num  = num5;
                                num3 = segment;
                            }
                        }
                    }
                }
            }
            bool start = netSegment.m_startNode == nodeID;
            bool flag;

            netSegment.CalculateCorner(nodeSegment, true, start, false, out zero, out zero3, out flag);
            netSegment.CalculateCorner(nodeSegment, true, start, true, out zero2, out zero4, out flag);
            if (num3 != 0 && num4 != 0)
            {
                float num6 = info.m_pavementWidth / info.m_halfWidth * 0.5f;
                float y    = 1f;
                if (num3 != 0)
                {
                    NetSegment netSegment3 = instance.m_segments.m_buffer[(int)num3];
                    NetInfo    info3       = netSegment3.Info;
                    start = (netSegment3.m_startNode == nodeID);
                    netSegment3.CalculateCorner(num3, true, start, true, out vector, out a, out flag);
                    netSegment3.CalculateCorner(num3, true, start, false, out vector2, out a2, out flag);
                    float num7 = info3.m_pavementWidth / info3.m_halfWidth * 0.5f;
                    num6 = (num6 + num7) * 0.5f;
                    y    = 2f * info.m_halfWidth / (info.m_halfWidth + info3.m_halfWidth);
                }
                float num8 = info.m_pavementWidth / info.m_halfWidth * 0.5f;
                float w    = 1f;
                if (num4 != 0)
                {
                    NetSegment netSegment4 = instance.m_segments.m_buffer[(int)num4];
                    NetInfo    info4       = netSegment4.Info;
                    start = (netSegment4.m_startNode == nodeID);
                    netSegment4.CalculateCorner(num4, true, start, true, out zero5, out zero7, out flag);
                    netSegment4.CalculateCorner(num4, true, start, false, out zero6, out zero8, out flag);
                    float num9 = info4.m_pavementWidth / info4.m_halfWidth * 0.5f;
                    num8 = (num8 + num9) * 0.5f;
                    w    = 2f * info.m_halfWidth / (info.m_halfWidth + info4.m_halfWidth);
                }
                Vector3 vector5;
                Vector3 vector6;
                NetSegment.CalculateMiddlePoints(zero, -zero3, vector, -a, true, true, out vector5, out vector6);
                Vector3 vector7;
                Vector3 vector8;
                NetSegment.CalculateMiddlePoints(zero2, -zero4, vector2, -a2, true, true, out vector7, out vector8);
                Vector3 vector9;
                Vector3 vector10;
                NetSegment.CalculateMiddlePoints(zero, -zero3, zero5, -zero7, true, true, out vector9, out vector10);
                Vector3 vector11;
                Vector3 vector12;
                NetSegment.CalculateMiddlePoints(zero2, -zero4, zero6, -zero8, true, true, out vector11, out vector12);

                data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(zero, vector5, vector6, vector, zero, vector5, vector6, vector, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(zero2, vector7, vector8, vector2, zero2, vector7, vector8, vector2, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(zero, vector9, vector10, zero5, zero, vector9, vector10, zero5, thisNode.m_position, vScale);
                data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(zero2, vector11, vector12, zero6, zero2, vector11, vector12, zero6, thisNode.m_position, vScale);
                data.m_dataVector0             = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
                data.m_dataVector1             = centerPos - data.m_position;

                if ((thisNode.m_flags & NetNode.Flags.Junction) == NetNode.Flags.None)
                {
                    data.m_dataVector1.w = (data.m_dataMatrix0.m33 + data.m_extraData.m_dataMatrix2.m33 + data.m_extraData.m_dataMatrix3.m33 + data.m_dataMatrix1.m33) * 0.25f;
                }
                else
                {
                    data.m_dataVector1.w = 0.01f;
                }

                data.m_dataVector2             = new Vector4(num6, y, num8, w);
                data.m_extraData.m_dataVector4 = RenderManager.GetColorLocation(65536u + (uint)nodeID);
            }
            else
            {
                centerPos.x = (zero.x + zero2.x) * 0.5f;
                centerPos.z = (zero.z + zero2.z) * 0.5f;
                vector      = zero2;
                vector2     = zero;
                a           = zero4;
                a2          = zero3;
                float   d        = Mathf.Min(info.m_halfWidth * 1.33333337f, 16f);
                Vector3 vector13 = zero - zero3 * d;
                Vector3 vector14 = vector - a * d;
                Vector3 vector15 = zero2 - zero4 * d;
                Vector3 vector16 = vector2 - a2 * d;
                Vector3 vector17 = zero + zero3 * d;
                Vector3 vector18 = vector + a * d;
                Vector3 vector19 = zero2 + zero4 * d;
                Vector3 vector20 = vector2 + a2 * d;
                data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(zero, vector13, vector14, vector, zero, vector13, vector14, vector, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(zero2, vector19, vector20, vector2, zero2, vector19, vector20, vector2, thisNode.m_position, vScale);
                data.m_extraData.m_dataMatrix3 = NetSegment.CalculateControlMatrix(zero, vector17, vector18, vector, zero, vector17, vector18, vector, thisNode.m_position, vScale);
                data.m_dataMatrix1             = NetSegment.CalculateControlMatrix(zero2, vector15, vector16, vector2, zero2, vector15, vector16, vector2, thisNode.m_position, vScale);
                data.m_dataMatrix0.SetRow(3, data.m_dataMatrix0.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_extraData.m_dataMatrix2.SetRow(3, data.m_extraData.m_dataMatrix2.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_extraData.m_dataMatrix3.SetRow(3, data.m_extraData.m_dataMatrix3.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_dataMatrix1.SetRow(3, data.m_dataMatrix1.GetRow(3) + new Vector4(0.2f, 0.2f, 0.2f, 0.2f));
                data.m_dataVector0             = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 0.5f - info.m_pavementWidth / info.m_halfWidth * 0.5f, info.m_pavementWidth / info.m_halfWidth * 0.5f);
                data.m_dataVector1             = centerPos - data.m_position;
                data.m_dataVector1.w           = (data.m_dataMatrix0.m33 + data.m_extraData.m_dataMatrix2.m33 + data.m_extraData.m_dataMatrix3.m33 + data.m_dataMatrix1.m33) * 0.25f;
                data.m_dataVector2             = new Vector4(info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f, info.m_pavementWidth / info.m_halfWidth * 0.5f, 1f);
                data.m_extraData.m_dataVector4 = RenderManager.GetColorLocation(65536u + (uint)nodeID);
            }
            data.m_dataInt0     = segmentIndex;
            data.m_dataColor0   = info.m_color;
            data.m_dataColor0.a = 0f;
            if (info.m_requireSurfaceMaps)
            {
                Singleton <TerrainManager> .instance.GetSurfaceMapping(data.m_position, out data.m_dataTexture0, out data.m_dataTexture1, out data.m_dataVector3);
            }
            instanceIndex = (uint)data.m_nextInstance;
        }
Exemplo n.º 25
0
    // NetNode
    // Token: 0x060034C5 RID: 13509 RVA: 0x0023CECC File Offset: 0x0023B2CC
    private void RefreshJunctionData(ushort nodeID, int segmentIndex, int segmentIndex2, NetInfo info, NetInfo info2, ushort segmentID, ushort segmentID2, ref uint instanceIndex, ref RenderManager.Instance data)
    {
        data.m_position    = this.m_position;
        data.m_rotation    = Quaternion.identity;
        data.m_initialized = true;
        float   vscale      = info.m_netAI.GetVScale();
        Vector3 CornerPos2L = Vector3.zero;
        Vector3 CornerPos2R = Vector3.zero;
        Vector3 CornerDir2L = Vector3.zero;
        Vector3 CornerDir2R = Vector3.zero;
        bool    startNode   = Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].m_startNode == nodeID;

        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].CalculateCorner(segmentID, true, startNode, false, out var CornerPosL, out var CornerDirL, out _);
        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].CalculateCorner(segmentID, true, startNode, true, out var CornerPosR, out var CornerDirR, out _);
        bool startNode2 = (Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID2].m_startNode == nodeID);

        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID2].CalculateCorner(segmentID2, true, startNode2, true, out CornerPos2L, out CornerDir2L, out _);
        Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID2].CalculateCorner(segmentID2, true, startNode2, false, out CornerPos2R, out CornerDir2R, out _);
        Vector3 b = (CornerPos2R - CornerPos2L) * (info.m_halfWidth / info2.m_halfWidth * 0.5f - 0.5f);

        CornerPos2L -= b;
        CornerPos2R += b;
        NetSegment.CalculateMiddlePoints(CornerPosL, -CornerDirL, CornerPos2L, -CornerDir2L, true, true, out var bpointL, out var cpointL);
        NetSegment.CalculateMiddlePoints(CornerPosR, -CornerDirR, CornerPos2R, -CornerDir2R, true, true, out var bpointR, out var cpointR);
        data.m_dataMatrix0             = NetSegment.CalculateControlMatrix(CornerPosL, bpointL, cpointL, CornerPos2L, CornerPosR, bpointR, cpointR, CornerPos2R, this.m_position, vscale);
        data.m_extraData.m_dataMatrix2 = NetSegment.CalculateControlMatrix(CornerPosR, bpointR, cpointR, CornerPos2R, CornerPosL, bpointL, cpointL, CornerPos2L, this.m_position, vscale);
        data.m_dataVector0             = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 1f, 1f);
        Vector4 colorLocation;
        Vector4 vector7;

        if (NetNode.BlendJunction(nodeID))
        {
            colorLocation = RenderManager.GetColorLocation(86016u + (uint)nodeID);
            vector7       = colorLocation;
        }
        else
        {
            colorLocation = RenderManager.GetColorLocation((uint)(49152 + segmentID));
            vector7       = RenderManager.GetColorLocation((uint)(49152 + segmentID2));
        }
        data.m_dataVector3  = new Vector4(colorLocation.x, colorLocation.y, vector7.x, vector7.y);
        data.m_dataInt0     = (8 | segmentIndex | segmentIndex2 << 4);
        data.m_dataColor0   = info.m_color;
        data.m_dataColor0.a = 0f;
        data.m_dataFloat0   = Singleton <WeatherManager> .instance.GetWindSpeed(data.m_position);

        if (info.m_requireSurfaceMaps)
        {
            Singleton <TerrainManager> .instance.GetSurfaceMapping(data.m_position, out data.m_dataTexture0, out data.m_dataTexture1, out data.m_dataVector1);
        }
        instanceIndex = (uint)data.m_nextInstance;
    }
Exemplo n.º 26
0
        public static bool RenderInstanceCommonBuildingAIPrefix(CommonBuildingAI __instance, RenderManager.CameraInfo cameraInfo, ushort buildingID, ref Building data, int layerMask, ref RenderManager.Instance instance)
        {
            if ((data.m_flags & (Building.Flags.Completed | Building.Flags.Collapsed)) != Building.Flags.Completed)
            {
                if ((data.m_flags & Building.Flags.Collapsed) != 0)
                {
                    uint           num        = (uint)(buildingID << 8) / 49152u;
                    uint           num2       = Singleton <SimulationManager> .instance.m_referenceFrameIndex - num;
                    float          t          = ((float)(double)(num2 & 0xFF) + Singleton <SimulationManager> .instance.m_referenceTimer) * 0.00390625f;
                    Building.Frame frameData  = data.GetFrameData(num2 - 512);
                    Building.Frame frameData2 = data.GetFrameData(num2 - 256);
                    instance.m_dataVector0.x = Mathf.Max(0f, (Mathf.Lerp((int)frameData.m_fireDamage, (int)frameData2.m_fireDamage, t) - 127f) * 0.0078125f);
                    instance.m_dataVector0.y = 0f;
                    instance.m_dataVector0.z = (((data.m_flags & Building.Flags.Abandoned) == 0) ? 0f : 1f);
                    float      num3       = 0f;
                    Randomizer randomizer = new Randomizer(buildingID);
                    int        num4       = randomizer.Int32(4u);
                    if (frameData.m_constructState != 0)
                    {
                        float y    = __instance.m_info.m_size.y;
                        float num5 = (float)GetCollapseTimeReverse(__instance);
                        num5 /= Mathf.Max(1f, num5 - 6f);
                        float num6 = Mathf.Lerp((int)frameData.m_constructState, (int)frameData2.m_constructState, t) * 0.003921569f;
                        num3 = 1f - num5 * (1f - num6);
                        instance.m_dataVector0.y = Mathf.Max(instance.m_dataVector0.y, y * num3);
                        if (instance.m_dataVector0.y > 0.1f)
                        {
                            __instance.RenderProps(cameraInfo, buildingID, ref data, layerMask, ref instance, renderFixed: false, renderNonfixed: true);
                            float      angle      = data.m_angle;
                            Vector3    position   = instance.m_position;
                            Quaternion rotation   = instance.m_rotation;
                            Matrix4x4  dataMatrix = instance.m_dataMatrix1;
                            float      f          = (float)randomizer.Int32(1000u) * ((float)Math.PI / 500f);
                            float      num7       = randomizer.Int32(10, 45);
                            float      angle2     = (1f - num3) * (1f - num3) * num7;
                            Vector3    axis       = new Vector3(Mathf.Cos(f), 0f, Mathf.Sin(f));
                            float      num8       = (y - instance.m_dataVector0.y) * (y - instance.m_dataVector0.y) / y;
                            instance.m_position.x += axis.z * num8 * num7 * 0.01f;
                            instance.m_position.z -= axis.x * num8 * num7 * 0.01f;
                            instance.m_position.y -= num8;
                            instance.m_rotation    = Quaternion.AngleAxis(angle2, axis) * Quaternion.AngleAxis(angle * 57.29578f, Vector3.down);
                            instance.m_dataMatrix1.SetTRS(instance.m_position, instance.m_rotation, Vector3.one);
                            instance.m_dataVector0.y = y;
#if UseTask
                            var localData     = data;
                            var localInstance = instance;
                            Patcher.Dispatcher.Add(() => __instance.RenderMeshes(cameraInfo, buildingID, ref localData, layerMask, ref localInstance));
#else
                            __instance.RenderMeshes(cameraInfo, buildingID, ref data, layerMask, ref instance);
#endif
                            __instance.RenderProps(cameraInfo, buildingID, ref data, layerMask, ref instance, renderFixed: true, renderNonfixed: false);
                            instance.m_dataVector0.y = y - num8;
                            instance.m_position      = position;
                            instance.m_rotation      = rotation;
                            instance.m_dataMatrix1   = dataMatrix;
                        }
                        else if ((data.m_flags & Building.Flags.Demolishing) == 0)
                        {
                            RenderDestroyedPropsPrefix(__instance, cameraInfo, buildingID, ref data, layerMask, ref instance, renderFixed: false, renderNonfixed: true);
                        }
                    }
                    else if ((data.m_flags & Building.Flags.Demolishing) == 0)
                    {
                        RenderDestroyedPropsPrefix(__instance, cameraInfo, buildingID, ref data, layerMask, ref instance, renderFixed: false, renderNonfixed: true);
                    }
                    float num9 = Mathf.Clamp01(1f - num3);
                    instance.m_dataVector0.x = 0f - instance.m_dataVector0.x;
                    if ((data.m_flags & Building.Flags.Demolishing) == 0 && num9 > 0.01f)
                    {
                        BuildingInfoBase collapsedInfo = __instance.m_info.m_collapsedInfo;
                        if (__instance.m_info.m_mesh != null && collapsedInfo != null)
                        {
                            if (((1 << num4) & __instance.m_info.m_collapsedRotations) == 0)
                            {
                                num4 = ((num4 + 1) & 3);
                            }
                            Vector3 min   = __instance.m_info.m_generatedInfo.m_min;
                            Vector3 max   = __instance.m_info.m_generatedInfo.m_max;
                            float   num10 = (float)data.Width * 4f;
                            float   num11 = (float)data.Length * 4f;
                            float   num12 = Building.CalculateLocalMeshOffset(__instance.m_info, data.Length);
                            min = Vector3.Max(min - new Vector3(4f, 0f, 4f + num12), new Vector3(0f - num10, 0f, 0f - num11));
                            max = Vector3.Min(max + new Vector3(4f, 0f, 4f - num12), new Vector3(num10, 0f, num11));
                            Vector3    vector  = (min + max) * 0.5f;
                            Vector3    vector2 = max - min;
                            float      x       = (((num4 & 1) != 0) ? vector2.z : vector2.x) * num9 / Mathf.Max(1f, collapsedInfo.m_generatedInfo.m_size.x);
                            float      z       = (((num4 & 1) != 0) ? vector2.x : vector2.z) * num9 / Mathf.Max(1f, collapsedInfo.m_generatedInfo.m_size.z);
                            Quaternion q       = Quaternion.AngleAxis((float)num4 * 90f, Vector3.down);
                            instance.m_dataVector0.y = Mathf.Max(instance.m_dataVector0.y, collapsedInfo.m_generatedInfo.m_size.y);
                            Matrix4x4 matrix = Matrix4x4.TRS(new Vector3(vector.x, 0f, vector.z + num12), q, new Vector3(x, num9, z));
                            collapsedInfo.m_rendered = true;
#if UseTask
                            var localInstance = instance;
                            Patcher.Dispatcher.Add(() => BuildingAI.RenderMesh(cameraInfo, __instance.m_info, collapsedInfo, matrix, ref localInstance));
#else
                            BuildingAI.RenderMesh(cameraInfo, __instance.m_info, collapsedInfo, matrix, ref instance);
#endif
                        }
                    }
                    if (Singleton <InfoManager> .instance.CurrentMode == InfoManager.InfoMode.None)
                    {
#if UseTask
                        var localData = data;
                        Patcher.Dispatcher.Add(() => __instance.RenderCollapseEffect(cameraInfo, buildingID, ref localData, num3));
#else
                        __instance.RenderCollapseEffect(cameraInfo, buildingID, ref data, num3);
#endif
                    }
                    return(false);
                }
                uint           num13      = (uint)(buildingID << 8) / 49152u;
                uint           num14      = Singleton <SimulationManager> .instance.m_referenceFrameIndex - num13;
                float          t2         = ((float)(double)(num14 & 0xFF) + Singleton <SimulationManager> .instance.m_referenceTimer) * 0.00390625f;
                Building.Frame frameData3 = data.GetFrameData(num14 - 512);
                Building.Frame frameData4 = data.GetFrameData(num14 - 256);
                float          num15      = 0f;
                BuildingInfo   buildingInfo;
                BuildingInfo   buildingInfo2;
                if ((data.m_flags & Building.Flags.Upgrading) != 0)
                {
                    BuildingInfo upgradeInfo = __instance.GetUpgradeInfo(buildingID, ref data);
                    if (upgradeInfo != null)
                    {
                        buildingInfo  = __instance.m_info;
                        buildingInfo2 = upgradeInfo;
                    }
                    else
                    {
                        buildingInfo  = null;
                        buildingInfo2 = __instance.m_info;
                    }
                }
                else
                {
                    buildingInfo  = null;
                    buildingInfo2 = __instance.m_info;
                }
                float num16 = buildingInfo2.m_size.y;
                if (buildingInfo != null)
                {
                    num16 = Mathf.Max(num16, buildingInfo.m_size.y);
                }
                float num17 = (float)GetConstructionTimeReverse(__instance);
                num17 /= Mathf.Max(1f, num17 - 6f);
                float num18 = Mathf.Max(0.5f, num16 / 60f);
                float num19 = Mathf.Ceil(num16 / num18 / 6f) * 6f;
                float num20 = (num19 * 2f + 6f) * num17 * Mathf.Lerp((int)frameData3.m_constructState, (int)frameData4.m_constructState, t2) * 0.003921569f;
                float num21 = (num20 - 6f) * num18;
                if (num21 >= buildingInfo2.m_size.y && instance.m_dataInt0 != buildingInfo2.m_prefabDataIndex)
                {
                    BuildingAI.RefreshInstance(buildingInfo2, cameraInfo, buildingID, ref data, layerMask, ref instance, requireHeightMap: false);
                }
                float num22 = (!(num20 > num19)) ? num20 : Mathf.Min(num19, num19 * 2f + 6f - num20);
                if (frameData4.m_productionState < frameData3.m_productionState)
                {
                    instance.m_dataVector3.w = Mathf.Lerp((int)frameData3.m_productionState, (float)(int)frameData4.m_productionState + 256f, t2) * 0.00390625f;
                    if (instance.m_dataVector3.w >= 1f)
                    {
                        instance.m_dataVector3.w -= 1f;
                    }
                }
                else
                {
                    instance.m_dataVector3.w = Mathf.Lerp((int)frameData3.m_productionState, (int)frameData4.m_productionState, t2) * 0.00390625f;
                }
                if (buildingInfo != null)
                {
                    instance.m_position = Building.CalculateMeshPosition(buildingInfo, data.m_position, data.m_angle, data.Length);
                    instance.m_rotation = Quaternion.AngleAxis(data.m_angle * 57.29578f, Vector3.down);
                    instance.m_dataMatrix1.SetTRS(instance.m_position, instance.m_rotation, Vector3.one);
                    instance.m_dataColor0 = buildingInfo.m_buildingAI.GetColor(buildingID, ref data, Singleton <InfoManager> .instance.CurrentMode);
                    float num23 = num20 * num18;
                    float num24 = (!(num23 > buildingInfo.m_size.y)) ? buildingInfo.m_size.y : (buildingInfo.m_size.y * 2f - num23);
                    if (num24 > 0f)
                    {
                        instance.m_dataVector0.y = 0f - num24;
                        instance.m_dataVector0.x = num22 * num18;
#if UseTask
                        var localData     = data;
                        var localInstance = instance;
                        Patcher.Dispatcher.Add(() => buildingInfo.m_buildingAI.RenderMeshes(cameraInfo, buildingID, ref localData, layerMask, ref localInstance));
#else
                        buildingInfo.m_buildingAI.RenderMeshes(cameraInfo, buildingID, ref data, layerMask, ref instance);
#endif
                        num15 = Mathf.Max(num15, instance.m_dataVector0.y);
                        if (instance.m_dataVector0.y >= buildingInfo.m_size.y && instance.m_dataInt0 == buildingInfo.m_prefabDataIndex)
                        {
                            layerMask &= ~(1 << Singleton <TreeManager> .instance.m_treeLayer);
                            buildingInfo.m_buildingAI.RenderProps(cameraInfo, buildingID, ref data, layerMask, ref instance, renderFixed: true, renderNonfixed: true);
                        }
                    }
                }
                float num25  = data.m_angle;
                int   length = data.Length;
                int   num26  = 0;
                if (buildingInfo != null && buildingInfo2 != null)
                {
                    if (buildingInfo.m_zoningMode == BuildingInfo.ZoningMode.CornerLeft && buildingInfo2.m_zoningMode == BuildingInfo.ZoningMode.CornerRight)
                    {
                        num25 -= (float)Math.PI / 2f;
                        num26  = -1;
                        length = data.Width;
                    }
                    else if (buildingInfo.m_zoningMode == BuildingInfo.ZoningMode.CornerRight && buildingInfo2.m_zoningMode == BuildingInfo.ZoningMode.CornerLeft)
                    {
                        num25 += (float)Math.PI / 2f;
                        num26  = 1;
                        length = data.Width;
                    }
                }
                instance.m_position = Building.CalculateMeshPosition(buildingInfo2, data.m_position, num25, length);
                instance.m_rotation = Quaternion.AngleAxis(num25 * 57.29578f, Vector3.down);
                instance.m_dataMatrix1.SetTRS(instance.m_position, instance.m_rotation, Vector3.one);
                instance.m_dataColor0 = buildingInfo2.m_buildingAI.GetColor(buildingID, ref data, Singleton <InfoManager> .instance.CurrentMode);
                if (num21 > 0f)
                {
                    instance.m_dataVector0.y = 0f - num21;
                    instance.m_dataVector0.x = num22 * num18;
#if UseTask
                    var localData     = data;
                    var localInstance = instance;
                    Patcher.Dispatcher.Add(() => buildingInfo2.m_buildingAI.RenderMeshes(cameraInfo, buildingID, ref localData, layerMask, ref localInstance));
#else
                    buildingInfo2.m_buildingAI.RenderMeshes(cameraInfo, buildingID, ref data, layerMask, ref instance);
#endif
                    num15 = Mathf.Max(num15, instance.m_dataVector0.y);
                    if (num21 >= buildingInfo2.m_size.y && instance.m_dataInt0 == buildingInfo2.m_prefabDataIndex)
                    {
                        layerMask &= ~(1 << Singleton <TreeManager> .instance.m_treeLayer);
                        buildingInfo2.m_buildingAI.RenderProps(cameraInfo, buildingID, ref data, layerMask, ref instance, renderFixed: true, renderNonfixed: true);
                    }
                }
                BuildingManager instance2 = Singleton <BuildingManager> .instance;
                if (instance2.m_common != null)
                {
                    BuildingInfoBase construction = instance2.m_common.m_construction;
                    Vector3          vector3      = buildingInfo2.m_generatedInfo.m_max;
                    Vector3          vector4      = buildingInfo2.m_generatedInfo.m_min;
                    if (buildingInfo != null)
                    {
                        Vector3 zero = Vector3.zero;
                        zero.z = 0f - Building.CalculateLocalMeshOffset(buildingInfo2, length);
                        switch (num26)
                        {
                        case -1:
                        {
                            zero.x -= Building.CalculateLocalMeshOffset(buildingInfo, data.Length);
                            Vector3 max3 = buildingInfo.m_generatedInfo.m_max;
                            Vector3 min3 = buildingInfo.m_generatedInfo.m_min;
                            vector3 = Vector3.Max(vector3, new Vector3(max3.z, max3.y, 0f - min3.x) - zero);
                            vector4 = Vector3.Min(vector4, new Vector3(min3.z, min3.y, 0f - max3.x) - zero);
                            break;
                        }

                        case 1:
                        {
                            zero.x += Building.CalculateLocalMeshOffset(buildingInfo, data.Length);
                            Vector3 max2 = buildingInfo.m_generatedInfo.m_max;
                            Vector3 min2 = buildingInfo.m_generatedInfo.m_min;
                            vector3 = Vector3.Max(vector3, new Vector3(max2.z, max2.y, max2.x) - zero);
                            vector4 = Vector3.Min(vector4, new Vector3(min2.z, min2.y, min2.x) - zero);
                            break;
                        }

                        default:
                            zero.z += Building.CalculateLocalMeshOffset(buildingInfo, data.Length);
                            vector3 = Vector3.Max(vector3, buildingInfo.m_generatedInfo.m_max - zero);
                            vector4 = Vector3.Min(vector4, buildingInfo.m_generatedInfo.m_min - zero);
                            break;
                        }
                    }
                    Vector3   vector5 = vector3 - vector4;
                    float     x2      = (vector5.x + 1f) / Mathf.Max(1f, construction.m_generatedInfo.m_size.x);
                    float     z2      = (vector5.z + 1f) / Mathf.Max(1f, construction.m_generatedInfo.m_size.z);
                    Matrix4x4 matrix2 = Matrix4x4.TRS(new Vector3((vector3.x + vector4.x) * 0.5f, 0f, (vector3.z + vector4.z) * 0.5f), s: new Vector3(x2, num18, z2), q: Quaternion.identity);
                    if (num22 > 0f)
                    {
                        instance.m_dataVector0.y = num22;
                        construction.m_rendered  = true;
#if UseTask
                        var localInstance = instance;
                        Patcher.Dispatcher.Add(() => BuildingAI.RenderMesh(cameraInfo, buildingInfo2, construction, matrix2, ref localInstance));
#else
                        BuildingAI.RenderMesh(cameraInfo, buildingInfo2, construction, matrix2, ref instance);
#endif
                        num15 = Mathf.Max(num15, instance.m_dataVector0.y);
                    }
                }
                instance.m_dataVector0.y = num15;
                return(false);
            }
            if (!__instance.m_hideGarbageBins)
            {
#if UseTask
                var localData     = data;
                var localInstance = instance;
                Patcher.Dispatcher.Add(() => __instance.RenderGarbageBins(cameraInfo, buildingID, ref localData, layerMask, ref localInstance));
#else
                __instance.RenderGarbageBins(cameraInfo, buildingID, ref data, layerMask, ref instance);
#endif
            }
            uint           num27      = (uint)(buildingID << 8) / 49152u;
            uint           num28      = Singleton <SimulationManager> .instance.m_referenceFrameIndex - num27;
            float          t3         = ((float)(double)(num28 & 0xFF) + Singleton <SimulationManager> .instance.m_referenceTimer) * 0.00390625f;
            Building.Frame frameData5 = data.GetFrameData(num28 - 512);
            Building.Frame frameData6 = data.GetFrameData(num28 - 256);
            instance.m_dataVector0.x = Mathf.Max(0f, (Mathf.Lerp((int)frameData5.m_fireDamage, (int)frameData6.m_fireDamage, t3) - 127f) * 0.0078125f);
            instance.m_dataVector0.z = (((data.m_flags & Building.Flags.Abandoned) == 0) ? 0f : 1f);
            if (frameData6.m_productionState < frameData5.m_productionState)
            {
                instance.m_dataVector3.w = Mathf.Lerp((int)frameData5.m_productionState, (float)(int)frameData6.m_productionState + 256f, t3) * 0.00390625f;
                if (instance.m_dataVector3.w >= 1f)
                {
                    instance.m_dataVector3.w -= 1f;
                }
            }
            else
            {
                instance.m_dataVector3.w = Mathf.Lerp((int)frameData5.m_productionState, (int)frameData6.m_productionState, t3) * 0.00390625f;
            }
            RenderInstanceBuildingAIPrefix(__instance, cameraInfo, buildingID, ref data, layerMask, ref instance);
            if (data.m_fireIntensity != 0 && Singleton <InfoManager> .instance.CurrentMode == InfoManager.InfoMode.None)
            {
#if UseTask
                var localData     = data;
                var localInstance = instance;
                var action        = new Action(() =>
                {
                    __instance.RenderFireEffect(cameraInfo, buildingID, ref localData, localInstance.m_dataVector0.x);
                    RenderFireEffectPropsReverse(__instance, cameraInfo, buildingID, ref localData, ref localInstance, (float)(int)localData.m_fireIntensity * 0.003921569f, localInstance.m_dataVector0.x, true, true);
                });
                Patcher.Dispatcher.Add(action);
#else
                __instance.RenderFireEffect(cameraInfo, buildingID, ref data, instance.m_dataVector0.x);
                RenderFireEffectPropsReverse(__instance, cameraInfo, buildingID, ref data, ref instance, (float)(int)data.m_fireIntensity * 0.003921569f, instance.m_dataVector0.x, true, true);
#endif
            }

            return(false);
        }
Exemplo n.º 27
0
 // NetNode
 // Token: 0x060034C1 RID: 13505 RVA: 0x0023A834 File Offset: 0x00238C34
 private void RenderInstance(RenderManager.CameraInfo cameraInfo, ushort nodeID, NetInfo info, int iter, NetNode.Flags flags, ref uint instanceIndex, ref RenderManager.Instance data)
 {
     if (data.m_dirty)
     {
         data.m_dirty = false;
         if (iter == 0)
         {
             if ((flags & NetNode.Flags.Junction) != NetNode.Flags.None)
             {
                 this.RefreshJunctionData(nodeID, info, instanceIndex);
             }
             else if ((flags & NetNode.Flags.Bend) != NetNode.Flags.None)
             {
                 this.RefreshBendData(nodeID, info, instanceIndex, ref data);
             }
             else if ((flags & NetNode.Flags.End) != NetNode.Flags.None)
             {
                 this.RefreshEndData(nodeID, info, instanceIndex, ref data);
             }
         }
     }
     if (data.m_initialized)
     {
         if ((flags & NetNode.Flags.Junction) != NetNode.Flags.None)
         {
             if ((data.m_dataInt0 & 8) != 0)
             {
                 ushort segment  = this.GetSegment(data.m_dataInt0 & 7);
                 ushort segment2 = this.GetSegment(data.m_dataInt0 >> 4);
                 if (segment != 0 && segment2 != 0)
                 {
                     NetManager instance = Singleton <NetManager> .instance;
                     info = instance.m_segments.m_buffer[(int)segment].Info;
                     NetInfo       info2  = instance.m_segments.m_buffer[(int)segment2].Info;
                     NetNode.Flags flags2 = flags;
                     if (((instance.m_segments.m_buffer[(int)segment].m_flags | instance.m_segments.m_buffer[(int)segment2].m_flags) & NetSegment.Flags.Collapsed) != NetSegment.Flags.None)
                     {
                         flags2 |= NetNode.Flags.Collapsed;
                     }
                     for (int i = 0; i < info.m_nodes.Length; i++)
                     {
                         NetInfo.Node node = info.m_nodes[i];
                         if (node.CheckFlags(flags2) && node.m_directConnect && (node.m_connectGroup == NetInfo.ConnectGroup.None || (node.m_connectGroup & info2.m_connectGroup & NetInfo.ConnectGroup.AllGroups) != NetInfo.ConnectGroup.None))
                         {
                             Vector4 dataVector  = data.m_dataVector3;
                             Vector4 dataVector2 = data.m_dataVector0;
                             if (node.m_requireWindSpeed)
                             {
                                 dataVector.w = data.m_dataFloat0;
                             }
                             if ((node.m_connectGroup & NetInfo.ConnectGroup.Oneway) != NetInfo.ConnectGroup.None)
                             {
                                 bool flag = instance.m_segments.m_buffer[(int)segment].m_startNode == nodeID == ((instance.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Invert) == NetSegment.Flags.None);
                                 if (info2.m_hasBackwardVehicleLanes != info2.m_hasForwardVehicleLanes || (node.m_connectGroup & NetInfo.ConnectGroup.Directional) != NetInfo.ConnectGroup.None)
                                 {
                                     bool flag2 = instance.m_segments.m_buffer[(int)segment2].m_startNode == nodeID == ((instance.m_segments.m_buffer[(int)segment2].m_flags & NetSegment.Flags.Invert) == NetSegment.Flags.None);
                                     if (flag == flag2)
                                     {
                                         goto IL_570;
                                     }
                                 }
                                 if (flag)
                                 {
                                     if ((node.m_connectGroup & NetInfo.ConnectGroup.OnewayStart) == NetInfo.ConnectGroup.None)
                                     {
                                         goto IL_570;
                                     }
                                 }
                                 else
                                 {
                                     if ((node.m_connectGroup & NetInfo.ConnectGroup.OnewayEnd) == NetInfo.ConnectGroup.None)
                                     {
                                         goto IL_570;
                                     }
                                     dataVector2.x = -dataVector2.x;
                                     dataVector2.y = -dataVector2.y;
                                 }
                             }
                             if (cameraInfo.CheckRenderDistance(data.m_position, node.m_lodRenderDistance))
                             {
                                 instance.m_materialBlock.Clear();
                                 instance.m_materialBlock.SetMatrix(instance.ID_LeftMatrix, data.m_dataMatrix0);
                                 instance.m_materialBlock.SetMatrix(instance.ID_RightMatrix, data.m_extraData.m_dataMatrix2);
                                 instance.m_materialBlock.SetVector(instance.ID_MeshScale, dataVector2);
                                 instance.m_materialBlock.SetVector(instance.ID_ObjectIndex, dataVector);
                                 instance.m_materialBlock.SetColor(instance.ID_Color, data.m_dataColor0);
                                 if (node.m_requireSurfaceMaps && data.m_dataTexture1 != null)
                                 {
                                     instance.m_materialBlock.SetTexture(instance.ID_SurfaceTexA, data.m_dataTexture0);
                                     instance.m_materialBlock.SetTexture(instance.ID_SurfaceTexB, data.m_dataTexture1);
                                     instance.m_materialBlock.SetVector(instance.ID_SurfaceMapping, data.m_dataVector1);
                                 }
                                 NetManager netManager = instance;
                                 netManager.m_drawCallData.m_defaultCalls = netManager.m_drawCallData.m_defaultCalls + 1;
                                 Graphics.DrawMesh(node.m_nodeMesh, data.m_position, data.m_rotation, node.m_nodeMaterial, node.m_layer, null, 0, instance.m_materialBlock);
                             }
                             else
                             {
                                 NetInfo.LodValue combinedLod = node.m_combinedLod;
                                 if (combinedLod != null)
                                 {
                                     if (node.m_requireSurfaceMaps && data.m_dataTexture0 != combinedLod.m_surfaceTexA)
                                     {
                                         if (combinedLod.m_lodCount != 0)
                                         {
                                             NetSegment.RenderLod(cameraInfo, combinedLod);
                                         }
                                         combinedLod.m_surfaceTexA    = data.m_dataTexture0;
                                         combinedLod.m_surfaceTexB    = data.m_dataTexture1;
                                         combinedLod.m_surfaceMapping = data.m_dataVector1;
                                     }
                                     combinedLod.m_leftMatrices[combinedLod.m_lodCount]  = data.m_dataMatrix0;
                                     combinedLod.m_rightMatrices[combinedLod.m_lodCount] = data.m_extraData.m_dataMatrix2;
                                     combinedLod.m_meshScales[combinedLod.m_lodCount]    = dataVector2;
                                     combinedLod.m_objectIndices[combinedLod.m_lodCount] = dataVector;
                                     combinedLod.m_meshLocations[combinedLod.m_lodCount] = data.m_position;
                                     combinedLod.m_lodMin = Vector3.Min(combinedLod.m_lodMin, data.m_position);
                                     combinedLod.m_lodMax = Vector3.Max(combinedLod.m_lodMax, data.m_position);
                                     if (++combinedLod.m_lodCount == combinedLod.m_leftMatrices.Length)
                                     {
                                         NetSegment.RenderLod(cameraInfo, combinedLod);
                                     }
                                 }
                             }
                         }
                         IL_570 :;
                     }
                 }
             }
             else
             {
                 ushort segment3 = this.GetSegment(data.m_dataInt0 & 7);
                 if (segment3 != 0)
                 {
                     NetManager instance2 = Singleton <NetManager> .instance;
                     info = instance2.m_segments.m_buffer[(int)segment3].Info;
                     for (int j = 0; j < info.m_nodes.Length; j++)
                     {
                         NetInfo.Node node2 = info.m_nodes[j];
                         if (node2.CheckFlags(flags) && !node2.m_directConnect)
                         {
                             Vector4 dataVector3 = data.m_extraData.m_dataVector4;
                             if (node2.m_requireWindSpeed)
                             {
                                 dataVector3.w = data.m_dataFloat0;
                             }
                             if (cameraInfo.CheckRenderDistance(data.m_position, node2.m_lodRenderDistance))
                             {
                                 instance2.m_materialBlock.Clear();
                                 instance2.m_materialBlock.SetMatrix(instance2.ID_LeftMatrix, data.m_dataMatrix0);
                                 instance2.m_materialBlock.SetMatrix(instance2.ID_RightMatrix, data.m_extraData.m_dataMatrix2);
                                 instance2.m_materialBlock.SetMatrix(instance2.ID_LeftMatrixB, data.m_extraData.m_dataMatrix3);
                                 instance2.m_materialBlock.SetMatrix(instance2.ID_RightMatrixB, data.m_dataMatrix1);
                                 instance2.m_materialBlock.SetVector(instance2.ID_MeshScale, data.m_dataVector0);
                                 instance2.m_materialBlock.SetVector(instance2.ID_CenterPos, data.m_dataVector1);
                                 instance2.m_materialBlock.SetVector(instance2.ID_SideScale, data.m_dataVector2);
                                 instance2.m_materialBlock.SetVector(instance2.ID_ObjectIndex, dataVector3);
                                 instance2.m_materialBlock.SetColor(instance2.ID_Color, data.m_dataColor0);
                                 if (node2.m_requireSurfaceMaps && data.m_dataTexture1 != null)
                                 {
                                     instance2.m_materialBlock.SetTexture(instance2.ID_SurfaceTexA, data.m_dataTexture0);
                                     instance2.m_materialBlock.SetTexture(instance2.ID_SurfaceTexB, data.m_dataTexture1);
                                     instance2.m_materialBlock.SetVector(instance2.ID_SurfaceMapping, data.m_dataVector3);
                                 }
                                 NetManager netManager2 = instance2;
                                 netManager2.m_drawCallData.m_defaultCalls = netManager2.m_drawCallData.m_defaultCalls + 1;
                                 Graphics.DrawMesh(node2.m_nodeMesh, data.m_position, data.m_rotation, node2.m_nodeMaterial, node2.m_layer, null, 0, instance2.m_materialBlock);
                             }
                             else
                             {
                                 NetInfo.LodValue combinedLod2 = node2.m_combinedLod;
                                 if (combinedLod2 != null)
                                 {
                                     if (node2.m_requireSurfaceMaps && data.m_dataTexture0 != combinedLod2.m_surfaceTexA)
                                     {
                                         if (combinedLod2.m_lodCount != 0)
                                         {
                                             NetNode.RenderLod(cameraInfo, combinedLod2);
                                         }
                                         combinedLod2.m_surfaceTexA    = data.m_dataTexture0;
                                         combinedLod2.m_surfaceTexB    = data.m_dataTexture1;
                                         combinedLod2.m_surfaceMapping = data.m_dataVector3;
                                     }
                                     combinedLod2.m_leftMatrices[combinedLod2.m_lodCount]    = data.m_dataMatrix0;
                                     combinedLod2.m_leftMatricesB[combinedLod2.m_lodCount]   = data.m_extraData.m_dataMatrix3;
                                     combinedLod2.m_rightMatrices[combinedLod2.m_lodCount]   = data.m_extraData.m_dataMatrix2;
                                     combinedLod2.m_rightMatricesB[combinedLod2.m_lodCount]  = data.m_dataMatrix1;
                                     combinedLod2.m_meshScales[combinedLod2.m_lodCount]      = data.m_dataVector0;
                                     combinedLod2.m_centerPositions[combinedLod2.m_lodCount] = data.m_dataVector1;
                                     combinedLod2.m_sideScales[combinedLod2.m_lodCount]      = data.m_dataVector2;
                                     combinedLod2.m_objectIndices[combinedLod2.m_lodCount]   = dataVector3;
                                     combinedLod2.m_meshLocations[combinedLod2.m_lodCount]   = data.m_position;
                                     combinedLod2.m_lodMin = Vector3.Min(combinedLod2.m_lodMin, data.m_position);
                                     combinedLod2.m_lodMax = Vector3.Max(combinedLod2.m_lodMax, data.m_position);
                                     if (++combinedLod2.m_lodCount == combinedLod2.m_leftMatrices.Length)
                                     {
                                         NetNode.RenderLod(cameraInfo, combinedLod2);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         else if ((flags & NetNode.Flags.End) != NetNode.Flags.None)
         {
             NetManager instance3 = Singleton <NetManager> .instance;
             for (int k = 0; k < info.m_nodes.Length; k++)
             {
                 NetInfo.Node node3 = info.m_nodes[k];
                 if (node3.CheckFlags(flags) && !node3.m_directConnect)
                 {
                     Vector4 dataVector4 = data.m_extraData.m_dataVector4;
                     if (node3.m_requireWindSpeed)
                     {
                         dataVector4.w = data.m_dataFloat0;
                     }
                     if (cameraInfo.CheckRenderDistance(data.m_position, node3.m_lodRenderDistance))
                     {
                         instance3.m_materialBlock.Clear();
                         instance3.m_materialBlock.SetMatrix(instance3.ID_LeftMatrix, data.m_dataMatrix0);
                         instance3.m_materialBlock.SetMatrix(instance3.ID_RightMatrix, data.m_extraData.m_dataMatrix2);
                         instance3.m_materialBlock.SetMatrix(instance3.ID_LeftMatrixB, data.m_extraData.m_dataMatrix3);
                         instance3.m_materialBlock.SetMatrix(instance3.ID_RightMatrixB, data.m_dataMatrix1);
                         instance3.m_materialBlock.SetVector(instance3.ID_MeshScale, data.m_dataVector0);
                         instance3.m_materialBlock.SetVector(instance3.ID_CenterPos, data.m_dataVector1);
                         instance3.m_materialBlock.SetVector(instance3.ID_SideScale, data.m_dataVector2);
                         instance3.m_materialBlock.SetVector(instance3.ID_ObjectIndex, dataVector4);
                         instance3.m_materialBlock.SetColor(instance3.ID_Color, data.m_dataColor0);
                         if (node3.m_requireSurfaceMaps && data.m_dataTexture1 != null)
                         {
                             instance3.m_materialBlock.SetTexture(instance3.ID_SurfaceTexA, data.m_dataTexture0);
                             instance3.m_materialBlock.SetTexture(instance3.ID_SurfaceTexB, data.m_dataTexture1);
                             instance3.m_materialBlock.SetVector(instance3.ID_SurfaceMapping, data.m_dataVector3);
                         }
                         NetManager netManager3 = instance3;
                         netManager3.m_drawCallData.m_defaultCalls = netManager3.m_drawCallData.m_defaultCalls + 1;
                         Graphics.DrawMesh(node3.m_nodeMesh, data.m_position, data.m_rotation, node3.m_nodeMaterial, node3.m_layer, null, 0, instance3.m_materialBlock);
                     }
                     else
                     {
                         NetInfo.LodValue combinedLod3 = node3.m_combinedLod;
                         if (combinedLod3 != null)
                         {
                             if (node3.m_requireSurfaceMaps && data.m_dataTexture0 != combinedLod3.m_surfaceTexA)
                             {
                                 if (combinedLod3.m_lodCount != 0)
                                 {
                                     NetNode.RenderLod(cameraInfo, combinedLod3);
                                 }
                                 combinedLod3.m_surfaceTexA    = data.m_dataTexture0;
                                 combinedLod3.m_surfaceTexB    = data.m_dataTexture1;
                                 combinedLod3.m_surfaceMapping = data.m_dataVector3;
                             }
                             combinedLod3.m_leftMatrices[combinedLod3.m_lodCount]    = data.m_dataMatrix0;
                             combinedLod3.m_leftMatricesB[combinedLod3.m_lodCount]   = data.m_extraData.m_dataMatrix3;
                             combinedLod3.m_rightMatrices[combinedLod3.m_lodCount]   = data.m_extraData.m_dataMatrix2;
                             combinedLod3.m_rightMatricesB[combinedLod3.m_lodCount]  = data.m_dataMatrix1;
                             combinedLod3.m_meshScales[combinedLod3.m_lodCount]      = data.m_dataVector0;
                             combinedLod3.m_centerPositions[combinedLod3.m_lodCount] = data.m_dataVector1;
                             combinedLod3.m_sideScales[combinedLod3.m_lodCount]      = data.m_dataVector2;
                             combinedLod3.m_objectIndices[combinedLod3.m_lodCount]   = dataVector4;
                             combinedLod3.m_meshLocations[combinedLod3.m_lodCount]   = data.m_position;
                             combinedLod3.m_lodMin = Vector3.Min(combinedLod3.m_lodMin, data.m_position);
                             combinedLod3.m_lodMax = Vector3.Max(combinedLod3.m_lodMax, data.m_position);
                             if (++combinedLod3.m_lodCount == combinedLod3.m_leftMatrices.Length)
                             {
                                 NetNode.RenderLod(cameraInfo, combinedLod3);
                             }
                         }
                     }
                 }
             }
         }
         else if ((flags & NetNode.Flags.Bend) != NetNode.Flags.None)
         {
             NetManager instance4 = Singleton <NetManager> .instance;
             for (int l = 0; l < info.m_segments.Length; l++)
             {
                 NetInfo.Segment segment4 = info.m_segments[l];
                 bool            flag3;
                 if (segment4.CheckFlags(info.m_netAI.GetBendFlags(nodeID, ref this), out flag3) && !segment4.m_disableBendNodes)
                 {
                     Vector4 dataVector5 = data.m_dataVector3;
                     Vector4 dataVector6 = data.m_dataVector0;
                     if (segment4.m_requireWindSpeed)
                     {
                         dataVector5.w = data.m_dataFloat0;
                     }
                     if (flag3)
                     {
                         dataVector6.x = -dataVector6.x;
                         dataVector6.y = -dataVector6.y;
                     }
                     if (cameraInfo.CheckRenderDistance(data.m_position, segment4.m_lodRenderDistance))
                     {
                         instance4.m_materialBlock.Clear();
                         instance4.m_materialBlock.SetMatrix(instance4.ID_LeftMatrix, data.m_dataMatrix0);
                         instance4.m_materialBlock.SetMatrix(instance4.ID_RightMatrix, data.m_extraData.m_dataMatrix2);
                         instance4.m_materialBlock.SetVector(instance4.ID_MeshScale, dataVector6);
                         instance4.m_materialBlock.SetVector(instance4.ID_ObjectIndex, dataVector5);
                         instance4.m_materialBlock.SetColor(instance4.ID_Color, data.m_dataColor0);
                         if (segment4.m_requireSurfaceMaps && data.m_dataTexture1 != null)
                         {
                             instance4.m_materialBlock.SetTexture(instance4.ID_SurfaceTexA, data.m_dataTexture0);
                             instance4.m_materialBlock.SetTexture(instance4.ID_SurfaceTexB, data.m_dataTexture1);
                             instance4.m_materialBlock.SetVector(instance4.ID_SurfaceMapping, data.m_dataVector1);
                         }
                         NetManager netManager4 = instance4;
                         netManager4.m_drawCallData.m_defaultCalls = netManager4.m_drawCallData.m_defaultCalls + 1;
                         Graphics.DrawMesh(segment4.m_segmentMesh, data.m_position, data.m_rotation, segment4.m_segmentMaterial, segment4.m_layer, null, 0, instance4.m_materialBlock);
                     }
                     else
                     {
                         NetInfo.LodValue combinedLod4 = segment4.m_combinedLod;
                         if (combinedLod4 != null)
                         {
                             if (segment4.m_requireSurfaceMaps && data.m_dataTexture0 != combinedLod4.m_surfaceTexA)
                             {
                                 if (combinedLod4.m_lodCount != 0)
                                 {
                                     NetSegment.RenderLod(cameraInfo, combinedLod4);
                                 }
                                 combinedLod4.m_surfaceTexA    = data.m_dataTexture0;
                                 combinedLod4.m_surfaceTexB    = data.m_dataTexture1;
                                 combinedLod4.m_surfaceMapping = data.m_dataVector1;
                             }
                             combinedLod4.m_leftMatrices[combinedLod4.m_lodCount]  = data.m_dataMatrix0;
                             combinedLod4.m_rightMatrices[combinedLod4.m_lodCount] = data.m_extraData.m_dataMatrix2;
                             combinedLod4.m_meshScales[combinedLod4.m_lodCount]    = dataVector6;
                             combinedLod4.m_objectIndices[combinedLod4.m_lodCount] = dataVector5;
                             combinedLod4.m_meshLocations[combinedLod4.m_lodCount] = data.m_position;
                             combinedLod4.m_lodMin = Vector3.Min(combinedLod4.m_lodMin, data.m_position);
                             combinedLod4.m_lodMax = Vector3.Max(combinedLod4.m_lodMax, data.m_position);
                             if (++combinedLod4.m_lodCount == combinedLod4.m_leftMatrices.Length)
                             {
                                 NetSegment.RenderLod(cameraInfo, combinedLod4);
                             }
                         }
                     }
                 }
             }
             for (int m = 0; m < info.m_nodes.Length; m++)
             {
                 ushort segment5 = this.GetSegment(data.m_dataInt0 & 7);
                 ushort segment6 = this.GetSegment(data.m_dataInt0 >> 4);
                 if (((instance4.m_segments.m_buffer[(int)segment5].m_flags | instance4.m_segments.m_buffer[(int)segment6].m_flags) & NetSegment.Flags.Collapsed) != NetSegment.Flags.None)
                 {
                     NetNode.Flags flags3 = flags | NetNode.Flags.Collapsed;
                 }
                 NetInfo.Node node4 = info.m_nodes[m];
                 if (node4.CheckFlags(flags) && node4.m_directConnect && (node4.m_connectGroup == NetInfo.ConnectGroup.None || (node4.m_connectGroup & info.m_connectGroup & NetInfo.ConnectGroup.AllGroups) != NetInfo.ConnectGroup.None))
                 {
                     Vector4 dataVector7 = data.m_dataVector3;
                     Vector4 dataVector8 = data.m_dataVector0;
                     if (node4.m_requireWindSpeed)
                     {
                         dataVector7.w = data.m_dataFloat0;
                     }
                     if ((node4.m_connectGroup & NetInfo.ConnectGroup.Oneway) != NetInfo.ConnectGroup.None)
                     {
                         bool flag4 = instance4.m_segments.m_buffer[(int)segment5].m_startNode == nodeID == ((instance4.m_segments.m_buffer[(int)segment5].m_flags & NetSegment.Flags.Invert) == NetSegment.Flags.None);
                         bool flag5 = instance4.m_segments.m_buffer[(int)segment6].m_startNode == nodeID == ((instance4.m_segments.m_buffer[(int)segment6].m_flags & NetSegment.Flags.Invert) == NetSegment.Flags.None);
                         if (flag4 == flag5)
                         {
                             goto IL_1637;
                         }
                         if (flag4)
                         {
                             if ((node4.m_connectGroup & NetInfo.ConnectGroup.OnewayStart) == NetInfo.ConnectGroup.None)
                             {
                                 goto IL_1637;
                             }
                         }
                         else
                         {
                             if ((node4.m_connectGroup & NetInfo.ConnectGroup.OnewayEnd) == NetInfo.ConnectGroup.None)
                             {
                                 goto IL_1637;
                             }
                             dataVector8.x = -dataVector8.x;
                             dataVector8.y = -dataVector8.y;
                         }
                     }
                     if (cameraInfo.CheckRenderDistance(data.m_position, node4.m_lodRenderDistance))
                     {
                         instance4.m_materialBlock.Clear();
                         instance4.m_materialBlock.SetMatrix(instance4.ID_LeftMatrix, data.m_dataMatrix0);
                         instance4.m_materialBlock.SetMatrix(instance4.ID_RightMatrix, data.m_extraData.m_dataMatrix2);
                         instance4.m_materialBlock.SetVector(instance4.ID_MeshScale, dataVector8);
                         instance4.m_materialBlock.SetVector(instance4.ID_ObjectIndex, dataVector7);
                         instance4.m_materialBlock.SetColor(instance4.ID_Color, data.m_dataColor0);
                         if (node4.m_requireSurfaceMaps && data.m_dataTexture1 != null)
                         {
                             instance4.m_materialBlock.SetTexture(instance4.ID_SurfaceTexA, data.m_dataTexture0);
                             instance4.m_materialBlock.SetTexture(instance4.ID_SurfaceTexB, data.m_dataTexture1);
                             instance4.m_materialBlock.SetVector(instance4.ID_SurfaceMapping, data.m_dataVector1);
                         }
                         NetManager netManager5 = instance4;
                         netManager5.m_drawCallData.m_defaultCalls = netManager5.m_drawCallData.m_defaultCalls + 1;
                         Graphics.DrawMesh(node4.m_nodeMesh, data.m_position, data.m_rotation, node4.m_nodeMaterial, node4.m_layer, null, 0, instance4.m_materialBlock);
                     }
                     else
                     {
                         NetInfo.LodValue combinedLod5 = node4.m_combinedLod;
                         if (combinedLod5 != null)
                         {
                             if (node4.m_requireSurfaceMaps && data.m_dataTexture0 != combinedLod5.m_surfaceTexA)
                             {
                                 if (combinedLod5.m_lodCount != 0)
                                 {
                                     NetSegment.RenderLod(cameraInfo, combinedLod5);
                                 }
                                 combinedLod5.m_surfaceTexA    = data.m_dataTexture0;
                                 combinedLod5.m_surfaceTexB    = data.m_dataTexture1;
                                 combinedLod5.m_surfaceMapping = data.m_dataVector1;
                             }
                             combinedLod5.m_leftMatrices[combinedLod5.m_lodCount]  = data.m_dataMatrix0;
                             combinedLod5.m_rightMatrices[combinedLod5.m_lodCount] = data.m_extraData.m_dataMatrix2;
                             combinedLod5.m_meshScales[combinedLod5.m_lodCount]    = dataVector8;
                             combinedLod5.m_objectIndices[combinedLod5.m_lodCount] = dataVector7;
                             combinedLod5.m_meshLocations[combinedLod5.m_lodCount] = data.m_position;
                             combinedLod5.m_lodMin = Vector3.Min(combinedLod5.m_lodMin, data.m_position);
                             combinedLod5.m_lodMax = Vector3.Max(combinedLod5.m_lodMax, data.m_position);
                             if (++combinedLod5.m_lodCount == combinedLod5.m_leftMatrices.Length)
                             {
                                 NetSegment.RenderLod(cameraInfo, combinedLod5);
                             }
                         }
                     }
                 }
                 IL_1637 :;
             }
         }
     }
     instanceIndex = (uint)data.m_nextInstance;
 }
Exemplo n.º 28
0
    public void RenderInstance(RenderManager.CameraInfo cameraInfo, ushort segmentID, uint laneID, NetInfo.Lane laneInfo, NetNode.Flags startFlags, NetNode.Flags endFlags, Color startColor, Color endColor, float startAngle, float endAngle, bool segmentInverted, int layerMask, Vector4 objectIndex1, Vector4 objectIndex2, ref RenderManager.Instance data, ref int propIndex)
    {
        NetLaneProps laneProps = laneInfo.m_laneProps;
        bool         backward  = (byte)(laneInfo.m_finalDirection & NetInfo.Direction.Both) == 2 || (byte)(laneInfo.m_finalDirection & NetInfo.Direction.AvoidBoth) == 11;
        bool         inverted  = backward != segmentInverted;

        if (backward)
        {
            NetNode.Flags flags = startFlags;
            startFlags = endFlags;
            endFlags   = flags;
            NetLaneProps.Prop prop = laneProps.m_props[0];
            float             num4 = prop.m_segmentOffset * 0.5f;
            num4 = Mathf.Clamp(num4 + prop.m_position.z / this.m_length, -0.5f, 0.5f);
            if (inverted)
            {
                num4 = -num4;
            }
        }
    }
Exemplo n.º 29
0
        private void RenderInstance(ref NetSegment This, RenderManager.CameraInfo cameraInfo, ushort segmentID, int layerMask, NetInfo info, ref RenderManager.Instance data)
        {
            NetManager instance = Singleton <NetManager> .instance;

            if (data.m_dirty)
            {
                data.m_dirty = false;
                Vector3 position  = instance.m_nodes.m_buffer[m_startNode].m_position;
                Vector3 position2 = instance.m_nodes.m_buffer[m_endNode].m_position;
                data.m_position     = (position + position2) * 0.5f;
                data.m_rotation     = Quaternion.identity;
                data.m_dataColor0   = info.m_color;
                data.m_dataColor0.a = 0f;
                data.m_dataFloat0   = Singleton <WeatherManager> .instance.GetWindSpeed(data.m_position);

                data.m_dataVector0 = new Vector4(0.5f / info.m_halfWidth, 1f / info.m_segmentLength, 1f, 1f);
                Vector4 colorLocation = RenderManager.GetColorLocation((uint)(49152 + segmentID));
                Vector4 vector        = colorLocation;
                if (NetNode.BlendJunction(m_startNode))
                {
                    colorLocation = RenderManager.GetColorLocation((uint)(86016 + m_startNode));
                }
                if (NetNode.BlendJunction(m_endNode))
                {
                    vector = RenderManager.GetColorLocation((uint)(86016 + m_endNode));
                }
                data.m_dataVector3 = new Vector4(colorLocation.x, colorLocation.y, vector.x, vector.y);
                if (info.m_segments == null || info.m_segments.Length == 0)
                {
                    if (info.m_lanes != null)
                    {
                        bool invert;
                        if ((m_flags & Flags.Invert) != 0)
                        {
                            invert = true;
                            instance.m_nodes.m_buffer[m_endNode].Info.m_netAI.GetNodeState(m_endNode, ref instance.m_nodes.m_buffer[m_endNode], segmentID, ref This, out _, out _);       // unused code
                            instance.m_nodes.m_buffer[m_startNode].Info.m_netAI.GetNodeState(m_startNode, ref instance.m_nodes.m_buffer[m_startNode], segmentID, ref This, out _, out _); // unused code
                        }
                        else
                        {
                            invert = false;
                            instance.m_nodes.m_buffer[m_startNode].Info.m_netAI.GetNodeState(m_startNode, ref instance.m_nodes.m_buffer[m_startNode], segmentID, ref This, out _, out _); // unused code
                            instance.m_nodes.m_buffer[m_endNode].Info.m_netAI.GetNodeState(m_endNode, ref instance.m_nodes.m_buffer[m_endNode], segmentID, ref This, out _, out _);       // unused code
                        }
                        float startAngle = (float)(int)m_cornerAngleStart * ((float)Math.PI / 128f);
                        float endAngle   = (float)(int)m_cornerAngleEnd * ((float)Math.PI / 128f);
                        int   propIndex  = 0;
                        uint  num        = m_lanes;
                        for (int i = 0; i < info.m_lanes.Length; i++)
                        {
                            if (num == 0)
                            {
                                break;
                            }
                            instance.m_lanes.m_buffer[num].RefreshInstance(num, info.m_lanes[i], startAngle, endAngle, invert, ref data, ref propIndex);
                            num = instance.m_lanes.m_buffer[num].m_nextLane;
                        }
                    }
                }
                else
                {
                    float vScale = info.m_netAI.GetVScale();
                    CalculateCorner(segmentID, heightOffset: true, start: true, leftSide: true, out var posSL, out var dirSL, out var smoothStart);
                    CalculateCorner(segmentID, heightOffset: true, start: false, leftSide: true, out var posEL, out var dirEL, out var smoothEnd);
                    CalculateCorner(segmentID, heightOffset: true, start: true, leftSide: false, out var posSR, out var dirSR, out smoothStart);
                    CalculateCorner(segmentID, heightOffset: true, start: false, leftSide: false, out var posER, out var dirER, out smoothEnd);
                    CalculateMiddlePoints(posSL, dirSL, posER, dirER, smoothStart, smoothEnd, out var b1, out var c1);
                    CalculateMiddlePoints(posSR, dirSR, posEL, dirEL, smoothStart, smoothEnd, out var b2, out var c2);
                    data.m_dataMatrix0 = CalculateControlMatrix(posSL, b1, c1, posER, posSR, b2, c2, posEL, data.m_position, vScale);
                    data.m_dataMatrix1 = CalculateControlMatrix(posSR, b2, c2, posEL, posSL, b1, c1, posER, data.m_position, vScale);
                }
                if (info.m_requireSurfaceMaps)
                {
                    Singleton <TerrainManager> .instance.GetSurfaceMapping(data.m_position, out data.m_dataTexture0, out data.m_dataTexture1, out data.m_dataVector1);
                }
                else if (info.m_requireHeightMap)
                {
                    Singleton <TerrainManager> .instance.GetHeightMapping(data.m_position, out data.m_dataTexture0, out data.m_dataVector1, out data.m_dataVector2);
                }
            }
            if (info.m_segments != null && (layerMask & info.m_netLayers) != 0)
            {
                for (int j = 0; j < info.m_segments.Length; j++)
                {
                    NetInfo.Segment segment = info.m_segments[j];
                    if (!segment.CheckFlags(m_flags, out var turnAround))
                    {
                        continue;
                    }
                    Vector4 objectIndex = data.m_dataVector3;
                    Vector4 meshScale   = data.m_dataVector0;
                    if (segment.m_requireWindSpeed)
                    {
                        objectIndex.w = data.m_dataFloat0;
                    }
                    if (turnAround)
                    {
                        meshScale.x = 0f - meshScale.x;
                        meshScale.y = 0f - meshScale.y;
                    }
                    if (cameraInfo.CheckRenderDistance(data.m_position, segment.m_lodRenderDistance))
                    {
                        instance.m_materialBlock.Clear();
                        instance.m_materialBlock.SetMatrix(instance.ID_LeftMatrix, data.m_dataMatrix0);
                        instance.m_materialBlock.SetMatrix(instance.ID_RightMatrix, data.m_dataMatrix1);
                        instance.m_materialBlock.SetVector(instance.ID_MeshScale, meshScale);
                        instance.m_materialBlock.SetVector(instance.ID_ObjectIndex, objectIndex);
                        instance.m_materialBlock.SetColor(instance.ID_Color, data.m_dataColor0);
                        if (segment.m_requireSurfaceMaps && data.m_dataTexture0 != null)
                        {
                            instance.m_materialBlock.SetTexture(instance.ID_SurfaceTexA, data.m_dataTexture0);
                            instance.m_materialBlock.SetTexture(instance.ID_SurfaceTexB, data.m_dataTexture1);
                            instance.m_materialBlock.SetVector(instance.ID_SurfaceMapping, data.m_dataVector1);
                        }
                        else if (segment.m_requireHeightMap && data.m_dataTexture0 != null)
                        {
                            instance.m_materialBlock.SetTexture(instance.ID_HeightMap, data.m_dataTexture0);
                            instance.m_materialBlock.SetVector(instance.ID_HeightMapping, data.m_dataVector1);
                            instance.m_materialBlock.SetVector(instance.ID_SurfaceMapping, data.m_dataVector2);
                        }
                        instance.m_drawCallData.m_defaultCalls++;
                        Graphics.DrawMesh(segment.m_segmentMesh, data.m_position, data.m_rotation, segment.m_segmentMaterial, segment.m_layer, null, 0, instance.m_materialBlock);
                        continue;
                    }
                    NetInfo.LodValue combinedLod = segment.m_combinedLod;
                    if (combinedLod == null)
                    {
                        continue;
                    }
                    if (segment.m_requireSurfaceMaps)
                    {
                        if (data.m_dataTexture0 != combinedLod.m_surfaceTexA)
                        {
                            if (combinedLod.m_lodCount != 0)
                            {
                                RenderLod(cameraInfo, combinedLod);
                            }
                            combinedLod.m_surfaceTexA    = data.m_dataTexture0;
                            combinedLod.m_surfaceTexB    = data.m_dataTexture1;
                            combinedLod.m_surfaceMapping = data.m_dataVector1;
                        }
                    }
                    else if (segment.m_requireHeightMap && data.m_dataTexture0 != combinedLod.m_heightMap)
                    {
                        if (combinedLod.m_lodCount != 0)
                        {
                            RenderLod(cameraInfo, combinedLod);
                        }
                        combinedLod.m_heightMap      = data.m_dataTexture0;
                        combinedLod.m_heightMapping  = data.m_dataVector1;
                        combinedLod.m_surfaceMapping = data.m_dataVector2;
                    }
                    ref Matrix4x4 reference = ref combinedLod.m_leftMatrices[combinedLod.m_lodCount];
                    reference = data.m_dataMatrix0;
                    ref Matrix4x4 reference2 = ref combinedLod.m_rightMatrices[combinedLod.m_lodCount];
                    reference2 = data.m_dataMatrix1;
                    combinedLod.m_meshScales[combinedLod.m_lodCount]    = meshScale;
                    combinedLod.m_objectIndices[combinedLod.m_lodCount] = objectIndex;
                    ref Vector4 reference3 = ref combinedLod.m_meshLocations[combinedLod.m_lodCount];
Exemplo n.º 30
0
        public void RenderInstance(
            RenderManager.CameraInfo cameraInfo,
            ushort segmentID, uint laneID, NetInfo.Lane laneInfo,
            NetNode.Flags startFlags, NetNode.Flags endFlags,
            Color startColor, Color endColor,
            float startAngle, float endAngle,
            bool invert, int layerMask,
            Vector4 objectIndex1, Vector4 objectIndex2, ref RenderManager.Instance data, ref int propIndex)
        {
            NetLaneProps laneProps = laneInfo.m_laneProps;

            if (laneProps != null && laneProps.m_props != null)
            {
                bool backward = (byte)(laneInfo.m_finalDirection & NetInfo.Direction.Both) == 2 || (byte)(laneInfo.m_finalDirection & NetInfo.Direction.AvoidBoth) == 11;
                bool reverse  = backward != invert;
                if (backward)  //swap
                {
                    NetNode.Flags flags = startFlags;
                    startFlags = endFlags;
                    endFlags   = flags;
                }
                Texture texture  = null;
                Vector4 zero     = Vector4.zero;
                Vector4 zero2    = Vector4.zero;
                Texture texture2 = null;
                Vector4 zero3    = Vector4.zero;
                Vector4 zero4    = Vector4.zero;
                int     nProps   = laneProps.m_props.Length;
                for (int i = 0; i < nProps; i++)
                {
                    NetLaneProps.Prop prop = laneProps.m_props[i];
                    if (this.m_length >= prop.m_minLength)
                    {
                        int repeatCountTimes2 = 2;
                        if (prop.m_repeatDistance > 1f)
                        {
                            repeatCountTimes2 *= Mathf.Max(1, Mathf.RoundToInt(this.m_length / prop.m_repeatDistance));
                        }
                        int currentPropIndex = propIndex;
                        if (propIndex != -1)
                        {
                            propIndex = currentPropIndex + (repeatCountTimes2 + 1) >> 1; // div 2
                        }
                        if (prop.CheckFlags(this.m_flags, startFlags, endFlags))
                        {
                            float halfSegmentOffset = prop.m_segmentOffset * 0.5f;
                            if (this.m_length != 0f)
                            {
                                halfSegmentOffset = Mathf.Clamp(halfSegmentOffset + prop.m_position.z / this.m_length, -0.5f, 0.5f);
                            }
                            if (reverse)
                            {
                                halfSegmentOffset = -halfSegmentOffset;
                            }
                            PropInfo finalProp = prop.m_finalProp;
                            if (finalProp != null && (layerMask & 1 << finalProp.m_prefabDataLayer) != 0)
                            {
                                Color      color      = (prop.m_colorMode != NetLaneProps.ColorMode.EndState) ? startColor : endColor;
                                Randomizer randomizer = new Randomizer((int)(laneID + (uint)i));
                                for (int j = 1; j <= repeatCountTimes2; j += 2)
                                {
                                    if (randomizer.Int32(100u) < prop.m_probability)
                                    {
                                        float    t         = halfSegmentOffset + (float)j / (float)repeatCountTimes2;
                                        PropInfo variation = finalProp.GetVariation(ref randomizer);
                                        float    scale     = variation.m_minScale + (float)randomizer.Int32(10000u) * (variation.m_maxScale - variation.m_minScale) * 0.0001f;
                                        if (prop.m_colorMode == NetLaneProps.ColorMode.Default)
                                        {
                                            color = variation.GetColor(ref randomizer);
                                        }
                                        Vector3 pos = this.m_bezier.Position(t);
                                        if (propIndex != -1)
                                        {
                                            pos.y = (float)data.m_extraData.GetUShort(currentPropIndex++) * 0.015625f;
                                        }
                                        pos.y += prop.m_position.y;
                                        if (cameraInfo.CheckRenderDistance(pos, variation.m_maxRenderDistance))
                                        {
                                            Vector3 tan = this.m_bezier.Tangent(t);
                                            if (tan != Vector3.zero)
                                            {
                                                if (reverse)
                                                {
                                                    tan = -tan;
                                                }
                                                Vector3 normalXZ = new Vector3 {
                                                    x = tan.z, z = -tan.x
                                                };
                                                if (prop.m_position.x != 0f)
                                                {
                                                    tan.Normalize();
                                                    normalXZ.Normalize();
                                                    pos += normalXZ * prop.m_position.x;
                                                }
                                                float normalAngle = Mathf.Atan2(normalXZ.z, normalXZ.x);
                                                if (prop.m_cornerAngle != 0f || prop.m_position.x != 0f)
                                                {
                                                    float angleDiff = endAngle - startAngle;
                                                    if (angleDiff > Mathf.PI)
                                                    {
                                                        angleDiff -= 2 * Mathf.PI;
                                                    }
                                                    if (angleDiff < -Mathf.PI)
                                                    {
                                                        angleDiff += 2 * Mathf.PI;
                                                    }
                                                    float currentAngle = startAngle + angleDiff * t;
                                                    float angle2       = currentAngle - normalAngle;
                                                    if (angle2 > Mathf.PI)
                                                    {
                                                        angle2 -= 2 * Mathf.PI;
                                                    }
                                                    if (angle2 < -Mathf.PI)
                                                    {
                                                        angle2 += 2 * Mathf.PI;
                                                    }
                                                    normalAngle += angle2 * prop.m_cornerAngle;
                                                    if (angle2 != 0f && prop.m_position.x != 0f)
                                                    {
                                                        float d = Mathf.Tan(angle2);
                                                        pos.x += tan.x * d * prop.m_position.x;
                                                        pos.z += tan.z * d * prop.m_position.x;
                                                    }
                                                }
                                                Vector4 objectIndex3 = (t <= 0.5f) ? objectIndex1 : objectIndex2;
                                                normalAngle += prop.m_angle * 0.0174532924f;
                                                InstanceID id = default(InstanceID);
                                                id.NetSegment = segmentID;
                                                if (variation.m_requireWaterMap)
                                                {
                                                    if (texture == null)
                                                    {
                                                        Singleton <TerrainManager> .instance.GetHeightMapping(Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].m_middlePosition, out texture, out zero, out zero2);
                                                    }
                                                    if (texture2 == null)
                                                    {
                                                        Singleton <TerrainManager> .instance.GetWaterMapping(Singleton <NetManager> .instance.m_segments.m_buffer[(int)segmentID].m_middlePosition, out texture2, out zero3, out zero4);
                                                    }
                                                    PropInstance.RenderInstance(cameraInfo, variation, id, pos, scale, normalAngle, color, objectIndex3, true, texture, zero, zero2, texture2, zero3, zero4);
                                                }
                                                else if (!variation.m_requireHeightMap)
                                                {
                                                    PropInstance.RenderInstance(cameraInfo, variation, id, pos, scale, normalAngle, color, objectIndex3, true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            TreeInfo finalTree = prop.m_finalTree;
                            if (finalTree != null && (layerMask & 1 << finalTree.m_prefabDataLayer) != 0)
                            {
                                Randomizer randomizer2 = new Randomizer((int)(laneID + (uint)i));
                                for (int k = 1; k <= repeatCountTimes2; k += 2)
                                {
                                    if (randomizer2.Int32(100u) < prop.m_probability)
                                    {
                                        float    t          = halfSegmentOffset + (float)k / (float)repeatCountTimes2;
                                        TreeInfo variation2 = finalTree.GetVariation(ref randomizer2);
                                        float    scale2     = variation2.m_minScale + (float)randomizer2.Int32(10000u) * (variation2.m_maxScale - variation2.m_minScale) * 0.0001f;
                                        float    brightness = variation2.m_minBrightness + (float)randomizer2.Int32(10000u) * (variation2.m_maxBrightness - variation2.m_minBrightness) * 0.0001f;
                                        Vector3  position   = this.m_bezier.Position(t);
                                        if (propIndex != -1)
                                        {
                                            position.y = (float)data.m_extraData.GetUShort(currentPropIndex++) * 0.015625f;
                                        }
                                        position.y += prop.m_position.y;
                                        if (prop.m_position.x != 0f)
                                        {
                                            Vector3 vector3 = this.m_bezier.Tangent(t);
                                            if (reverse)
                                            {
                                                vector3 = -vector3;
                                            }
                                            vector3.y   = 0f;
                                            vector3     = Vector3.Normalize(vector3);
                                            position.x += vector3.z * prop.m_position.x;
                                            position.z -= vector3.x * prop.m_position.x;
                                        }
                                        global::TreeInstance.RenderInstance(cameraInfo, variation2, position, scale2, brightness, RenderManager.DefaultColorLocation);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }