Ejemplo n.º 1
0
    protected override void OnButtonClicked(UIComponent comp)
    {
        object       objectUserData = comp.objectUserData;
        BuildingInfo buildingInfo   = objectUserData as BuildingInfo;
        NetInfo      netInfo        = objectUserData as NetInfo;
        TreeInfo     treeInfo       = objectUserData as TreeInfo;
        PropInfo     propInfo       = objectUserData as PropInfo;

        if (buildingInfo != null)
        {
            BuildingTool buildingTool = ToolsModifierControl.SetTool <BuildingTool>();
            if (buildingTool != null)
            {
                if (base.pathsOptionPanel != null)
                {
                    base.pathsOptionPanel.Hide();
                }
                buildingTool.m_prefab   = buildingInfo;
                buildingTool.m_relocate = 0;
            }
        }
        if (netInfo != null)
        {
            NetToolFine netTool = ToolsModifierControl.SetTool <NetToolFine>();
            if (netTool != null)
            {
                if (base.pathsOptionPanel != null)
                {
                    base.pathsOptionPanel.Show();
                }
                netTool.m_prefab = netInfo;
            }
        }
        if (treeInfo != null)
        {
            TreeTool treeTool = ToolsModifierControl.SetTool <TreeTool>();
            if (treeTool != null)
            {
                if (base.pathsOptionPanel != null)
                {
                    base.pathsOptionPanel.Hide();
                }
                treeTool.m_prefab = treeInfo;
                treeTool.m_mode   = TreeTool.Mode.Single;
            }
        }
        if (propInfo != null)
        {
            PropTool propTool = ToolsModifierControl.SetTool <PropTool>();
            if (propTool != null)
            {
                if (base.pathsOptionPanel != null)
                {
                    base.pathsOptionPanel.Hide();
                }
                propTool.m_prefab = propInfo;
                propTool.m_mode   = PropTool.Mode.Single;
            }
        }
    }
Ejemplo n.º 2
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            base.RenderOverlay(cameraInfo);
            if (!enabled)
            {
                return;
            }

            if (np_hoveredObject.NetSegment != 0)
            {
                NetSegment hoveredSegment = np_hoveredObject.NetSegment.S();
                NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, _hovc, new Color(1f, 0f, 0f, 1f));
            }
            else if (np_hoveredObject.NetNode != 0 && np_hoveredObject.NetNode < 32768)
            {
                NetNode hoveredNode = np_hoveredObject.NetNode.N();
                RenderManager.instance.OverlayEffect.DrawCircle(cameraInfo, _hovc, hoveredNode.m_position, Mathf.Max(6f, hoveredNode.Info.m_halfWidth * 2f), -1f, 1280f, false, true);
            }
            else if (np_hoveredObject.Building != 0)
            {
                Building hoveredBuilding = np_hoveredObject.Building.B();
                BuildingTool.RenderOverlay(cameraInfo, ref hoveredBuilding, _hovc, _hovc);
            }
            else if (np_hoveredObject.Tree != 0)
            {
                TreeInstance hoveredTree = np_hoveredObject.Tree.T();
                TreeTool.RenderOverlay(cameraInfo, hoveredTree.Info, hoveredTree.Position, hoveredTree.Info.m_minScale, _hovc);
            }
            else if (np_hoveredObject.Prop != 0)
            {
                PropInstance hoveredTree = np_hoveredObject.Prop.P();
                PropTool.RenderOverlay(cameraInfo, hoveredTree.Info, hoveredTree.Position, hoveredTree.Info.m_minScale, hoveredTree.Angle, _hovc);
            }
        }
Ejemplo n.º 3
0
        public override void RenderCloneOverlay(InstanceState instanceState, ref Matrix4x4 matrix4x, Vector3 deltaPosition, float deltaAngle, Vector3 center, bool followTerrain, RenderManager.CameraInfo cameraInfo, Color toolColor)
        {
            if (MoveItTool.m_isLowSensitivity)
            {
                return;
            }

            PropState state = instanceState as PropState;

            PropInfo   info       = state.Info.Prefab as PropInfo;
            Randomizer randomizer = new Randomizer(state.instance.id.Prop);
            float      scale      = info.m_minScale + (float)randomizer.Int32(10000u) * (info.m_maxScale - info.m_minScale) * 0.0001f;

            Vector3 newPosition = matrix4x.MultiplyPoint(state.position - center);

            newPosition.y = state.position.y + deltaPosition.y;

            if (followTerrain)
            {
                newPosition.y = newPosition.y - state.terrainHeight + TerrainManager.instance.SampleOriginalRawHeightSmooth(newPosition);
            }

            float newAngle = state.angle + deltaAngle;

            PropTool.RenderOverlay(cameraInfo, info, newPosition, scale, newAngle, toolColor);
        }
        public new void OnClick(UIComponent comp, UIMouseEventParameter p)
        {
            UIButton uiButton = p.source as UIButton;
            int      byIndex  = this.GetByIndex((UIComponent)uiButton);

            if (byIndex == -1)
            {
                return;
            }
            this.SelectByIndex(byIndex);
            Texture2D texture2D        = uiButton.objectUserData as Texture2D;
            var       brushesContainer =
                (UIScrollablePanel)typeof(BrushOptionPanel).GetField("m_BrushesContainer", BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(this);

            if (!((UnityEngine.Object)uiButton.parent == (UnityEngine.Object)brushesContainer) || !((UnityEngine.Object)texture2D != (UnityEngine.Object)null))
            {
                return;
            }
            TerrainTool tool1 = ToolsModifierControl.GetTool <TerrainTool>();

            if ((UnityEngine.Object)tool1 != (UnityEngine.Object)null)
            {
                tool1.m_brush = texture2D;
            }
            TreeTool tool2 = ToolsModifierControl.GetTool <TreeTool>();

            if ((UnityEngine.Object)tool2 != (UnityEngine.Object)null)
            {
                tool2.m_brush = texture2D;
            }
            ResourceTool tool3 = ToolsModifierControl.GetTool <ResourceTool>();

            if ((UnityEngine.Object)tool3 != (UnityEngine.Object)null)
            {
                tool3.m_brush = texture2D;
            }
            PropTool tool4 = ToolsModifierControl.GetTool <PropTool>();

            if ((UnityEngine.Object)tool4 == (UnityEngine.Object)null)
            {
                tool4.m_brush = texture2D;
            }
            //begin mod
            try
            {
                Plugins.SetBrush(texture2D);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }
            //end mod
        }
Ejemplo n.º 5
0
        public static void SelectPrefab(PrefabInfo prefab)
        {
            BuildingInfo  buildingInfo  = prefab as BuildingInfo;
            NetInfo       netInfo       = prefab as NetInfo;
            TransportInfo transportInfo = prefab as TransportInfo;
            TreeInfo      treeInfo      = prefab as TreeInfo;
            PropInfo      propInfo      = prefab as PropInfo;

            if (buildingInfo != null)
            {
                BuildingTool buildingTool = ToolsModifierControl.SetTool <BuildingTool>();
                if (buildingTool != null)
                {
                    buildingTool.m_prefab   = buildingInfo;
                    buildingTool.m_relocate = 0;
                }
            }
            if (netInfo != null)
            {
                NetTool netTool = ToolsModifierControl.SetTool <NetTool>();
                if (netTool != null)
                {
                    netTool.Prefab = netInfo;
                }
            }
            if (transportInfo != null)
            {
                TransportTool transportTool = ToolsModifierControl.SetTool <TransportTool>();
                if (transportTool != null)
                {
                    transportTool.m_prefab   = transportInfo;
                    transportTool.m_building = 0;
                }
            }
            if (treeInfo != null)
            {
                TreeTool treeTool = ToolsModifierControl.SetTool <TreeTool>();
                if (treeTool != null)
                {
                    treeTool.m_prefab = treeInfo;
                    treeTool.m_mode   = TreeTool.Mode.Single;
                }
            }
            if (propInfo != null)
            {
                PropTool propTool = ToolsModifierControl.SetTool <PropTool>();
                if (propTool != null)
                {
                    propTool.m_prefab = propInfo;
                    propTool.m_mode   = PropTool.Mode.Single;
                }
            }
        }
        protected override void OnButtonClicked(UIComponent comp)
        {
            object   objectUserData = comp.objectUserData;
            PropInfo propInfo       = objectUserData as PropInfo;

            if (propInfo != null)
            {
                PropTool propTool = ToolsModifierControl.SetTool <PropTool>();
                if (propTool != null)
                {
                    propTool.m_prefab = propInfo;
                }
            }
        }
        private void SetBrushSize(float val)
        {
            var brushSizeSlider =
                (UISlider)typeof(BrushOptionPanel).GetField("m_BrushSizeSlider", BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(this);

            PropTool currentTool1 = ToolsModifierControl.GetCurrentTool <PropTool>();

            if ((UnityEngine.Object)currentTool1 != (UnityEngine.Object)null)
            {
                currentTool1.m_brushSize = val;
                currentTool1.m_mode      = (double)currentTool1.m_brushSize != (double)brushSizeSlider.minValue ? PropTool.Mode.Brush : PropTool.Mode.Single;
            }
            TerrainTool currentTool2 = ToolsModifierControl.GetCurrentTool <TerrainTool>();

            //begin mod
            if ((UnityEngine.Object)currentTool2 != (UnityEngine.Object)null)
            {
                currentTool2.m_brushSize     = val;
                TerrainToolDetour.m_sizeMode = (double)currentTool2.m_brushSize != (double)brushSizeSlider.minValue ? TerrainToolDetour.SizeMode.Brush : TerrainToolDetour.SizeMode.Single;
            }
            //end mod
            TreeTool currentTool3 = ToolsModifierControl.GetCurrentTool <TreeTool>();

            if ((UnityEngine.Object)currentTool3 != (UnityEngine.Object)null)
            {
                currentTool3.m_brushSize = val;
                currentTool3.m_mode      = (double)currentTool3.m_brushSize != (double)brushSizeSlider.minValue ? TreeTool.Mode.Brush : TreeTool.Mode.Single;
            }
            ResourceTool currentTool4 = ToolsModifierControl.GetCurrentTool <ResourceTool>();

            if ((UnityEngine.Object)currentTool4 != (UnityEngine.Object)null)
            {
                currentTool4.m_brushSize = val;
            }
            //begin mod
            try
            {
                Plugins.SetSize(val, val == (double)brushSizeSlider.minValue);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }
            //end mod
        }
Ejemplo n.º 8
0
        public static bool Prefix()
        {
            if (Event.current.type == EventType.MouseDown && Event.current.button == (int)UIMouseButton.None)
            {
                if (ContainerHolder.instance != null)
                {
                    PropInstance propInstance = ContainerHolder.instance.propInstance;
                    PropUnlimiterManager.instance.DeleteProp(ContainerHolder.gridKey, ContainerHolder.instance);
                    PropTool.DispatchPlacementEffect(propInstance.Position, true);

                    ContainerHolder.instance = null;
                    ContainerHolder.gridKey  = -1;
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 9
0
        public static bool Prefix(ref PropInfo info, ref Vector3 position, ref float angle, ref bool single)
        {
            if (!(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)))
            {
                return(true);
            }
            else
            {
#if DEBUG
                string str = String.Format("Invoking prop at:{0}, angle:{1}, info:{2}", position, angle, info.GetLocalizedTitle());
                LoggerUtils.Log(str);
#endif
                PropUnlimiterManager.instance.SetUnlimitedProp(info.m_prefabDataIndex, position, angle, single);
                PropTool.DispatchPlacementEffect(position, true);
                PropManager.instance.UpdateProp(0);
                PropManager.instance.UpdatePropRenderer(0, true);
                return(false);
            }
        }
Ejemplo n.º 10
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo, Color toolColor, Color despawnColor)
        {
            if (!isValid)
            {
                return;
            }

            ushort      prop        = id.Prop;
            PropManager propManager = PropManager.instance;
            PropInfo    propInfo    = propManager.m_props.m_buffer[prop].Info;
            Vector3     position    = propManager.m_props.m_buffer[prop].Position;
            float       angle       = propManager.m_props.m_buffer[prop].Angle;
            Randomizer  randomizer  = new Randomizer((int)prop);
            float       scale       = propInfo.m_minScale + (float)randomizer.Int32(10000u) * (propInfo.m_maxScale - propInfo.m_minScale) * 0.0001f;
            float       alpha       = 1f;

            PropTool.CheckOverlayAlpha(propInfo, scale, ref alpha);
            toolColor.a *= alpha;
            PropTool.RenderOverlay(cameraInfo, propInfo, position, scale, angle, toolColor);
        }
Ejemplo n.º 11
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            base.RenderOverlay(cameraInfo);
            if (!enabled)
            {
                return;
            }

            if (hoveredId.NetSegment != 0)
            {
                NetSegment hoveredSegment = hoveredId.NetSegment.S();
                NetTool.RenderOverlay(cameraInfo, ref hoveredSegment, hoverColor, hoverColor);
            }
            //else if (hoveredObject.NetNode != 0 && hoveredObject.NetNode < 32768)
            //{
            //    NetNode hoveredNode = hoveredObject.NetNode.N();
            //    RenderManager.instance.OverlayEffect.DrawCircle(cameraInfo, hoverColor, hoveredNode.m_position, Mathf.Max(6f, hoveredNode.Info.m_halfWidth * 2f), -1f, 1280f, false, true);
            //}
            else if (hoveredId.Building != 0)
            {
                Building hoveredBuilding = hoveredId.Building.B();
                BuildingTool.RenderOverlay(cameraInfo, ref hoveredBuilding, hoverColor, hoverColor);

                while (hoveredBuilding.m_subBuilding > 0)
                {
                    hoveredBuilding = BuildingManager.instance.m_buildings.m_buffer[hoveredBuilding.m_subBuilding];
                    BuildingTool.RenderOverlay(cameraInfo, ref hoveredBuilding, hoverColor, hoverColor);
                }
            }
            else if (hoveredId.Tree != 0)
            {
                TreeInstance hoveredTree = hoveredId.Tree.T();
                TreeTool.RenderOverlay(cameraInfo, hoveredTree.Info, hoveredTree.Position, hoveredTree.Info.m_minScale, hoverColor);
            }
            else if (hoveredId.Prop != 0)
            {
                PropInstance hoveredProp = hoveredId.Prop.P();
                PropTool.RenderOverlay(cameraInfo, hoveredProp.Info, hoveredProp.Position, hoveredProp.Info.m_minScale, hoveredProp.Angle, hoverColor);
            }
        }
Ejemplo n.º 12
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo, Color toolColor, Color despawnColor)
        {
            if (!isValid)
            {
                return;
            }
            if (MoveItTool.m_isLowSensitivity)
            {
                return;
            }

            IProp    prop     = PropLayer.Manager.Buffer(id);
            PropInfo propInfo = prop.Info;
            Vector3  position = prop.Position;
            float    angle    = prop.Angle;
            float    scale    = PropLayer.Manager.GetScale(id, prop);
            float    alpha    = 1f;

            PropTool.CheckOverlayAlpha(propInfo, scale, ref alpha);
            toolColor.a *= alpha;
            PropTool.RenderOverlay(cameraInfo, propInfo, position, scale, angle, toolColor);
        }
        private void SetBrushStrength(float val)
        {
            PropTool currentTool1 = ToolsModifierControl.GetCurrentTool <PropTool>();

            if ((UnityEngine.Object)currentTool1 != (UnityEngine.Object)null)
            {
                currentTool1.m_strength = val;
            }
            TerrainTool currentTool2 = ToolsModifierControl.GetCurrentTool <TerrainTool>();

            if ((UnityEngine.Object)currentTool2 != (UnityEngine.Object)null)
            {
                currentTool2.m_strength = val;
            }
            TreeTool currentTool3 = ToolsModifierControl.GetCurrentTool <TreeTool>();

            if ((UnityEngine.Object)currentTool3 != (UnityEngine.Object)null)
            {
                currentTool3.m_strength = val;
            }
            ResourceTool currentTool4 = ToolsModifierControl.GetCurrentTool <ResourceTool>();

            if ((UnityEngine.Object)currentTool4 != (UnityEngine.Object)null)
            {
                currentTool4.m_strength = val;
            }
            //begin mod
            try
            {
                Plugins.SetStrength(val);
            }
            catch (Exception e)
            {
                UnityEngine.Debug.LogException(e);
            }
            //end mod
        }
Ejemplo n.º 14
0
        protected override void OnButtonClicked(UIComponent comp)
        {
            object       objectUserData = comp.objectUserData;
            BuildingInfo buildingInfo   = objectUserData as BuildingInfo;
            NetInfo      netInfo        = objectUserData as NetInfo;
            TreeInfo     treeInfo       = objectUserData as TreeInfo;
            PropInfo     propInfo       = objectUserData as PropInfo;

            m_OptionsBrushPanel?.Hide();
            if (buildingInfo != null)
            {
                BuildingTool buildingTool = SetTool <BuildingTool>();
                if (buildingTool != null)
                {
                    this.HideAllOptionPanels();
                    buildingTool.m_prefab   = buildingInfo;
                    buildingTool.m_relocate = 0;
                }
            }
            if (netInfo != null)
            {
                NetTool netTool = ToolsModifierControl.SetTool <NetTool>();
                if ((Object)netTool != (Object)null)
                {
                    if (netInfo.GetSubService() == ItemClass.SubService.BeautificationParks)
                    {
                        this.ShowPathsOptionPanel();
                    }
                    else if (netInfo.GetClassLevel() == ItemClass.Level.Level3)
                    {
                        this.ShowFloodwallsOptionPanel();
                    }
                    else if (netInfo.GetClassLevel() == ItemClass.Level.Level4)
                    {
                        this.ShowQuaysOptionPanel();
                    }
                    else
                    {
                        this.ShowCanalsOptionPanel();
                    }
                    netTool.Prefab = netInfo;
                }
            }
            if (treeInfo != null)
            {
                var      prevTreeTool = GetCurrentTool <TreeTool>();
                TreeTool treeTool     = SetTool <TreeTool>();
                if (treeTool != null)
                {
                    this.HideAllOptionPanels();
                    treeTool.m_prefab = treeInfo;
                    //begin mod
                    if (prevTreeTool == null)
                    {
                        treeTool.m_brush     = toolController.m_brushes[3];
                        treeTool.m_brushSize = 30;
                        treeTool.m_mode      = TreeTool.Mode.Single;
                    }

                    ShowBrushOptionsPanel();
                    //end mod
                }
            }
            if (!(propInfo != null))
            {
                return;
            }
            var      prevPropTool = GetCurrentTool <PropTool>();
            PropTool propTool     = SetTool <PropTool>();

            if (!(propTool != null))
            {
                return;
            }
            this.HideAllOptionPanels();
            propTool.m_prefab = propInfo;
            if (prevPropTool == null)
            {
                propTool.m_mode = PropTool.Mode.Single;
            }
            //begin mod
            ShowBrushOptionsPanel();
            //end mod
        }
Ejemplo n.º 15
0
        public override void SimulationStep()
        {
            if (this.m_prefab == null)
            {
                this.m_wasPrefab = (PropInfo)null;
                this.m_propInfo  = (PropInfo)null;
            }
            else
            {
                if (this.m_propInfo == null || this.m_wasPrefab != this.m_prefab)
                {
                    this.m_wasPrefab = this.m_prefab;
                    Randomizer r = this.m_randomizer;
                    this.m_propInfo = (Singleton <ToolManager> .instance.m_properties.m_mode & ItemClass.Availability.AssetEditor) == ItemClass.Availability.None ? this.m_prefab.GetVariation(ref r) : this.m_prefab;
                    m_randomizer    = this.m_randomizer;
                }
                ToolBase.RaycastInput input = new ToolBase.RaycastInput(this.m_mouseRay, this.m_mouseRayLength);
                //begin mod
                input.m_ignoreBuildingFlags = Building.Flags.None;
                input.m_ignoreNodeFlags     = NetNode.Flags.None;
                input.m_ignoreSegmentFlags  = NetSegment.Flags.None;
                input.m_buildingService     = new RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default);
                input.m_netService          = new RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default);
                input.m_netService2         = new RaycastService(ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Layer.Default);
                //end mod
                ulong[] collidingSegments;
                ulong[] collidingBuildings;
                this.m_toolController.BeginColliding(out collidingSegments, out collidingBuildings);
                try
                {
                    ToolBase.RaycastOutput output;
                    if (this.m_mouseRayValid && ToolBase.RayCast(input, out output))
                    {
                        if (this.m_mode == PropTool.Mode.Brush)
                        {
                            this.m_mousePosition   = output.m_hitPos;
                            this.m_placementErrors = !Singleton <PropManager> .instance.CheckLimits()
                                ? ToolBase.ToolErrors.TooManyObjects
                                : ToolBase.ToolErrors.Pending;

                            if (this.m_mouseLeftDown == this.m_mouseRightDown)
                            {
                                return;
                            }
                            this.ApplyBrush();
                        }
                        else
                        {
                            if (this.m_mode != PropTool.Mode.Single)
                            {
                                return;
                            }
                            //begin mod
                            //end mod
                            Randomizer r  = this.m_randomizer;
                            ushort     id = Singleton <PropManager> .instance.m_props.NextFreeItem(ref r);

                            ToolBase.ToolErrors toolErrors = PropTool.CheckPlacementErrors(this.m_propInfo,
                                                                                           output.m_hitPos, /*output.m_currentEditObject*/ false, id, collidingSegments,
                                                                                           collidingBuildings);
                            if ((Singleton <ToolManager> .instance.m_properties.m_mode & ItemClass.Availability.Game) !=
                                ItemClass.Availability.None)
                            {
                                int constructionCost = this.m_propInfo.GetConstructionCost();
                                if (constructionCost != 0 &&
                                    constructionCost !=
                                    Singleton <EconomyManager> .instance.PeekResource(
                                        EconomyManager.Resource.Construction, constructionCost))
                                {
                                    toolErrors |= ToolBase.ToolErrors.NotEnoughMoney;
                                }
                            }
                            if (!Singleton <PropManager> .instance.CheckLimits())
                            {
                                toolErrors |= ToolBase.ToolErrors.TooManyObjects;
                            }
                            this.m_mousePosition   = output.m_hitPos;
                            this.m_placementErrors = toolErrors;
                            //begin mod
                            //end mod
                        }
                    }
                    else
                    {
                        this.m_placementErrors = ToolBase.ToolErrors.RaycastFailed;
                    }
                }
                finally
                {
                    this.m_toolController.EndColliding();
                }
            }
        }
Ejemplo n.º 16
0
        internal static void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            //Log.DebugWait($"Managers_RenderOverlay.Postfix(): LaneIndex={LaneIndex} Info={Info}");
            if (HoveredInfo is NetInfo.Lane laneInfo)
            {
                for (ushort segmentID = 1; segmentID < NetManager.MAX_SEGMENT_COUNT; ++segmentID)
                {
                    if (!NetUtil.IsSegmentValid(segmentID))
                    {
                        continue;
                    }
                    var m_lanes   = segmentID.ToSegment().Info.m_lanes;
                    int laneIndex = m_lanes.IndexOf(laneInfo);
                    if (laneIndex < 0)
                    {
                        continue;
                    }
                    uint     laneID = NetUtil.GetlaneID(segmentID, laneIndex);
                    LaneData lane   = new LaneData(laneID, laneIndex);
                    RenderUtil.RenderLaneOverlay(cameraInfo, lane, Color.yellow);
                }
            }

            while (SegmentQueue.Count > 0)
            {
                var   item  = SegmentQueue.Dequeue();
                Color color = item.TurnAround ? ORANGE : Color.yellow;
                RenderUtil.RenderSegmnetOverlay(cameraInfo, item.SegmentID, color);
            }

            while (NodeQueue.Count > 0)
            {
                var  item = NodeQueue.Dequeue();
                bool end  = item.NodeID.ToNode().m_flags.IsFlagSet(NetNode.Flags.End);
                if (item.IsBendNode || end)
                {
                    RenderUtil.DrawNodeCircle(cameraInfo, Color.yellow, item.NodeID);
                }
                else if (item.IsDC)
                {
                    DrawDC(cameraInfo, item.SegmentID, item.SegmentID2, item.NodeID);
                }
                else
                {
                    HighlightSegmentEnd(cameraInfo, item.SegmentID, item.NodeID, Color.yellow);
                }
            }


            while (PropQueue.Count > 0)
            {
                var item = PropQueue.Dequeue();
                PropTool.RenderOverlay(
                    cameraInfo, item.Prop, item.Pos, item.Scale, item.Angle, Color.yellow);
            }
            while (TreeQueue.Count > 0)
            {
                var item = TreeQueue.Dequeue();
                TreeTool.RenderOverlay(cameraInfo, item.Tree, item.Pos, item.Scale, Color.yellow);
            }
        }
        protected override void OnButtonClicked(UIComponent comp)
        {
            object       objectUserData = comp.objectUserData;
            BuildingInfo buildingInfo   = objectUserData as BuildingInfo;
            NetInfo      netInfo        = objectUserData as NetInfo;
            TreeInfo     treeInfo       = objectUserData as TreeInfo;
            PropInfo     propInfo       = objectUserData as PropInfo;

            m_OptionsBrushPanel?.Hide();
            if (buildingInfo != null)
            {
                BuildingTool buildingTool = SetTool <BuildingTool>();
                if (buildingTool != null)
                {
                    this.HideAllOptionPanels();
                    buildingTool.m_prefab   = buildingInfo;
                    buildingTool.m_relocate = 0;
                }
            }
            if (netInfo != null)
            {
                NetTool netTool = SetTool <NetTool>();
                if (netTool != null)
                {
                    if (netInfo.GetClassLevel() == ItemClass.Level.Level3)
                    {
                        this.ShowFloodwallsOptionPanel();
                    }
                    else if (netInfo.GetClassLevel() == ItemClass.Level.Level4)
                    {
                        this.ShowQuaysOptionPanel();
                    }
                    else if (netInfo.GetClassLevel() == ItemClass.Level.Level5)
                    {
                        this.ShowCanalsOptionPanel();
                    }
                    else
                    {
                        this.ShowPathsOptionPanel();
                    }
                    netTool.m_prefab = netInfo;
                }
            }
            if (treeInfo != null)
            {
                var      prevTreeTool = GetCurrentTool <TreeTool>();
                TreeTool treeTool     = SetTool <TreeTool>();
                if (treeTool != null)
                {
                    this.HideAllOptionPanels();
                    treeTool.m_prefab = treeInfo;
                    if (prevTreeTool == null)
                    {
                        treeTool.m_brush     = toolController.m_brushes[3];
                        treeTool.m_brushSize = 30;
                        treeTool.m_mode      = TreeTool.Mode.Single;
                    }

                    if (this.m_OptionsBar != null && m_OptionsBrushPanel == null)
                    {
                        m_OptionsBrushPanel = this.m_OptionsBar.Find <UIPanel>("BrushPanel");
                    }
                    m_OptionsBrushPanel.zOrder = 1;
                    m_OptionsBrushPanel.Show();
                }
            }
            if (!(propInfo != null))
            {
                return;
            }
            var      prevPropTool = GetCurrentTool <PropTool>();
            PropTool propTool     = SetTool <PropTool>();

            if (!(propTool != null))
            {
                return;
            }
            this.HideAllOptionPanels();
            propTool.m_prefab = propInfo;
            if (prevPropTool == null)
            {
                propTool.m_mode = PropTool.Mode.Single;
            }
        }
Ejemplo n.º 18
0
        //Works BEAUTIFULLY!! :DDD
        public static void SwitchTools(out bool allNull)
        {
            allNull                 = true;
            m_wasPLTActive          = m_PLTActive;
            m_wasBulldozeToolActive = m_bulldozeToolActive;

            ICities.LoadMode _loadMode = PropLineToolMod.GetLoadMode();

            PropTool     _propTool     = ToolsModifierControl.GetCurrentTool <PropTool>();
            TreeTool     _treeTool     = ToolsModifierControl.GetCurrentTool <TreeTool>();
            PropLineTool _propLineTool = ToolsModifierControl.GetCurrentTool <PropLineTool>();

            BulldozeTool _bulldozeTool = ToolsModifierControl.GetCurrentTool <BulldozeTool>();

            if ((_propTool == null) && (_treeTool == null) && (_propLineTool == null))
            {
                allNull = true;
                if (!m_wasBulldozeToolActive)
                {
                    m_PLTActive = false;
                }

                if (m_wasPLTActive == true)
                {
                    PropLineTool.m_keepActiveState = true;
                }

                if (_bulldozeTool != null)
                {
                    m_bulldozeToolActive = true;
                }
                else
                {
                    m_bulldozeToolActive = false;
                }

                if (m_resetCounterActive && resetCounterElapsedTimeSeconds > RESET_THRESHOLD_SECONDS)
                {
                    m_resetCounterActive  = false;
                    m_resetCounterExpired = true;
                }
                else if (!m_resetCounterExpired && !m_resetCounterActive)
                {
                    m_resetCounterActive           = true;
                    m_resetCounterStartTimeSeconds = Time.time;

                    //Debug.Log("[PLTDEBUG]: m_resetCounterStartTimeSeconds = " + m_resetCounterStartTimeSeconds);
                }

                return;
            }
            else
            {
                allNull = false;
                if (_propLineTool != null)
                {
                    m_PLTActive = true;
                }
                //continue along
            }

            //single mode: signal tool switch
            //not-single mode: signal standby
            bool _PLTActiveExclusive = ((_propLineTool != null) && (_propTool == null) && (_treeTool == null));

            //single mode: signal standby
            //not-single mode: signal tool switch
            bool _PLTInactiveButPropOrTreeActive = ((_propLineTool == null) && ((_propTool != null) || (_treeTool != null)));

            //error checking?
            bool _multipleActivePropTreeTools = ((_propLineTool != null) && ((_propTool != null) || (_treeTool != null)));

            if (_multipleActivePropTreeTools)
            {
                Debug.LogError("[PLT]: ToolSwitch: More than one active tool!");
                return;
            }

            //loadmode is in-game
            bool _inGame = ((_loadMode == ICities.LoadMode.NewGame) || (_loadMode == ICities.LoadMode.LoadGame));
            //loadmode is map-editor or asset-editor [EDIT: ACTUALLY JUST MAP EDITOR]
            //bool flag4 = (  (_loadMode == ICities.LoadMode.LoadMap) || (_loadMode == ICities.LoadMode.LoadAsset) || (_loadMode == ICities.LoadMode.NewAsset) || (_loadMode == ICities.LoadMode.NewMap)  );
            bool _mapEditor = ((_loadMode == ICities.LoadMode.LoadMap) || (_loadMode == ICities.LoadMode.NewMap));

            //test if BrushPanel was found
            m_brushPanelFound = (m_brushPanel != null);

            switch (PropLineTool.drawMode)
            {
            case PropLineTool.DrawMode.Single:
            {
                //reset active state
                PropLineTool.m_keepActiveState = false;

                if (_PLTActiveExclusive)
                {
                    switch (PropLineTool.objectMode)
                    {
                    case PropLineTool.ObjectMode.Undefined:
                    {
                        Debug.LogError("[PLT]: ToolSwitch: Object mode is undefined!");
                        break;
                    }

                    case PropLineTool.ObjectMode.Props:
                    {
                        PropInfo oldPropInfo = _propLineTool.propPrefab;
                        PropTool newPropTool = ToolsModifierControl.SetTool <PropTool>();
                        if (oldPropInfo == null)
                        {
                            Debug.LogError("[PLT]: ToolSwitch: PropLineTool prop prefab is null!");
                            return;
                        }
                        newPropTool.m_prefab = oldPropInfo;

                        //new as of 190809
                        FindBrushPanel();

                        if (_mapEditor && m_brushPanelFound)
                        {
                            m_brushPanel.Show();
                        }
                        break;
                    }

                    case PropLineTool.ObjectMode.Trees:
                    {
                        TreeInfo oldTreeInfo = _propLineTool.treePrefab;
                        TreeTool newTreeTool = ToolsModifierControl.SetTool <TreeTool>();
                        if (oldTreeInfo == null)
                        {
                            Debug.LogError("[PLT]: ToolSwitch: PropLineTool tree prefab is null!");
                            return;
                        }
                        newTreeTool.m_prefab = _propLineTool.treePrefab;

                        //new as of 190809
                        FindBrushPanel();

                        if ((_mapEditor || (_inGame)) && m_brushPanelFound)
                        {
                            m_brushPanel.Show();
                        }
                        break;
                    }
                    }
                    return;
                }
                else if (_PLTInactiveButPropOrTreeActive)
                {
                    return;
                }
                else
                {
                    Debug.LogError("[PLT]: ToolSwitch: PropLineTool -> mismatch!");
                    return;
                }
            }

            case PropLineTool.DrawMode.Straight:
            case PropLineTool.DrawMode.Curved:
            case PropLineTool.DrawMode.Freeform:
            case PropLineTool.DrawMode.Circle:
            {
                if (_PLTInactiveButPropOrTreeActive)
                {
                    if (m_wasPLTActive == true)
                    {
                        PropLineTool.m_keepActiveState = true;
                    }
                    else
                    {
                        if (pendingReset)
                        {
                            PropLineTool.m_keepActiveState = false;
                        }
                        else         //do not reset
                        {
                            PropLineTool.m_keepActiveState = true;
                        }
                    }

                    m_resetCounterExpired = false;
                    m_resetCounterActive  = false;

                    //continue along (no "return;" on this line)
                    if (_propTool != null)
                    {
                        PropInfo     oldPropInfo     = _propTool.m_prefab;
                        PropLineTool newPropLineTool = ToolsModifierControl.SetTool <PropLineTool>();
                        //PropLineTool.objectMode = PropLineTool.ObjectMode.Props;
                        if (oldPropInfo == null)
                        {
                            Debug.LogError("[PLT]: ToolSwitch: PropTool prop prefab is null!");
                            return;
                        }
                        newPropLineTool.propPrefab = oldPropInfo;
                        //calling after setting prefab
                        PropLineTool.objectMode = PropLineTool.ObjectMode.Props;

                        //new as of 190809
                        FindBrushPanel();

                        if (m_brushPanelFound)
                        {
                            m_brushPanel.Hide();
                        }
                        return;
                    }
                    if (_treeTool != null)
                    {
                        TreeInfo     oldTreeInfo     = _treeTool.m_prefab;
                        PropLineTool newPropLineTool = ToolsModifierControl.SetTool <PropLineTool>();
                        //PropLineTool.objectMode = PropLineTool.ObjectMode.Trees;
                        if (oldTreeInfo == null)
                        {
                            Debug.LogError("[PLT]: ToolSwitch: TreeTool tree prefab is null!");
                            return;
                        }
                        newPropLineTool.treePrefab = oldTreeInfo;
                        //calling after setting prefab
                        PropLineTool.objectMode = PropLineTool.ObjectMode.Trees;

                        //new as of 190809
                        FindBrushPanel();

                        if (m_brushPanelFound)
                        {
                            m_brushPanel.Hide();
                        }
                        return;
                    }
                }
                else if (_PLTActiveExclusive)
                {
                    if ((_propLineTool.propPrefab == null) && (_propLineTool.treePrefab == null))
                    {
                        Debug.LogError("[PLT]: ToolSwitch: PropLineTool prop and tree prefabs are null!");
                    }
                    return;
                }
                break;
            }

            default:
            {
                Debug.LogError("[PLT]: ToolSwitch: Draw Mode is out of bounds!");
                return;
            }
            }

            //safety-net return
            Debug.LogError("[PLT]: Reached safety-net return of ToolSwitch.SwitchTools");
            return;
        }