本文整理汇总了C#中Vehicle.GetLastVehicle方法的典型用法代码示例。如果您正苦于以下问题:C# Vehicle.GetLastVehicle方法的具体用法?C# Vehicle.GetLastVehicle怎么用?C# Vehicle.GetLastVehicle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle.GetLastVehicle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomSimulationStep
public void CustomSimulationStep(ushort vehicleId, ref Vehicle vehicleData, Vector3 physicsLodRefPos) {
if ((vehicleData.m_flags & Vehicle.Flags.WaitingPath) != 0) {
byte pathFindFlags = Singleton<PathManager>.instance.m_pathUnits.m_buffer[(int)((UIntPtr)vehicleData.m_path)].m_pathFindFlags;
if ((pathFindFlags & 4) != 0) {
this.PathfindSuccess(vehicleId, ref vehicleData);
this.PathFindReady(vehicleId, ref vehicleData);
} else if ((pathFindFlags & 8) != 0 || vehicleData.m_path == 0u) {
vehicleData.m_flags &= ~Vehicle.Flags.WaitingPath;
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
vehicleData.m_path = 0u;
this.PathfindFailure(vehicleId, ref vehicleData);
return;
}
} else if ((vehicleData.m_flags & Vehicle.Flags.WaitingSpace) != 0) {
this.TrySpawn(vehicleId, ref vehicleData);
}
/// NON-STOCK CODE START ///
bool reversed = (vehicleData.m_flags & Vehicle.Flags.Reversed) != 0;
ushort frontVehicleId;
if (reversed) {
frontVehicleId = vehicleData.GetLastVehicle(vehicleId);
} else {
frontVehicleId = vehicleId;
}
try {
//Log._Debug($"HandleVehicle for trams. vehicleId={vehicleId} frontVehicleId={frontVehicleId}");
CustomVehicleAI.HandleVehicle(frontVehicleId, ref Singleton<VehicleManager>.instance.m_vehicles.m_buffer[frontVehicleId], false, false, 2);
} catch (Exception e) {
Log.Error("TrainAI TrafficManagerSimulationStep Error: " + e.ToString());
}
/// NON-STOCK CODE END ///
VehicleManager instance = Singleton<VehicleManager>.instance;
VehicleInfo info = instance.m_vehicles.m_buffer[(int)vehicleId].Info;
info.m_vehicleAI.SimulationStep(vehicleId, ref instance.m_vehicles.m_buffer[(int)vehicleId], vehicleId, ref vehicleData, 0);
if ((vehicleData.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
ushort trailingVehicle = instance.m_vehicles.m_buffer[(int)vehicleId].m_trailingVehicle;
int num = 0;
while (trailingVehicle != 0) {
info = instance.m_vehicles.m_buffer[(int)trailingVehicle].Info;
info.m_vehicleAI.SimulationStep(trailingVehicle, ref instance.m_vehicles.m_buffer[(int)trailingVehicle], vehicleId, ref vehicleData, 0);
if ((vehicleData.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
trailingVehicle = instance.m_vehicles.m_buffer[(int)trailingVehicle].m_trailingVehicle;
if (++num > 16384) {
CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
if ((vehicleData.m_flags & (Vehicle.Flags.Spawned | Vehicle.Flags.WaitingPath | Vehicle.Flags.WaitingSpace | Vehicle.Flags.WaitingCargo)) == 0 || (vehicleData.m_blockCounter == 255 && Options.enableDespawning)) {
Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
}
}
示例2: TrafficManagerSimulationStep
public void TrafficManagerSimulationStep(ushort vehicleId, ref Vehicle vehicleData, Vector3 physicsLodRefPos) {
if ((vehicleData.m_flags & Vehicle.Flags.WaitingPath) != Vehicle.Flags.None) {
byte pathFindFlags = Singleton<PathManager>.instance.m_pathUnits.m_buffer[(int)((UIntPtr)vehicleData.m_path)].m_pathFindFlags;
if ((pathFindFlags & 4) != 0) {
this.PathFindReady(vehicleId, ref vehicleData);
} else if ((pathFindFlags & 8) != 0 || vehicleData.m_path == 0u) {
vehicleData.m_flags &= ~Vehicle.Flags.WaitingPath;
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
vehicleData.m_path = 0u;
vehicleData.Unspawn(vehicleId);
return;
}
} else if ((vehicleData.m_flags & Vehicle.Flags.WaitingSpace) != Vehicle.Flags.None) {
this.TrySpawn(vehicleId, ref vehicleData);
}
/// NON-STOCK CODE START ///
try {
CustomCarAI.HandleVehicle(vehicleId, ref Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId], false, 5);
} catch (Exception e) {
Log.Error("TrainAI TrafficManagerSimulationStep Error: " + e.ToString());
}
/// NON-STOCK CODE END ///
bool flag = (vehicleData.m_flags & Vehicle.Flags.Reversed) != Vehicle.Flags.None;
ushort num;
if (flag) {
num = vehicleData.GetLastVehicle(vehicleId);
} else {
num = vehicleId;
}
VehicleManager instance = Singleton<VehicleManager>.instance;
VehicleInfo info = instance.m_vehicles.m_buffer[(int)num].Info;
info.m_vehicleAI.SimulationStep(num, ref instance.m_vehicles.m_buffer[(int)num], vehicleId, ref vehicleData, 0);
if ((vehicleData.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
bool flag2 = (vehicleData.m_flags & Vehicle.Flags.Reversed) != Vehicle.Flags.None;
if (flag2 != flag) {
flag = flag2;
if (flag) {
num = vehicleData.GetLastVehicle(vehicleId);
} else {
num = vehicleId;
}
info = instance.m_vehicles.m_buffer[(int)num].Info;
info.m_vehicleAI.SimulationStep(num, ref instance.m_vehicles.m_buffer[(int)num], vehicleId, ref vehicleData, 0);
if ((vehicleData.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
flag2 = ((vehicleData.m_flags & Vehicle.Flags.Reversed) != Vehicle.Flags.None);
if (flag2 != flag) {
Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
return;
}
}
if (flag) {
num = instance.m_vehicles.m_buffer[(int)num].m_leadingVehicle;
int num2 = 0;
while (num != 0) {
info = instance.m_vehicles.m_buffer[(int)num].Info;
info.m_vehicleAI.SimulationStep(num, ref instance.m_vehicles.m_buffer[(int)num], vehicleId, ref vehicleData, 0);
if ((vehicleData.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
num = instance.m_vehicles.m_buffer[(int)num].m_leadingVehicle;
if (++num2 > 16384) {
CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
} else {
num = instance.m_vehicles.m_buffer[(int)num].m_trailingVehicle;
int num3 = 0;
while (num != 0) {
info = instance.m_vehicles.m_buffer[(int)num].Info;
info.m_vehicleAI.SimulationStep(num, ref instance.m_vehicles.m_buffer[(int)num], vehicleId, ref vehicleData, 0);
if ((vehicleData.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
num = instance.m_vehicles.m_buffer[(int)num].m_trailingVehicle;
if (++num3 > 16384) {
CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
}
if ((vehicleData.m_flags & (Vehicle.Flags.Spawned | Vehicle.Flags.WaitingPath | Vehicle.Flags.WaitingSpace | Vehicle.Flags.WaitingCargo)) == Vehicle.Flags.None || vehicleData.m_blockCounter == 255) {
Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
}
}
开发者ID:akira-ishizaki,项目名称:Cities-Skylines-Traffic-Manager-President-Edition,代码行数:91,代码来源:CustomTrainAI.cs
示例3: SimulationStep
public override void SimulationStep(ushort vehicleID, ref Vehicle data, Vector3 physicsLodRefPos)
{
if ((data.m_flags & Vehicle.Flags.WaitingPath) != Vehicle.Flags.None) {
byte pathFindFlags = Singleton<PathManager>.instance.m_pathUnits.m_buffer [(int)((UIntPtr)data.m_path)].m_pathFindFlags;
if ((pathFindFlags & 4) != 0) {
this.PathFindReady (vehicleID, ref data);
} else {
if ((pathFindFlags & 8) != 0 || data.m_path == 0u) {
data.m_flags &= ~Vehicle.Flags.WaitingPath;
Singleton<PathManager>.instance.ReleasePath (data.m_path);
data.m_path = 0u;
data.Unspawn (vehicleID);
return;
}
}
} else {
if ((data.m_flags & Vehicle.Flags.WaitingSpace) != Vehicle.Flags.None) {
this.TrySpawn (vehicleID, ref data);
}
}
bool flag = (data.m_flags & Vehicle.Flags.Reversed) != Vehicle.Flags.None;
ushort num;
if (flag) {
num = data.GetLastVehicle (vehicleID);
} else {
num = vehicleID;
}
VehicleManager instance = Singleton<VehicleManager>.instance;
VehicleInfo info = instance.m_vehicles.m_buffer [(int)num].Info;
info.m_vehicleAI.SimulationStep (num, ref instance.m_vehicles.m_buffer [(int)num], vehicleID, ref data, 0);
if ((data.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
bool flag2 = (data.m_flags & Vehicle.Flags.Reversed) != Vehicle.Flags.None;
if (flag2 != flag) {
flag = flag2;
if (flag) {
num = data.GetLastVehicle (vehicleID);
} else {
num = vehicleID;
}
info = instance.m_vehicles.m_buffer [(int)num].Info;
info.m_vehicleAI.SimulationStep (num, ref instance.m_vehicles.m_buffer [(int)num], vehicleID, ref data, 0);
if ((data.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
flag2 = ((data.m_flags & Vehicle.Flags.Reversed) != Vehicle.Flags.None);
if (flag2 != flag) {
Singleton<VehicleManager>.instance.ReleaseVehicle (vehicleID);
return;
}
}
if (flag) {
num = instance.m_vehicles.m_buffer [(int)num].m_leadingVehicle;
int num2 = 0;
while (num != 0) {
info = instance.m_vehicles.m_buffer [(int)num].Info;
info.m_vehicleAI.SimulationStep (num, ref instance.m_vehicles.m_buffer [(int)num], vehicleID, ref data, 0);
if ((data.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
num = instance.m_vehicles.m_buffer [(int)num].m_leadingVehicle;
if (++num2 > 65536) {
CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
} else {
num = instance.m_vehicles.m_buffer [(int)num].m_trailingVehicle;
int num3 = 0;
while (num != 0) {
info = instance.m_vehicles.m_buffer [(int)num].Info;
info.m_vehicleAI.SimulationStep (num, ref instance.m_vehicles.m_buffer [(int)num], vehicleID, ref data, 0);
if ((data.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) != Vehicle.Flags.Created) {
return;
}
num = instance.m_vehicles.m_buffer [(int)num].m_trailingVehicle;
if (++num3 > 65536) {
CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
}
if ((data.m_flags & (Vehicle.Flags.Spawned | Vehicle.Flags.WaitingPath | Vehicle.Flags.WaitingSpace | Vehicle.Flags.WaitingCargo)) == Vehicle.Flags.None || data.m_blockCounter == 255) {
Singleton<VehicleManager>.instance.ReleaseVehicle (vehicleID);
}
}