Esempio n. 1
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;
            }

            TreeState state = instanceState as TreeState;

            TreeInfo info = state.Info.Prefab as TreeInfo;

            Randomizer randomizer = new Randomizer(state.instance.id.Tree);
            float      scale      = info.m_minScale + (float)randomizer.Int32(10000u) * (info.m_maxScale - info.m_minScale) * 0.0001f;
            //float brightness = info.m_minBrightness + (float)randomizer.Int32(10000u) * (info.m_maxBrightness - info.m_minBrightness) * 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);
            }

            TreeTool.RenderOverlay(cameraInfo, info, newPosition, scale, toolColor);
        }
Esempio 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);
            }
        }
Esempio n. 3
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo, Color toolColor, Color despawnColor)
        {
            if (!isValid)
            {
                return;
            }

            uint        tree        = id.Tree;
            TreeManager treeManager = TreeManager.instance;
            TreeInfo    treeInfo    = treeManager.m_trees.m_buffer[tree].Info;
            Vector3     position    = treeManager.m_trees.m_buffer[tree].Position;
            Randomizer  randomizer  = new Randomizer(tree);
            float       scale       = treeInfo.m_minScale + (float)randomizer.Int32(10000u) * (treeInfo.m_maxScale - treeInfo.m_minScale) * 0.0001f;
            float       alpha       = 1f;

            TreeTool.CheckOverlayAlpha(treeInfo, scale, ref alpha);
            toolColor.a *= alpha;
            TreeTool.RenderOverlay(cameraInfo, treeInfo, position, scale, toolColor);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
        public override void RenderOverlay(RenderManager.CameraInfo cameraInfo)
        {
            if (this.m_toolController.IsInsideUI || !Cursor.visible)
            {
                base.RenderOverlay(cameraInfo);
                return;
            }
            switch (HoverInstance.Type)
            {
            case InstanceType.Building:
            {
                ushort          building   = HoverInstance.Building;
                NetManager      instance   = Singleton <NetManager> .instance;
                BuildingManager instance2  = Singleton <BuildingManager> .instance;
                BuildingInfo    info5      = instance2.m_buildings.m_buffer[(int)building].Info;
                Color           toolColor6 = GetOverlayColor();
                float           num        = 1f;
                BuildingTool.CheckOverlayAlpha(info5, ref num);
                ushort num2 = instance2.m_buildings.m_buffer[(int)building].m_netNode;
                int    num3 = 0;
                while (num2 != 0)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        ushort segment = instance.m_nodes.m_buffer[(int)num2].GetSegment(j);
                        if (segment != 0 && instance.m_segments.m_buffer[(int)segment].m_startNode == num2 && (instance.m_segments.m_buffer[(int)segment].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                        {
                            NetTool.CheckOverlayAlpha(ref instance.m_segments.m_buffer[(int)segment], ref num);
                        }
                    }
                    num2 = instance.m_nodes.m_buffer[(int)num2].m_nextBuildingNode;
                    if (++num3 > 32768)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                ushort subBuilding = instance2.m_buildings.m_buffer[(int)building].m_subBuilding;
                num3 = 0;
                while (subBuilding != 0)
                {
                    BuildingTool.CheckOverlayAlpha(instance2.m_buildings.m_buffer[(int)subBuilding].Info, ref num);
                    subBuilding = instance2.m_buildings.m_buffer[(int)subBuilding].m_subBuilding;
                    if (++num3 > 49152)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                toolColor6.a *= num;
                int     length    = instance2.m_buildings.m_buffer[(int)building].Length;
                Vector3 position2 = instance2.m_buildings.m_buffer[(int)building].m_position;
                float   angle2    = instance2.m_buildings.m_buffer[(int)building].m_angle;
                BuildingTool.RenderOverlay(cameraInfo, info5, length, position2, angle2, toolColor6, false);
                num2 = instance2.m_buildings.m_buffer[(int)building].m_netNode;
                num3 = 0;
                while (num2 != 0)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        ushort segment2 = instance.m_nodes.m_buffer[(int)num2].GetSegment(k);
                        if (segment2 != 0 && instance.m_segments.m_buffer[(int)segment2].m_startNode == num2 && (instance.m_segments.m_buffer[(int)segment2].m_flags & NetSegment.Flags.Untouchable) != NetSegment.Flags.None)
                        {
                            NetTool.RenderOverlay(cameraInfo, ref instance.m_segments.m_buffer[(int)segment2], toolColor6, toolColor6);
                        }
                    }
                    num2 = instance.m_nodes.m_buffer[(int)num2].m_nextBuildingNode;
                    if (++num3 > 32768)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                subBuilding = instance2.m_buildings.m_buffer[(int)building].m_subBuilding;
                num3        = 0;
                while (subBuilding != 0)
                {
                    BuildingInfo info6     = instance2.m_buildings.m_buffer[(int)subBuilding].Info;
                    int          length2   = instance2.m_buildings.m_buffer[(int)subBuilding].Length;
                    Vector3      position3 = instance2.m_buildings.m_buffer[(int)subBuilding].m_position;
                    float        angle3    = instance2.m_buildings.m_buffer[(int)subBuilding].m_angle;
                    BuildingTool.RenderOverlay(cameraInfo, info6, length2, position3, angle3, toolColor6, false);
                    subBuilding = instance2.m_buildings.m_buffer[(int)subBuilding].m_subBuilding;
                    if (++num3 > 49152)
                    {
                        CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                        break;
                    }
                }
                break;
            }

            case InstanceType.Tree:
            {
                uint        tree        = HoverInstance.Tree;
                TreeManager instance11  = Singleton <TreeManager> .instance;
                TreeInfo    info9       = instance11.m_trees.m_buffer[(int)((UIntPtr)tree)].Info;
                Vector3     position6   = instance11.m_trees.m_buffer[(int)((UIntPtr)tree)].Position;
                Randomizer  randomizer4 = new Randomizer(tree);
                float       scale4      = info9.m_minScale + (float)randomizer4.Int32(10000u) * (info9.m_maxScale - info9.m_minScale) * 0.0001f;
                Color       toolColor13 = GetOverlayColor();
                float       num13       = 1f;
                TreeTool.CheckOverlayAlpha(info9, scale4, ref num13);
                toolColor13.a *= num13;
                TreeTool.RenderOverlay(cameraInfo, info9, position6, scale4, toolColor13);
                break;
            }
            }
            base.RenderOverlay(cameraInfo);
        }