protected override void Handle(TransportLineCreateCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); ArrayHandler.StartApplying(command.Array16Ids, null); tool.m_prefab = PrefabCollection <TransportInfo> .GetPrefab(command.Prefab); ReflectionHelper.SetAttr(tool, "m_building", command.Building); IgnoreHelper.StartIgnore(); int mode = ReflectionHelper.GetEnumValue(typeof(TransportTool).GetNestedType("Mode", ReflectionHelper.AllAccessFlags), "NewLine"); ReflectionHelper.SetAttr(tool, "m_mode", mode); ReflectionHelper.SetAttr(tool, "m_errors", ToolBase.ToolErrors.None); IEnumerator newLine = (IEnumerator)ReflectionHelper.Call(tool, "NewLine"); newLine.MoveNext(); IgnoreHelper.EndIgnore(); ArrayHandler.StopApplying(); }
public void Display(object data, bool isRowOdd) { if (data != null) { vehicleInfoIndex = (uint)(data); vehicleInfo = PrefabCollection <VehicleInfo> .GetPrefab(vehicleInfoIndex); vehicleName = PrefabCollection <VehicleInfo> .PrefabName(vehicleInfoIndex); if (vehicleInfo != null && background != null) { Match m = workshopRegex.Match(vehicleName); if (m.Success) { label.text = m.Groups[1].ToString().Replace("_", " "); } else { label.text = vehicleName; } if (isRowOdd) { background.backgroundSprite = "UnlockingItemBackground"; background.color = new Color32(0, 0, 0, 128); } else { background.backgroundSprite = null; } } } }
protected override void Handle(BuildingToolCreateCommand command) { BuildingTool tool = ToolSimulator.GetTool <BuildingTool>(command.SenderId); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(command.Array16Ids, command.Array32Ids); BuildingInfo prefab = null; if (command.Relocate == 0) { prefab = PrefabCollection <BuildingInfo> .GetPrefab(command.Prefab); } tool.m_prefab = prefab; tool.m_relocate = command.Relocate; ReflectionHelper.SetAttr(tool, "m_mousePosition", command.MousePosition); ReflectionHelper.SetAttr(tool, "m_mouseAngle", command.MouseAngle); ReflectionHelper.SetAttr(tool, "m_elevation", command.Elevation); ReflectionHelper.SetAttr(tool, "m_placementErrors", ToolBase.ToolErrors.None); ReflectionHelper.SetAttr(tool, "m_constructionCost", 0); ToolController controller = ReflectionHelper.GetAttr <ToolController>(tool, "m_toolController"); ReflectionHelper.SetAttr(controller, "m_collidingSegments1", command.CollidingSegments); ReflectionHelper.SetAttr(controller, "m_collidingBuildings1", command.CollidingBuildings); ReflectionHelper.SetAttr(controller, "m_collidingDepth", 1); ReflectionHelper.Call <IEnumerator>(tool, "CreateBuilding")?.MoveNext(); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
private void HandleBuilding(BuildingCreateCommand command) { BuildingInfo info = PrefabCollection <BuildingInfo> .GetPrefab(command.Infoindex); BuildingExtension.LastPosition = command.Position; Singleton <BuildingManager> .instance.CreateBuilding(out ushort building, ref Singleton <SimulationManager> .instance.m_randomizer, info, command.Position, command.Angle, command.Length, Singleton <SimulationManager> .instance.m_currentBuildIndex); Extensions.BuildingExtension.BuildingID.Add(command.BuildingID, building); switch (MultiplayerManager.Instance.CurrentRole) //returns the newly created buildings buildingID so that it can be added to the original builders Dictionary { case MultiplayerRole.Client: { Command.SendToServer(new BuildingIdCommand { BuildingIdSender = building, BuildingIdReciever = command.BuildingID }); break; } case MultiplayerRole.Server: { Command.SendToServer(new BuildingIdCommand { BuildingIdSender = building, BuildingIdReciever = command.BuildingID }); break; } } }
private IEnumerable <NetInfo> EnumeratePrefabs() { for (uint c = 0; c < PrefabCollection <NetInfo> .PrefabCount(); c++) { yield return(PrefabCollection <NetInfo> .GetPrefab(c)); } }
// Called every frame on building upgrade public static BuildingInfo GetRandomBuildingInfo_Upgrade(Vector3 position, ushort prefabIndex, ref Randomizer r, ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, int width, int length, BuildingInfo.ZoningMode zoningMode, int style) { // This method is very fragile, no logging here! var districtId = Singleton <DistrictManager> .instance.GetDistrict(position); // See if there is a special upgraded building var buildingInfo = BuildingThemesManager.instance.GetUpgradeBuildingInfo(prefabIndex, districtId); if (buildingInfo != null) { return(buildingInfo); } var areaIndex = BuildingThemesManager.GetAreaIndex(service, subService, level, width, length, zoningMode); // list of possible prefabs var fastList = Singleton <BuildingThemesManager> .instance.GetAreaBuildings(districtId, areaIndex); if (fastList == null || fastList.m_size == 0) { return((BuildingInfo)null); } // select a random prefab from the list int index = r.Int32((uint)fastList.m_size); return(PrefabCollection <BuildingInfo> .GetPrefab((uint)fastList.m_buffer[index])); }
private void FindAllPrefabs() { List <PrefabData> prefabDataList1 = new List <PrefabData>(); List <PrefabData> prefabDataList2 = new List <PrefabData>(); List <PrefabData> prefabDataList3 = new List <PrefabData>(); List <PrefabData> prefabDataList4 = new List <PrefabData>(); List <PrefabData> prefabDataList5 = new List <PrefabData>(); List <PrefabData> prefabDataList6 = new List <PrefabData>(); List <PrefabData> prefabDataList7 = new List <PrefabData>(); for (int index = 0; index < PrefabCollection <VehicleInfo> .PrefabCount(); ++index) { VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab((uint)index); if ((Object)prefab != (Object)null && !VehiclePrefabs.IsTrailer(prefab) && (prefab.m_class.m_service == ItemClass.Service.PublicTransport && prefab.m_class.m_level == ItemClass.Level.Level1)) { switch (prefab.m_class.m_subService) { case ItemClass.SubService.PublicTransportBus: prefabDataList1.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportMetro: prefabDataList2.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportTrain: prefabDataList3.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportShip: prefabDataList4.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportPlane: prefabDataList5.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportTaxi: prefabDataList6.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportTram: prefabDataList7.Add(new PrefabData(prefab)); continue; default: continue; } } } this._busPrefabData = prefabDataList1.ToArray(); this._metroPrefabData = prefabDataList2.ToArray(); this._trainPrefabData = prefabDataList3.ToArray(); this._shipPrefabData = prefabDataList4.ToArray(); this._planePrefabData = prefabDataList5.ToArray(); this._taxiPrefabData = prefabDataList6.ToArray(); this._tramPrefabData = prefabDataList7.ToArray(); }
private List <BuildingItem> GetBuildingItemList(Configuration.Theme theme) { List <BuildingItem> list = new List <BuildingItem>(); // List of all growables prefabs Dictionary <string, BuildingItem> buildingDictionary = new Dictionary <string, BuildingItem>(); for (uint i = 0; i < PrefabCollection <BuildingInfo> .PrefabCount(); i++) { BuildingInfo prefab = PrefabCollection <BuildingInfo> .GetPrefab(i); if (prefab != null && prefab.m_placementStyle == ItemClass.Placement.Automatic) { BuildingItem item = new BuildingItem(); item.prefab = PrefabCollection <BuildingInfo> .GetPrefab(i); buildingDictionary.Add(item.name, item); if (!BuildingVariationManager.instance.IsVariation(item.name)) { list.Add(item); } } } // Combine growables with buildings in configuration Configuration.Building[] buildings = theme.buildings.ToArray(); for (int i = 0; i < buildings.Length; i++) { if (buildingDictionary.ContainsKey(buildings[i].name)) { // Associate building with prefab BuildingItem item = buildingDictionary[buildings[i].name]; item.building = buildings[i]; if (!list.Contains(item)) { list.Add(item); } } else { // Prefab not found, adding building without prefab if (buildings[i].dlc != null && !Steam.IsDlcInstalled(Convert.ToUInt32(buildings[i].dlc))) { continue; } BuildingItem item = new BuildingItem(); item.building = buildings[i]; list.Add(item); } } // Sorting list.Sort(BuildingCompare); return(list); }
private void DebugOutput() { for (uint i = 0; i < PrefabCollection <RadioChannelInfo> .PrefabCount(); ++i) { String message = ""; RadioChannelInfo info = PrefabCollection <RadioChannelInfo> .GetPrefab(i); if (info == null) { continue; } message += "[ChannelInfo] " + info + "\n"; message += "Schedule:\n"; if (info.m_stateChain != null) { foreach (RadioChannelInfo.State s in info.m_stateChain) { message += "\t" + s.m_contentType + " " + s.m_minCount + " - " + s.m_maxCount + "\n"; } } message += "Content:\n"; for (uint j = 0; j < PrefabCollection <RadioContentInfo> .PrefabCount(); ++j) { RadioContentInfo content = PrefabCollection <RadioContentInfo> .GetPrefab(j); if (content == null) { continue; } if (content.m_radioChannels != null) { if (content.m_radioChannels.Contains(info)) { message += "\t[ContentInfo] " + content + " " + content.m_fileName + "\n"; } } } CSLMusicMod.Log(message); } for (uint i = 0; i < PrefabCollection <DisasterInfo> .PrefabCount(); ++i) { DisasterInfo info = PrefabCollection <DisasterInfo> .GetPrefab(i); if (info == null) { continue; } CSLMusicMod.Log("[DisasterContext] Disaster name: " + info.name); } }
protected new virtual float CalculateTargetSpeed(ushort vehicleID, ref Vehicle data, float speedLimit, float curve) { float a = 1000f / (1f + curve * 1000f / this.m_info.m_turning) + 2f; float b = 8f * speedLimit; // Original code : // return Mathf.Min(Mathf.Min(a, b), this.m_info.m_maxSpeed); // New code : if (!highwaySpeed) { _lastFactor = _factors[vehicleID]; return(Mathf.Min(Mathf.Min(a, b), this.m_info.m_maxSpeed) * _lastFactor); } // Highway Speeds : uint laneID = PathManager.GetLaneID(_pathManager.m_pathUnits.m_buffer[data.m_path].GetPosition(data.m_pathPositionIndex >> 1)); if (laneID != 0) { if (_lastLaneIDs[vehicleID] == laneID) { // Still on same lane _lastFactor = _lastFactors[vehicleID]; return(Mathf.Min(Mathf.Min(a, b), this.m_info.m_maxSpeed) * _lastFactor); } _lastLaneIDs[vehicleID] = laneID; NetInfo info = PrefabCollection <NetInfo> .GetPrefab(_netManager.m_segments.m_buffer[_netManager.m_lanes.m_buffer[laneID].m_segment].m_infoIndex); for (int i = 0; i < _highways.Length; i++) { if (_highways[i] == info) { // On highway uint currentLane = _netManager.m_segments.m_buffer[_netManager.m_lanes.m_buffer[laneID].m_segment].m_lanes; int lanePos = 0; while (currentLane != 0u && currentLane != laneID) { lanePos++; currentLane = _netManager.m_lanes.m_buffer[(int)currentLane].m_nextLane; } lanePos = 2 - lanePos; _lastFactor = _lastFactors[vehicleID] = _factors[vehicleID] + lanePos / 8f - 0.10f; return(Mathf.Min(Mathf.Min(a, b), this.m_info.m_maxSpeed) * _lastFactor); } } } // Not on highway _lastFactor = _lastFactors[vehicleID] = _factors[vehicleID]; return(Mathf.Min(Mathf.Min(a, b), this.m_info.m_maxSpeed) * _lastFactor); }
//based on CitizenManager#GetGroupAnimalInfo() public CitizenInfo GetGroupAnimalInfo(ref Randomizer r, ItemClass.Service service, ItemClass.SubService subService, int animalIndex) { var index = r.Int32((uint)Animals.m_size); if (animalIndex > -1) { index = animalIndex; } return(PrefabCollection <CitizenInfo> .GetPrefab((uint)Animals.m_buffer[index])); }
public static void StoreAll() { DefaultOptions.Clear(); for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++) { DefaultOptions.Store(PrefabCollection <VehicleInfo> .GetPrefab(i)); } DebugUtils.Log("Default values stored"); }
public override void Handle(TreeCreateCommand command) { TreeInfo info = PrefabCollection <TreeInfo> .GetPrefab(command.InfoIndex); TreeHandler.IgnoreAll = true; ArrayHandler.StartApplying(null, new uint[] { command.TreeID }); TreeManager.instance.CreateTree(out uint _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Single); ArrayHandler.StopApplying(); TreeHandler.IgnoreAll = false; }
protected override void Handle(TreeCreateCommand command) { TreeInfo info = PrefabCollection <TreeInfo> .GetPrefab(command.InfoIndex); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(null, new uint[] { command.TreeId }); TreeManager.instance.CreateTree(out uint _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Single); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
private static void EndRenderingImpl(TreeManager tm, RenderManager.CameraInfo cameraInfo) { unsafe { if (Input.GetKeyDown(KeyCode.F5) && Event.current.control) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, string.Format("TreeLimit: TreeCount={0}, TreeLimit={1}, CanPlaceMoreTrees={2}", tm.m_treeCount, LimitTreeManager.Helper.TreeLimit, tm.CheckLimits())); Array32<TreeInstance> mTrees = tm.m_trees; DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, string.Format("TreeLimit: ArraySize={0}, ItemCount={1}, UnusedCount={2}", mTrees.m_size, mTrees.ItemCount(), mTrees.GetType().GetField("m_unusedCount", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(mTrees))); } FastList<RenderGroup> mRenderedGroups = Singleton<RenderManager>.instance.m_renderedGroups; for (int i = 0; i < mRenderedGroups.m_size; i++) { RenderGroup mBuffer = mRenderedGroups.m_buffer[i]; if ((mBuffer.m_instanceMask & 1 << (tm.m_treeLayer & 31)) != 0) { int mX = mBuffer.m_x * 540 / 45; int mZ = mBuffer.m_z * 540 / 45; int num = (mBuffer.m_x + 1) * 540 / 45 - 1; int mZ1 = (mBuffer.m_z + 1) * 540 / 45 - 1; for (int j = mZ; j <= mZ1; j++) { for (int k = mX; k <= num; k++) { uint mTreeGrid = tm.m_treeGrid[j * 540 + k]; int num1 = 0; while (mTreeGrid != 0) { tm.m_trees.m_buffer[mTreeGrid].RenderInstance(cameraInfo, mTreeGrid, mBuffer.m_instanceMask); mTreeGrid = tm.m_trees.m_buffer[mTreeGrid].m_nextGridTree; int num2 = num1 + 1; num1 = num2; if (num2 < LimitTreeManager.Helper.TreeLimit) { continue; } CODebugBase<LogChannel>.Error(LogChannel.Core, string.Concat("Invalid list detected!\n", Environment.StackTrace)); break; } } } } } int num3 = PrefabCollection<TreeInfo>.PrefabCount(); for (int l = 0; l < num3; l++) { TreeInfo prefab = PrefabCollection<TreeInfo>.GetPrefab((uint)l); if (prefab != null && prefab.m_lodCount != 0) { TreeInstance.RenderLod(cameraInfo, prefab); } } } }
public static void Initialize() { Dispose(); var uiView = UIView.GetAView(); _panel = uiView.AddUIComponent(typeof(UIPanel)) as UIPanel; _panel.name = "WildlifeSpawnerPanel"; _panel.backgroundSprite = "MenuPanel2"; _panel.size = new Vector2(100 + 200 + 12, 72); _panel.isVisible = false; _panel.relativePosition = new Vector3(0, 874); UIUtil.SetupTitle("Wildlife Spawn Point", _panel); var collideLabel = _panel.AddUIComponent <UILabel>(); collideLabel.text = "Animal"; collideLabel.width = 100; collideLabel.height = 24; collideLabel.textScale = 0.8f; collideLabel.relativePosition = new Vector2(4, 44); _animalDropDown = UIUtil.CreateDropDown(_panel); _animalDropDown.width = 200; _animalDropDown.height = 24; _animalDropDown.listWidth = 200; _animalDropDown.tooltip = "Select animal"; _animalDropDown.relativePosition = new Vector2(8 + 100, 44); _animalDropDown.items = new[] { "Random" }.Concat(WildlifeSpawnManager.instance.Animals.m_buffer.Select(index => { var prefab = PrefabCollection <CitizenInfo> .GetPrefab(index); return(prefab != null ? prefab.name : ""); }).Where(s => !string.IsNullOrEmpty(s))).ToArray(); _animalDropDown.listPosition = UIDropDown.PopupListPosition.Above; Reset(); _plopButton = UIView.GetAView().FindUIComponent <UITabstrip>("MainToolstrip").AddUIComponent <UIButton>(); //main button on in game tool strip. _plopButton.size = new Vector2(43, 49); _plopButton.eventClick += (component, param) => { var tool = ToolsModifierControl.SetTool <BuildingTool>(); tool.m_prefab = PrefabCollection <BuildingInfo> .FindLoaded("Wildlife Spawn Point"); }; _plopButton.normalBgSprite = "ToolbarIconGroup6Normal"; _plopButton.normalFgSprite = "IconPolicyBigBusiness"; _plopButton.focusedBgSprite = "ToolbarIconGroup6Focused"; _plopButton.hoveredBgSprite = "ToolbarIconGroup6Hovered"; _plopButton.pressedBgSprite = "ToolbarIconGroup6Pressed"; _plopButton.disabledBgSprite = "ToolbarIconGroup6Disabled"; _plopButton.name = "WildlifeSpawnPointPlopButton"; _plopButton.tooltip = "Place animal spawn point"; }
protected override void Handle(PropCreateCommand command) { PropInfo info = PrefabCollection <PropInfo> .GetPrefab(command.InfoIndex); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(new ushort[] { command.PropId }, null); PropManager.instance.CreateProp(out ushort _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Angle, command.Single); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
public override void Handle(PropCreateCommand command) { PropInfo info = PrefabCollection <PropInfo> .GetPrefab(command.infoindex); PropHandler.IgnoreAll = true; ArrayHandler.StartApplying(new ushort[] { command.PropID }, null); PropManager.instance.CreateProp(out ushort _, ref SimulationManager.instance.m_randomizer, info, command.position, command.angle, command.single); ArrayHandler.StopApplying(); PropHandler.IgnoreAll = false; }
public override void Handle(NodeCreateCommand command) { NetInfo info = PrefabCollection <NetInfo> .GetPrefab(command.InfoIndex); NodeHandler.IgnoreAll = true; ArrayHandler.StartApplying(new ushort[] { command.NodeId }, null); NetManager.instance.CreateNode(out ushort _, ref SimulationManager.instance.m_randomizer, info, command.Position, SimulationManager.instance.m_currentBuildIndex++); ArrayHandler.StopApplying(); NodeHandler.IgnoreAll = false; }
public override void Handle(SegmentCreateCommand command) { NetInfo info = PrefabCollection <NetInfo> .GetPrefab(command.InfoIndex); NodeHandler.IgnoreAll = true; ArrayHandler.StartApplying(new ushort[] { command.SegmentId }, null); NetManager.instance.CreateSegment(out ushort _, ref SimulationManager.instance.m_randomizer, info, command.StartNode, command.EndNode, command.StartDirection, command.EndDirection, SimulationManager.instance.m_currentBuildIndex++, command.ModifiedIndex, command.Invert); ArrayHandler.StopApplying(); NodeHandler.IgnoreAll = false; }
public static VehicleInfo GetVehicleInfo(ref Randomizer randomizer, ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, string prefabName, VehicleInfo.VehicleType vehicleType) { var prefabData = VehiclePrefabs.instance.GetPrefabs(service, subService, level, vehicleType) .Find(item => item.PrefabName == prefabName); if (prefabData != null) { return(PrefabCollection <VehicleInfo> .GetPrefab((uint)prefabData.PrefabDataIndex)); } Utils.LogWarning((object)("Unknown prefab: " + prefabName)); return(Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref randomizer, service, subService, level)); }
protected override void Handle(BuildingCreateCommand command) { BuildingInfo info = PrefabCollection <BuildingInfo> .GetPrefab(command.InfoIndex); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(command.Array16Ids, command.Array32Ids); BuildingManager.instance.CreateBuilding(out _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Angle, command.Length, SimulationManager.instance.m_currentBuildIndex++); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
public override void Handle(BuildingCreateCommand command) { BuildingInfo info = PrefabCollection <BuildingInfo> .GetPrefab(command.InfoIndex); BuildingHandler.IgnoreAll = true; ArrayHandler.StartApplying(new ushort[] { command.BuildingId }, null); BuildingManager.instance.CreateBuilding(out _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Angle, command.Length, SimulationManager.instance.m_currentBuildIndex++); ArrayHandler.StopApplying(); BuildingHandler.IgnoreAll = false; }
/* Load road netinfos */ public void Populate(bool keepSelection = false) { NetInfo lastSelection = null; if (keepSelection) { try { lastSelection = Value; } catch { keepSelection = false; } } var count = PrefabCollection <NetInfo> .PrefabCount(); m_dictionary = new SortedDictionary <StringWithLaneCount, NetInfo>(); bool freeCursor = UIWindow2.instance?.toolOnUI is FreeCursorTool; for (uint i = 0; i < count; i++) { var prefab = PrefabCollection <NetInfo> .GetPrefab(i); if (prefab != null) { //Debug.Log($"Prefab {prefab.GetUncheckedLocalizedTitle()}, fl {prefab.m_hasBackwardVehicleLanes}, bl {prefab.m_hasForwardVehicleLanes}, car flag {(prefab.m_vehicleTypes & VehicleInfo.VehicleType.Car) != 0}"); if (IsEligible(prefab, freeCursor)) { StringWithLaneCount slc = new StringWithLaneCount(prefab); //beautified = (prefab.m_forwardVehicleLaneCount + prefab.m_backwardVehicleLaneCount) + "_" + beautified; if (m_dictionary.ContainsKey(slc)) { slc.Name += " [" + i + "]"; } m_dictionary[slc] = prefab; //Debug.Log("Loaded prefab: " + slc.Name + " ,underground: " + prefab.m_netAI.IsUnderground() + " ,overground: " + prefab.m_netAI.IsOverground()); } } } UpdateListWithPrefab(null); /* It seems that this code is there twice. (In this method and in the UpdateListWithPrefab method.) Yes, basically it is... :( */ if (keepSelection) { int i = Array.IndexOf(m_netInfos, lastSelection); if (i > -1 && i < m_netInfos.Length) { selectedIndex = i; } } }
public static void Postfix(ref RenderManager.CameraInfo cameraInfo) { ItemClass.Availability availability = ToolManager.instance.m_properties.m_mode; FastList <RenderGroup> fastList = RenderManager.instance.m_renderedGroups; int num1 = 1 << LayerMask.NameToLayer("Props") | 1 << RenderManager.instance.lightSystem.m_lightLayer; for (int index1 = 0; index1 < fastList.m_size; ++index1) { RenderGroup renderGroup = fastList.m_buffer[index1]; if ((renderGroup.m_instanceMask & num1) != 0) { int minX = renderGroup.m_x * 270 / 45; int minZ = renderGroup.m_z * 270 / 45; int maxX = (renderGroup.m_x + 1) * 270 / 45 - 1; int maxZ = (renderGroup.m_z + 1) * 270 / 45 - 1; for (int index2 = minZ; index2 <= maxZ; ++index2) { for (int index3 = minX; index3 <= maxX; ++index3) { int gridKey = index2 * 270 + index3; List <PropContainer> list = PropUnlimiterManager.instance.GetPropsInGrid(gridKey); if (list != null) { foreach (PropContainer instance in list) { if (instance.extras.ContainsKey("accx") && instance.extras.ContainsKey("accy") && instance.extras.ContainsKey("accz")) { RenderProp(cameraInfo, instance); } else { instance.propInstance.RenderInstance(cameraInfo, 0, renderGroup.m_instanceMask); } } } } } } } for (int index = 0; index < PrefabCollection <PropInfo> .PrefabCount(); ++index) { PropInfo prefab = PrefabCollection <PropInfo> .GetPrefab((uint)index); if (prefab != null && prefab.m_lodCount != 0) { PropInstance.RenderLod(cameraInfo, prefab); } } }
public static void PatchEveryBuildingAI() { prefabCount = PrefabCollection <BuildingInfo> .PrefabCount(); for (int i = 0; i < prefabCount; ++i) { prefab = PrefabCollection <BuildingInfo> .GetPrefab((uint)i); if (prefab != null) { component = prefab.GetComponent <BuildingAI>(); if (component != null) { Type currentAiType = component.GetType(); Type newAiType = null; if (currentAiType == typeof(ResidentialBuildingAI)) { newAiType = typeof(MyResidentialBuildingAI); } else if (currentAiType == typeof(CommercialBuildingAI)) { newAiType = typeof(MyCommercialBuildingAI); } else if (currentAiType == typeof(IndustrialBuildingAI)) { newAiType = typeof(MyIndustrialBuildingAI); } else if (currentAiType == typeof(IndustrialExtractorAI)) { newAiType = typeof(MyIndustrialExtractorAI); } else if (currentAiType == typeof(OfficeBuildingAI)) { newAiType = typeof(MyOfficeBuildingAI); } if (newAiType != null) { BuildingAI buildingAI = (BuildingAI)prefab.gameObject.AddComponent(newAiType); buildingAI.m_info = prefab; prefab.m_buildingAI = buildingAI; buildingAI.InitializePrefab(); } } } } }
public override void HandleOnServer(NodeSegmentCreateCommand command, Player player) { //Extensions.NodeAndSegmentExtension.NetSegmentLocked = true; NetInfo netinfo = PrefabCollection <NetInfo> .GetPrefab(command.InfoIndex); var startNode = Extensions.NodeAndSegmentExtension.NodeIDDictionary[command.StartNode]; //uses the Dictionary of the Client and Servers different NodeID to convert the recived NodeID the the NodeID of the reciever var endNode = Extensions.NodeAndSegmentExtension.NodeIDDictionary[command.EndNode]; StartEndNode startEndNode = new StartEndNode(Singleton <NetManager> .instance.m_nodes.m_buffer[startNode].m_position, Singleton <NetManager> .instance.m_nodes.m_buffer[endNode].m_position); Extensions.NodeAndSegmentExtension.StartEndNodeDictionary.Add(startEndNode, 100); // add dummy segment to hinder occilation Singleton <NetManager> .instance.CreateSegment(out ushort id, ref Singleton <SimulationManager> .instance.m_randomizer, netinfo, startNode, endNode, command.StartDirection, command.EndDirection, Singleton <SimulationManager> .instance.m_currentBuildIndex, command.ModifiedIndex, false); Extensions.NodeAndSegmentExtension.StartEndNodeDictionary[startEndNode] = id; }
void propToolDropdown_eventSelectedIndexChanged(UIComponent component, int value) { for (uint i = 0; i < PrefabCollection <PropInfo> .PrefabCount(); i++) { var prefab = PrefabCollection <PropInfo> .GetPrefab(i); if ((prefab != null) && prefab.name == propToolDropdown.selectedValue) { var netTool = GameObject.FindObjectOfType <PropTool>(); netTool.m_prefab = prefab; netTool.enabled = true; } } }
public static void BuildVehicleInfoDictionary() { m_prefabs.Clear(); for (uint i = 0; i < PrefabCollection <VehicleInfo> .PrefabCount(); i++) { VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(i); if (prefab != null) { m_prefabs[prefab.name] = prefab; } } }
/// <summary> /// Collects prefabs of the specified prefab type. /// </summary> /// <typeparam name="TPrefab">The type of the prefab.</typeparam> /// <returns> /// A sequence of assets of the specified type. /// </returns> public static IEnumerable <PrefabInfo> Collect <TPrefab>() where TPrefab : PrefabInfo { int count = PrefabCollection <TPrefab> .PrefabCount(); for (uint i = 0; i < count; i++) { PrefabInfo prefab = PrefabCollection <TPrefab> .GetPrefab(i); if ((UnityEngine.Object)prefab != (UnityEngine.Object)null) { yield return(prefab); } } }