Example #1
0
 public static void SetUpFloorItemSystem()
 {
     foreach (var kvp in FloorItems)
     {
         if (kvp.Value.Jobs == null)
         {
             kvp.Value.Jobs = new List <Job>();
         }
         ScreenSystem.Create(kvp.Value);
         AddCountdown(kvp.Value);
         ScheduleDestruction(kvp.Value);
         ScheduleOwnerRemove(kvp.Value);
         GameWorld.Maps[kvp.Value.MapId].LoadInEntity(kvp.Value);
     }
 }
Example #2
0
 private static void QueueDrop(FloorItem drop)
 {
     YiScheduler.Instance.Do(SchedulerPriority.Medium, () =>
     {
         for (var i = 0; i < 10; i++)
         {
             if (!GameWorld.Maps[drop.MapId].ItemValid(drop.Location.X, drop.Location.Y))
             {
                 drop.Location.X += (ushort)YiCore.Random.Next(-1, 2);
                 drop.Location.Y += (ushort)YiCore.Random.Next(-1, 2);
             }
             else
             {
                 AddCountdown(drop);
                 ScheduleDestruction(drop);
                 ScheduleOwnerRemove(drop);
                 ScreenSystem.Create(drop);
                 FloorItems.AddOrUpdate(drop.UniqueId, drop);
                 GameWorld.Maps[drop.MapId].Enter(drop);
                 if (drop.Original != null && drop.Owner is Player player)
                 {
                     var packet = MsgItem.Create(drop.Original.UniqueId, drop.Original.UniqueId, drop.Original.UniqueId, MsgItemType.RemoveInventory);
                     player.Send(packet);
                 }
                 ScreenSystem.Send(drop, MsgFloorItem.Create(drop, MsgFloorItemType.Create), true);
                 drop.AddStatusEffect(StatusEffect.SuperMan);
                 return;
             }
         }
         if (drop.Original != null && drop.Owner is Player owner)
         {
             owner.Inventory.AddOrUpdate(drop.Original.UniqueId, drop.Original);
             owner.Send(new MsgItemInformation(drop.Original, MsgItemPosition.Inventory));
         }
         else
         {
             drop.Owner.Money += drop.Amount;
         }
     });
 }