public static void HandleInstallBillBoard(GameSession session, PacketReader packet, Item item)
        {
            string[] parameters  = packet.ReadUnicodeString().Split("'");
            string   title       = parameters[0];
            string   description = parameters[1];
            bool     publicHouse = parameters[2].Equals("1");

            int       balloonUid = GuidGenerator.Int();
            string    id         = "AdBalloon_" + balloonUid.ToString();
            AdBalloon balloon    = new AdBalloon(id, item.Function.InstallBillboard.InteractId, InteractObjectState.Default, InteractObjectType.AdBalloon, session.FieldPlayer, item.Function.InstallBillboard, title, description, publicHouse);

            session.FieldManager.State.AddInteractObject(balloon);
            session.FieldManager.BroadcastPacket(InteractObjectPacket.LoadAdBallon(balloon));
            InventoryController.Consume(session, item.Uid, 1);
        }
Esempio n. 2
0
        public void AddPlayer(GameSession sender, IFieldObject <Player> player)
        {
            Debug.Assert(player.ObjectId > 0, "Player was added to field without initialized objectId.");
            player.Coord       = player.Value.Coord;
            player.Value.MapId = MapId;
            // TODO: Determine new coordinates for player as well
            lock (Sessions)
            {
                Sessions.Add(sender);
            }

            // TODO: Send the initialization state of the field
            foreach (IFieldObject <Player> existingPlayer in State.Players.Values)
            {
                sender.Send(FieldPacket.AddPlayer(existingPlayer));
                sender.Send(FieldObjectPacket.LoadPlayer(existingPlayer));
            }

            State.AddPlayer(player);
            // Broadcast new player to all players in map
            Broadcast(session =>
            {
                session.Send(FieldPacket.AddPlayer(player));
                session.Send(FieldObjectPacket.LoadPlayer(player));
            });

            foreach (IFieldObject <Item> existingItem in State.Items.Values)
            {
                sender.Send(FieldPacket.AddItem(existingItem, 123456));
            }
            foreach (IFieldObject <Npc> existingNpc in State.Npcs.Values)
            {
                sender.Send(FieldPacket.AddNpc(existingNpc));
                sender.Send(FieldObjectPacket.LoadNpc(existingNpc));
            }
            foreach (IFieldObject <Portal> existingPortal in State.Portals.Values)
            {
                sender.Send(FieldPacket.AddPortal(existingPortal));
            }
            foreach (IFieldObject <Mob> existingMob in State.Mobs.Values)
            {
                sender.Send(FieldPacket.AddMob(existingMob));
                sender.Send(FieldObjectPacket.LoadMob(existingMob));
            }

            if (player.Value.MapId == (int)Map.PrivateResidence && !player.Value.IsInDecorPlanner)
            {
                // Send function cubes
                List <Cube> functionCubes = State.Cubes.Values.Where(x => x.Value.PlotNumber == 1 &&
                                                                     (x.Value.Item.HousingCategory is ItemHousingCategory.Farming or ItemHousingCategory.Ranching))
                                            .Select(x => x.Value).ToList();

                if (functionCubes.Count > 0)
                {
                    sender.Send(FunctionCubePacket.SendCubes(functionCubes));
                }
            }

            foreach (IFieldObject <GuideObject> guide in State.Guide.Values)
            {
                sender.Send(GuideObjectPacket.Add(guide));
            }

            foreach (IFieldObject <HealingSpot> healingSpot in State.HealingSpots.Values)
            {
                sender.Send(RegionSkillPacket.Send(healingSpot.ObjectId, healingSpot.Value.Coord, new SkillCast(70000018, 1, 0, 1)));
            }

            foreach (IFieldObject <Instrument> instrument in State.Instruments.Values)
            {
                if (instrument.Value.Improvise)
                {
                    sender.Send(InstrumentPacket.StartImprovise(instrument));
                }
                else
                {
                    sender.Send(InstrumentPacket.PlayScore(instrument));
                }
            }

            List <BreakableObject> breakables = new List <BreakableObject>();

            breakables.AddRange(State.BreakableActors.Values.ToList());
            breakables.AddRange(State.BreakableNifs.Values.ToList());
            sender.Send(BreakablePacket.LoadBreakables(breakables));

            List <InteractObject> interactObjects = new List <InteractObject>();

            interactObjects.AddRange(State.InteractObjects.Values.Where(t => t is not AdBalloon).ToList());
            sender.Send(InteractObjectPacket.LoadInteractObject(interactObjects));

            List <AdBalloon> adBalloons = new List <AdBalloon>();

            adBalloons.AddRange(State.InteractObjects.Values.OfType <AdBalloon>().ToList());
            foreach (AdBalloon balloon in adBalloons)
            {
                sender.Send(InteractObjectPacket.LoadAdBallon(balloon));
            }

            List <TriggerObject> triggerObjects = new List <TriggerObject>();

            triggerObjects.AddRange(State.TriggerMeshes.Values.ToList());
            triggerObjects.AddRange(State.TriggerEffects.Values.ToList());
            triggerObjects.AddRange(State.TriggerCameras.Values.ToList());
            triggerObjects.AddRange(State.TriggerActors.Values.ToList());
            triggerObjects.AddRange(State.TriggerCubes.Values.ToList());
            triggerObjects.AddRange(State.TriggerLadders.Values.ToList());
            triggerObjects.AddRange(State.TriggerRopes.Values.ToList());
            triggerObjects.AddRange(State.TriggerSounds.Values.ToList());
            sender.Send(TriggerPacket.LoadTriggers(triggerObjects));

            if (MapLoopTask == null)
            {
                MapLoopTask = StartMapLoop(); //TODO: find a better place to initialise MapLoopTask
            }
        }