Beispiel #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);
            }
        }
Beispiel #2
0
        // Preloads all shell positions and normalized variants of those positions so we dont't have to retrieve them every frame
        void GenShellVectors(int viewDistance)
        {
            // Vintage Story loaded chunk radius forms an octagonal shape
            Vec2i[] points     = ShapeUtil.GetOctagonPoints(0, 0, viewDistance / chunksize + 1);
            int     cmapheight = game.WorldMap.ChunkMapSizeY;

            HashSet <Vec3i> shellPositions = new HashSet <Vec3i>();

            for (int i = 0; i < points.Length; i++)
            {
                Vec2i point = points[i];
                for (int cy = -cmapheight; cy <= cmapheight; cy++)
                {
                    shellPositions.Add(new Vec3i(point.X, cy, point.Y));
                }
            }

            for (int r = 0; r < viewDistance / chunksize + 1; r++)
            {
                points = ShapeUtil.GetOctagonPoints(0, 0, r);
                for (int i = 0; i < points.Length; i++)
                {
                    Vec2i point = points[i];
                    // We do overextend the shell positions on the vertical axis as we seem to have overculling issues otherwise
                    shellPositions.Add(new Vec3i(point.X, -cmapheight, point.Y));
                    shellPositions.Add(new Vec3i(point.X, cmapheight, point.Y));
                }
            }

            cubicShellPositions = shellPositions.ToArray();

            cubicShellPositionsNormalized = new Vec3f[cubicShellPositions.Length];
            for (int i = 0; i < cubicShellPositions.Length; i++)
            {
                cubicShellPositionsNormalized[i] = new Vec3f(cubicShellPositions[i]).Normalize();
            }
        }