本文整理汇总了C#中NetInfo类的典型用法代码示例。如果您正苦于以下问题:C# NetInfo类的具体用法?C# NetInfo怎么用?C# NetInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetInfo类属于命名空间,在下文中一共展示了NetInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindPathPosition
public static bool FindPathPosition(Vector3 position, ItemClass.Service service, NetInfo.LaneType laneType, VehicleInfo.VehicleType vehicleTypes, bool allowUnderground, bool requireConnect, float maxDistance, out PathUnit.Position pathPos, RoadManager.VehicleType vehicleType)
{
PathUnit.Position position2;
float num;
float num2;
return CustomPathManager.FindPathPosition(position, service, laneType, vehicleTypes, allowUnderground, requireConnect, maxDistance, out pathPos, out position2, out num, out num2, vehicleType);
}
示例2: GetSubPrefabs
public static NetInfo[] GetSubPrefabs(NetInfo prefab)
{
var subPrefabs = new NetInfo[NET_TYPE_NAMES.Length];
if (prefab.m_netAI is TrainTrackAI)
{
var netAI = (TrainTrackAI) prefab.m_netAI;
subPrefabs[(int)NetType.Tunnel] = netAI.m_tunnelInfo;
subPrefabs[(int)NetType.Ground] = netAI.m_info;
subPrefabs[(int)NetType.Elevated] = netAI.m_elevatedInfo;
subPrefabs[(int)NetType.Bridge] = netAI.m_bridgeInfo;
}
else if (prefab.m_netAI is RoadAI)
{
var netAI = (RoadAI) prefab.m_netAI;
subPrefabs[(int)NetType.Tunnel] = netAI.m_tunnelInfo;
subPrefabs[(int)NetType.Ground] = netAI.m_info;
subPrefabs[(int)NetType.Elevated] = netAI.m_elevatedInfo;
subPrefabs[(int)NetType.Bridge] = netAI.m_bridgeInfo;
}
else if (prefab.m_netAI is PedestrianPathAI)
{
var netAI = (PedestrianPathAI) prefab.m_netAI;
subPrefabs[(int)NetType.Tunnel] = netAI.m_tunnelInfo;
subPrefabs[(int)NetType.Ground] = netAI.m_info;
subPrefabs[(int)NetType.Elevated] = netAI.m_elevatedInfo;
subPrefabs[(int)NetType.Bridge] = netAI.m_bridgeInfo;
}
return subPrefabs;
}
示例3: GetCustomSpeedLimit
/// <summary>
/// Determines the currently set speed limit for the given segment and lane direction in terms of discrete speed limit levels.
/// An in-game speed limit of 2.0 (e.g. on highway) is hereby translated into a discrete speed limit value of 100 (km/h).
/// </summary>
/// <param name="segmentId"></param>
/// <param name="dir"></param>
/// <returns></returns>
public static ushort GetCustomSpeedLimit(ushort segmentId, NetInfo.Direction dir) {
// calculate the currently set mean speed limit
if (segmentId == 0)
return 0;
if ((Singleton<NetManager>.instance.m_segments.m_buffer[segmentId].m_flags & NetSegment.Flags.Created) == NetSegment.Flags.None)
return 0;
var segmentInfo = Singleton<NetManager>.instance.m_segments.m_buffer[segmentId].Info;
uint curLaneId = Singleton<NetManager>.instance.m_segments.m_buffer[segmentId].m_lanes;
int laneIndex = 0;
float meanSpeedLimit = 0f;
uint validLanes = 0;
while (laneIndex < segmentInfo.m_lanes.Length && curLaneId != 0u) {
NetInfo.Direction d = segmentInfo.m_lanes[laneIndex].m_direction;
if ((segmentInfo.m_lanes[laneIndex].m_laneType & (NetInfo.LaneType.Vehicle | NetInfo.LaneType.TransportVehicle)) == NetInfo.LaneType.None || d != dir)
goto nextIter;
ushort? setSpeedLimit = Flags.getLaneSpeedLimit(curLaneId);
if (setSpeedLimit != null)
meanSpeedLimit += ToGameSpeedLimit((ushort)setSpeedLimit); // custom speed limit
else
meanSpeedLimit += segmentInfo.m_lanes[laneIndex].m_speedLimit; // game default
++validLanes;
nextIter:
curLaneId = Singleton<NetManager>.instance.m_lanes.m_buffer[curLaneId].m_nextLane;
laneIndex++;
}
if (validLanes > 0)
meanSpeedLimit /= (float)validLanes;
return ToCustomSpeedLimit(meanSpeedLimit);
}
示例4: AdjustElevation
//Test
public static void AdjustElevation(ushort startNode, Vector3 vector, NetInfo netInfo)
{
NetManager nm = NetManager.instance;
var node = nm.m_nodes.m_buffer[startNode];
float elevation = NetSegment.SampleTerrainHeight(netInfo, vector, false);
byte ele = (byte)Mathf.Clamp(Mathf.RoundToInt(Math.Max(node.m_elevation, elevation)), 0, 255);
float terrain = TerrainManager.instance.SampleRawHeightSmoothWithWater(node.m_position, false, 0f);
node.m_elevation = ele;
node.m_position = new Vector3(node.m_position.x, ele + terrain, node.m_position.z);
if (elevation < 11f)
{
node.m_flags |= NetNode.Flags.OnGround;
}
else
{
node.m_flags &= ~NetNode.Flags.OnGround;
UpdateSegment(node.m_segment0, elevation);
UpdateSegment(node.m_segment1, elevation);
UpdateSegment(node.m_segment2, elevation);
UpdateSegment(node.m_segment3, elevation);
UpdateSegment(node.m_segment4, elevation);
UpdateSegment(node.m_segment5, elevation);
UpdateSegment(node.m_segment6, elevation);
UpdateSegment(node.m_segment7, elevation);
}
nm.m_nodes.m_buffer[startNode] = node;
//Singleton<NetManager>.instance.UpdateNode(startNode);
}
示例5: GetAllowedVehicleTypes
/// <summary>
/// Determines the allowed vehicle types for the given segment and lane.
/// </summary>
/// <param name="segmentId"></param>
/// <param name="laneIndex"></param>
/// <param name="laneId"></param>
/// <param name="laneInfo"></param>
/// <returns></returns>
internal static ExtVehicleType GetAllowedVehicleTypes(ushort segmentId, uint laneIndex, uint laneId, NetInfo.Lane laneInfo) {
if (Flags.IsInitDone()) {
ExtVehicleType?[] fastArray = Flags.laneAllowedVehicleTypesArray[segmentId];
if (fastArray != null && fastArray.Length > laneIndex && fastArray[laneIndex] != null) {
return (ExtVehicleType)fastArray[laneIndex];
}
}
ExtVehicleType ret = ExtVehicleType.None;
if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Bicycle) != VehicleInfo.VehicleType.None)
ret |= ExtVehicleType.Bicycle;
if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Tram) != VehicleInfo.VehicleType.None)
ret |= ExtVehicleType.Tram;
if ((laneInfo.m_laneType & NetInfo.LaneType.TransportVehicle) != NetInfo.LaneType.None)
ret |= ExtVehicleType.RoadPublicTransport | ExtVehicleType.Emergency;
else if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Car) != VehicleInfo.VehicleType.None)
ret |= ExtVehicleType.RoadVehicle;
if ((laneInfo.m_vehicleType & (VehicleInfo.VehicleType.Train | VehicleInfo.VehicleType.Metro)) != VehicleInfo.VehicleType.None)
ret |= ExtVehicleType.RailVehicle;
if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Ship) != VehicleInfo.VehicleType.None)
ret |= ExtVehicleType.Ship;
if ((laneInfo.m_vehicleType & VehicleInfo.VehicleType.Plane) != VehicleInfo.VehicleType.None)
ret |= ExtVehicleType.Plane;
return ret;
}
示例6: CreatePath
public new bool CreatePath(out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, PathUnit.Position vehiclePosition, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue, ItemClass.Service vehicleService)
{
while (!Monitor.TryEnter(this.m_bufferLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
{
}
uint num;
try
{
if (!this.m_pathUnits.CreateItem(out num, ref randomizer))
{
unit = 0u;
bool result = false;
return result;
}
this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u);
}
finally
{
Monitor.Exit(this.m_bufferLock);
}
unit = num;
byte simulationFlags = createSimulationFlag(isHeavyVehicle, ignoreBlocked, stablePath, vehicleService);
assignPathProperties(unit, buildIndex, startPosA, startPosB, endPosA, endPosB, vehiclePosition, laneTypes, vehicleTypes, maxLength, simulationFlags);
return findShortestPath(unit, skipQueue);
}
示例7: FindPathPosition
// from CitizenAI
public static bool FindPathPosition(ushort instanceID, ref CitizenInstance citizenData, Vector3 pos, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, bool allowUnderground, out PathUnit.Position position)
{
position = default(PathUnit.Position);
float num = 1E+10f;
PathUnit.Position position2;
PathUnit.Position position3;
float num2;
float num3;
if (CustomPathManager.FindPathPosition(pos, ItemClass.Service.Road, laneTypes, vehicleTypes, allowUnderground, 32f, out position2, out position3, out num2, out num3, RoadManager.VehicleType.PassengerCar) && num2 < num)
{
num = num2;
position = position2;
}
PathUnit.Position position4;
PathUnit.Position position5;
float num4;
float num5;
if (CustomPathManager.FindPathPosition(pos, ItemClass.Service.Beautification, laneTypes, vehicleTypes, allowUnderground, 32f, out position4, out position5, out num4, out num5, RoadManager.VehicleType.PassengerCar) && num4 < num)
{
num = num4;
position = position4;
}
PathUnit.Position position6;
PathUnit.Position position7;
float num6;
float num7;
if ((citizenData.m_flags & CitizenInstance.Flags.CannotUseTransport) == CitizenInstance.Flags.None && CustomPathManager.FindPathPosition(pos, ItemClass.Service.PublicTransport, laneTypes, vehicleTypes, allowUnderground, 32f, out position6, out position7, out num6, out num7, RoadManager.VehicleType.PassengerCar) && num6 < num)
{
position = position6;
}
return position.m_segment != 0;
}
示例8: BuildUp
public void BuildUp(NetInfo info, NetInfoVersion version)
{
///////////////////////////
// Texturing //
///////////////////////////
SetupTextures(info, version);
///////////////////////////
// Set up //
///////////////////////////
info.m_createGravel = false;
info.m_createPavement = true;
info.m_setVehicleFlags = 0;
///////////////////////////
// AI //
///////////////////////////
var playerNetAI = info.GetComponent<PlayerNetAI>();
if (playerNetAI != null)
{
playerNetAI.m_constructionCost = playerNetAI.m_constructionCost * 3 / 2;
playerNetAI.m_maintenanceCost = playerNetAI.m_maintenanceCost * 3 / 2;
}
}
示例9: GetActiveTreeDistance
public float GetActiveTreeDistance(NetInfo prefab, LanePosition position)
{
var segmentData = SegmentDataManager.Instance.GetActiveOptions(prefab);
var result = 0f;
if (segmentData != null && segmentData.Features.IsFlagSet(SegmentData.FeatureFlags.RepeatDistances))
{
switch (position)
{
case LanePosition.Left:
result = segmentData.RepeatDistances.x;
break;
case LanePosition.Middle:
result = segmentData.RepeatDistances.y;
break;
case LanePosition.Right:
result = segmentData.RepeatDistances.z;
break;
default:
throw new ArgumentOutOfRangeException(nameof(position));
}
}
return result > 0f ? result : GetDefaultTreeDistance(prefab, position);
}
示例10: CreateSegment
public static bool CreateSegment(NetManager _this, out ushort segmentID, ref Randomizer randomizer, NetInfo info, ushort startNode, ushort endNode, Vector3 startDirection, Vector3 endDirection, uint buildIndex, uint modifiedIndex, bool invert)
{
var ai = info.m_netAI as RoadAI;
if (ai != null && ai.m_enableZoning)
{
var caller = new System.Diagnostics.StackFrame(1).GetMethod().Name;
switch (caller)
{
case "MoveMiddleNode": // segment that was modified because user added network, apply style of previous segment
newBlockColumnCount = MoveMiddleNode_releasedColumnCount >= 0 ?
MoveMiddleNode_releasedColumnCount : InputThreadingExtension.userSelectedColumnCount;
break;
case "SplitSegment": // segment that was split by new node, apply style of previous segment
newBlockColumnCount = SplitSegment_releasedColumnCount >= 0 ?
SplitSegment_releasedColumnCount : InputThreadingExtension.userSelectedColumnCount;
break;
default: // unknown caller (e.g. new road placed), set to depth selected by user
newBlockColumnCount = InputThreadingExtension.userSelectedColumnCount;
SplitSegment_releasedColumnCount = -1;
MoveMiddleNode_releasedColumnCount = -1;
break;
}
}
// Call original method
CreateSegmentRedirector.Revert();
var success = _this.CreateSegment(out segmentID, ref randomizer, info, startNode, endNode, startDirection, endDirection, buildIndex, modifiedIndex, invert);
CreateSegmentRedirector.Apply();
return success;
}
示例11: GetActiveOptions
public SegmentData GetActiveOptions(NetInfo prefab)
{
var options = _assetMode ? _assetSegmentOptions : _selectedSegmentOptions;
SegmentData segmentData;
options.TryGetValue(prefab, out segmentData);
return segmentData;
}
示例12: IsServiceValid
protected override bool IsServiceValid(NetInfo info)
{
if (info.GetService() == this.service)
return true;
if (this.isMapEditor)
return info.GetService() == ItemClass.Service.PublicTransport;
return false;
}
示例13: Populate
public bool Populate(NetInfo prefab)
{
Populating = true;
SelectedPrefab = prefab;
var result = PopulateImpl();
Populating = false;
return result;
}
示例14: CalculateGuideLines
public static void CalculateGuideLines(NetInfo netInfo, NetTool.ControlPoint startPoint, NetTool.ControlPoint endPoint,
IList<GuideLine> resultList)
{
lock (SegmentCache) {
var startPosition = startPoint.m_position;
var endPosition = endPoint.m_position;
//var segments = NetManager.instance.m_segments;
//NetManager.instance.GetClosestSegments(endPosition, SegmentCache, out _segmentCacheCount);
NetUtil.GetClosestSegments(netInfo, endPosition, SegmentCache, out _segmentCacheCount);
SnapController.DebugPrint = String.Format("Closest Segment Count: {0}", _segmentCacheCount);
var c = _segmentCacheCount;
for (ushort i = 0; i < c; i++) {
var segmentId = SegmentCache[i];
var s = NetManager.instance.m_segments.m_buffer[segmentId];
// Ensure they are part of the same network
if (!NetUtil.AreSimilarClass(s.Info, netInfo))
continue;
if (
Vector3Extensions.DistanceSquared(NetManager.instance.m_nodes.m_buffer[s.m_startNode].m_position, endPosition) >
Settings.MaxGuideLineQueryDistanceSqr)
continue;
// Test the start and end of the segment
// Check if the node can branch in the guide direction (angles less than 45deg or so should be discarded)
if (CanNodeBranchInDirection(s.m_endNode, s.m_startDirection)) {
var endNode = NetManager.instance.m_nodes.m_buffer[s.m_endNode];
TestLine(s.Info, startPosition, endPosition,
endNode.m_position,
endNode.m_position + s.m_startDirection.Flatten(),
resultList, segmentId, s.m_endNode);
}
if (CanNodeBranchInDirection(s.m_startNode, s.m_endDirection)) {
var startNode = NetManager.instance.m_nodes.m_buffer[s.m_startNode];
TestLine(s.Info, startPosition, endPosition,
startNode.m_position,
startNode.m_position + s.m_endDirection.Flatten(),
resultList, segmentId, s.m_startNode);
}
}
}
}
示例15: CreatePavement
public static void CreatePavement(NetInfo prefab)
{
if (prefab == null)
{
return;
}
prefab.m_createGravel = false;
prefab.m_createRuining = false;
prefab.m_createPavement = true;
}