Exemplo n.º 1
0
 private void ReplaceWithTunnelCatenary(NetworkSkin skin, int l, int p)
 {
     skin.UpdateLaneProp(l, p, laneProp2 =>
     {
         laneProp2.m_prop      = _tunnelCatenary;
         laneProp2.m_finalProp = _tunnelCatenary;
         CatenaryUtils.CorrectCatenaryPropAngleAndPosition(laneProp2);
     });
 }
Exemplo n.º 2
0
        private void UpdateCatenaries(NetworkSkin skin)
        {
            if (skin.m_lanes == null)
            {
                return;
            }

            // TODO implement tunnel cats
            //var tunnelCatenary = CatenaryUtils.GetEndCatenary(Catenary);

            for (var l = 0; l < skin.m_lanes.Length; l++)
            {
                if (skin.m_lanes[l]?.m_laneProps?.m_props == null)
                {
                    continue;
                }

                for (var p = skin.m_lanes[l].m_laneProps.m_props.Length - 1; p >= 0; p--)
                {
                    var laneProp = skin.m_lanes[l].m_laneProps.m_props[p];
                    if (laneProp?.m_finalProp == null)
                    {
                        continue;
                    }

                    if (CatenaryUtils.IsNormalCatenaryProp(laneProp.m_finalProp) || CatenaryUtils.IsEndCatenaryProp(laneProp.m_finalProp))
                    {
                        if (Catenary == _endCatenary)
                        {
                            ReplaceWithNormalCatenary(skin, l, p);
                        }
                        else
                        {
                            // Start node catenary
                            if (laneProp.m_segmentOffset == -1f)
                            {
                                // Start-of-track node
                                if ((laneProp.m_startFlagsRequired & NetNode.Flags.End) != 0)
                                {
                                    ReplaceWithEndCatenary(skin, l, p);
                                }
                                // Mid-track node
                                else if ((laneProp.m_startFlagsForbidden & NetNode.Flags.End) != 0)
                                {
                                    ReplaceWithNormalCatenary(skin, l, p);
                                }
                                // Vanilla rail: Create separate lane prop for start-of-track
                                else
                                {
                                    skin.CopyAndUpdateLaneProp(l, p, laneProp2 =>
                                    {
                                        laneProp2.m_prop                = _endCatenary;
                                        laneProp2.m_finalProp           = _endCatenary;
                                        laneProp2.m_startFlagsRequired |= NetNode.Flags.End;
                                        CatenaryUtils.CorrectCatenaryPropAngleAndPosition(laneProp2);
                                    });
                                    skin.UpdateLaneProp(l, p, laneProp2 =>
                                    {
                                        laneProp2.m_prop                 = Catenary;
                                        laneProp2.m_finalProp            = Catenary;
                                        laneProp2.m_startFlagsForbidden |= NetNode.Flags.End;
                                        CatenaryUtils.CorrectCatenaryPropAngleAndPosition(laneProp2);
                                    });
                                }
                            }

                            // End node catenary
                            else if (laneProp.m_segmentOffset == 1f)
                            {
                                // End-of-track node
                                if ((laneProp.m_endFlagsRequired & NetNode.Flags.End) != 0)
                                {
                                    ReplaceWithEndCatenary(skin, l, p);
                                }
                                // Mid-track node
                                else if ((laneProp.m_endFlagsForbidden & NetNode.Flags.End) != 0)
                                {
                                    ReplaceWithNormalCatenary(skin, l, p);
                                }
                                // Vanilla rail: Create separate lane prop for end-of-track
                                else
                                {
                                    skin.CopyAndUpdateLaneProp(l, p, laneProp2 =>
                                    {
                                        laneProp2.m_prop              = _endCatenary;
                                        laneProp2.m_finalProp         = _endCatenary;
                                        laneProp2.m_endFlagsRequired |= NetNode.Flags.End;
                                        CatenaryUtils.CorrectCatenaryPropAngleAndPosition(laneProp2);
                                    });
                                    skin.UpdateLaneProp(l, p, laneProp2 =>
                                    {
                                        laneProp2.m_prop               = Catenary;
                                        laneProp2.m_finalProp          = Catenary;
                                        laneProp2.m_endFlagsForbidden |= NetNode.Flags.End;
                                        CatenaryUtils.CorrectCatenaryPropAngleAndPosition(laneProp2);
                                    });
                                }
                            }

                            // Mid-segment catenary
                            else
                            {
                                ReplaceWithNormalCatenary(skin, l, p);
                            }
                        }
                    }
                    else if (CatenaryUtils.IsTunnelCatenaryProp(laneProp.m_finalProp))
                    {
                        if (_tunnelCatenary != null)
                        {
                            ReplaceWithTunnelCatenary(skin, l, p);
                        }
                    }
                }
            }
        }