示例#1
0
        public PlayerObservers(Player player, UltimaClient client, UltimaServer server, IConsole console,
                               Legacy legacyApi, GameObjectCollection gameObjects, EventJournalSource eventJournalSource,
                               PacketDefinitionRegistry packetRegistry)
        {
            this.client             = client;
            this.server             = server;
            this.player             = player;
            this.console            = console;
            this.legacyApi          = legacyApi;
            this.gameObjects        = gameObjects;
            this.eventJournalSource = eventJournalSource;
            this.packetRegistry     = packetRegistry;
            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.Subscribe(PacketDefinitions.MoveRequest, HandleMoveRequest);
            clientPacketSubject.RegisterOutputFilter(FilterSentClientPackets);

            server.RegisterFilter(FilterServerPackets);

            server.Subscribe(PacketDefinitions.CharacterLocaleAndBody, HandleCharLocaleAndBodyPacket);
            server.Subscribe(PacketDefinitions.DrawGamePlayer, HandleDrawGamePlayerPacket);
            server.Subscribe(PacketDefinitions.CharMoveRejection, HandleCharMoveRejectionPacket);
            server.Subscribe(PacketDefinitions.UpdateCurrentHealth, HandleUpdateCurrentHealthPacket);
            server.Subscribe(PacketDefinitions.UpdateCurrentStamina, HandleUpdateCurrentStaminaPacket);
            server.Subscribe(PacketDefinitions.UpdateCurrentMana, HandleUpdateCurrentManaPacket);
            server.Subscribe(PacketDefinitions.StatusBarInfo, HandleStatusBarInfoPacket);
            server.Subscribe(PacketDefinitions.SendSkills, HandleSendSkillsPacket);
            server.Subscribe(PacketDefinitions.DrawObject, HandleDrawObjectPacket);
            server.Subscribe(PacketDefinitions.AllowRefuseAttack, HandleAllowRefuseAttack);
            server.Subscribe(PacketDefinitions.UpdatePlayer, HandleUpdatePlayerPacket);
            server.Subscribe(PacketDefinitions.BoatMoving, HandleBoatMovingPacket);

            clientPacketSubject.Subscribe(PacketDefinitions.RequestSkills, HandleRequestSkills);
        }
示例#2
0
        internal Legacy(Configuration configuration, CommandHandler commandHandler,
                        UltimaServer ultimaServer, UltimaClient ultimaClient, ILogger logger)
        {
            Trace = new GlobalTrace(logger);

            cancellation       = new Cancellation(() => CancellationToken);
            eventJournalSource = new EventJournalSource();
            Me = new Player(() => GameObjects.OfType <Item>().OnLayer(Layer.Mount).FirstOrDefault() != null,
                            ultimaServer, this, eventJournalSource);
            gumpObservers       = new GumpObservers(ultimaServer, ultimaClient, eventJournalSource, cancellation);
            GameObjects         = new GameObjectCollection(Me);
            Items               = new ItemCollection(GameObjects);
            Mobiles             = new MobileCollection(GameObjects);
            Corpses             = new CorpseCollection(GameObjects);
            itemsObserver       = new ItemsObservers(GameObjects, ultimaServer, ultimaClient, this, eventJournalSource);
            Me.LocationChanged += itemsObserver.OnPlayerPositionChanged;
            journalSource       = new SpeechJournalSource();
            journalSource.NewMessageReceived +=
                (sender, entry) => eventJournalSource.Publish(new SpeechReceivedEvent(entry));
            Journal          = new SpeechJournal(journalSource, cancellation, () => DefaultTimeout, Trace.JournalTrace);
            journalObservers = new JournalObservers(journalSource, ultimaServer);
            targeting        = new Targeting(ultimaServer, ultimaClient, cancellation, eventJournalSource);

            blockedPacketsFilters = new BlockedClientPacketsFilters(ultimaClient);
            lightObserver         = new LightObserver(ultimaServer, ultimaClient, Me, this);
            weatherObserver       = new WeatherObserver(ultimaServer, ultimaClient, this);
            soundObserver         = new SoundObserver(ultimaServer, eventJournalSource);
            questArrowObserver    = new QuestArrowObserver(ultimaServer, eventJournalSource);
            shapeShifter          = new ShapeshiftingFilter(ultimaServer, ultimaClient);
            var speechRequestObserver = new SpeechRequestObserver(ultimaClient, commandHandler, eventJournalSource, logger);
            var staminaFilter         = new StaminaFilter(ultimaServer, ultimaClient);

            dialogBoxObervers = new DialogBoxObservers(ultimaServer, eventJournalSource);

            playerObservers = new PlayerObservers(Me, ultimaClient, ultimaServer, logger, this, GameObjects, eventJournalSource);
            playerObservers.WalkRequestDequeued += Me.OnWalkRequestDequeued;

            this.logger = logger;
            Server      = ultimaServer;
            Client      = ultimaClient;

            CommandHandler = commandHandler;
            CommandHandler.CancellationTokenCreated += (sender, token) => CancellationToken = token;

            Configuration      = configuration;
            legacyEventJournal = CreateEventJournal();

            ClientFilters = new LegacyFilters(staminaFilter, lightObserver, weatherObserver, soundObserver, shapeShifter);
            RegisterDefaultCommands();
        }
示例#3
0
        public ItemsObservers(GameObjectCollection gameObjects, IServerPacketSubject serverPacketSubject, IClientPacketSubject clientPacketSubject,
                              Legacy legacyApi, EventJournalSource eventJournalSource)
        {
            this.eventJournal = new EventJournal(eventJournalSource);
            this.waitForItemDraggedJournal = new EventJournal(eventJournalSource);

            this.gameObjects = gameObjects;
            this.gameObjects.MobileLeftView += (sender, mobile) =>
            {
                eventJournalSource.Publish(new MobileLeftViewEvent(mobile));
            };
            this.gameObjects.MobileDeleted += (sender, mobile) =>
            {
                eventJournalSource.Publish(new MobileLeftViewEvent(mobile));
            };

            this.legacyApi          = legacyApi;
            this.eventJournalSource = eventJournalSource;
            serverPacketSubject.Subscribe(PacketDefinitions.AddMultipleItemsInContainer,
                                          HandleAddMultipleItemsInContainer);
            serverPacketSubject.Subscribe(PacketDefinitions.AddItemToContainer, HandleAddItemToContainer);
            serverPacketSubject.Subscribe(PacketDefinitions.DeleteObject, HandleDeleteObjectPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.ObjectInfo, HandleObjectInfoPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.SecondAgeObjectInformation7090, HandleSecondAgeObjectInfoPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.DrawObject, HandleDrawObjectPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.UpdatePlayer, HandleUpdatePlayerPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.UpdateCurrentHealth, HandleUpdateCurrentHealthPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.WornItem, HandleWornItemPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.RejectMoveItemRequest, HandleRejectMoveItemRequestPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.DrawContainer, HandleDrawContainer);
            serverPacketSubject.Subscribe(PacketDefinitions.PauseClient, HandlePauseClient);
            serverPacketSubject.Subscribe(PacketDefinitions.SendSpeech, HandleSendSpeechPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.StatusBarInfo, HandleStatusBarInfo);
            serverPacketSubject.Subscribe(PacketDefinitions.GraphicalEffect, HandleGraphicalEffect);
            clientPacketSubject.Subscribe(PacketDefinitions.DoubleClick, HandleDoubleClick);

            serverPacketSubject.RegisterOutputFilter(FilterServerPackets);
        }
示例#4
0
 internal MobileCollection(GameObjectCollection gameObjects) : base(gameObjects)
 {
 }
示例#5
0
 internal CorpseCollection(GameObjectCollection gameObjects) : base(gameObjects)
 {
 }
示例#6
0
 internal ItemCollection(GameObjectCollection gameObjects) : base(gameObjects)
 {
 }
 internal GameObjectCollectionWrapper(GameObjectCollection gameObjects)
 {
     this.gameObjects = gameObjects;
 }