Пример #1
0
 public static void CreateGalaxy_Postfix(GameDesc gameDesc, GalaxyData __result)
 {
     if (Multiplayer.IsActive && UIVirtualStarmap_Transpiler.customBirthStar != -1)
     {
         Debug.Log("Overwriting with " + __result.PlanetById(UIVirtualStarmap_Transpiler.customBirthPlanet) + " and " + __result.StarById(UIVirtualStarmap_Transpiler.customBirthStar));
         __result.birthPlanetId = UIVirtualStarmap_Transpiler.customBirthPlanet;
         __result.birthStarId   = UIVirtualStarmap_Transpiler.customBirthStar;
     }
 }
        public static void DeletePlanet(this GalaxyData galaxy, int planetId, bool updateChildren)
        {
            var target = galaxy.PlanetById(planetId);

            if (target != null)
            {
                target.star.DeletePlanet(target, updateChildren);
                return;
            }

            Debug.LogWarningFormat("No planet with ID {0} found in galaxy", planetId);
        }
        public static EntityData[] EntitiesByPlanetId(this GalaxyData galaxy, int planetId)
        {
            var target = galaxy.PlanetById(planetId);

            EntityData[] entities = { };
            if (target != null)
            {
                Array.Copy(target.factory.entityPool, entities, target.factory.entityCount);
            }
            else
            {
                Debug.LogWarningFormat("No planet with ID {0} found in galaxy", planetId);
            }

            return(entities);
        }
Пример #4
0
        public override void ProcessPacket(NameInputPacket packet, NebulaConnection conn)
        {
            if (IsHost)
            {
                INebulaPlayer player = playerManager.GetPlayer(conn);
                if (player != null)
                {
                    playerManager.SendPacketToOtherPlayers(packet, player);
                }
            }

            using (Multiplayer.Session.Factories.IsIncomingRequest.On())
            {
                // If in lobby, apply change to UI galaxy
                GalaxyData galaxyData = Multiplayer.Session.IsInLobby ? UIRoot.instance.galaxySelect.starmap.galaxyData : GameMain.galaxy;
                if (galaxyData == null)
                {
                    return;
                }

                for (int i = 0; i < packet.Names.Length; i++)
                {
                    if (packet.StarIds[i] != NebulaModAPI.STAR_NONE)
                    {
                        StarData star = galaxyData.StarById(packet.StarIds[i]);
                        star.overrideName = packet.Names[i];
                        star.NotifyOnDisplayNameChange();
                        Log.Debug($"star{star.id}: {star.name} -> {star.overrideName}");
                    }
                    else
                    {
                        PlanetData planet = galaxyData.PlanetById(packet.PlanetIds[i]);
                        planet.overrideName = packet.Names[i];
                        planet.NotifyOnDisplayNameChange();
                        Log.Debug($"planet{planet.id}: {planet.name} -> {planet.overrideName}");
                    }
                }
                galaxyData.NotifyAstroNameChange();
                if (Multiplayer.Session.IsInLobby)
                {
                    // Refresh star name in lobby
                    UIRoot.instance.galaxySelect.starmap.OnGalaxyDataReset();
                }
            }
        }