joaofarias / csl-traffic

A WIP mod for Cities: Skylines to improve traffic.
91 stars 30 forks source link

Removing wires on train tracks? #46

Open jtharpla opened 9 years ago

jtharpla commented 9 years ago

Would you guys be interested in including such a feature in a future Traffic++ release? I did some research on this and managed to make a track prefab without the catenary wires or gantries (poles):

    // Catenary wires are the last node / segment
    int nodeToRemove = trackPrefab.m_nodes.Length - 1;
    int segToRemove = trackPrefab.m_segments.Length - 1;
    trackPrefab.m_nodes[nodeToRemove] = null;
    trackPrefab.m_segments[segToRemove] = null;
    removeNull(ref trackPrefab.m_nodes);
    removeNull(ref trackPrefab.m_segments);

    // Gantries are props named "RailwayPowerline"
    foreach (NetInfo.Lane lane in trackPrefab.m_lanes)
    {
    FastList<NetLaneProps.Prop> proplist = new FastList<NetLaneProps.Prop>();
    foreach (NetLaneProps.Prop prop in lane.m_laneProps.m_props)
    {
        if (prop.m_prop.name == "RailwayPowerline") continue;
        proplist.Add(prop);
    }
    lane.m_laneProps.m_props = proplist.ToArray();
    proplist.Clear();
    proplist.Release();
    }

This was built off the way SomeRoads creates new roads. Problem is I can't figure out how to edit the existing prefabs (so that stations, existing track and the like are affected). Maybe this would be useful for you to start from? If not and I'm off base, no worries, I'll keep hacking on it -- just think it'd be cool to have a button to disable the wires now that there's diesel trains out there in the Workshop

joaofarias commented 9 years ago

I'm currently making huge changes to the mod to improve performance. When I'm done, I'll get back to you so we can finish this properly.

You should be able to edit the existing prefabs by changing the original prefab.