Ejemplo n.º 1
0
        private void Pulse(RadiationPulse Pulse)
        {
            StopWatchlog.Restart();

            //Radiation distance
            int Radius = (int)Math.Round(Pulse.Strength / (Math.PI * 75));

            if (Radius > 50)
            {
                Radius = 50;
            }

            //Logger.Log("Radius > " + Radius);
            //Generates the conference
            circleBres(Pulse.Location.x, Pulse.Location.y, Radius);

            //Logger.Log("CircleCircumference.Count > " + CircleCircumference.Count);
            //Logger.Log("Pulse.Strengt> " + Pulse.Strength);
            //Radiation for each line ( Dont worry it stacks)
            float InitialRadiation = Pulse.Strength / CircleCircumference.Count;

            foreach (var ToPoint in CircleCircumference)
            {
                DrawRadiationLine(Pulse.Location.x, Pulse.Location.y, ToPoint.x, ToPoint.y, InitialRadiation, Pulse);
            }

            //Logger.Log("CircleArea.Count > " + CircleArea.Count);
            //Set values on tiles
            foreach (var NodePoint in CircleArea)
            {
                NodePoint.AddRadiationPulse(NodePoint.MidCalculationNumbers, DateTime.Now, Pulse.SourceID);                 //Drops off too quickly
                NodePoint.MidCalculationNumbers = 0;
                //Logger.Log("rad onv " + NodePoint.RadiationLevel);
            }

            CircleCircumference.Clear();
            CircleArea.Clear();

            StopWatchlog.Stop();
            Logger.Log("StopWatchlog ElapsedMilliseconds time " + StopWatchlog.ElapsedMilliseconds);
        }
Ejemplo n.º 2
0
        //https://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#C.23
        void DrawRadiationLine(int x0, int y0, int x1, int y1, float RadiationStrength, RadiationPulse Pulse)
        {
            int   dx = Math.Abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
            int   dy = Math.Abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
            int   err = (dx > dy ? dx : -dy) / 2, e2;
            float RadiationOnStep = RadiationStrength;

            for (;;)
            {
                var NodePoint     = Pulse.Matrix.GetMetaDataNode(new Vector2Int(x0, y0));
                var RadiationNode = NodePoint?.RadiationNode;
                if (RadiationNode != null)
                {
                    if (NodePoint.IsOccupied)
                    {
                        RadiationOnStep *= 0.15f;
                    }
                    //RadiationOnStep *= RadiationNode.RadiationPassability;

                    CircleArea.Add(RadiationNode);
                    RadiationNode.MidCalculationNumbers += RadiationOnStep;
                }
                if (x0 == x1 && y0 == y1)
                {
                    break;
                }
                e2 = err;
                if (e2 > -dx)
                {
                    err -= dy;
                    x0  += sx;
                }

                if (e2 < dy)
                {
                    err += dx;
                    y0  += sy;
                }
            }
        }