示例#1
0
        public void ProcessPacket(FoundationBuildUpdatePacket packet, NebulaConnection conn)
        {
            //Check if client has loaded planet
            PlanetData    planet  = GameMain.galaxy.PlanetById(packet.PlanetId);
            PlanetFactory factory = planet?.factory;

            if (factory != null)
            {
                Vector3 reformCenterPoint = new Vector3();
                for (int i = 0; i < reformPoints.Length; i++)
                {
                    reformPoints[i] = Vector3.zero;
                }
                if (factory.platformSystem.reformData == null)
                {
                    factory.platformSystem.InitReformData();
                }
                if (planet.physics == null || planet.physics.colChunks == null)
                {
                    planet.physics = new PlanetPhysics(planet);
                    planet.physics.Init();
                }
                if (planet.aux == null)
                {
                    planet.aux = new PlanetAuxData(planet);
                }
                int reformPointsCount = factory.planet.aux.ReformSnap(packet.GroundTestPos.ToVector3(), packet.ReformSize, packet.ReformType, packet.ReformColor, reformPoints, packet.ReformIndices, factory.platformSystem, out reformCenterPoint);
                factory.ComputeFlattenTerrainReform(reformPoints, reformCenterPoint, packet.Radius, reformPointsCount, 3f, 1f);
                using (FactoryManager.EventFromServer.On())
                {
                    factory.FlattenTerrainReform(reformCenterPoint, packet.Radius, packet.ReformSize, packet.VeinBuried, 3f);
                }
                int area = packet.ReformSize * packet.ReformSize;
                for (int i = 0; i < area; i++)
                {
                    int            num71          = packet.ReformIndices[i];
                    PlatformSystem platformSystem = factory.platformSystem;
                    if (num71 >= 0)
                    {
                        int type  = platformSystem.GetReformType(num71);
                        int color = platformSystem.GetReformColor(num71);
                        if (type != packet.ReformType || color != packet.ReformColor)
                        {
                            factory.platformSystem.SetReformType(num71, packet.ReformType);
                            factory.platformSystem.SetReformColor(num71, packet.ReformColor);
                        }
                    }
                }
            }
        }
示例#2
0
        public void ProcessPacket(FoundationBuildUpdatePacket packet, NebulaConnection conn)
        {
            PlanetData    planet  = GameMain.galaxy.PlanetById(packet.PlanetId);
            PlanetFactory factory = GameMain.data.GetOrCreateFactory(planet);

            Vector3[] reformPoints      = new Vector3[100];
            Vector3   reformCenterPoint = new Vector3();

            //Check if some mandatory variables are missing
            if (factory.platformSystem.reformData == null)
            {
                factory.platformSystem.InitReformData();
            }

            if (planet.physics == null || planet.physics.colChunks == null)
            {
                planet.physics = new PlanetPhysics(planet);
                planet.physics.Init();
            }
            if (planet.aux == null)
            {
                planet.aux = new PlanetAuxData(planet);
            }

            //Perform terrain operation
            int reformPointsCount = factory.planet.aux.ReformSnap(packet.GroundTestPos.ToVector3(), packet.ReformSize, packet.ReformType, packet.ReformColor, reformPoints, packet.ReformIndices, factory.platformSystem, out reformCenterPoint);

            factory.ComputeFlattenTerrainReform(reformPoints, reformCenterPoint, packet.Radius, reformPointsCount, 3f, 1f);
            using (FactoryManager.EventFromClient.On())
            {
                factory.FlattenTerrainReform(reformCenterPoint, packet.Radius, packet.ReformSize, packet.VeinBuried, 3f);
            }
            int area = packet.ReformSize * packet.ReformSize;

            for (int i = 0; i < area; i++)
            {
                int            num71          = packet.ReformIndices[i];
                PlatformSystem platformSystem = factory.platformSystem;
                if (num71 >= 0)
                {
                    int type  = platformSystem.GetReformType(num71);
                    int color = platformSystem.GetReformColor(num71);
                    if (type != packet.ReformType || color != packet.ReformColor)
                    {
                        factory.platformSystem.SetReformType(num71, packet.ReformType);
                        factory.platformSystem.SetReformColor(num71, packet.ReformColor);
                    }
                }
            }
        }
        public override void ProcessPacket(FoundationBuildUpdatePacket packet, NebulaConnection conn)
        {
            PlanetData    planet  = GameMain.galaxy.PlanetById(packet.PlanetId);
            PlanetFactory factory = IsHost ? GameMain.data.GetOrCreateFactory(planet) : planet?.factory;

            if (factory != null)
            {
                Array.Clear(reformPoints, 0, reformPoints.Length);

                //Check if some mandatory variables are missing
                if (factory.platformSystem.reformData == null)
                {
                    factory.platformSystem.InitReformData();
                }

                Multiplayer.Session.Factories.TargetPlanet = packet.PlanetId;
                Multiplayer.Session.Factories.AddPlanetTimer(packet.PlanetId);
                Multiplayer.Session.Factories.TargetPlanet = NebulaModAPI.PLANET_NONE;

                //Perform terrain operation
                int reformPointsCount = factory.planet.aux.ReformSnap(packet.GroundTestPos.ToVector3(), packet.ReformSize, packet.ReformType, packet.ReformColor, reformPoints, packet.ReformIndices, factory.platformSystem, out Vector3 reformCenterPoint);
                factory.ComputeFlattenTerrainReform(reformPoints, reformCenterPoint, packet.Radius, reformPointsCount, 3f, 1f);
                using (Multiplayer.Session.Factories.IsIncomingRequest.On())
                {
                    factory.FlattenTerrainReform(reformCenterPoint, packet.Radius, packet.ReformSize, packet.VeinBuried, 3f);
                }
                int area = packet.ReformSize * packet.ReformSize;
                for (int i = 0; i < area; i++)
                {
                    int            num71          = packet.ReformIndices[i];
                    PlatformSystem platformSystem = factory.platformSystem;
                    if (num71 >= 0)
                    {
                        int type  = platformSystem.GetReformType(num71);
                        int color = platformSystem.GetReformColor(num71);
                        if (type != packet.ReformType || color != packet.ReformColor)
                        {
                            factory.platformSystem.SetReformType(num71, packet.ReformType);
                            factory.platformSystem.SetReformColor(num71, packet.ReformColor);
                        }
                    }
                }
            }

            if (IsHost)
            {
                Multiplayer.Session.Network.SendPacketToStar(packet, planet.star.id);
            }
        }