TEditXna.ViewModel.WorldViewModel.AddNpc C# (CSharp) Method

AddNpc() private method

private AddNpc ( int npcId ) : void
npcId int
return void
        private void AddNpc(int npcId)
        {
            if (CurrentWorld != null && World.NpcNames.ContainsKey(npcId))
            {
                string name = World.NpcNames[npcId];
                if (CurrentWorld.NPCs.All(n => n.SpriteId != npcId))
                {
                    var spawn = new Vector2Int32(CurrentWorld.SpawnX, CurrentWorld.SpawnY);
                    CurrentWorld.NPCs.Add(new NPC{Home = spawn, IsHomeless = true, DisplayName = name, Name = name, Position= new Vector2(spawn.X * 16, spawn.Y * 16), SpriteId = npcId});
                    Points.Add(name);
                    MessageBox.Show(string.Format("{0} added to spawn.", name), "NPC Added");
                }
                else
                {
                    MessageBox.Show(string.Format("{0} is already on the map.", name), "NPC Exists");
                }
            }
            else
            {
                MessageBox.Show(string.Format("Choose an NPC. NPC {0} not found.", npcId), "NPC Error");
            }
        }