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; } } }
public void ProcessPacket(BuildEntityRequest packet, NebulaConnection conn) { if (!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; } using (FactoryManager.EventFromClient.On()) { PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId); FactoryManager.EventFactory = planet.factory; FactoryManager.PacketAuthor = packet.AuthorId; FactoryManager.TargetPlanet = packet.PlanetId; FactoryManager.AddPlanetTimer(packet.PlanetId); //Remove building from drone queue GameMain.mainPlayer.mecha.droneLogic.serving.Remove(-packet.PrebuildId); planet.factory.BuildFinally(GameMain.mainPlayer, packet.PrebuildId); FactoryManager.EventFactory = null; FactoryManager.PacketAuthor = -1; FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE; } }
public override void ProcessPacket(DestructEntityRequest packet, NebulaConnection conn) { using (FactoryManager.IsIncomingRequest.On()) { PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId); PlayerAction_Build pab = GameMain.mainPlayer.controller != null ? GameMain.mainPlayer.controller.actionBuild : null; // We only execute the code if the client has loaded the factory at least once. // Else they will get it once they go to the planet for the first time. if (planet?.factory == null || pab == null) { return; } FactoryManager.TargetPlanet = packet.PlanetId; FactoryManager.PacketAuthor = packet.AuthorId; PlanetFactory tmpFactory = pab.factory; pab.factory = planet.factory; pab.noneTool.factory = planet.factory; FactoryManager.AddPlanetTimer(packet.PlanetId); pab.DoDismantleObject(packet.ObjId); pab.factory = tmpFactory; pab.noneTool.factory = tmpFactory; FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE; FactoryManager.PacketAuthor = FactoryManager.AUTHOR_NONE; } }
public override void ProcessPacket(FoundationBuildUpdatePacket packet, NebulaConnection conn) { // TODO: MISSING CLIENT -> HOST -> CLIENT CODE PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId); PlanetFactory factory = IsHost ? GameMain.data.GetOrCreateFactory(planet) : planet?.factory; if (factory != null) { Vector3 reformCenterPoint = new Vector3(); Array.Clear(reformPoints, 0, reformPoints.Length); //Check if some mandatory variables are missing if (factory.platformSystem.reformData == null) { factory.platformSystem.InitReformData(); } FactoryManager.TargetPlanet = packet.PlanetId; FactoryManager.AddPlanetTimer(packet.PlanetId); FactoryManager.TargetPlanet = FactoryManager.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 reformCenterPoint); factory.ComputeFlattenTerrainReform(reformPoints, reformCenterPoint, packet.Radius, reformPointsCount, 3f, 1f); using (FactoryManager.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); } } } } }
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(); } FactoryManager.AddPlanetTimer(packet.PlanetId); 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); } } } } }
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; } } }
public override void ProcessPacket(UpgradeEntityRequest packet, NebulaConnection conn) { using (FactoryManager.IsIncomingRequest.On()) { PlanetData planet = GameMain.galaxy.PlanetById(packet.PlanetId); // We only execute the code if the client has loaded the factory at least once. // Else they will get it once they go to the planet for the first time. if (planet?.factory == null) { return; } FactoryManager.TargetPlanet = packet.PlanetId; FactoryManager.PacketAuthor = packet.AuthorId; FactoryManager.AddPlanetTimer(packet.PlanetId); ItemProto itemProto = LDB.items.Select(packet.UpgradeProtoId); planet.factory.UpgradeFinally(GameMain.mainPlayer, packet.ObjId, itemProto); FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE; FactoryManager.PacketAuthor = FactoryManager.AUTHOR_NONE; } }