コード例 #1
0
        public void ProcessPacket(BuildEntityRequest packet, NebulaConnection conn)
        {
            PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId);

            // We only execute the code if the client has loaded the factory at least once.
            // Else it will get it once it goes to the planet for the first time.
            if (planet.factory != null)
            {
                using (FactoryManager.EventFromServer.On())
                {
                    FactoryManager.EventFactory = planet.factory;
                    FactoryManager.TargetPlanet = packet.PlanetId;
                    FactoryManager.PacketAuthor = packet.AuthorId;

                    FactoryManager.AddPlanetTimer(packet.PlanetId);

                    //Remove building from drone queue
                    GameMain.mainPlayer.mecha.droneLogic.serving.Remove(-packet.PrebuildId);
                    planet.factory.BuildFinally(GameMain.mainPlayer, packet.PrebuildId);
                    DroneManager.RemoveBuildRequest(-packet.PrebuildId);

                    FactoryManager.PacketAuthor = -1;
                    FactoryManager.EventFactory = null;
                    FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE;
                }
            }
        }
コード例 #2
0
        public void ProcessPacket(BuildEntityRequest packet, NebulaConnection conn)
        {
            PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId);

            // We only execute the code if the client has loaded the factory at least once.
            // Else it will get it once it goes to the planet for the first time.
            if (planet.factory != null)
            {
                using (FactoryManager.EventFromServer.On())
                {
                    FactoryManager.EventFactory = planet.factory;
                    FactoryManager.PacketAuthor = packet.AuthorId;

                    // Physics could be null, if the host is not on the requested planet
                    if (packet.PlanetId != GameMain.localPlanet?.id)
                    {
                        planet.physics = new PlanetPhysics(planet);
                        planet.physics.Init();

                        planet.audio = new PlanetAudio(planet);
                        planet.audio.Init();
                    }

                    //Remove building from drone queue
                    GameMain.mainPlayer.mecha.droneLogic.serving.Remove(-packet.PrebuildId);
                    planet.factory.BuildFinally(GameMain.mainPlayer, packet.PrebuildId);
                    if (!DroneManager.RemoveBuildRequest(-packet.PrebuildId))
                    {
                        Log.Warn($"Build Request was not succesfully removed.");
                    }
                    planet.factory.BuildFinally(GameMain.mainPlayer, packet.PrebuildId);

                    // Make sure to free the physics once the FlattenTerrain is done
                    if (packet.PlanetId != GameMain.localPlanet?.id)
                    {
                        planet.physics.Free();
                        planet.physics = null;

                        planet.audio.Free();
                        planet.audio = null;
                    }
                    FactoryManager.PacketAuthor = -1;
                    FactoryManager.EventFactory = null;
                }
            }
        }
コード例 #3
0
        public override void ProcessPacket(BuildEntityRequest packet, NebulaConnection conn)
        {
            if (IsHost && !FactoryManager.ContainsPrebuildRequest(packet.PlanetId, packet.PrebuildId))
            {
                Log.Warn($"BuildEntityRequest received does not have a corresponding PrebuildRequest with the id {packet.PrebuildId} for the planet {packet.PlanetId}");
                return;
            }

            PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId);

            // We only execute the code if the client has loaded the factory at least once.
            // Else it will get it once it goes to the planet for the first time.
            if (planet.factory != null)
            {
                using (FactoryManager.IsIncomingRequest.On())
                {
                    FactoryManager.EventFactory = planet.factory;
                    FactoryManager.TargetPlanet = packet.PlanetId;
                    FactoryManager.PacketAuthor = packet.AuthorId;

                    FactoryManager.AddPlanetTimer(packet.PlanetId);

                    //Remove building from drone queue
                    GameMain.mainPlayer.mecha.droneLogic.serving.Remove(-packet.PrebuildId);
                    planet.factory.BuildFinally(GameMain.mainPlayer, packet.PrebuildId);

                    if (IsClient)
                    {
                        DroneManager.RemoveBuildRequest(-packet.PrebuildId);
                    }

                    FactoryManager.EventFactory = null;
                    FactoryManager.PacketAuthor = FactoryManager.AUTHOR_NONE;
                    FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE;
                }
            }
        }