Skip to content

Commit 185e638

Browse files
committed
TMPE Version 1.7.9:
- In-game traffic light states are now correctly rendered when showing "yellow" - Removed negative effects on public transport usage - GUI: Traffic light states do not flicker anymore - Performance improvements
1 parent f1b930a commit 185e638

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+369
-141
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ A work-in-progress modification for **Cities: Skylines** to add additional traff
44
User manual: http://www.viathinksoft.de/tmpe
55

66
# Changelog
7+
1.7.9, 08/22/2016
8+
- In-game traffic light states are now correctly rendered when showing "yellow"
9+
- Removed negative effects on public transport usage
10+
- GUI: Traffic light states do not flicker anymore
11+
- Performance improvements
12+
713
1.7.8, 08/18/2016:
814
- Bugfix: Cims sometimes got stuck (thanks to all reports and especially to @Thilawyn for providing a savegame)
9-
- GUI: Improved traffic light arrow disply
15+
- GUI: Improved traffic light arrow display
1016
- Improved performance while saving
1117

1218
1.7.7, 08/16/2016:

TLM/TLM/Custom/AI/CustomAmbulanceAI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using ColossalFramework;
22
using System;
33
using System.Collections.Generic;
4-
using System.Linq;
54
using System.Text;
65
using TrafficManager.Custom.PathFinding;
76
using TrafficManager.Geometry;

TLM/TLM/Custom/AI/CustomBusAI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using ColossalFramework;
44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
76
using System.Text;
87
using TrafficManager.Custom.PathFinding;
98
using TrafficManager.Geometry;

TLM/TLM/Custom/AI/CustomCitizenAI.cs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using ColossalFramework.Math;
33
using System;
44
using System.Collections.Generic;
5-
using System.Linq;
65
using System.Text;
76
using TrafficManager.Custom.PathFinding;
87
using TrafficManager.State;
@@ -19,14 +18,14 @@ internal enum TransportMode {
1918
Taxi
2019
}
2120

22-
public static readonly int[] FREE_TRANSPORT_USAGE_PROBABILITY = { 90, 80, 50 };
21+
public static readonly int[] FREE_TRANSPORT_USAGE_PROBABILITY = { 95, 80, 50 };
2322
public static readonly int[] TRANSPORT_USAGE_PROBABILITY = { 50, 40, 30 };
24-
public static readonly int[] DAY_TAXI_USAGE_PROBABILITY = { 5, 10, 50 };
25-
public static readonly int[] NIGHT_TAXI_USAGE_PROBABILITY = { 10, 40, 70 };
23+
public static readonly int[] DAY_TAXI_USAGE_PROBABILITY = { 5, 25, 50 }; // if a taxi is available and assigned to this citizen, this probability kicks in
24+
public static readonly int[] NIGHT_TAXI_USAGE_PROBABILITY = { 25, 75, 100 }; // if a taxi is available and assigned to this citizen, this probability kicks in
2625

2726
internal static TransportMode[] currentTransportMode = new TransportMode[CitizenManager.MAX_INSTANCE_COUNT];
2827

29-
internal void OnLevelUnloading() {
28+
internal static void OnBeforeLoadData() {
3029
for (int i = 0; i < currentTransportMode.Length; ++i)
3130
currentTransportMode[i] = TransportMode.None;
3231
}
@@ -39,6 +38,7 @@ public bool CustomStartPathFind(ushort instanceID, ref CitizenInstance citizenDa
3938

4039
SimulationManager simManager = Singleton<SimulationManager>.instance;
4140
Citizen.Wealth wealthLevel = citMan.m_citizens.m_buffer[citizenData.m_citizen].WealthLevel;
41+
4242
bool couldUseTaxi = false; // could cim use a taxi if it was not forbidden because of randomization?
4343
bool couldUseCar = false;
4444
bool couldUseBike = false;
@@ -51,9 +51,14 @@ public bool CustomStartPathFind(ushort instanceID, ref CitizenInstance citizenDa
5151
Singleton<DistrictManager>.instance.m_districts.m_buffer[0].m_productionData.m_finalTaxiCapacity != 0u) {
5252
couldUseTaxi = true;
5353

54-
if (currentTransportMode[instanceID] == TransportMode.Taxi || (currentTransportMode[instanceID] == TransportMode.None &&
55-
((simManager.m_isNightTime && simManager.m_randomizer.Int32(100) < NIGHT_TAXI_USAGE_PROBABILITY[(int)wealthLevel]) ||
56-
(!simManager.m_isNightTime && simManager.m_randomizer.Int32(100) < DAY_TAXI_USAGE_PROBABILITY[(int)wealthLevel])))) {
54+
if (currentTransportMode[instanceID] == TransportMode.Taxi ||
55+
(currentTransportMode[instanceID] == TransportMode.None &&
56+
(
57+
(!Options.realisticMassTransitUsage && simManager.m_isNightTime && simManager.m_randomizer.Int32(2) == 0) ||
58+
(Options.realisticMassTransitUsage &&
59+
((simManager.m_isNightTime && simManager.m_randomizer.Int32(100) < NIGHT_TAXI_USAGE_PROBABILITY[(int)wealthLevel]) ||
60+
(!simManager.m_isNightTime && simManager.m_randomizer.Int32(100) < DAY_TAXI_USAGE_PROBABILITY[(int)wealthLevel])))
61+
))) {
5762
wouldAffordTaxiVoluntarily = true; // NON-STOCK CODE
5863
}
5964
}
@@ -72,18 +77,22 @@ public bool CustomStartPathFind(ushort instanceID, ref CitizenInstance citizenDa
7277
}
7378
}
7479

75-
byte districtId = Singleton<DistrictManager>.instance.GetDistrict(startPos);
76-
DistrictPolicies.Services servicePolicies = Singleton<DistrictManager>.instance.m_districts.m_buffer[(int)districtId].m_servicePolicies;
77-
int transportUsageProb = (servicePolicies & DistrictPolicies.Services.FreeTransport) != DistrictPolicies.Services.None ? FREE_TRANSPORT_USAGE_PROBABILITY[(int)wealthLevel] : TRANSPORT_USAGE_PROBABILITY[(int)wealthLevel];
78-
7980
bool useTaxi = false;
8081
bool useBike = false;
8182
bool useCar = false;
8283
bool usePublicTransport = false;
8384

8485
if ((citizenData.m_flags & CitizenInstance.Flags.CannotUseTransport) == CitizenInstance.Flags.None) { // STOCK CODE
86+
int transportUsageProb = 0;
87+
if (Options.realisticMassTransitUsage) {
88+
byte districtId = Singleton<DistrictManager>.instance.GetDistrict(startPos);
89+
DistrictPolicies.Services servicePolicies = Singleton<DistrictManager>.instance.m_districts.m_buffer[(int)districtId].m_servicePolicies;
90+
transportUsageProb = (servicePolicies & DistrictPolicies.Services.FreeTransport) != DistrictPolicies.Services.None ? FREE_TRANSPORT_USAGE_PROBABILITY[(int)wealthLevel] : TRANSPORT_USAGE_PROBABILITY[(int)wealthLevel];
91+
}
92+
8593
if (currentTransportMode[instanceID] == TransportMode.PublicTransport || useTaxi ||
86-
(currentTransportMode[instanceID] == TransportMode.None && simManager.m_randomizer.Int32(100) < transportUsageProb)) {
94+
! Options.realisticMassTransitUsage ||
95+
(Options.realisticMassTransitUsage && currentTransportMode[instanceID] == TransportMode.None && simManager.m_randomizer.Int32(100) < transportUsageProb)) {
8796
usePublicTransport = true;
8897
}
8998
}

TLM/TLM/Custom/AI/CustomFireTruckAI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using ColossalFramework;
44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
76
using System.Text;
87
using TrafficManager.Custom.PathFinding;
98
using TrafficManager.Geometry;

TLM/TLM/Custom/AI/CustomHumanAI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define DEBUGTTL
2+
13
using ColossalFramework;
24
using TrafficManager.State;
35
using TrafficManager.Geometry;

TLM/TLM/Custom/AI/CustomPoliceCarAI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using ColossalFramework;
44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
76
using System.Text;
87
using TrafficManager.Custom.PathFinding;
98
using TrafficManager.Geometry;

TLM/TLM/Custom/AI/CustomRoadAI.cs

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,85 @@ public void CustomUpdateLanes(ushort segmentID, ref NetSegment data, bool loadin
381381
}
382382
}
383383

384-
#region stock code
384+
public static void CustomGetTrafficLightNodeState(ushort nodeID, ref NetNode nodeData, ushort segmentID, ref NetSegment segmentData, ref NetNode.Flags flags, ref Color color) {
385+
TrafficLightSimulation nodeSim = Options.timedLightsEnabled ? TrafficLightSimulationManager.Instance().GetNodeSimulation(nodeID) : null;
386+
bool customSim = nodeSim != null && nodeSim.IsSimulationActive();
387+
388+
uint num = Singleton<SimulationManager>.instance.m_referenceFrameIndex - 15u;
389+
uint num2 = (uint)(((int)nodeID << 8) / 32768);
390+
uint num3 = num - num2 & 255u;
391+
RoadBaseAI.TrafficLightState trafficLightState;
392+
RoadBaseAI.TrafficLightState trafficLightState2;
393+
RoadBaseAI.GetTrafficLightState(nodeID, ref segmentData, num - num2, out trafficLightState, out trafficLightState2);
394+
color.a = 0.5f;
395+
switch (trafficLightState) {
396+
case RoadBaseAI.TrafficLightState.Green:
397+
color.g = 1f;
398+
break;
399+
case RoadBaseAI.TrafficLightState.RedToGreen:
400+
if (customSim) {
401+
color.r = 1f;
402+
} else {
403+
if (num3 < 45u) {
404+
color.g = 0f;
405+
} else if (num3 < 60u) {
406+
color.r = 1f;
407+
} else {
408+
color.g = 1f;
409+
}
410+
}
411+
break;
412+
case RoadBaseAI.TrafficLightState.Red:
413+
color.g = 0f;
414+
break;
415+
case RoadBaseAI.TrafficLightState.GreenToRed:
416+
if (customSim) {
417+
color.r = 1f;
418+
} else {
419+
if (num3 < 45u) {
420+
color.r = 1f;
421+
} else {
422+
color.g = 0f;
423+
}
424+
}
425+
break;
426+
}
427+
switch (trafficLightState2) {
428+
case RoadBaseAI.TrafficLightState.Green:
429+
color.b = 1f;
430+
break;
431+
case RoadBaseAI.TrafficLightState.RedToGreen:
432+
if (customSim) {
433+
color.b = 0f;
434+
} else {
435+
if (num3 < 45u) {
436+
color.b = 0f;
437+
} else {
438+
color.b = 1f;
439+
}
440+
}
441+
break;
442+
case RoadBaseAI.TrafficLightState.Red:
443+
color.b = 0f;
444+
break;
445+
case RoadBaseAI.TrafficLightState.GreenToRed:
446+
if (customSim) {
447+
color.b = 0f;
448+
} else {
449+
if (num3 < 45u) {
450+
if ((num3 / 8u & 1u) == 1u) {
451+
color.b = 1f;
452+
}
453+
} else {
454+
color.b = 0f;
455+
}
456+
}
457+
break;
458+
}
459+
}
460+
461+
#region stock code
462+
385463
public void OriginalUpdateLanes(ushort segmentID, ref NetSegment data, bool loading) {
386464
NetManager instance = Singleton<NetManager>.instance;
387465
bool flag = Singleton<SimulationManager>.instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True;

TLM/TLM/Custom/AI/CustomShipAI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using ColossalFramework;
22
using System;
33
using System.Collections.Generic;
4-
using System.Linq;
54
using System.Text;
65
using TrafficManager.Custom.PathFinding;
76
using TrafficManager.Geometry;

TLM/TLM/Custom/AI/CustomTaxiAI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using ColossalFramework;
44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
76
using System.Text;
87
using TrafficManager.Custom.PathFinding;
98
using TrafficManager.Geometry;

0 commit comments

Comments
 (0)