Пример #1
0
 internal EventJournal(IEventJournalSource source, Cancellation cancellation = null, Func <TimeSpan?> defaultTimeout = null)
 {
     this.source         = source;
     this.cancellation   = cancellation;
     this.defaultTimeout = defaultTimeout;
     JournalStartEventId = source.LastEventId;
 }
Пример #2
0
 internal SpeechJournalAwaiter(Cancellation cancellation, SpeechJournalSource journalSource = null,
                               SpeechJournal journal = null, Func <TimeSpan?> defaultTimeout = null, DiagnosticTrace trace = null)
 {
     this.cancellation   = cancellation;
     this.journalSource  = journalSource;
     this.journal        = journal;
     this.defaultTimeout = defaultTimeout;
     this.trace          = trace;
 }
Пример #3
0
 internal EventJournalAwaiter(IEventJournalSource source, Cancellation cancellation,
                              EventJournal journal, Func <TimeSpan?> defaultTimeout)
 {
     this.source              = source;
     this.cancellation        = cancellation;
     this.journal             = journal;
     this.defaultTimeout      = defaultTimeout;
     source.NewEventReceived += HandleNewEvent;
     preallocatedAllEvents    = new List <OrderedEvent>();
 }
Пример #4
0
 internal SpeechJournal(SpeechJournalSource source, Cancellation cancellation = null,
                        Func <TimeSpan?> defaultTimeout = null, DiagnosticTrace trace = null)
 {
     this.source         = source;
     this.cancellation   = cancellation;
     this.defaultTimeout = defaultTimeout;
     this.trace          = trace;
     journalEntryStartId = source.CurrentJournalEntryId;
     LastWaitEntryId     = journalEntryStartId;
 }
Пример #5
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);
        }
Пример #6
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();
        }
Пример #7
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);
        }
Пример #8
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);
        }