protected void OnValueChanged() { if (!_valueWasAssigned) { return; } Nodes.Node node = _object as Nodes.Node; if (node != null) { node.OnPropertyValueChanged(true); if (ValueWasChanged != null) { ValueWasChanged(); } return; } Events.Event evnt = _object as Events.Event; if (evnt != null) { evnt.OnPropertyValueChanged(true); if (ValueWasChanged != null) { ValueWasChanged(); } return; } }
/// <summary>Removes function from call list of this event </summary> public void UnsubscribeToEvent(Events.Event _event, EventTrigger _trigger) { EventList tempList = m_eventList[(int)_event]; tempList.m_event -= _trigger; m_eventList[(int)_event] = tempList; }
private void OnSocketData(Events.Event eventObj) { SocketEvent socketEvent = (SocketEvent)eventObj; TestPacket packet = (TestPacket)socketEvent.SocketPacket; Debug.Log(packet.Text); IntegrationTest.Pass(gameObject); }
private void OnServerExceptionCaught(Events.Event eventObj) { SocketEvent socketEvent = (SocketEvent)eventObj; Exception e = socketEvent.Exception; Debug.Log(e.Message); Debug.Log(e.StackTrace); }
/// <summary> /// Initialises a property on a given event. /// </summary> /// <param name="xml">The XML element containing the attribute we want to get.</param> /// <param name="node">The event whose property we want to set.</param> /// <param name="property">The property on the event we want to set.</param> protected void InitProperty(XmlNode xml, Events.Event evnt, DesignerPropertyInfo property) { string value; if (GetAttribute(xml, property.Property.Name, out value)) { property.SetValueFromString(evnt, value); } }
/// <summary> /// Called when [timer handler]. /// </summary> /// <param name="eventObj">The event object.</param> private void OnTimerHandler(Events.Event eventObj) { TimerEvent timerEvent = eventObj as TimerEvent; QuickUnity.Timers.ITimer timer = timerEvent.timer; float deltaTime = timerEvent.deltaTime; Debug.Log("timer1 count: " + timer.currentCount + ", delta time: " + deltaTime); }
public override void OnEventReceived(Events.Event e, object o) { if (e == Events.Event.PleaseDoSomething) { if (_actions.Count == 0) { StartCoroutine(DoNextThing(Random.Range(0.1f, 1f))); } else { DoNextAction(); } } // Debug.Log("Event Received"); if (e == Events.Event.RoomCreated) { // If already doing something, just redo the paths if (_actions != null && _actions.Count > 0) { List <(List <ARoom> path, Action action)> newactions = new List <(List <ARoom> path, Action action)>(); // do not forget to start from the current room and not from the next one !! _actions[0].path.Insert(0, _currentRoom); foreach (var action in _actions) { newactions.Add(( Astar.FindPath(action.path[0], action.path[action.path.Count - 1]), action.action )); } _actions = newactions; } // else { // ChooseAction(); // } } if (e == Events.Event.RoomDestroyed) { // oups } if (e == Events.Event.BlueprintDrawn || e == Events.Event.RoomCreated) { // Debug.Log("Blueprint Drawn event received for warehouseman"); if (_actions.Count == 0) { // Debug.Log("I'm available"); StartCoroutine(DoNextThing(Random.Range(0.1f, 1f))); } } if (e == Events.Event.ResourceMined) { if (_actions.Count == 0) { StartCoroutine(DoNextThing(Random.Range(0.1f, 1f))); } } }
public static void ShouldBeTheSameAs(this CommittedEvent committedEvent, Events.Event storedEvent) { committedEvent.EventLogSequenceNumber.Value.ShouldEqual(storedEvent.EventLogSequenceNumber); committedEvent.EventSource.Value.ShouldEqual(storedEvent.Metadata.EventSource); committedEvent.ExecutionContext.ShouldBeTheSameAs(storedEvent.ExecutionContext); committedEvent.Occurred.UtcDateTime.ShouldEqual(storedEvent.Metadata.Occurred); committedEvent.Public.ShouldEqual(storedEvent.Metadata.Public); committedEvent.Type.Id.Value.ShouldEqual(storedEvent.Metadata.TypeId); committedEvent.Type.Generation.Value.ShouldEqual(storedEvent.Metadata.TypeGeneration); }
public void ReceiveEvent(Events.Event e) { if (e == Events.Event.ExplorationFlagSet) { PlayAudio(_explorationSet); } else if (e == Events.Event.ExplorationFlagUnset) { PlayAudio(_yes); } }
private static Dictionary <OutputAction, Events.Event <T> > GenerateEventsForOutputActions <T>() { var values = Enum.GetValues(typeof(OutputAction)); var dict = new Dictionary <OutputAction, Events.Event <T> >(values.Length); foreach (OutputAction outputAction in values) { dict[outputAction] = new Events.Event <T>(); } return(dict); }
/// <summary> /// Called when [timer complete handler]. /// </summary> /// <param name="eventObj">The event object.</param> private void OnTimerCompleteHandler(Events.Event eventObj) { TimerEvent timerEvent = eventObj as TimerEvent; QuickUnity.Timers.ITimer timer = timerEvent.timer; float deltaTime = timerEvent.deltaTime; Debug.Log("timer2 count: " + timer.currentCount + ", delta time: " + deltaTime); TimerManager timerManager = TimerManager.instance; timerManager.RemoveTimer("test1"); timerManager.RemoveTimer("test2"); }
private Status ConvertFailureToException(Events.Event _event) { if (_event is Events.DailyLimitOver) { return(new Status.Failure(new DailyLimitOverException())); } if (_event is Events.InsufficientProduct) { return(new Status.Failure(new ProductStockExcessException())); } if (_event is Events.ProductNotFound) { return(new Status.Failure(new ArgumentException("Product is not found"))); } return(new Status.Failure(new Exception())); }
/// <summary> /// Loads an event which is attached to a node. /// </summary> /// <param name="node">The node the event is created for.</param> /// <param name="xml">The XML node the event retrieves its name and attributes from.</param> /// <returns>Returns the created SubItems.Event.</returns> protected Events.Event CreateEvent(Node node, XmlNode xml) { // get the type of the event and create it // maintain compatibility with version 1 //string clss= GetAttribute(xml, "Class"); string clss; if (!GetAttribute(xml, "Class", out clss)) { string find = ".Events." + GetAttribute(xml, "name"); Type found = Plugin.FindType(find); if (found != null) { clss = found.FullName; } } Type t = Plugin.GetType(clss); if (t == null) { throw new Exception(string.Format(Resources.ExceptionUnknownEventType, clss)); } Events.Event evnt = Events.Event.Create(t, node); // initialise the events properties IList <DesignerPropertyInfo> properties = evnt.GetDesignerProperties(); for (int p = 0; p < properties.Count; ++p) { if (properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) { continue; } InitProperty(xml, evnt, properties[p]); } // update event with attributes evnt.OnPropertyValueChanged(false); return(evnt); }
protected void AddHandler <ChangeEvent>( StateChangeHandlerDelegate <ChangeEvent> handler, EventComparator <ChangeEvent> comparator, Events.Event <ChangeEvent> changeEvent ) { UnityAction <ChangeEvent> ephemeralHandler = (ChangeEvent pEv) => { handler(pEv); }; changeEvent.Listen(ephemeralHandler); // Cleanup cleanupActions.Add(() => { changeEvent.Remove(ephemeralHandler); }); }
public override void OnEventReceived(Events.Event e, object o) { if (e == Events.Event.MasterBlueprintFinished) { MasterBlueprint mbp = (MasterBlueprint)o; if (mbp.Owner == _id) { // this is our BP GenerateNewMasterBlueprint(); } } if (e == Events.Event.ExplorationNewZone) { // check if any blueprints is active if (!MapManager.S.MapMasterBlueprints.Any(mbp => mbp.Owner == _id)) { GenerateNewMasterBlueprint(); } } }
protected void AddHandler <PressEvent>( PressHandlerDelegate <PressEvent> handler, PressEventComparator <PressEvent> comparator, Events.Event <PressEvent> pressEvent, Events.Event <PressEvent> unpressEvent ) { UnityAction <PressEvent> ephemeralHandler = (PressEvent pEv) => { var unpressHandler = handler(pEv); UnityAction <PressEvent> ephemeralUnpressHandler = null; void cleanupEphemeralUnpressHandler() { unpressEvent.Remove(ephemeralUnpressHandler); } ephemeralUnpressHandler = (PressEvent uEv) => { if (!comparator(pEv, uEv)) { return; } unpressHandler(uEv); cleanupEphemeralUnpressHandler(); cleanupActions.Remove(cleanupEphemeralUnpressHandler); }; unpressEvent.Listen(ephemeralUnpressHandler); cleanupActions.Add(cleanupEphemeralUnpressHandler); }; pressEvent.Listen(ephemeralHandler); // Cleanup cleanupActions.Add(() => { pressEvent.Remove(ephemeralHandler); }); }
/// <summary> /// Finds the correct Apply() method in the AggregateRoot and call it to apply changes to state /// </summary> /// <param name="event">The event to handle</param> /// <param name="isNew">Is this a new Event</param> private void HandleEvent(Events.Event @event, bool isNew) { //All state changes to AggregateRoot must happen via the Apply method //Make sure the right Apply method is called with the right type. //We will use reflection for this. //TODO: I tried dynamic object for this but ran into some issues. Give it a try using dynamics again. try { object[] args = new object[] { @event }; var method = ((object)this).GetType().GetMethod("Apply", new Type[] { @event.GetType() }); //Find the right method method.Invoke(this, args); //invoke with the event as argument if (isNew) { _changes.Add(@event); //only add to the events collection if it's a new event } } catch (Exception ex) { throw new EventHandlerApplyMethodMissingException(ex.Message); } }
private void OnSocketDisconnected(Events.Event eventObj) { Debug.Log("socket is disconnected"); }
protected void tab_Click(object sender, Events.Event e) { pages.ActivatePage(e.properties.Get("id")); }
private void OnSocketClosed(Events.Event eventObj) { Debug.Log("socket is closed"); }
/// <summary>Adds event call to EventBuffer for processing in LateUpdate </summary> public void AddEvent(Events.Event _event) { m_tempBuffer.Add(_event); }
/// <summary> /// Creates a new subitm which can render an event on the node. /// </summary> /// <param name="evnt">The event we want to draw.</param> public SubItemEvent(Events.Event evnt) : base(_theDefaultEventBrush, _theSelectedEventBrush, _theEventLabelFont, null, Alignment.Center, false) { _event= evnt; }
/// <summary> /// Tests the event handler. /// </summary> /// <param name="eventObj">The event object.</param> private void TestEventHandler(Events.Event eventObj) { EventExample example = GetComponent <EventExample>(); example.RemoveEventListener(EventExample.TestEvent, TestEventHandler); }
public void onEvent(Events.Event e) { }
public static void ShouldBeTheSameAs(this CommittedAggregateEvent committedEvent, Events.Event storedEvent) { (committedEvent as CommittedEvent).ShouldBeTheSameAs(storedEvent); committedEvent.AggregateRoot.Id.Value.ShouldEqual(storedEvent.Aggregate.TypeId); committedEvent.AggregateRoot.Generation.Value.ShouldEqual(storedEvent.Aggregate.TypeGeneration); committedEvent.AggregateRootVersion.Value.ShouldEqual(storedEvent.Aggregate.Version); }
/// <summary> /// Creates a new subitm which can render an event on the node. /// </summary> /// <param name="evnt">The event we want to draw.</param> public SubItemEvent(Events.Event evnt) : base(_theDefaultEventBrush, _theSelectedEventBrush, _theEventLabelFont, null, Alignment.Center, false) { _event = evnt; }
private void OnClientConnected(Events.Event eventObj) { Debug.Log("client connected!"); IntegrationTest.Pass(); }
/// <summary> /// Returns the property's value. /// </summary> /// <param name="node">The event we want to get the value from.</param> /// <returns>The value as an object.</returns> public object GetValue(Events.Event evnt) { return(_property.GetValue(evnt, null)); }
private void OnServerStop(Events.Event eventObj) { Debug.Log("server stop"); }
private void OnServerStart(Events.Event eventObj) { Debug.Log("server started!"); }
/// <summary> /// Saves a node to the XML file. /// </summary> /// <param name="root">The XML node we want to attach the node to.</param> /// <param name="node">The node we want to save.</param> protected void SaveNode(XmlElement root, Node node) { // allow the node to process its attributes in preparation of the save node.PreSave(_node); // store the class we have to create when loading XmlElement elem = _xmlfile.CreateElement("Node"); elem.SetAttribute("Class", node.GetType().FullName); // save attributes IList <DesignerPropertyInfo> properties = node.GetDesignerProperties(); for (int p = 0; p < properties.Count; ++p) { if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) { elem.SetAttribute(properties[p].Property.Name, properties[p].GetStringValue(node)); } } // append node to root root.AppendChild(elem); // save comment if (node.CommentObject != null) { XmlElement comment = _xmlfile.CreateElement("Comment"); properties = node.CommentObject.GetDesignerProperties(); for (int p = 0; p < properties.Count; ++p) { if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) { comment.SetAttribute(properties[p].Property.Name, properties[p].GetStringValue(node.CommentObject)); } } elem.AppendChild(comment); } // save events foreach (Nodes.Node.SubItem sub in node.SubItems) { if (sub is Nodes.Node.SubItemEvent) { Events.Event ne = ((Nodes.Node.SubItemEvent)sub).Event; XmlElement evnt = _xmlfile.CreateElement("Event"); evnt.SetAttribute("Class", ne.GetType().FullName); // save attributes properties = ne.GetDesignerProperties(); for (int p = 0; p < properties.Count; ++p) { if (!properties[p].Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave)) { elem.SetAttribute(properties[p].Property.Name, properties[p].GetStringValue(ne)); } } elem.AppendChild(evnt); } } // save children if allowed. Disallowed for referenced behaviours. if (node.SaveChildren) { // save connectors foreach (Nodes.Node.Connector connector in node.Connectors) { // if we have no children to store we can skip the connector if (connector.ChildCount < 1) { continue; } XmlElement conn = _xmlfile.CreateElement("Connector"); conn.SetAttribute("Identifier", connector.Identifier); elem.AppendChild(conn); // save their children for (int i = 0; i < connector.ChildCount; ++i) { SaveNode(conn, connector.GetChild(i)); } } } }