public static void EndSession(ItemClass.Availability availability) { try { if (Mod.IsEnabled && Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableAll) || Helper.HasTelemFlag(Mod.config.TelemetryLevel, Helper.TelemOption.DisableEndSession)) { if (Mod.DEBUG_LOG_ON) { Helper.dbgLog("End Session telemetry disabled."); } return; } TelemetryKH telemetry = new TelemetryKH(); telemetry.AddEvent("end_session", new Telemetry.Pair[] { new Telemetry.Pair("type", availability.ToString()) }); telemetry.Push(); } catch (Exception ex) { CODebugBase <LogChannel> .Warn(LogChannel.HTTP, ex.GetType() + ": Telemetry event failed " + ex.Message); } }
private static float CalculateCameraHeightOffset(Vector3 worldPos, float distance) { float num = TerrainManager.instance.SampleRawHeightSmoothWithWater(worldPos, true, 2f); float num2 = num - worldPos.y; distance *= 0.45f; num2 = Mathf.Max(num2, -distance); num2 += distance * 0.375f * Mathf.Pow(1f + 1f / distance, -num2); num = worldPos.y + num2; ItemClass.Availability mode = ToolManager.instance.m_properties.m_mode; if ((mode & ItemClass.Availability.AssetEditor) == ItemClass.Availability.None) { ItemClass.Layer layer = ItemClass.Layer.Default; if ((mode & ItemClass.Availability.MapEditor) != ItemClass.Availability.None) { layer |= ItemClass.Layer.Markers; } worldPos.y -= 5f; num = Mathf.Max(num, BuildingManager.instance.SampleSmoothHeight(worldPos, layer) + 5f); num = Mathf.Max(num, NetManager.instance.SampleSmoothHeight(worldPos) + 5f); num = Mathf.Max(num, PropManager.instance.SampleSmoothHeight(worldPos) + 5f); num = Mathf.Max(num, TreeManager.instance.SampleSmoothHeight(worldPos) + 5f); worldPos.y += 5f; } return(num - worldPos.y); }
public new bool PointOutOfArea(Vector3 p) { //begin mod if (_isCrossingLineProhibited != null) { if (!(bool)_isCrossingLineProhibited.Invoke(null, new object[] { })) { return(false); } } //end mod ItemClass.Availability availability = Singleton <ToolManager> .instance.m_properties.m_mode; if ((availability & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { //begin mod //end mod } else { bool flag = (availability & ItemClass.Availability.Editors) != ItemClass.Availability.None; //begin mod int area = this.GetArea(Mathf.FloorToInt((float)((double)p.x / 1920.0 + HALFGRID)), Mathf.FloorToInt((float)((double)p.z / 1920.0 + HALFGRID))); //end mod if (area == -2 || !flag && area <= 0) { return(true); } } return(false); }
public new bool CheckLimits() { //begin mod if (BuildingDecorationDetour.DisableLimits) { return(true); } //end mod ItemClass.Availability availability = Singleton <ToolManager> .instance.m_properties.m_mode; if ((availability & ItemClass.Availability.MapEditor) != ItemClass.Availability.None) { if (this.m_treeCount >= 250000) { return(false); } } else if ((availability & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { //begin mod if (this.m_treeCount + Singleton <PropManager> .instance.m_propCount >= 64 + SpecialPoints.CountSpecialPoints()) { return(false); } //end mod } else if (this.m_treeCount >= 262139) { return(false); } return(true); }
private static bool CheckLimits(TreeManager tm) { ItemClass.Availability mMode = Singleton<ToolManager>.instance.m_properties.m_mode; if ((mMode & ItemClass.Availability.MapEditor) != ItemClass.Availability.None) { // changed to enable >250k in mapeditor. //if (tm.m_treeCount >= 250000) if (tm.m_treeCount >= LimitTreeManager.Helper.TreeLimit - 5) { return false; } } else if ((mMode & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { if (tm.m_treeCount + Singleton<PropManager>.instance.m_propCount >= 64) { return false; } } else if (tm.m_treeCount >= LimitTreeManager.Helper.TreeLimit - 5) { return false; } return true; }
private void UpdateAreaMapping() { if (this.AreasVisible) { this.UpdateAreaTexture(); } var camController = (CameraController)typeof(GameAreaManager).GetField("m_cameraController", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this); if (camController == null) { return; } if (this.AreasVisible) { Vector3 vector = camController.transform.TransformDirection(Vector3.right); ItemClass.Availability mode = Singleton <ToolManager> .instance.m_properties.m_mode; Bounds freeBounds; if ((mode & ItemClass.Availability.MapEditor) != ItemClass.Availability.None) { freeBounds = new Bounds(new Vector3(0f, 512f, 0f), new Vector3(9600f, 1024f, 9600f)); } else { freeBounds = this.GetFreeBounds(); } Vector3 center = freeBounds.center; if (Mathf.Abs(vector.x) >= Mathf.Abs(vector.z)) { if (vector.x > 0f) { center.z -= freeBounds.size.z * 0.02f + 50f; } else { center.z += freeBounds.size.z * 0.02f + 50f; } camController.SetOverrideModeOn(center, new Vector2((vector.x <= 0f) ? 180f : 0f, 80f), freeBounds.size.z); } else { if (vector.z > 0f) { center.x += freeBounds.size.x * 0.02f + 50f; } else { center.x -= freeBounds.size.x * 0.02f + 50f; } camController.SetOverrideModeOn(center, new Vector2((vector.z <= 0f) ? 90f : -90f, 80f), freeBounds.size.x); } } else { camController.SetOverrideModeOff(); } }
public new bool QuadOutOfArea(Quad2 quad) { //begin mod if (_isCrossingLineProhibited != null) { if (!(bool)_isCrossingLineProhibited.Invoke(null, new object[] {})) { return(false); } } //end mod ItemClass.Availability availability = Singleton <ToolManager> .instance.m_properties.m_mode; if ((availability & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { //begin mod //end mod } else { bool flag = (availability & ItemClass.Availability.Editors) != ItemClass.Availability.None; Vector2 vector2_1 = quad.Min(); Vector2 vector2_2 = quad.Max(); //begin mod int num1 = Mathf.FloorToInt((float)(((double)vector2_1.x - 8.0) / 1920.0 + HALFGRID)); int num2 = Mathf.FloorToInt((float)(((double)vector2_1.y - 8.0) / 1920.0 + HALFGRID)); int num3 = Mathf.FloorToInt((float)(((double)vector2_2.x + 8.0) / 1920.0 + HALFGRID)); int num4 = Mathf.FloorToInt((float)(((double)vector2_2.y + 8.0) / 1920.0 + HALFGRID)); //end mod for (int z = num2; z <= num4; ++z) { for (int x = num1; x <= num3; ++x) { int area = this.GetArea(x, z); if (area == -2 || !flag && area <= 0) { //begin mod if (quad.Intersect(new Quad2() { a = new Vector2((float)(((double)x - HALFGRID) * 1920.0 - 8.0), (float)(((double)z - HALFGRID) * 1920.0 - 8.0)), b = new Vector2((float)(((double)x - HALFGRID) * 1920.0 - 8.0), (float)(((double)z - HALFGRID + 1.0) * 1920.0 + 8.0)), c = new Vector2((float)(((double)x - HALFGRID + 1.0) * 1920.0 + 8.0), (float)(((double)z - HALFGRID + 1.0) * 1920.0 + 8.0)), d = new Vector2((float)(((double)x - HALFGRID + 1.0) * 1920.0 + 8.0), (float)(((double)z - HALFGRID) * 1920.0 - 8.0)) })) { //end mod return(true); } } } } } return(false); }
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 new bool CheckLimits() { //begin mod if (BuildingDecorationDetour.DisableLimits) { return(true); } var propTool = ToolsModifierControl.GetCurrentTool <PropTool>(); if (propTool != null) { var pointType = SpecialPoints.GetSpecialPointType(propTool.m_prefab); if (pointType != SpecialPointType.Unknown) { if (!Panel.specialPointTypeCount.TryGetValue(pointType, out var pointTypeCount)) { pointTypeCount = 9999; } return(pointTypeCount < SpecialPoints.GetMaxNumberOfPoints(ToolsModifierControl.toolController.m_editPrefabInfo as BuildingInfo, pointType)); } } //end mod ItemClass.Availability availability = Singleton <ToolManager> .instance.m_properties.m_mode; if ((availability & ItemClass.Availability.MapEditor) != ItemClass.Availability.None) { if (this.m_propCount >= 50000) { return(false); } } else if ((availability & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { //begin mod if (this.m_propCount + Singleton <TreeManager> .instance.m_treeCount >= 64 + SpecialPoints.CountSpecialPoints()) { return(false); } //end mod } else if (this.m_propCount >= 65531) { return(false); } return(true); }
public bool PointOutOfArea(Vector3 p, float radius) { //begin mod if (_isCrossingLineProhibited != null) { if (!(bool)_isCrossingLineProhibited.Invoke(null, new object[] { })) { return(false); } } //end mod ItemClass.Availability availability = Singleton <ToolManager> .instance.m_properties.m_mode; if ((availability & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { //begin mod //end mod } else { bool flag = (availability & ItemClass.Availability.Editors) != ItemClass.Availability.None; //begin mod int num1 = Mathf.FloorToInt((float)(((double)p.x - (double)radius) / 1920.0 + HALFGRID)); int num2 = Mathf.FloorToInt((float)(((double)p.z - (double)radius) / 1920.0 + HALFGRID)); int num3 = Mathf.FloorToInt((float)(((double)p.x + (double)radius) / 1920.0 + HALFGRID)); int num4 = Mathf.FloorToInt((float)(((double)p.z + (double)radius) / 1920.0 + HALFGRID)); //end mod for (int z = num2; z <= num4; ++z) { for (int x = num1; x <= num3; ++x) { int area = this.GetArea(x, z); if (area == -2 || !flag && area <= 0) { return(true); } } } } return(false); }
public override ToolBase.RaycastService GetService() { ItemClass.Layer trafficLayer = (this.GetType() != typeof(BulldozeTool)) ? ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels | ItemClass.Layer.Markers : ItemClass.Layer.MetroTunnels; ItemClass.Availability mode = Singleton <ToolManager> .instance.m_properties.m_mode; if ((mode & ItemClass.Availability.MapAndAsset) != ItemClass.Availability.None) { InfoManager.InfoMode currentMode = Singleton <InfoManager> .instance.CurrentMode; if (currentMode == InfoManager.InfoMode.Transport) { return(new ToolBase.RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels | ItemClass.Layer.AirplanePaths | ItemClass.Layer.ShipPaths | ItemClass.Layer.Markers)); } if (currentMode != InfoManager.InfoMode.Traffic) { return(new ToolBase.RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default | ItemClass.Layer.Markers)); } return(new ToolBase.RaycastService(ItemClass.Service.None, ItemClass.SubService.None, trafficLayer | ItemClass.Layer.Markers)); } else { InfoManager.InfoMode currentMode = Singleton <InfoManager> .instance.CurrentMode; if (currentMode == InfoManager.InfoMode.Water) { return(new ToolBase.RaycastService(ItemClass.Service.Water, ItemClass.SubService.None, ItemClass.Layer.Default | ItemClass.Layer.WaterPipes)); } if (currentMode == InfoManager.InfoMode.Transport) { return(new ToolBase.RaycastService(ItemClass.Service.PublicTransport, ItemClass.SubService.None, ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels)); } if (currentMode != InfoManager.InfoMode.Traffic) { return(new ToolBase.RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default)); } return(new ToolBase.RaycastService(ItemClass.Service.None, ItemClass.SubService.None, trafficLayer)); } }
public override void OnAfterSimulationFrame() { if (!Singleton <ExtendedGameOptionsManager> .instance.values.EnableRandomDisastersForScenarios) { return; } // If playing a scenario if (!string.IsNullOrEmpty(Singleton <SimulationManager> .instance.m_metaData.m_ScenarioAsset)) { DisasterManager dm = Singleton <DisasterManager> .instance; // From DisasterManager.SimulationStepImpl ItemClass.Availability mode = Singleton <ToolManager> .instance.m_properties.m_mode; if ((mode & ItemClass.Availability.Game) != ItemClass.Availability.None) { int areaCount = Singleton <GameAreaManager> .instance.m_areaCount; float num = dm.m_randomDisastersProbability; if (num > 0.001f) { num *= num; num *= (float)((areaCount > 1) ? (550 + areaCount * 50) : 500); int num2 = Mathf.Max(1, Mathf.RoundToInt(num)); if (dm.m_randomDisasterCooldown < 65536 - 49152 * num2 / 1000) { dm.m_randomDisasterCooldown++; } else { SimulationManager instance = Singleton <SimulationManager> .instance; if (instance.m_randomizer.Int32(67108864u) < num2) { dm.StartRandomDisaster(); dm.m_randomDisasterCooldown = 0; } } } } } }
public override void Handle(PropCreateCommand command) { PropInfo info = PrefabCollection <PropInfo> .GetPrefab(command.infoindex); ushort prop = command.PropID; PropManager.instance.m_props.RemoveUnused(prop); PropManager.instance.m_props.m_buffer[prop].m_flags = 1; PropManager.instance.m_props.m_buffer[prop].Info = info; PropManager.instance.m_props.m_buffer[prop].Single = command.single; PropManager.instance.m_props.m_buffer[prop].Blocked = false; PropManager.instance.m_props.m_buffer[prop].Position = command.position; PropManager.instance.m_props.m_buffer[prop].Angle = command.angle; DistrictManager instance = Singleton <DistrictManager> .instance; byte park = instance.GetPark(command.position); instance.m_parks.m_buffer[park].m_propCount = (ushort)(instance.m_parks.m_buffer[park].m_propCount + 1); ItemClass.Availability mode = Singleton <ToolManager> .instance.m_properties.m_mode; _initializeProp.Invoke(Singleton <PropManager> .instance, new object[] { prop, Singleton <PropManager> .instance.m_props.m_buffer[prop], ((mode & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) }); PropManager.instance.UpdateProp(prop); PropManager.instance.m_propCount = ((int)PropManager.instance.m_props.ItemCount()) - 1; }
public override void Handle(TreeCreateCommand command) { TreeInfo info = PrefabCollection <TreeInfo> .GetPrefab(command.InfoIndex); uint tree = command.TreeID; TreeManager.instance.m_trees.RemoveUnused(tree); TreeManager.instance.m_trees.m_buffer[tree].m_flags = 1; TreeManager.instance.m_trees.m_buffer[tree].Info = info; TreeManager.instance.m_trees.m_buffer[tree].Single = command.Single; TreeManager.instance.m_trees.m_buffer[tree].GrowState = 15; TreeManager.instance.m_trees.m_buffer[tree].Position = command.Position; DistrictManager instance = Singleton <DistrictManager> .instance; byte park = instance.GetPark(command.Position); instance.m_parks.m_buffer[park].m_treeCount++; ItemClass.Availability mode = Singleton <ToolManager> .instance.m_properties.m_mode; _initializeTree.Invoke(Singleton <TreeManager> .instance, new object[] { tree, Singleton <TreeManager> .instance.m_trees.m_buffer[tree], ((mode & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) }); TreeManager.instance.UpdateTree(tree); TreeManager.instance.m_treeCount = ((int)TreeManager.instance.m_trees.ItemCount()) - 1; }
/// <summary> /// Gets called upon the base UI component's creation. Basically it's the constructor...but not really. /// </summary> public override void Start() { base.Start(); if (SomeModName.DEBUG_LOG_ON & SomeModName.DEBUG_LOG_LEVEL > 0) Logger.dbgLog(string.Concat("Attempting to create our display panel. ",DateTime.Now.ToString(DTMilli).ToString())); this.size = new Vector2(WIDTH, HEIGHT); this.backgroundSprite = "MenuPanel"; this.canFocus = true; this.isInteractive = true; this.BringToFront(); this.relativePosition = new Vector3((Loader.parentGuiView.fixedWidth / 2) - 200, (Loader.parentGuiView.fixedHeight / 2) - 350); this.opacity = SomeModName.config.GuiOpacity; this.cachedName = cacheName; SomeModNameGUI.instance = this; CurrentMode = Singleton<ToolManager>.instance.m_properties.m_mode; //DragHandler m_DragHandler = this.AddUIComponent<UIDragHandle>(); m_DragHandler.target = this; //set the drag hangler target to this panel. it will do the rest magically. //Our Titlebar UILabel m_title = this.AddUIComponent<UILabel>(); m_title.text = "Vehicle Cargo Data"; //spaces on purpose m_title.relativePosition = new Vector3(WIDTH / 2 - (m_title.width / 2) - 25f, (HEADER / 2) - (m_title.height / 2)); m_title.textAlignment = UIHorizontalAlignment.Center; //Our Close Button UIButton m_closeButton = this.AddUIComponent<UIButton>(); m_closeButton.normalBgSprite = "buttonclose"; m_closeButton.hoveredBgSprite = "buttonclosehover"; m_closeButton.pressedBgSprite = "buttonclosepressed"; m_closeButton.relativePosition = new Vector3(WIDTH - 35, 5, 10); m_closeButton.eventClick += (component, eventParam) => { this.Hide(); }; //^^above that's just an inline delegate to trigger hidding the panel when someone clicks the ' X ' (close) Button //What's our config say about Showing on map load? if (!SomeModName.config.AutoShowOnMapLoad) { this.Hide(); } DoOnStartup(); //let go do some other stuff too during "start" if (SomeModName.DEBUG_LOG_ON) Logger.dbgLog(string.Concat("Display panel created. ",DateTime.Now.ToString(DTMilli).ToString())); }
protected new void BeginOverlayImpl(RenderManager.CameraInfo cameraInfo) { float borderAlpha = (float)_borderAlphaField.GetValue(this); float areaAlpha = (float)_areaAlphaField.GetValue(this); Material borderMaterial = (Material)_borderMaterialField.GetValue(this); Material areaMaterial = (Material)_areaMaterialField.GetValue(this); Mesh borderMesh = (Mesh)_borderMeshField.GetValue(this); int ID_Color = (int)_idColorField.GetValue(this); int ID_AreaMapping = (int)_idAreaMappingField.GetValue(this); Texture2D areaTex = (Texture2D)_areaTex.GetValue(this); ItemClass.Availability availability = Singleton <ToolManager> .instance.m_properties.m_mode; if ((availability & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { //begin mod //end mod } else if ((availability & (ItemClass.Availability.MapEditor | ItemClass.Availability.ScenarioEditor)) != ItemClass.Availability.None) { //begin mod //end mod } else { if ((availability & ItemClass.Availability.Editors) != ItemClass.Availability.None) { return; } if (borderAlpha >= 1.0 / 1000.0 && borderMaterial != (UnityEngine.Object)null) { Quaternion rotation = Quaternion.AngleAxis(90f, Vector3.up); Color color = Color.white; ToolController toolController = Singleton <ToolManager> .instance.m_properties; if ((UnityEngine.Object)toolController != (UnityEngine.Object)null && (toolController.CurrentTool.GetErrors() & ToolBase.ToolErrors.OutOfArea) != ToolBase.ToolErrors.None) { color = Color.red; } color.a = borderAlpha; //begin mod for (int z = 0; z <= FakeGameAreaManager.GRID; ++z) { for (int x = 0; x <= FakeGameAreaManager.GRID; ++x) { //end mod bool flag1 = this.GetArea(x, z) > 0; bool flag2 = this.GetArea(x, z - 1) > 0; bool flag3 = this.GetArea(x - 1, z) > 0; if (flag1 != flag2) { //begin mod Vector3 vector3 = new Vector3((float)(((double)x - FakeGameAreaManager.HALFGRID + 0.5) * 1920.0), 0.0f, (float)(((double)z - FakeGameAreaManager.HALFGRID) * 1920.0)); //end mod Vector3 size = new Vector3(1920f, 1024f, 100f); Bounds bounds = new Bounds(vector3 + new Vector3(0.0f, size.y * 0.5f, 0.0f), size); if (cameraInfo.Intersect(bounds)) { Singleton <TerrainManager> .instance.SetWaterMaterialProperties(vector3, borderMaterial); borderMaterial.SetColor(ID_Color, color); if (borderMaterial.SetPass(0)) { ++Singleton <GameAreaManager> .instance.m_drawCallData.m_overlayCalls; Graphics.DrawMeshNow(borderMesh, vector3, rotation); } } } if (flag1 != flag3) { //begin mod Vector3 vector3 = new Vector3((float)(((double)x - FakeGameAreaManager.HALFGRID) * 1920.0), 0.0f, (float)(((double)z - FakeGameAreaManager.HALFGRID + 0.5) * 1920.0)); //end mod Vector3 size = new Vector3(100f, 1024f, 1920f); Bounds bounds = new Bounds(vector3 + new Vector3(0.0f, size.y * 0.5f, 0.0f), size); if (cameraInfo.Intersect(bounds)) { Singleton <TerrainManager> .instance.SetWaterMaterialProperties(vector3, borderMaterial); borderMaterial.SetColor(ID_Color, color); if (borderMaterial.SetPass(0)) { ++Singleton <GameAreaManager> .instance.m_drawCallData.m_overlayCalls; Graphics.DrawMeshNow(borderMesh, vector3, Quaternion.identity); } } } } } } if (areaAlpha < 1.0 / 1000.0 || !(areaMaterial != (UnityEngine.Object)null)) { return; } Vector4 vector; vector.z = 1.0f / (1920.0f * AREA_TEX_SIZE); vector.x = (FakeGameAreaManager.GRID + 0.0f) / (AREA_TEX_SIZE * 2.0f); vector.y = (FakeGameAreaManager.GRID + 0.0f) / (AREA_TEX_SIZE * 2.0f); vector.w = 1.0f / (1.0f * AREA_TEX_SIZE); areaMaterial.mainTexture = areaTex; areaMaterial.SetColor(ID_Color, new Color(1f, 1f, 1f, areaAlpha)); areaMaterial.SetVector(ID_AreaMapping, vector); Bounds freeBounds = this.GetFreeBounds(); freeBounds.size = freeBounds.size + new Vector3(100f, 1f, 100f); ++Singleton <GameAreaManager> .instance.m_drawCallData.m_overlayCalls; Singleton <RenderManager> .instance.OverlayEffect.DrawEffect(cameraInfo, areaMaterial, 0, freeBounds); } }
public new bool ClampPoint(ref Vector3 position) { ItemClass.Availability availability = Singleton <ToolManager> .instance.m_properties.m_mode; if ((availability & ItemClass.Availability.AssetEditor) != ItemClass.Availability.None) { //begin mod //end mod return(true); } if ((availability & ItemClass.Availability.Editors) != ItemClass.Availability.None) { //begin mod //end mod return(true); } //begin mod if (this.GetArea(Mathf.FloorToInt((float)((double)position.x / 1920.0 + HALFGRID)), Mathf.FloorToInt((float)((double)position.z / 1920.0 + HALFGRID))) > 0) { //end mod return(true); } Rect rect1 = new Rect(); //begin mod rect1.xMin = -1920 * HALFGRID; rect1.yMin = -1920 * HALFGRID; rect1.xMax = 1920 * HALFGRID; rect1.yMax = 1920 * HALFGRID; //end mod float num3 = 1000000f; //begin mod if (m_areaGrid.Length == 25) { //end mod //the following is original code for (int index1 = 0; index1 < 5; ++index1) { for (int index2 = 0; index2 < 5; ++index2) { if (this.m_areaGrid[index1 * 5 + index2] > 0) { Rect rect2 = new Rect(); rect2.xMin = (float)(((double)index2 - 2.5) * 1920.0); rect2.yMin = (float)(((double)index1 - 2.5) * 1920.0); rect2.xMax = rect2.xMin + 1920f; rect2.yMax = rect2.yMin + 1920f; float num1 = Mathf.Max(Mathf.Max(position.x - rect2.xMax, rect2.xMin - position.x), Mathf.Max(position.z - rect2.yMax, rect2.yMin - position.z)); if ((double)num1 < (double)num3) { rect1 = rect2; num3 = num1; } } } } //begin mod //the following is the modified version of original above } else { for (int index1 = 0; index1 < GRID; ++index1) { for (int index2 = 0; index2 < GRID; ++index2) { if (this.m_areaGrid[index1 * GRID + index2] > 0) { //end mod Rect rect2 = new Rect(); //begin mod rect2.xMin = (float)(((double)index2 - HALFGRID) * 1920.0); rect2.yMin = (float)(((double)index1 - HALFGRID) * 1920.0); //end mod rect2.xMax = rect2.xMin + 1920f; rect2.yMax = rect2.yMin + 1920f; float num1 = Mathf.Max(Mathf.Max(position.x - rect2.xMax, rect2.xMin - position.x), Mathf.Max(position.z - rect2.yMax, rect2.yMin - position.z)); if ((double)num1 < (double)num3) { rect1 = rect2; num3 = num1; } } } } } if ((double)position.x < (double)rect1.xMin) { position.x = rect1.xMin; } if ((double)position.x > (double)rect1.xMax) { position.x = rect1.xMax; } if ((double)position.z < (double)rect1.yMin) { position.z = rect1.yMin; } if ((double)position.z > (double)rect1.yMax) { position.z = rect1.yMax; } return((double)num3 != 1000000.0); }
// copy modified from DefaultTool.GetService() public virtual RaycastService GetService() { var currentMode = Singleton <InfoManager> .instance.CurrentMode; var currentSubMode = Singleton <InfoManager> .instance.CurrentSubMode; ItemClass.Availability avaliblity = Singleton <ToolManager> .instance.m_properties.m_mode; if ((avaliblity & ItemClass.Availability.MapAndAsset) == ItemClass.Availability.None) { switch (currentMode) { case InfoManager.InfoMode.TrafficRoutes: case InfoManager.InfoMode.Tours: break; case InfoManager.InfoMode.Underground: if (currentSubMode == InfoManager.SubInfoMode.Default) { return(new RaycastService { m_itemLayers = ItemClass.Layer.MetroTunnels }); } // ignore water pipes: return(new RaycastService { m_itemLayers = ItemClass.Layer.Default }); default: if (currentMode != InfoManager.InfoMode.Water) { if (currentMode == InfoManager.InfoMode.Transport) { return(new RaycastService( ItemClass.Service.PublicTransport, ItemClass.SubService.None, ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels /*| ItemClass.Layer.MetroTunnels | ItemClass.Layer.BlimpPaths | ItemClass.Layer.HelicopterPaths | ItemClass.Layer.FerryPaths*/ )); } if (currentMode == InfoManager.InfoMode.Traffic) { break; } if (currentMode != InfoManager.InfoMode.Heating) { return(new RaycastService { m_itemLayers = ItemClass.Layer.Default }); } } // ignore water pipes: //return new RaycastService(ItemClass.Service.Water, ItemClass.SubService.None, ItemClass.Layer.Default | ItemClass.Layer.WaterPipes); return(new RaycastService { m_itemLayers = ItemClass.Layer.Default }); case InfoManager.InfoMode.Fishing: // ignore fishing //return new RaycastService(ItemClass.Service.Fishing, ItemClass.SubService.None, ItemClass.Layer.Default | ItemClass.Layer.FishingPaths); return(new RaycastService { m_itemLayers = ItemClass.Layer.Default }); } return(new RaycastService { m_itemLayers = ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels }); } if (currentMode != InfoManager.InfoMode.Underground) { if (currentMode != InfoManager.InfoMode.Tours) { if (currentMode == InfoManager.InfoMode.Transport) { return(new RaycastService { m_itemLayers = ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels /*| ItemClass.Layer.AirplanePaths | ItemClass.Layer.ShipPaths | ItemClass.Layer.Markers*/ }); } if (currentMode != InfoManager.InfoMode.Traffic) { return(new RaycastService { m_itemLayers = ItemClass.Layer.Default | ItemClass.Layer.Markers }); } } return(new RaycastService { m_itemLayers = ItemClass.Layer.Default | ItemClass.Layer.MetroTunnels | ItemClass.Layer.Markers }); } return(new RaycastService { m_itemLayers = ItemClass.Layer.MetroTunnels }); }
/// <summary> /// Gets called upon the base UI component's creation. Basically it's the constructor...but not really. /// </summary> public override void Start() { base.Start(); CSLShowMoreLimitsGUI.instance = this; if (Mod.DEBUG_LOG_ON & Mod.DEBUG_LOG_LEVEL > 0) Helper.dbgLog(string.Concat("Attempting to create our display panel. ",DateTime.Now.ToString(DTMilli).ToString())); this.size = new Vector2(WIDTH, HEIGHT); this.backgroundSprite = "MenuPanel"; this.canFocus = true; this.isInteractive = true; this.BringToFront(); this.relativePosition = new Vector3((Loader.parentGuiView.fixedWidth / 2) - 200, (Loader.parentGuiView.fixedHeight / 2) - 350); this.opacity = Mod.config.GuiOpacity; this.cachedName = cacheName; CurrentMode = Singleton<ToolManager>.instance.m_properties.m_mode; /* if (CurrentMode == ItemClass.Availability.MapEditor) { Helper.dbgLog("sdfsfasdfasdfasdfasdfasdfasdf"); UITextureAtlas[] tAtlas; tAtlas = FindObjectsOfType<UITextureAtlas>(); if (tAtlas != null) { for (int i = 0; i < tAtlas.Length; i++) { if (tAtlas[i].name == "Ingame") { this.atlas = tAtlas[i]; Helper.dbgLog("sdfsfa22222222222222222222asdf"); break; } } } } */ //DragHandler m_DragHandler = this.AddUIComponent<UIDragHandle>(); m_DragHandler.target = this; //Title UILabel m_title = this.AddUIComponent<UILabel>(); m_title.text = "Counter and Object Limit Data"; //spaces on purpose m_title.relativePosition = new Vector3(WIDTH / 2 - (m_title.width / 2) - 25f, (HEADER / 2) - (m_title.height / 2)); m_title.textAlignment = UIHorizontalAlignment.Center; //Close Button UIButton m_closeButton = this.AddUIComponent<UIButton>(); m_closeButton.normalBgSprite = "buttonclose"; m_closeButton.hoveredBgSprite = "buttonclosehover"; m_closeButton.pressedBgSprite = "buttonclosepressed"; m_closeButton.relativePosition = new Vector3(WIDTH - 35, 5, 10); m_closeButton.eventClick += (component, eventParam) => { this.Hide(); }; if (!Mod.config.AutoShowOnMapLoad) { this.Hide(); } DoOnStartup(); if (Mod.DEBUG_LOG_ON) Helper.dbgLog(string.Concat("Display panel created. ",DateTime.Now.ToString(DTMilli).ToString())); }