本文整理汇总了C#中NetInfo类的典型用法代码示例。如果您正苦于以下问题:C# NetInfo类的具体用法?C# NetInfo怎么用?C# NetInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetInfo类属于命名空间,在下文中一共展示了NetInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Rovanion,项目名称:csl-traffic,代码行数:7,代码来源:CustomPathManager.cs
示例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;
}
开发者ID:boformer,项目名称:NetworkSkins,代码行数:30,代码来源:NetUtil.cs
示例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);
}
开发者ID:Katalyst6,项目名称:CSL.TransitAddonMod,代码行数:40,代码来源:SpeedLimitManager.cs
示例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);
}
开发者ID:rockhowse,项目名称:Gurkenplayer,代码行数:30,代码来源:RoadSyncHelper.cs
示例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;
}
开发者ID:Katalyst6,项目名称:CSL.TransitAddonMod,代码行数:34,代码来源:VehicleRestrictionsManager.cs
示例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);
}
开发者ID:robbiemu,项目名称:Skylines-Traffic-Manager,代码行数:27,代码来源:CustomPathManager.cs
示例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;
}
开发者ID:moverperfect,项目名称:csl-traffic,代码行数:33,代码来源:CustomPassengerCarAI.cs
示例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;
}
}
开发者ID:Katalyst6,项目名称:CSL.TransitAddonMod,代码行数:25,代码来源:PlainStreetBuilder.cs
示例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);
}
开发者ID:boformer,项目名称:NetworkSkins,代码行数:25,代码来源:PropCustomizer.cs
示例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;
}
开发者ID:boformer,项目名称:GrowableOverhaul,代码行数:34,代码来源:NetManagerDetour.cs
示例11: GetActiveOptions
public SegmentData GetActiveOptions(NetInfo prefab)
{
var options = _assetMode ? _assetSegmentOptions : _selectedSegmentOptions;
SegmentData segmentData;
options.TryGetValue(prefab, out segmentData);
return segmentData;
}
开发者ID:boformer,项目名称:NetworkSkins,代码行数:8,代码来源:SegmentDataManager.cs
示例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;
}
开发者ID:FIDOCABRA,项目名称:Skylines-FineRoadHeights,代码行数:8,代码来源:RoadsFinePanel.cs
示例13: Populate
public bool Populate(NetInfo prefab)
{
Populating = true;
SelectedPrefab = prefab;
var result = PopulateImpl();
Populating = false;
return result;
}
开发者ID:boformer,项目名称:NetworkSkins,代码行数:8,代码来源:UIOption.cs
示例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);
}
}
}
}
开发者ID:wyllman,项目名称:PrecisionEngineering,代码行数:58,代码来源:Guides.cs
示例15: CreatePavement
public static void CreatePavement(NetInfo prefab)
{
if (prefab == null)
{
return;
}
prefab.m_createGravel = false;
prefab.m_createRuining = false;
prefab.m_createPavement = true;
}
开发者ID:earalov,项目名称:Skylines-ElevatedTrainStationTrack,代码行数:10,代码来源:Modifiers.cs
示例16: AreSimilarClass
public static bool AreSimilarClass(NetInfo i1, NetInfo i2)
{
if (i1 == i2)
return true;
if (i1 != null && i2 != null && i1.m_class.m_service == i2.m_class.m_service)
return true;
return false;
}
开发者ID:wyllman,项目名称:PrecisionEngineering,代码行数:10,代码来源:NetUtil.cs
示例17: ClonePrefab
public static NetInfo ClonePrefab(NetInfo originalPrefab, string newName, Transform parentTransform)
{
var instance = Object.Instantiate(originalPrefab.gameObject);
instance.name = newName;
instance.transform.SetParent(parentTransform);
instance.transform.localPosition = new Vector3(-7500, -7500, -7500);
var newPrefab = instance.GetComponent<NetInfo>();
instance.SetActive(false);
newPrefab.m_prefabInitialized = false;
return newPrefab;
}
开发者ID:earalov,项目名称:Skylines-ElevatedTrainStationTrack,代码行数:11,代码来源:Util.cs
示例18: MakePedestrianLanesNarrow
public static void MakePedestrianLanesNarrow(NetInfo prefab)
{
if (prefab?.m_lanes == null)
{
return;
}
foreach (var lane in prefab.m_lanes.Where(lane => lane != null && lane.m_laneType == NetInfo.LaneType.Pedestrian))
{
lane.m_width = 2;
lane.m_position = Math.Sign(lane.m_position) * (4 + .5f * lane.m_width);
}
}
开发者ID:earalov,项目名称:Skylines-ElevatedTrainStationTrack,代码行数:12,代码来源:Modifiers.cs
示例19: SetHighwayProps
public static void SetHighwayProps(this NetInfo info, NetInfo highwayInfoTemplate)
{
var leftHwLane = highwayInfoTemplate
.m_lanes
.Where(l => l != null && l.m_laneProps != null && l.m_laneProps.name != null && l.m_laneProps.m_props != null)
.FirstOrDefault(l => l.m_laneProps.name.ToLower().Contains("left"));
var rightHwLane = highwayInfoTemplate
.m_lanes
.Where(l => l != null && l.m_laneProps != null && l.m_laneProps.name != null && l.m_laneProps.m_props != null)
.FirstOrDefault(l => l.m_laneProps.name.ToLower().Contains("right"));
foreach (var lane in info.m_lanes)
{
if (lane.m_laneProps != null && lane.m_laneProps.name != null)
{
if (leftHwLane != null)
{
if (lane.m_laneProps.name.ToLower().Contains("left"))
{
var newProps = ScriptableObject.CreateInstance<NetLaneProps>();
newProps.name = "Highway6L Left Props";
newProps.m_props = leftHwLane
.m_laneProps
.m_props
.Select(p => p.ShallowClone())
.ToArray();
lane.m_laneProps = newProps;
}
}
if (rightHwLane != null)
{
if (lane.m_laneProps.name.ToLower().Contains("right"))
{
var newProps = ScriptableObject.CreateInstance<NetLaneProps>();
newProps.name = "Highway6L Right Props";
newProps.m_props = rightHwLane
.m_laneProps
.m_props
.Select(p => p.ShallowClone())
.ToArray();
lane.m_laneProps = newProps;
}
}
}
}
}
开发者ID:TheColorRed,项目名称:CSL.NetworkExtensions,代码行数:52,代码来源:HighwayHelper.cs
示例20: GetActiveStreetLightDistance
public float GetActiveStreetLightDistance(NetInfo prefab)
{
var segmentData = SegmentDataManager.Instance.GetActiveOptions(prefab);
if (segmentData != null && segmentData.Features.IsFlagSet(SegmentData.FeatureFlags.RepeatDistances) && segmentData.RepeatDistances.w > 0f)
{
return segmentData.RepeatDistances.w;
}
else
{
return GetDefaultStreetLightDistance(prefab);
}
}
开发者ID:boformer,项目名称:NetworkSkins,代码行数:13,代码来源:PropCustomizer.cs
注:本文中的NetInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论