public static void Add(YiObj obj, YiObj target) { if (!Entities.ContainsKey(obj.UniqueId)) { Create(obj); } if (target.UniqueId == obj.UniqueId || Entities[obj.UniqueId].Contains(target.UniqueId)) { return; } Entities[obj.UniqueId].Add(target.UniqueId); Add(target, obj); switch (target) { case Bot botTarget: //(obj as Player)?.Send(MsgSpawn.Create(botTarget)); break; case Player playerTarget: (obj as Player)?.Send(MsgSpawn.Create(playerTarget)); break; case Monster monsterTarget: monsterTarget.Brain.PlayersInSight++; (obj as Player)?.Send(MsgSpawn.Create(monsterTarget)); break; case Npc npcTarget: (obj as Player)?.Send(MsgNpcSpawn.Create(npcTarget)); if (npcTarget.BoothId != 0) { (obj as Player)?.Send(LegacyPackets.SpawnCarpet(npcTarget, npcTarget.BoothId)); } break; case DynamicNpc dynNpcTarget: (obj as Player)?.Send(MsgDynNpcSpawn.Create(dynNpcTarget)); break; case FloorItem floorItemTarget: (obj as Player)?.Send(MsgFloorItem.Create(floorItemTarget, MsgFloorItemType.Create)); break; case Portal portal: break; case null: Debugger.Break(); break; default: Debugger.Break(); break; } }
public static void CreateFor(YiObj owner) { if (owner is Npc npc) { npc.Type = 2; owner.BoothId = 10000000 + owner.UniqueId; BoothPool.AddOrUpdate(owner.BoothId, new ConcurrentDictionary <int, Product>()); foreach (var item in owner.Inventory) { var product = new Product(owner.UniqueId, item.Value.PriceBaseline, owner.BoothId, item.Value); Add(owner, item.Key, product.Price); } } else { owner.BoothId = owner.BoothId; BoothPool.AddOrUpdate(owner.BoothId, new ConcurrentDictionary <int, Product>()); (owner as Player)?.Send(MsgStatus.Create(owner.MapId, 0x0010)); (owner as Player)?.Send(LegacyPackets.SpawnCarpet((Player)owner, owner.BoothId)); } }