Пример #1
0
 public void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.tag == "CidadaoMutante")
     {
         NpcBase monster = collision.GetComponent <NpcBase>();
         UI.SetLifeMonster(monster.totalLife, monster.currentLife);
         UI.objectSliderMonster.SetActive(true);
     }
     else if (collision.tag == "Morcego")
     {
         NpcBase monster = collision.GetComponent <NpcBase>();
         UI.SetLifeMonster(monster.totalLife, monster.currentLife);
         UI.objectSliderMonster.SetActive(true);
     }
     else if (collision.tag == "LoboSelvagem")
     {
         NpcBase monster = collision.GetComponent <NpcBase>();
         UI.SetLifeMonster(monster.totalLife, monster.currentLife);
         UI.objectSliderMonster.SetActive(true);
     }
     else if (collision.tag == "LoboDecomposto")
     {
         NpcBase monster = collision.GetComponent <NpcBase>();
         UI.SetLifeMonster(monster.totalLife, monster.currentLife);
         UI.objectSliderMonster.SetActive(true);
     }
     else if (collision.tag == "Esqueleto")
     {
         NpcBase monster = collision.GetComponent <NpcBase>();
         UI.SetLifeMonster(monster.totalLife, monster.currentLife);
         UI.objectSliderMonster.SetActive(true);
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            mMyTask.Objective   = (QuestObjective)cmbTaskType.SelectedIndex;
            mMyTask.Description = txtStartDesc.Text;
            switch (mMyTask.Objective)
            {
            case QuestObjective.EventDriven:     //Event Driven
                mMyTask.TargetId = Guid.Empty;
                mMyTask.Quantity = 1;

                break;

            case QuestObjective.GatherItems:     //Gather Items
                mMyTask.TargetId = ItemBase.IdFromList(cmbItem.SelectedIndex);
                mMyTask.Quantity = (int)nudItemAmount.Value;

                break;

            case QuestObjective.KillNpcs:     //Kill Npcs
                mMyTask.TargetId = NpcBase.IdFromList(cmbNpc.SelectedIndex);
                mMyTask.Quantity = (int)nudNpcQuantity.Value;

                break;
            }

            ParentForm.Close();
        }
Пример #3
0
 public void DestroyNpcList(NpcBase npc)
 {
     if (allNpc.Contains(npc))
     {
         allNpc.Remove(npc);
     }
 }
Пример #4
0
 public static void KillNpcsOf(NpcBase npc)
 {
     foreach (MapInstance map in MapInstance.Lookup.Values)
     {
         map?.DespawnNpcsOf(npc);
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            mMyCommand.NpcId = NpcBase.IdFromList(cmbNpc.SelectedIndex);
            switch (cmbConditionType.SelectedIndex)
            {
            case 0:     //Tile Spawn
                mMyCommand.EntityId = Guid.Empty;
                mMyCommand.MapId    = MapList.OrderedMaps[cmbMap.SelectedIndex].MapId;
                mMyCommand.X        = (sbyte)nudWarpX.Value;
                mMyCommand.Y        = (sbyte)nudWarpY.Value;
                mMyCommand.Dir      = (byte)cmbDirection.SelectedIndex;

                break;

            case 1:     //On/Around Entity Spawn
                mMyCommand.MapId = Guid.Empty;
                if (cmbEntities.SelectedIndex == 0 || cmbEntities.SelectedIndex == -1)
                {
                    mMyCommand.EntityId = Guid.Empty;
                }
                else
                {
                    mMyCommand.EntityId = mCurrentMap.LocalEvents.Keys.ToList()[cmbEntities.SelectedIndex - 1];
                }

                mMyCommand.X   = (sbyte)mSpawnX;
                mMyCommand.Y   = (sbyte)mSpawnY;
                mMyCommand.Dir = (byte)Convert.ToInt32(chkDirRelative.Checked);

                break;
            }

            mEventEditor.FinishCommandEdit();
        }
Пример #6
0
        public void RefreshNpcList()
        {
            // Update the list incase npcs have been modified since form load.
            cmbNpc.Items.Clear();
            cmbNpc.Items.AddRange(NpcBase.Names);

            // Add the map NPCs
            lstMapNpcs.Items.Clear();
            for (var i = 0; i < Globals.CurrentMap.Spawns.Count; i++)
            {
                lstMapNpcs.Items.Add(NpcBase.GetName(Globals.CurrentMap.Spawns[i].NpcId));
            }

            // Don't select if there are no NPCs, to avoid crashes.
            if (cmbNpc.Items.Count > 0)
            {
                cmbNpc.SelectedIndex = 0;
            }

            cmbDir.SelectedIndex = 0;
            rbRandom.Checked     = true;
            if (lstMapNpcs.Items.Count > 0)
            {
                lstMapNpcs.SelectedIndex = 0;
                if (lstMapNpcs.SelectedIndex < Globals.CurrentMap.Spawns.Count)
                {
                    cmbDir.SelectedIndex = (int)Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].Direction;
                    cmbNpc.SelectedIndex = NpcBase.ListIndex(Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId);
                    if (Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].X >= 0)
                    {
                        rbDeclared.Checked = true;
                    }
                }
            }
        }
Пример #7
0
 public void EnterState()
 {
     alertRaised = true;
     safeSpaces  = NpcBase.FindTargets <Safety>("Safety", NpcController.Location, 100f, mask, s => s.isOpen);
     if (safeSpaces.Count > 0)
     {
         safeHouse = NpcBase.TargetNearest <Safety>(NpcController.Location, safeSpaces).transform;
     }
 }
Пример #8
0
 public void DespawnNpcsOf(NpcBase npcBase)
 {
     foreach (var entity in mEntities)
     {
         if (entity.Value is Npc npc && npc.Base == npcBase)
         {
             npc.Die(0);
         }
     }
 }
Пример #9
0
        private void setupScripts()
        {
            _bossBattleScript = createEntity("bossScript")
                                .addComponent(new BossBattleScript("boss battle script"));

            _startGameScript = createEntity("startGameScript")
                               .addComponent(new StartGameScript("start game script"));

            _grabFirstCoreScript = createEntity("grabFirstCoreScript")
                                   .addComponent(new GrabFirstCoreScript("grab first core script"));
        }
Пример #10
0
 protected override void GameObjectUpdatedDelegate(GameObjectType type)
 {
     if (type == GameObjectType.Npc)
     {
         InitEditor();
         if (mEditorItem != null && !NpcBase.Lookup.Values.Contains(mEditorItem))
         {
             mEditorItem = null;
             UpdateEditor();
         }
     }
 }
Пример #11
0
        private void SpawnMapNpc(int i)
        {
            byte x       = 0;
            byte y       = 0;
            byte dir     = 0;
            var  npcBase = NpcBase.Get(Spawns[i].NpcId);

            if (npcBase != null)
            {
                MapNpcSpawn npcSpawnInstance;
                if (NpcSpawnInstances.ContainsKey(Spawns[i]))
                {
                    npcSpawnInstance = NpcSpawnInstances[Spawns[i]];
                }
                else
                {
                    npcSpawnInstance = new MapNpcSpawn();
                    NpcSpawnInstances.Add(Spawns[i], npcSpawnInstance);
                }

                if (Spawns[i].Direction != NpcSpawnDirection.Random)
                {
                    dir = (byte)(Spawns[i].Direction - 1);
                }
                else
                {
                    dir = (byte)Randomization.Next(0, 4);
                }

                if (Spawns[i].X >= 0 && Spawns[i].Y >= 0)
                {
                    npcSpawnInstance.Entity = SpawnNpc((byte)Spawns[i].X, (byte)Spawns[i].Y, dir, Spawns[i].NpcId);
                }
                else
                {
                    for (var n = 0; n < 100; n++)
                    {
                        x = (byte)Randomization.Next(0, Options.MapWidth);
                        y = (byte)Randomization.Next(0, Options.MapHeight);
                        if (Attributes[x, y] == null || Attributes[x, y].Type == (int)MapAttributes.Walkable)
                        {
                            break;
                        }

                        x = 0;
                        y = 0;
                    }

                    npcSpawnInstance.Entity = SpawnNpc(x, y, dir, Spawns[i].NpcId);
                }
            }
        }
Пример #12
0
 public void applyDamageMonster(NpcBase monster)
 {
     if (explosionActivation)
     {
         monster.IstantiateExplosion(explosion);
         explosionActivation = false;
         monster.applyDamage(player.danoTotal + 4, player.danoTotal + 4);
     }
     else
     {
         monster.applyDamage(player.danoTotal, player.danoTotal);
     }
 }
Пример #13
0
 public void EnterState()
 {
     safeSpaces = NpcBase.FindTargets <Safety>("Safety", NpcController.Location, 100f, mask, s => s.isOpen);
     if (safeSpaces.Count > 0)
     {
         safeHouse = NpcBase.TargetNearest <Safety>(NpcController.Location, safeSpaces).transform;
         if (safeHouse != null)
         {
             NpcController.mover.MoveTo(safeHouse.position);
             // bMovingToSafety = true;
         }
     }
 }
Пример #14
0
        public bool CanNpcCombat(Entity enemy, bool friendly = false)
        {
            //Check for NpcVsNpc Combat, both must be enabled and the attacker must have it as an enemy or attack all types of npc.
            if (!friendly)
            {
                if (enemy != null && enemy.GetType() == typeof(Npc) && Base != null)
                {
                    if (((Npc)enemy).Base.NpcVsNpcEnabled == false)
                    {
                        return(false);
                    }

                    if (Base.AttackAllies && ((Npc)enemy).Base == Base)
                    {
                        return(true);
                    }

                    for (var i = 0; i < Base.AggroList.Count; i++)
                    {
                        if (NpcBase.Get(Base.AggroList[i]) == ((Npc)enemy).Base)
                        {
                            return(true);
                        }
                    }

                    return(false);
                }

                if (enemy != null && enemy.GetType() == typeof(Player))
                {
                    return(true);
                }
            }
            else
            {
                if (enemy != null &&
                    enemy.GetType() == typeof(Npc) &&
                    Base != null &&
                    ((Npc)enemy).Base == Base &&
                    Base.AttackAllies == false)
                {
                    return(true);
                }
                else if (enemy != null && enemy.GetType() == typeof(Player))
                {
                    return(false);
                }
            }

            return(false);
        }
Пример #15
0
 void RunToSafety()
 {
     if (safeSpaces.Count > 0)
     {
         safeHouse = NpcBase.TargetNearest <Safety>(NpcController.Location, safeSpaces).transform;
     }
     if (safeHouse != null)
     {
         movement = (safeHouse.position - NpcController.Location).normalized;
         NpcController.Animate(movement, 1f);
         NpcController.mover.MoveTo(safeHouse.position);
         bMovingToSafety = true;
     }
 }
Пример #16
0
        public Npc([NotNull] NpcBase myBase, bool despawnable = false) : base()
        {
            Name        = myBase.Name;
            Sprite      = myBase.Sprite;
            Level       = myBase.Level;
            Base        = myBase;
            Despawnable = despawnable;

            for (var i = 0; i < (int)Stats.StatCount; i++)
            {
                BaseStats[i] = myBase.Stats[i];
                Stat[i]      = new Stat((Stats)i, this);
            }

            var spellSlot = 0;

            for (var I = 0; I < Base.Spells.Count; I++)
            {
                var slot = new SpellSlot(spellSlot);
                slot.Set(new Spell(Base.Spells[I]));
                Spells.Add(slot);
                spellSlot++;
            }

            //Give NPC Drops
            var itemSlot = 0;

            foreach (var drop in myBase.Drops)
            {
                //if (Globals.Rand.Next(1, 10001) <= drop.Chance * 100 && ItemBase.Get(drop.ItemId) != null)
                //{
                var slot = new InventorySlot(itemSlot);
                slot.Set(new Item(drop.ItemId, drop.Quantity, true));
                slot.DropChance = drop.Chance;
                Items.Add(slot);
                itemSlot++;

                //}
            }

            for (var i = 0; i < (int)Vitals.VitalCount; i++)
            {
                SetMaxVital(i, myBase.MaxVital[i]);
                SetVital(i, myBase.MaxVital[i]);
            }

            Range       = (byte)myBase.SightRange;
            mPathFinder = new Pathfinder(this);
        }
Пример #17
0
        private void lstNpcs_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (mChangingName)
            {
                return;
            }

            if (lstNpcs.SelectedNode == null || lstNpcs.SelectedNode.Tag == null)
            {
                return;
            }

            mEditorItem = NpcBase.Get((Guid)lstNpcs.SelectedNode.Tag);
            UpdateEditor();
        }
Пример #18
0
 private void btnAddAggro_Click(object sender, EventArgs e)
 {
     mEditorItem.AggroList.Add(NpcBase.IdFromList(cmbHostileNPC.SelectedIndex));
     lstAggro.Items.Clear();
     for (var i = 0; i < mEditorItem.AggroList.Count; i++)
     {
         if (mEditorItem.AggroList[i] != Guid.Empty)
         {
             lstAggro.Items.Add(NpcBase.GetName(mEditorItem.AggroList[i]));
         }
         else
         {
             lstAggro.Items.Add(Strings.General.none);
         }
     }
 }
Пример #19
0
 private void lstMapNpcs_Click(object sender, EventArgs e)
 {
     if (lstMapNpcs.Items.Count > 0 && lstMapNpcs.SelectedIndex > -1)
     {
         cmbNpc.SelectedIndex = NpcBase.ListIndex(Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId);
         cmbDir.SelectedIndex = (int)Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].Direction;
         if (Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].X >= 0)
         {
             rbDeclared.Checked = true;
         }
         else
         {
             rbRandom.Checked = true;
         }
     }
 }
        public EventCommandSpawnNpc(
            FrmEvent eventEditor,
            MapBase currentMap,
            EventBase currentEvent,
            SpawnNpcCommand editingCommand
            )
        {
            InitializeComponent();
            mMyCommand    = editingCommand;
            mEventEditor  = eventEditor;
            mEditingEvent = currentEvent;
            mCurrentMap   = currentMap;
            InitLocalization();
            cmbNpc.Items.Clear();
            cmbNpc.Items.AddRange(NpcBase.Names);
            cmbNpc.SelectedIndex = NpcBase.ListIndex(mMyCommand.NpcId);
            if (mMyCommand.MapId != Guid.Empty)
            {
                cmbConditionType.SelectedIndex = 0;
            }
            else
            {
                cmbConditionType.SelectedIndex = 1;
            }

            nudWarpX.Maximum = Options.MapWidth;
            nudWarpY.Maximum = Options.MapHeight;
            UpdateFormElements();
            switch (cmbConditionType.SelectedIndex)
            {
            case 0:     //Tile spawn
                //Fill in the map cmb
                nudWarpX.Value             = mMyCommand.X;
                nudWarpY.Value             = mMyCommand.Y;
                cmbDirection.SelectedIndex = mMyCommand.Dir;

                break;

            case 1:     //On/Around Entity Spawn
                mSpawnX = mMyCommand.X;
                mSpawnY = mMyCommand.Y;
                chkDirRelative.Checked = Convert.ToBoolean(mMyCommand.Dir);
                UpdateSpawnPreview();

                break;
            }
        }
Пример #21
0
        //Map NPC List
        private void btnAddMapNpc_Click(object sender, EventArgs e)
        {
            var n = new NpcSpawn();

            //Don't add nothing
            if (cmbNpc.SelectedIndex > -1)
            {
                n.NpcId     = NpcBase.IdFromList(cmbNpc.SelectedIndex);
                n.X         = -1;
                n.Y         = -1;
                n.Direction = NpcSpawnDirection.Random;

                Globals.CurrentMap.Spawns.Add(n);
                lstMapNpcs.Items.Add(NpcBase.GetName(n.NpcId));
                lstMapNpcs.SelectedIndex = lstMapNpcs.Items.Count - 1;
            }
        }
Пример #22
0
        /// <summary>
        /// Does the action.
        /// </summary>
        public virtual void DoAction()
        {
            Logger.Write(string.Format("Processing NpcId: {0}", this.NpcId), "NPC", 20, 0, TraceEventType.Start, "Npc.DoAction");
            NpcBase npc = null;

            switch (this.NType)
            {
            case NpcType.GoodBalancer:
                // Special system good price/count balancer NPC
                npc = new NpcGoodBalancer(this);
                break;

            case NpcType.NpcBalancer:
                // Npc Balancer NPC
                npc = new NpcBalancer(this);
                break;

            case NpcType.Cleaner:
                // Cleaner NPC
                npc = new NpcCleaner(this);
                break;

            case NpcType.Trader:
                // Trader NPC
                npc = new NpcTrader(this);
                break;

            case NpcType.Pirate:
                // Pirate NPC
                npc = new NpcPirate(this);
                break;

            case NpcType.Police:
                // Police NPC
                npc = new NpcPolice(this);
                break;

            default:
                throw new ArgumentOutOfRangeException("NType", this.NType, "Invalid NPC Type");
            }

            // Do the actual NPC action
            npc.DoAction();
        }
Пример #23
0
        public QuestTaskEditor(QuestBase refQuest, QuestBase.QuestTask refTask)
        {
            if (refQuest == null)
            {
                Log.Warn($@"{nameof(refQuest)} is null.");
            }

            if (refTask == null)
            {
                Log.Warn($@"{nameof(refTask)} is null.");
            }

            InitializeComponent();
            mMyTask  = refTask;
            mMyQuest = refQuest;

            if (mMyTask?.EditingEvent == null)
            {
                Log.Warn($@"{nameof(mMyTask.EditingEvent)} is null.");
            }

            mEventBackup = mMyTask?.EditingEvent?.JsonData;
            InitLocalization();
            cmbTaskType.SelectedIndex = mMyTask == null ? -1 : (int)mMyTask.Objective;
            txtStartDesc.Text         = mMyTask?.Description;
            UpdateFormElements();
            switch (cmbTaskType.SelectedIndex)
            {
            case 0:     //Event Driven
                break;

            case 1:     //Gather Items
                cmbItem.SelectedIndex = ItemBase.ListIndex(mMyTask?.TargetId ?? Guid.Empty);
                nudItemAmount.Value   = mMyTask?.Quantity ?? 0;

                break;

            case 2:     //Kill NPCS
                cmbNpc.SelectedIndex = NpcBase.ListIndex(mMyTask?.TargetId ?? Guid.Empty);
                nudNpcQuantity.Value = mMyTask?.Quantity ?? 0;

                break;
            }
        }
Пример #24
0
 public void AttackEnemy(NpcBase defender, Action onAttackCompleted)
 {
     this.GetAnimator().SetBool("isWalking", true);
     if (this.AttackDamage() > defender.EvadeDamage())
     {
         Vector3 slideTargetPosition = defender.transform.position;
         SlideToPosition(slideTargetPosition, () =>
         {
             state = EState.Busy;
             defender.OnDamageReceived(this.AttackDamage() - stats.dexterity / 2);
             AnimAttack(() =>
             {
                 this.GetAnimator().SetBool("isAttacking", false);
                 SlideToPosition(startPosition, () =>
                 {
                     state = EState.Idle;
                     this.GetAnimator().SetBool("isWalking", false);
                     onAttackCompleted();
                 });
             });
         });
     }
     else
     {
         Vector3 slideTargetPosition = defender.transform.position;
         SlideToPosition(slideTargetPosition, () =>
         {
             state = EState.Busy;
             defender.GetAnimator().SetBool("Duck", true);
             print(this.stats.npcName + " Missed " + defender.stats.npcName + "!");
             AnimAttack(() =>
             {
                 this.GetAnimator().SetBool("isAttacking", false);
                 SlideToPosition(startPosition, () =>
                 {
                     state = EState.Idle;
                     defender.GetAnimator().SetBool("Duck", false);
                     this.GetAnimator().SetBool("isWalking", false);
                     onAttackCompleted();
                 });
             });
         });
     }
 }
Пример #25
0
    private void DoBattle(List <NpcBase> playerList, List <NpcBase> enemyList)
    {
        NpcBase defender;
        NpcBase fighter = orderList[combatant];

        if (fighter.stats.GetNpcCurrentHealth() > 0)
        {
            battleStatus = EBattleStatus.NpcAttacking;
            if (fighter.GetPlayerTeam())
            {
                int position = UnityEngine.Random.Range(0, enemyList.Count);
                defender = enemyList[position];
                fighter.AttackEnemy(defender, () =>
                {
                    if (defender.stats.GetNpcCurrentHealth() <= 0)
                    {
                        enemyList.Remove(defender);
                    }
                    NextCombatant();
                });
                print(fighter.stats.npcName + " has attacked " + defender.stats.npcName);
            }
            else
            {
                int position = UnityEngine.Random.Range(0, playerList.Count);
                defender = playerList[position];
                fighter.AttackEnemy(defender, () =>
                {
                    if (defender.GetNpcCurrentHealth() <= 0)
                    {
                        defender.GetAnimator().SetBool("isDead", true);
                        playerList.Remove(defender);
                    }
                    NextCombatant();
                });
                print(fighter.stats.npcName + " has attacked " + defender.stats.npcName);
            }
        }
        else
        {
            NextCombatant();
        }
    }
Пример #26
0
        private void cmbNpc_SelectedIndexChanged(object sender, EventArgs e)
        {
            var n = 0;

            if (lstMapNpcs.SelectedIndex >= 0)
            {
                Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId = NpcBase.IdFromList(cmbNpc.SelectedIndex);

                // Refresh List
                n = lstMapNpcs.SelectedIndex;
                lstMapNpcs.Items.Clear();
                for (var i = 0; i < Globals.CurrentMap.Spawns.Count; i++)
                {
                    lstMapNpcs.Items.Add(NpcBase.GetName(Globals.CurrentMap.Spawns[i].NpcId));
                }

                lstMapNpcs.SelectedIndex = n;
            }
        }
Пример #27
0
 private static int SetBattleOrder(NpcBase APirate, NpcBase BPirate)
 {
     if (APirate == null)
     {
         if (BPirate == null)
         {
             //If both null equals
             return(0);
         }
         else
         {
             //if APirate null then smaller
             return(-1);
         }
     }
     else
     {
         if (BPirate == null)
         {
             //if BPirate null then A bigger
             return(1);
         }
         else
         {
             //else compare level+dexterity
             int aOrder = APirate.stats.level + APirate.stats.dexterity;
             int bOrder = BPirate.stats.level + BPirate.stats.dexterity;
             if (bOrder.CompareTo(aOrder) == 0)
             {
                 if (BPirate.stats.level > APirate.stats.level)
                 {
                     return(1);
                 }
                 else
                 {
                     return(-1);
                 }
             }
             return(bOrder.CompareTo(aOrder));
         }
     }
 }
Пример #28
0
        public void DespawnNpcsOf(NpcBase npcBase)
        {
            var npcs = new List <Npc>();

            lock (GetMapLock())
            {
                foreach (var entity in mEntities)
                {
                    if (entity.GetType() == typeof(Npc) && ((Npc)entity).Base == npcBase)
                    {
                        npcs.Add((Npc)entity);
                    }
                }

                foreach (var en in npcs)
                {
                    en.Die(0);
                }
            }
        }
Пример #29
0
        private void btnRemoveMapNpc_Click(object sender, EventArgs e)
        {
            if (lstMapNpcs.SelectedIndex > -1)
            {
                Globals.CurrentMap.Spawns.RemoveAt(lstMapNpcs.SelectedIndex);
                lstMapNpcs.Items.RemoveAt(lstMapNpcs.SelectedIndex);

                // Refresh List
                lstMapNpcs.Items.Clear();
                for (var i = 0; i < Globals.CurrentMap.Spawns.Count; i++)
                {
                    lstMapNpcs.Items.Add(NpcBase.GetName(Globals.CurrentMap.Spawns[i].NpcId));
                }

                if (lstMapNpcs.Items.Count > 0)
                {
                    lstMapNpcs.SelectedIndex = 0;
                }
            }
        }
Пример #30
0
        public Entity SpawnNpc(byte tileX, byte tileY, byte dir, Guid npcId, bool despawnable = false)
        {
            var npcBase = NpcBase.Get(npcId);

            if (npcBase != null)
            {
                var npc = new Npc(npcBase, despawnable)
                {
                    MapId = Id,
                    X     = tileX,
                    Y     = tileY,
                    Dir   = dir
                };

                AddEntity(npc);
                PacketSender.SendEntityDataToProximity(npc);

                return(npc);
            }

            return(null);
        }