//public List<BridgePillarPropItem> pillarPropList { get; set; }
 //public PropInfo m_ElevatedPillarPropInfo { get; set; }
 public override void GetNodeBuilding(ushort nodeID, ref NetNode data, out BuildingInfo building, out float heightOffset)
 {
     if ((data.m_flags & NetNode.Flags.Outside) == NetNode.Flags.None)
     {
         if (this.m_middlePillarInfo != null && (data.m_flags & NetNode.Flags.Double) != NetNode.Flags.None)
         {
             building     = this.m_middlePillarInfo;
             heightOffset = this.m_middlePillarOffset - 1f - this.m_middlePillarInfo.m_generatedInfo.m_size.y;
             return;
         }
         if (this.m_bridgePillarInfo != null)
         {
             building     = this.m_bridgePillarInfo;
             heightOffset = this.m_bridgePillarOffset - 1f - this.m_bridgePillarInfo.m_generatedInfo.m_size.y;
             if (pillarList != null && pillarList.Count > 0)
             {
                 if (m_NetTool == null)
                 {
                     m_NetTool = FindObjectOfType <NetTool>();
                 }
                 if (m_NetTool != null)
                 {
                     var elevation = m_NetTool.GetElevation();
                     var theList   = pillarList.Where(d => d.HeightLimit >= elevation).OrderBy(x => x.HeightLimit).ToList();
                     if (theList == null || theList.Count == 0)
                     {
                         var thePillarInfo = pillarList.LastOrDefault();
                         building     = thePillarInfo.info;
                         heightOffset = thePillarInfo.HeightOffset - 1f - thePillarInfo.info.m_generatedInfo.m_size.y;
                     }
                     else
                     {
                         var thePillarInfo = theList.FirstOrDefault();
                         building     = thePillarInfo.info;
                         heightOffset = thePillarInfo.HeightOffset - 1f - thePillarInfo.info.m_generatedInfo.m_size.y;
                     }
                 }
             }
             return;
         }
     }
     base.GetNodeBuilding(nodeID, ref data, out building, out heightOffset);
 }
Example #2
0
        private void SetNetToolPrefab()
        {
            if (trackStyle == 0)
            {
                ToggleButtonPairs(btnModernStyle, btnClassicStyle);
            }
            else if (trackStyle == 1)
            {
                ToggleButtonPairs(btnClassicStyle, btnModernStyle);
            }

            btnSingleTrack.isVisible     = isStation == 0;
            btnDoubleTrack.isVisible     = isStation == 0;
            btnOneWay.isVisible          = isStation == 0;
            btnTwoWay.isVisible          = isStation == 0;
            m_useFenceCheckBox.isVisible = isStation == 0;
            m_useExtraElevatedPillarsCheckBox.isVisible = isStation == 0;

            btnSidePlatform.isVisible   = isStation == 1;
            btnIslandPlatform.isVisible = isStation == 1;
            btnSinglePlatform.isVisible = isStation == 1;

            if (isStation == 0)
            {
                ToggleButtonPairs(btnTrack, btnStation);
                if (trackSize == 0)
                {
                    ToggleButtonPairs(btnSingleTrack, btnDoubleTrack);
                }
                else if (trackSize == 1)
                {
                    ToggleButtonPairs(btnDoubleTrack, btnSingleTrack);
                }
                if (trackDirection == 0)
                {
                    ToggleButtonPairs(btnOneWay, btnTwoWay);
                }
                else if (trackDirection == 1)
                {
                    ToggleButtonPairs(btnTwoWay, btnOneWay);
                }
            }
            else if (isStation == 1)
            {
                ToggleButtonPairs(btnStation, btnTrack);
                if (stationType == 0)
                {
                    ToggleButtonPairs(btnSidePlatform, btnIslandPlatform, btnSinglePlatform);
                }
                else if (stationType == 1)
                {
                    ToggleButtonPairs(btnIslandPlatform, btnSidePlatform, btnSinglePlatform);
                }
                else if (stationType == 2)
                {
                    ToggleButtonPairs(btnSinglePlatform, btnIslandPlatform, btnSidePlatform);
                }
            }
            NetInfo prefab = null;

            switch (trackStyle)
            {
            case 0:
            {
                switch (isStation)
                {
                case 0:
                {
                    switch (trackSize)
                    {
                    case 0:
                    {
                        if (trackDirection == 0)
                        {
                            prefab = fence ? concreteSmallPrefab : concreteSmallPrefabNoBar;
                        }
                        else
                        {
                            prefab = fence ? concreteSmallTwoWayPrefab : concreteSmallTwoWayPrefabNoBar;
                        }
                    }
                    break;

                    case 1:
                    {
                        if (trackDirection == 0)
                        {
                            prefab = fence ? concreteTwoLaneOneWayPrefab : concreteTwoLaneOneWayPrefabNoBar;
                        }
                        else
                        {
                            prefab = fence ? concretePrefab : concretePrefabNoBar;
                        }
                    }
                    break;

                    case 2:
                    {
                        if (trackDirection == 0)
                        {
                        }
                        else
                        {
                            prefab = fence ? concreteLargePrefab : concreteLargePrefabNoBar;
                        }
                    }
                    break;
                    }
                    break;
                }

                case 1:
                {
                    switch (stationType)
                    {
                    case 0:
                        prefab = concreteSidePlatformStationPrefab;
                        break;

                    case 1:
                        prefab = concreteIslandPlatformStationPrefab;
                        break;

                    case 2:
                        prefab = concreteSinglePlatformStationPrefab;
                        break;
                    }
                }
                break;
                }
            }
            break;

            case 1:
            {
                switch (isStation)
                {
                case 0:
                {
                    switch (trackSize)
                    {
                    case 0:
                    {
                        if (trackDirection == 0)
                        {
                            prefab = fence ? steelSmallPrefab : steelSmallPrefabNoBar;
                        }
                        else
                        {
                            prefab = fence ? steelSmallTwoWayPrefab : steelSmallTwoWayPrefabNoBar;
                        }
                    }
                    break;

                    case 1:
                    {
                        if (trackDirection == 0)
                        {
                            prefab = fence ? steelTwoLaneOneWayPrefab : steelTwoLaneOneWayPrefabNoBar;
                        }
                        else
                        {
                            prefab = fence ? steelPrefab : steelPrefabNoBar;
                        }
                    }
                    break;

                    case 2:
                    {
                        if (trackDirection == 0)
                        {
                            //prefab = fence ? steelTwoLaneOneWayPrefab : steelTwoLaneOneWayPrefabNoBar;
                        }
                        else
                        {
                            prefab = fence ? steelLargePrefab : steelLargePrefabNoBar;
                        }
                    }
                    break;
                    }
                    break;
                }

                case 1:
                {
                    switch (stationType)
                    {
                    case 0:
                        prefab = steelSidePlatformStationPrefab;
                        break;

                    case 1:
                        prefab = steelIslandPlatformStationPrefab;
                        break;

                    case 2:
                        prefab = steelSinglePlatformStationPrefab;
                        break;
                    }
                }
                break;
                }
                break;
            }
            }
            if (prefab != null)
            {
                m_netTool.m_prefab = prefab;
                var elevation = m_netTool.GetElevation();
                var lanes     = m_netTool.m_prefab.m_lanes.ToList();
                Next.Debug.Log($"MOM EE lane count: {lanes.Count()}");
                var lane = lanes.FirstOrDefault(l => l.m_laneType == NetInfo.LaneType.None);
                NetLaneProps.Prop prop = null;
                if (lane != null)
                {
                    var propList = lane.m_laneProps.m_props?.ToList();
                    if (propList != null)
                    {
                        Next.Debug.Log($"MOM EE lane found with {propList.Count()} props");
                        prop = propList.FirstOrDefault(p => p.m_prop.name.ToLower().Contains("l pillar ("));
                        if (prop != null)
                        {
                            Next.Debug.Log($"MOM EE Examining aLane");
                            var name = prop.m_prop.name;
                            if (extraElevated)
                            {
                                prop.m_probability = 100;
                                Next.Debug.Log("MOM EE Enabled");
                            }
                            else
                            {
                                prop.m_probability = 0;
                                Next.Debug.Log("MOM EE Disabled");
                            }
                            var props = lane.m_laneProps.m_props?.ToList();
                            if (props != null)
                            {
                                var replacementPair = new KeyValuePair <string, PropInfo>(name, prop.m_prop);

                                if (props.Any(p => p.m_prop.name.ToLower().Contains(replacementPair.Key.ToLower())))
                                {
                                    var tempProp       = new NetLaneProps.Prop();
                                    var propsToReplace = props.Where(p => p.m_prop.name.ToLower().Contains(replacementPair.Key.ToLower())).ToList();
                                    for (var i = 0; i < propsToReplace.Count; i++)
                                    {
                                        tempProp = propsToReplace[i].ShallowClone();
                                        props.Remove(propsToReplace[i]);
                                        tempProp.m_prop = replacementPair.Value;
                                        props.Add(tempProp);
                                    }
                                }
                                lane.m_laneProps.m_props = props.ToArray();
                            }
                        }
                    }
                }
                m_netTool.m_prefab.m_lanes = lanes.ToArray();
            }
        }
        private void SetNetToolPrefab()
        {
            if (trackStyle == 0)
            {
                btnModernStyle.color           = new Color32(163, 255, 16, 255);
                btnModernStyle.normalBgSprite  = "ButtonMenuFocused";
                btnModernStyle.useDropShadow   = true;
                btnModernStyle.opacity         = 95;
                btnClassicStyle.color          = new Color32(150, 150, 150, 255);
                btnClassicStyle.normalBgSprite = "ButtonMenu";
                btnClassicStyle.useDropShadow  = false;
                btnClassicStyle.opacity        = 75;
            }
            else if (trackStyle == 1)
            {
                btnClassicStyle.color          = new Color32(163, 255, 16, 255);
                btnClassicStyle.normalBgSprite = "ButtonMenuFocused";
                btnClassicStyle.useDropShadow  = true;
                btnClassicStyle.opacity        = 95;
                btnModernStyle.color           = new Color32(150, 150, 150, 255);
                btnModernStyle.normalBgSprite  = "ButtonMenu";
                btnModernStyle.useDropShadow   = false;
                btnModernStyle.opacity         = 75;
            }
            if (trackSize == 0)
            {
                btnSingleTrack.color          = new Color32(163, 255, 16, 255);
                btnSingleTrack.normalBgSprite = "ButtonMenuFocused";
                btnSingleTrack.useDropShadow  = true;
                btnSingleTrack.opacity        = 95;
                btnDoubleTrack.color          = new Color32(150, 150, 150, 255);
                btnDoubleTrack.normalBgSprite = "ButtonMenu";
                btnDoubleTrack.useDropShadow  = false;
                btnDoubleTrack.opacity        = 75;
            }
            else if (trackSize == 1)
            {
                btnDoubleTrack.color          = new Color32(163, 255, 16, 255);
                btnDoubleTrack.normalBgSprite = "ButtonMenuFocused";
                btnDoubleTrack.useDropShadow  = true;
                btnDoubleTrack.opacity        = 95;
                btnSingleTrack.color          = new Color32(150, 150, 150, 255);
                btnSingleTrack.normalBgSprite = "ButtonMenu";
                btnSingleTrack.useDropShadow  = false;
                btnSingleTrack.opacity        = 75;
            }
            if (trackDirection == 0)
            {
                btnOneWay.color          = new Color32(163, 255, 16, 255);
                btnOneWay.normalBgSprite = "ButtonMenuFocused";
                btnOneWay.useDropShadow  = true;
                btnOneWay.opacity        = 95;
                btnTwoWay.color          = new Color32(150, 150, 150, 255);
                btnTwoWay.normalBgSprite = "ButtonMenu";
                btnOneWay.useDropShadow  = false;
                btnTwoWay.opacity        = 75;
            }
            else if (trackDirection == 1)
            {
                btnTwoWay.color          = new Color32(163, 255, 16, 255);
                btnTwoWay.normalBgSprite = "ButtonMenuFocused";
                btnTwoWay.useDropShadow  = true;
                btnTwoWay.opacity        = 95;
                btnOneWay.color          = new Color32(150, 150, 150, 255);
                btnOneWay.normalBgSprite = "ButtonMenu";
                btnOneWay.useDropShadow  = false;
                btnOneWay.opacity        = 75;
            }
            NetInfo prefab = null;

            switch (trackStyle)
            {
            case 0:
                switch (trackSize)
                {
                case 0:
                {
                    if (trackDirection == 0)
                    {
                        prefab = fence ? concreteSmallPrefab : concreteSmallPrefabNoBar;
                    }
                    else
                    {
                        prefab = fence ? concreteSmallTwoWayPrefab : concreteSmallTwoWayPrefabNoBar;
                    }
                }
                break;

                case 1:
                {
                    if (trackDirection == 0)
                    {
                        prefab = fence ? concreteTwoLaneOneWayPrefab : concreteTwoLaneOneWayPrefabNoBar;
                    }
                    else
                    {
                        prefab = fence ? concretePrefab : concretePrefabNoBar;
                    }
                }
                break;

                case 2:
                {
                    if (trackDirection == 0)
                    {
                    }
                    else
                    {
                        prefab = fence ? concreteLargePrefab : concreteLargePrefabNoBar;
                    }
                }
                break;
                }
                break;

            case 1:
                switch (trackSize)
                {
                case 0:
                {
                    if (trackDirection == 0)
                    {
                        prefab = fence ? steelSmallPrefab : steelSmallPrefabNoBar;
                    }
                    else
                    {
                        prefab = fence ? steelSmallTwoWayPrefab : steelSmallTwoWayPrefabNoBar;
                    }
                }
                break;

                case 1:
                {
                    if (trackDirection == 0)
                    {
                        prefab = fence ? steelTwoLaneOneWayPrefab : steelTwoLaneOneWayPrefabNoBar;
                    }
                    else
                    {
                        prefab = fence ? steelPrefab : steelPrefabNoBar;
                    }
                }
                break;

                case 2:
                {
                    if (trackDirection == 0)
                    {
                        //prefab = fence ? steelTwoLaneOneWayPrefab : steelTwoLaneOneWayPrefabNoBar;
                    }
                    else
                    {
                        prefab = fence ? steelLargePrefab : steelLargePrefabNoBar;
                    }
                }
                break;
                }
                break;
            }
            if (prefab != null)
            {
                m_netTool.m_prefab = prefab;
                var elevation = m_netTool.GetElevation();
                var lanes     = m_netTool.m_prefab.m_lanes.ToList();
                Next.Debug.Log($"MOM EE lane count: {lanes.Count()}");
                var lane = lanes.FirstOrDefault(l => l.m_laneType == NetInfo.LaneType.None);
                NetLaneProps.Prop prop = null;
                if (lane != null)
                {
                    var propList = lane.m_laneProps.m_props?.ToList();
                    if (propList != null)
                    {
                        Next.Debug.Log($"MOM EE lane found with {propList.Count()} props");
                        prop = propList.FirstOrDefault(p => p.m_prop.name.ToLower().Contains("l pillar ("));
                        if (prop != null)
                        {
                            Next.Debug.Log($"MOM EE Examining aLane");
                            var name = prop.m_prop.name;
                            if (extraElevated)
                            {
                                prop.m_probability = 100;
                                Next.Debug.Log("MOM EE Enabled");
                            }
                            else
                            {
                                prop.m_probability = 0;
                                Next.Debug.Log("MOM EE Disabled");
                            }
                            var props = lane.m_laneProps.m_props?.ToList();
                            if (props != null)
                            {
                                var replacementPair = new KeyValuePair <string, PropInfo>(name, prop.m_prop);

                                if (props.Any(p => p.m_prop.name.ToLower().Contains(replacementPair.Key.ToLower())))
                                {
                                    var tempProp       = new NetLaneProps.Prop();
                                    var propsToReplace = props.Where(p => p.m_prop.name.ToLower().Contains(replacementPair.Key.ToLower())).ToList();
                                    for (var i = 0; i < propsToReplace.Count; i++)
                                    {
                                        tempProp = propsToReplace[i].ShallowClone();
                                        props.Remove(propsToReplace[i]);
                                        tempProp.m_prop = replacementPair.Value;
                                        props.Add(tempProp);
                                    }
                                }
                                lane.m_laneProps.m_props = props.ToArray();
                            }
                        }
                    }
                }
                m_netTool.m_prefab.m_lanes = lanes.ToArray();
            }
        }
        public override void GetNodeBuilding(ushort nodeID, ref NetNode data, out BuildingInfo building, out float heightOffset)
        {
            if ((data.m_flags & NetNode.Flags.Outside) == NetNode.Flags.None)
            {
                if (this.m_middlePillarInfo != null && (data.m_flags & NetNode.Flags.Double) != NetNode.Flags.None)
                {
                    building     = this.m_middlePillarInfo;
                    heightOffset = this.m_middlePillarOffset - 1f - this.m_middlePillarInfo.m_generatedInfo.m_size.y;
                    return;
                }
                if (this.m_bridgePillarInfo != null)
                {
                    heightOffset = this.m_bridgePillarOffset - 1f - this.m_bridgePillarInfo.m_generatedInfo.m_size.y;
                    building     = m_bridgePillarInfo;
                    if (pillarList != null && pillarList.Count > 0)
                    {
                        if (m_NetTool == null)
                        {
                            m_NetTool = FindObjectOfType <NetTool>();
                        }
                        if (m_NetTool?.Prefab != null)
                        {
                            var elevation = m_NetTool.GetElevation();
                            var theList   = pillarList.Where(d => d.HeightLimit == 0 || d.HeightLimit >= elevation).OrderBy(x => x.HeightLimit).ToList();
                            BridgePillarItem thePillarInfo = null;
                            if (theList == null || theList.Count == 0)
                            {
                                thePillarInfo = pillarList.LastOrDefault();
                            }
                            else
                            {
                                thePillarInfo = theList.FirstOrDefault();
                            }
                            BuildingInfo info      = null;
                            BuildingInfo noColInfo = null;
                            if (m_NetTool.Prefab.name.Contains("Bridge"))
                            {
                                pillarType = PillarType.WideMedian;
                            }
                            switch (pillarType)
                            {
                            case PillarType.WideMedian:
                                info      = thePillarInfo.WideMedianInfo;
                                noColInfo = thePillarInfo.WideMedianInfoNoCol;
                                break;

                            case PillarType.Wide:
                                info      = thePillarInfo.WideInfo;
                                noColInfo = thePillarInfo.WideInfoNoCol;
                                break;

                            case PillarType.NarrowMedian:
                                info      = thePillarInfo.NarrowMedianInfo;
                                noColInfo = thePillarInfo.NarrowMedianInfoNoCol;
                                break;

                            case PillarType.Narrow:
                                info      = thePillarInfo.NarrowInfo;
                                noColInfo = thePillarInfo.NarrowInfoNoCol;
                                break;
                            }

                            var prefab = m_NetTool.Prefab;
                            if (NoPillarCollision && elevation >= 0)
                            {
                                building = noColInfo;
                                if (m_IntersectClass == null)
                                {
                                    m_IntersectClass = prefab.m_intersectClass;
                                }
                                prefab.m_intersectClass = null;
                            }
                            else
                            {
                                building = info;
                                if (m_IntersectClass != null)
                                {
                                    prefab.m_intersectClass = m_IntersectClass;
                                }
                            }
                            m_bridgePillarInfo = building;
                            if (thePillarInfo != null && info != null)
                            {
                                heightOffset = thePillarInfo.HeightOffset - 1f - info.m_generatedInfo.m_size.y;
                            }
                        }
                    }
                    return;
                }
            }
            base.GetNodeBuilding(nodeID, ref data, out building, out heightOffset);
        }