Beispiel #1
0
 internal Player(Func <bool> hasMount, UltimaServer server, Legacy legacyApi, EventJournalSource eventJournalSource)
 {
     this.hasMount           = hasMount;
     this.server             = server;
     this.legacyApi          = legacyApi;
     this.eventJournalSource = eventJournalSource;
 }
Beispiel #2
0
        public PlayerObservers(Player player, UltimaClient client, UltimaServer server, ILogger logger, Legacy legacyApi, GameObjectCollection gameObjects, EventJournalSource eventJournalSource)
        {
            this.client             = client;
            this.server             = server;
            this.player             = player;
            this.logger             = logger;
            this.legacyApi          = legacyApi;
            this.gameObjects        = gameObjects;
            this.eventJournalSource = eventJournalSource;

            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);

            clientPacketSubject.Subscribe(PacketDefinitions.RequestSkills, HandleRequestSkills);
        }
Beispiel #3
0
        public GumpObservers(UltimaServer server, UltimaClient client, EventJournalSource eventSource, Cancellation cancellation)
        {
            this.server       = server;
            this.client       = client;
            this.eventSource  = eventSource;
            this.cancellation = cancellation;
            server.RegisterFilter(FilterSendGumpMenuDialog);

            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.RegisterFilter(FilterGumpMenuSelection);
            clientPacketSubject.Subscribe(PacketDefinitions.GumpMenuSelection, GumpMenuSelectionRequest);
        }
Beispiel #4
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();
        }
Beispiel #5
0
        public Targeting(UltimaServer server, UltimaClient client, Cancellation cancellation,
                         EventJournalSource eventSource)
        {
            this.server       = server;
            this.client       = client;
            this.cancellation = cancellation;
            this.eventSource  = eventSource;
            server.Subscribe(PacketDefinitions.TargetCursor, HanldeServerTargetCursorPacket);
            eventJournal = new EventJournal(eventSource, cancellation);

            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.RegisterFilter(FilterClientTargetCursorPacket);

            IServerPacketSubject serverPacketSubject = server;

            serverPacketSubject.RegisterFilter(FilterSeverTargetCursorPacket);
        }
Beispiel #6
0
        public GumpObservers(UltimaServer server, UltimaClient client, EventJournalSource eventSource,
                             Cancellation cancellation, PacketDefinitionRegistry packetRegistry)
        {
            this.server         = server;
            this.client         = client;
            this.eventSource    = eventSource;
            this.cancellation   = cancellation;
            this.packetRegistry = packetRegistry;
            server.RegisterFilter(FilterSendGumpMenuDialog);

            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.RegisterFilter(FilterGumpMenuSelection);
            clientPacketSubject.Subscribe(PacketDefinitions.GumpMenuSelection, GumpMenuSelectionRequest);

            IServerPacketSubject serverPacketSubject = server;

            serverPacketSubject.Subscribe(PacketDefinitions.SendGumpMenuDialog, HandleGump);
            serverPacketSubject.Subscribe(PacketDefinitions.CompressedGump, HandleGump);
        }
Beispiel #7
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);
        }
Beispiel #8
0
 public DialogBoxObservers(UltimaServer server, EventJournalSource eventJournalSource)
 {
     this.server             = server;
     this.eventJournalSource = eventJournalSource;
     server.RegisterFilter(FilterServerPackets);
 }