Exemple #1
0
        public void OnUpdate(float dt)
        {
            snap1 = snap2;
            snap2 = new WeatherSnapshot()
            {
                hoursTotal = world.Calendar.TotalHours
            };

            IPlayer[] players;

            if (world is IClientWorldAccessor)
            {
                players = new IPlayer[] { ((IClientWorldAccessor)world).Player };
            }
            else
            {
                players = world.AllOnlinePlayers;
            }

            for (int i = 0; i < players.Length; i++)
            {
                int     viewdistance = players[i].WorldData.LastApprovedViewDistance;
                int     chunksize    = world.BlockAccessor.ChunkSize;
                int     chunkRadius  = (int)Math.Ceiling((float)viewdistance / chunksize) + 1;
                Vec2i[] points       = ShapeUtil.GetOctagonPoints(
                    (int)players[i].Entity.Pos.X / chunksize,
                    (int)players[i].Entity.Pos.Z / chunksize,
                    chunkRadius
                    );

                GenWeatherForPoints(points, snap2);
            }
        }
Exemple #2
0
        private void GenWeatherForPoints(Vec2i[] points, WeatherSnapshot intoSnap)
        {
            for (int i = 0; i < points.Length; i++)
            {
                long chunkIndex2d = ((points[i].X + chunksize / 2) << 32) | (points[i].Y + chunksize / 2);

                if (!intoSnap.WeatherNoiseByChunk.ContainsKey(chunkIndex2d))
                {
                    intoSnap.WeatherNoiseByChunk[chunkIndex2d] = CalcWeatherAt(points[i].X, points[i].Y, intoSnap.hoursTotal);
                }
            }
        }