Ejemplo n.º 1
0
        public static void Despawn(NPC noFace)
        {
            SpiritedAway.Announce($"{noFace.FullName} has mysteriously vanished when nobody was looking!");

            noFace.active  = false;
            noFace.netSkip = -1;
            noFace.life    = 0;
            noFace         = null;
        }
Ejemplo n.º 2
0
        public static void UpdateNoFaceMerchant()
        {
            NPC no_face = Find();             // Find NoFace if one is spawned in the world

            // If it is night or past the despawn time for the NPC, and he is not on the screen, despawn him
            if (no_face != null && (!Main.dayTime || Main.time >= DespawnTimeOfDay) && !IsNPCOnScreen(no_face.Center))
            {
                Despawn(no_face);
            }

            // Stop the NPC from spawning on this day if he stayed overnight
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (Main.dayTime && Main.time == 0)
            {
                if (no_face == null && Main.rand.NextBool(4 /* 25% chance */))
                {
                    SpawnTime = GetRandomSpawnTime(5400, 8100);
                }
                else
                {
                    SpawnTime = double.MaxValue;
                }
            }

            // Spawn if the conditions are met
            if (no_face == null && CanSpawnNow())
            {
                int new_no_face = NPC.NewNPC(Main.spawnTileX * 16, Main.spawnTileY * 16, NPCType <NoFace>(), 1);
                no_face           = Main.npc[new_no_face];
                no_face.homeless  = true;
                no_face.direction = Main.spawnTileX >= WorldGen.bestX ? -1 : 1;
                no_face.netUpdate = true;
                ShopItems         = CreateNewShop();

                // Prevent any more spawns for today
                SpawnTime = double.MaxValue;

                // Announce his arrival
                SpiritedAway.Announce($"A strange ghostly figure has appeared!");
            }
        }
Ejemplo n.º 3
0
        public static void SpawnOrRespawn()
        {
            NPC no_face = Find();

            if (no_face != null)
            {
                Despawn(no_face);
            }

            int new_no_face = NPC.NewNPC(Main.spawnTileX * 16, Main.spawnTileY * 16, NPCType <NoFace>(), 1);

            no_face           = Main.npc[new_no_face];
            no_face.homeless  = true;
            no_face.direction = Main.spawnTileX >= WorldGen.bestX ? -1 : 1;
            no_face.netUpdate = true;
            ShopItems         = CreateNewShop();

            // Prevent any more spawns for today
            SpawnTime = double.MaxValue;

            // Announce his arrival
            SpiritedAway.Announce($"A strange ghostly figure has appeared!");
        }