Example #1
0
		protected override void CreateSink() {
			base.CreateSink();

			// Create an instance of the client that will handle the event
			// and associate it with the underlying ActiveX control.
			helper = new EventHelper(this);
			cookie = new AxHost.ConnectionPointCookie(
				ActiveXInstance, helper, typeof(DWebBrowserEvents2));
		}
Example #2
0
 /// <summary>
 /// Raises <see cref="ExceptionCaught"/>.
 /// </summary>
 /// <param name="args"></param>
 private void OnExceptionCaught(EventArgs <Exception> args)
 {
     EventHelper.Raise(ExceptionCaught, this, args);
 }
Example #3
0
        public void UpdatePerceptions(RolePlayCharacterAsset rpc)
        {
            /*
             * Find every InSight, InInventory, and IsEquipped belief and set them to false
             * */
            CleanBeliefs(rpc);

            /*
             * Update the KB with the new beliefs
             * */
            string bv = rpc.GetBeliefValue("Hunger(" + rpc.CharacterName.ToString() + ")");

            if (bv == null || !bv.Equals(Hunger.ToString()))
            {
                Debug.WriteLine("Hunger: " + bv + " -> " + Hunger.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Hunger(" + rpc.CharacterName.ToString() + ")", Hunger.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Health(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Health.ToString()))
            {
                Debug.WriteLine("Health: " + bv + " -> " + Health.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Health(" + rpc.CharacterName.ToString() + ")", Health.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Sanity(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Sanity.ToString()))
            {
                Debug.WriteLine("Sanity: " + bv + " -> " + Sanity.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Sanity(" + rpc.CharacterName.ToString() + ")", Sanity.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsFreezing(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsFreezing.ToString()))
            {
                Debug.WriteLine("IsFreezing: " + bv + " -> " + IsFreezing.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsFreezing(" + rpc.CharacterName.ToString() + ")", IsFreezing.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsOverheating(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsOverheating.ToString()))
            {
                Debug.WriteLine("IsOverheating: " + bv + " -> " + IsOverheating.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsOverheating(" + rpc.CharacterName.ToString() + ")", IsOverheating.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Moisture(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Moisture.ToString()))
            {
                Debug.WriteLine("Moisture: " + bv + " -> " + Moisture.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Moisture(" + rpc.CharacterName.ToString() + ")", Moisture.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Temperature(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Temperature.ToString()))
            {
                Debug.WriteLine("Temperature: " + bv + " -> " + Temperature.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Temperature(" + rpc.CharacterName.ToString() + ")", Temperature.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsBusy(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsBusy.ToString()))
            {
                Debug.WriteLine("IsBusy: " + bv + " -> " + IsBusy.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsBusy(" + rpc.CharacterName.ToString() + ")", IsBusy.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("PosX(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosX.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosX(" + rpc.CharacterName.ToString() + ")", PosX.ToString(), rpc.CharacterName.ToString()));
            }

            /*
             * The Y-axis is always equal to zero, no need to save it in the knowledge base
             * */
            //bv = rpc.GetBeliefValue("PosY(" + rpc.CharacterName.ToString() + ")");
            //if (bv == null || !bv.Equals(PosY.ToString()))
            //    rpc.Perceive(EventHelper.PropertyChange("PosY(" + rpc.CharacterName.ToString() + ")", PosY.ToString(), rpc.CharacterName.ToString()));

            bv = rpc.GetBeliefValue("PosZ(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosZ.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosZ(" + rpc.CharacterName.ToString() + ")", PosZ.ToString(), rpc.CharacterName.ToString()));
            }


            foreach (Item i in Vision)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InSight(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InSight(" + i.GUID + ")", "True", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (Item i in ItemSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InInventory(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InInventory(" + i.GUID + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (EquippedItems i in EquipSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("IsEquipped(" + i.GUID + "," + i.Slot + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("IsEquipped(" + i.GUID + "," + i.Slot + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            rpc.Update();
        }
Example #4
0
 /// <summary>
 /// Raises <see cref="BeforeRequestReceived"/>.
 /// </summary>
 /// <param name="args"></param>
 private void OnBeforeRequestReceived(RequestReceivedEventArgs args)
 {
     EventHelper.RaiseQuickly(BeforeRequestReceived, this, args);
 }
Example #5
0
 /// <summary>
 /// Raises <see cref="ResponseSent"/>.
 /// </summary>
 /// <param name="args"></param>
 private void OnResponseSent(ResponseSentEventArgs args)
 {
     EventHelper.RaiseQuickly(ResponseSent, this, args);
 }
 /// <summary>
 /// Shortcut method to call <see cref="OnPropertyChanged"/>.
 /// </summary>
 /// <param name="record"></param>
 /// <param name="group"></param>
 /// <param name="propertyChanged"></param>
 /// <param name="isListChild"></param>
 private void RaisePropertyChanged(object record, ConfigurationListenerGroup group, PropertyChangedEventArgs propertyChanged, bool isListChild = false)
 {
     EventHelper.Raise(PropertyChanged, this, () => new ConfigurationListenerEventArgs(_Configuration, record, isListChild, group, propertyChanged.PropertyName));
 }
Example #7
0
 /// <summary>
 /// Raises <see cref="OnAuthenticationRequired"/>.
 /// </summary>
 /// <param name="args"></param>
 private void OnAuthenticationRequired(AuthenticationRequiredEventArgs args)
 {
     EventHelper.RaiseQuickly(AuthenticationRequired, this, args);
 }
 private void HandleButtonRepairEquipmentClicked(object sender, UserInterfaceEquipmentEventArgs e)
 {
     EventHelper.FireEvent(EquipmentRepaired, sender, e);
 }
Example #9
0
        private void DoNormalUpdate()
        {
            //make sure client is not move ahead too much than server
            var maxContinueServerTick = _cmdBuffer.MaxContinueServerTick;

            if ((_world.Tick - maxContinueServerTick) > MaxPredictFrameCount)
            {
                return;
            }

            var minTickToBackup = (maxContinueServerTick - (maxContinueServerTick % snapshotFrameInterval));

            // Pursue Server frames
            var deadline = LTime.realtimeSinceStartupMS + MaxSimulationMsPerFrame;

            while (_world.Tick < _cmdBuffer.CurTickInServer)
            {
                var tick   = _world.Tick;
                var sFrame = _cmdBuffer.GetServerFrame(tick);
                if (sFrame == null)
                {
                    OnPursuingFrame();
                    return;
                }

                _cmdBuffer.PushLocalFrame(sFrame);
                Simulate(sFrame, tick == minTickToBackup);
                if (LTime.realtimeSinceStartupMS > deadline)
                {
                    OnPursuingFrame();
                    return;
                }
            }

            if (_constStateService.IsPursueFrame)
            {
                _constStateService.IsPursueFrame = false;
                EventHelper.Trigger(EEvent.PursueFrameDone);
            }


            // Roll back
            if (_cmdBuffer.IsNeedRollback)
            {
                RollbackTo(_cmdBuffer.NextTickToCheck, maxContinueServerTick);
                CleanUselessSnapshot(System.Math.Min(_cmdBuffer.NextTickToCheck - 1, _world.Tick));

                minTickToBackup = System.Math.Max(minTickToBackup, _world.Tick + 1);
                while (_world.Tick <= maxContinueServerTick)
                {
                    var sFrame = _cmdBuffer.GetServerFrame(_world.Tick);
                    Logging.Debug.Assert(sFrame != null && sFrame.tick == _world.Tick,
                                         $" logic error: server Frame  must exist tick {_world.Tick}");
                    _cmdBuffer.PushLocalFrame(sFrame);
                    Simulate(sFrame, _world.Tick == minTickToBackup);
                }
            }


            //Run frames
            while (_world.Tick <= TargetTick)
            {
                var         curTick = _world.Tick;
                ServerFrame frame   = null;
                var         sFrame  = _cmdBuffer.GetServerFrame(curTick);
                if (sFrame != null)
                {
                    frame = sFrame;
                }
                else
                {
                    var cFrame = _cmdBuffer.GetLocalFrame(curTick);
                    FillInputWithLastFrame(cFrame);
                    frame = cFrame;
                }

                _cmdBuffer.PushLocalFrame(frame);
                Predict(frame, true);
            }

            _hashHelper.CheckAndSendHashCodes();
        }
 private void MenuInspectEmployeeOnButtonFireEmployeeClicked(object sender, UserInterfaceEmployeeEventArgs e)
 {
     EventHelper.FireEvent(EmployeeFired, sender, e);
     ChangeState(UserInterfaceState.Default);
 }
 private void HandleButtonSellEquipmentClicked(object sender, UserInterfaceEquipmentEventArgs e)
 {
     EventHelper.FireEvent(EquipmentSold, sender, e);
     ChangeState(UserInterfaceState.Default);
 }
 private void MenuInspectEmployeeOnButtonDisciplineEmployeeClicked(object sender, UserInterfaceEmployeeEventArgs e)
 {
     EventHelper.FireEvent(EmployeeDisciplined, sender, e);
 }
Example #13
0
 public async Task <Event> GetAsync(string eventId)
 {
     eventId = eventId.Trim().Replace(" ", "+");
     Request.Headers.TryGetValue("Custom-Token", out StringValues token);
     return(await EventHelper.GetEventByEventId(eventId, token.ToString()));
 }
Example #14
0
 private void OnPropertyChanged(string propertyName)
 {
     EventHelper.Raise(ref PropertyChanged, this, new PropertyChangedEventArgs(propertyName));
 }
Example #15
0
 private void OnUseRecommendedRawDecodingSettingsClicked(EventArgs args)
 {
     EventHelper.Raise(UseRecommendedRawDecodingSettingsClicked, this, args);
 }
Example #16
0
 /// <summary>
 /// Called when [user deleted].
 /// </summary>
 /// <param name="user">The user.</param>
 private void OnUserDeleted(User user)
 {
     EventHelper.QueueEventIfNotNull(UserDeleted, this, new GenericEventArgs <User> {
         Argument = user
     }, _logger);
 }
 /// <summary>
 /// Raises <see cref="PropertyChanged"/>.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnPropertyChanged(ConfigurationListenerEventArgs args)
 {
     EventHelper.Raise(PropertyChanged, this, args);
 }
Example #18
0
 /// <summary>
 /// Raises <see cref="ConnectionStateChanged"/>.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnConnectionStateChanged(EventArgs args)
 {
     EventHelper.Raise(ConnectionStateChanged, this, args);
 }
Example #19
0
 /// <summary>
 /// Raises <see cref="ExternalAddressChanged"/>.
 /// </summary>
 /// <param name="args"></param>
 private void OnExternalAddressChanged(EventArgs args)
 {
     EventHelper.Raise(ExternalAddressChanged, this, args);
 }
Example #20
0
        public async Task ClearLog()
        {
            await _repo.DeleteAll();

            EventHelper.FireEventIfNotNull(LogReset, this, EventArgs.Empty, _logger);
        }
Example #21
0
 /// <summary>
 /// Raises <see cref="OnlineChanged"/>.
 /// </summary>
 /// <param name="args"></param>
 private void OnOnlineChanged(EventArgs args)
 {
     EventHelper.Raise(OnlineChanged, this, args);
 }
Example #22
0
 /// <summary>
 /// Raises <see cref="FetchRecordContent"/>.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnFetchRecordContent(ListContentEventArgs args)
 {
     EventHelper.Raise(FetchRecordContent, this, args);
 }
Example #23
0
 /// <summary>
 /// Raises <see cref="AfterRequestReceived"/>.
 /// </summary>
 /// <param name="args"></param>
 private void OnAfterRequestReceived(RequestReceivedEventArgs args)
 {
     EventHelper.RaiseQuickly(AfterRequestReceived, this, args);
 }
Example #24
0
 /// <summary>
 /// Raises <see cref="SelectedRecordChanged"/>.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnSelectedRecordChanged(EventArgs args)
 {
     EventHelper.Raise(SelectedRecordChanged, this, args);
 }
Example #25
0
 /// <summary>
 /// Raises <see cref="RequestFinished"/>
 /// </summary>
 /// <param name="args"></param>
 private void OnRequestFinished(EventArgs <long> args)
 {
     EventHelper.RaiseQuickly(RequestFinished, this, args);
 }
Example #26
0
 /// <summary>
 /// Raises <see cref="AddClicked"/>.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnAddClicked(EventArgs args)
 {
     EventHelper.Raise(AddClicked, this, args);
 }
Example #27
0
 /// <summary>
 /// FindEntriesByEvent.
 /// </summary>
 /// <param name="doorEvent">En sträng<see cref="string"/> med händelse ID (DÖIN = Dörren öppnades inifrån).</param>
 /// <returns>En DataTable<see cref="DataTable"/> med sökresultat.</returns>
 public static DataTable FindEntriesByEvent(string doorEvent)
 {
     return(EventHelper.FindEntriesByEvent(doorEvent, MaxEntries));
 }
Example #28
0
 /// <summary>
 /// Raises <see cref="DeleteClicked"/>.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnDeleteClicked(EventArgs args)
 {
     EventHelper.Raise(DeleteClicked, this, args);
 }
Example #29
0
 void socket_OnError(object sender, SocketHttpListener.ErrorEventArgs e)
 {
     EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger);
 }
Example #30
0
 /// <summary>
 /// Raises <see cref="CheckedChanged"/>.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnCheckedChanged(ListCheckedEventArgs args)
 {
     EventHelper.Raise(CheckedChanged, this, args);
 }
 public static void Register(OnCall method, Priority priority)
 {
     EventHelper temp = new EventHelper(method, priority, new OnPlayerConnect());
     EventHelper.Push(temp);
 }
Example #32
0
 private void OnTestConnectionClicked(EventArgs <Receiver> args)
 {
     EventHelper.Raise(TestConnectionClicked, this, args);
 }