示例#1
0
 public JournalObservers(SpeechJournalSource journalSource, IServerPacketSubject serverPacketSubject)
 {
     this.journalSource = journalSource;
     serverPacketSubject.Subscribe(PacketDefinitions.SpeechMessage, HandleSpeechMessagePacket);
     serverPacketSubject.Subscribe(PacketDefinitions.SendSpeech, HanldeSendSpeechPacket);
     serverPacketSubject.Subscribe(PacketDefinitions.ClilocMessage, HandleClilocMessage);
     serverPacketSubject.Subscribe(PacketDefinitions.ClilocMessageAffix, HandleClilocMessageAffix);
 }
示例#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 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;
 }
示例#4
0
        public JournalObservers(SpeechJournalSource journalSource, IServerPacketSubject serverPacketSubject, IConsole console,
                                IClilocSource clilocSource)
        {
            this.journalSource = journalSource;
            this.console       = console;
            this.clilocSource  = clilocSource;
            translator         = new ClilocTranslator(clilocSource);

            serverPacketSubject.Subscribe(PacketDefinitions.SpeechMessage, HandleSpeechMessagePacket);
            serverPacketSubject.Subscribe(PacketDefinitions.SendSpeech, HanldeSendSpeechPacket);
            serverPacketSubject.Subscribe(PacketDefinitions.ClilocMessage, HandleClilocMessage);
            serverPacketSubject.Subscribe(PacketDefinitions.ClilocMessageAffix, HandleClilocMessageAffix);
        }
示例#5
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();
        }