public override bool UseItem(Player player)
        {
            //Enter should be called on exactly one side, which here is either the singleplayer player, or the server
            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                bool result = SubworldManager.Enter(SubworldManager.mySubworldID) ?? false;

                if (!result)
                {
                    //If some issue occured, inform why (can't know exactly obviously, might need to check logs)
                    string message;
                    if (!SubworldManager.Loaded)
                    {
                        message = "SubworldLibrary Mod is required to be enabled for this item to work!";
                    }
                    else
                    {
                        message = $"Unable to enter {SubworldManager.mySubworldID}!";
                    }

                    if (Main.netMode == NetmodeID.Server)
                    {
                        NetMessage.BroadcastChatMessage(NetworkText.FromLiteral(message), Color.Orange);
                    }
                    else
                    {
                        Main.NewText(message, Color.Orange);
                    }
                }

                return(result);
            }
            return(true);
        }
 public override void EditSpawnPool(IDictionary <int, float> pool, NPCSpawnInfo spawnInfo)
 {
     //If any subworld from our mod is loaded, disable spawns
     if (SubworldManager.AnyActive(mod) ?? false)
     {
         pool.Clear();
     }
 }
Esempio n. 3
0
        public override void PostUpdate()
        {
            //This hook also runs in the subworld if we choose to specify ExclusiveWorld for the "Register"

            if (!(SubworldManager.IsActive(SubworldManager.mySubworldID) ?? false))
            {
                return;                                                                                 //No point executing the code below if we aren't in the subworld we want
            }
            if (!enteredWorld)
            {
                enteredWorld = true;
                string message = $"Hey, We successfully entered '{SubworldManager.mySubworldID}' and only the '{Name}' will update here!";
                if (Main.netMode == NetmodeID.Server)
                {
                    NetMessage.BroadcastChatMessage(NetworkText.FromLiteral(message), Color.Orange);
                }
                else
                {
                    Main.NewText(message, Color.Orange);
                }
            }
        }
Esempio n. 4
0
 public override void Unload()
 {
     SubworldManager.Unload();
 }
Esempio n. 5
0
 public override void PostSetupContent()
 {
     SubworldManager.Load();
 }