private void OnMessageHandleHandler(Type callerType, Type handlerType, Type messageType, string messageName, string handlerMethodName)
        {
            MessageActorWidget callerActor  = GetOrCreateActor(callerType);
            MessageActorWidget handlerActor = GetOrCreateActor(handlerType);

            callerActor.LogSentMessage(handlerActor, messageType, messageName);
            handlerActor.LogHandledMessage(callerActor, messageType, messageName);

            MessageLine line           = messageLines.Find(x => (x.CallerActor == callerActor && x.HandlerActor == handlerActor));
            bool        newLineCreated = false;
            bool        reversed       = false;

            if (line == null)
            {
                // Check for reversed to change it to TwoWay line
                line = messageLines.Find(x => (x.HandlerActor == callerActor && x.CallerActor == handlerActor));
                if (line != null)
                {
                    reversed = true;
                }
                else
                {
                    line = new MessageLine(callerActor, handlerActor);
                    messageLines.Add(line);
                    newLineCreated = true;
                }
            }

            line.SendMessage(messageType, messageName == "" ? messageType.ToString() : '"' + messageName + '"', reversed);

            if (newLineCreated)
            {
                chainesAreDirty = true;
            }
        }
Exemple #2
0
        private MessageActorWidget GetRootMessageActor()
        {
            MessageActorWidget rootActor = null;
            Dictionary <MessageActorWidget, int> handlerCounts = new Dictionary <MessageActorWidget, int>();

            foreach (MessageLine line in Lines)
            {
                if (handlerCounts.ContainsKey(line.HandlerActor))
                {
                    handlerCounts[line.HandlerActor]++;
                }
                else
                {
                    handlerCounts.Add(line.HandlerActor, 1);
                }
            }
            foreach (KeyValuePair <MessageActorWidget, int> pair in handlerCounts)
            {
                if (rootActor == null)
                {
                    rootActor = pair.Key;
                    continue;
                }
                if (pair.Value > handlerCounts[rootActor])
                {
                    rootActor = pair.Key;
                }
            }
            return(rootActor);
        }
Exemple #3
0
            public Vector2 GetPosition(MessageActorWidget callerActor, float offset)
            {
                Vector2 relativeGridPosition = GridPosition - callerActor.GridPosition;
                Vector2 wayPointPosition     = callerActor.Position + new Vector2(relativeGridPosition.x * MessageFlowRenderer.ActorOffset.x, relativeGridPosition.y * MessageFlowRenderer.ActorOffset.y);

                wayPointPosition += Normal * offset;
                return(wayPointPosition);
            }
Exemple #4
0
        public MessageLine(MessageActorWidget callerActor, MessageActorWidget handlerActor)
        {
            CallerActor  = callerActor;
            HandlerActor = handlerActor;
            lineMessages = new List <LineMessage>();
            wayPoints    = new List <WayPoint>();

            instances.Add(this);
            UpdateWayPoints();
        }
        public void RemoveUnrelatedActors(MessageActorWidget actor)
        {
            MessageChain chain = GetChainOfActor(actor);

            if (chain == null)
            {
                return;
            }
            FilterLinesAndActors(x => chain.Lines.Contains(x));
        }
        private MessageActorWidget GetOrCreateActor(Type type)
        {
            MessageActorWidget actor = messageActors.Find(x => x.ActorType == type);

            if (actor != null)
            {
                return(actor);
            }
            actor = new MessageActorWidget(type, this);
            messageActors.Add(actor);
            return(actor);
        }
        private void LogMessage(Dictionary <Type, List <LoggedMessage> > logs, MessageActorWidget associatedActor, Type messageType, string messageName)
        {
            if (!logs.ContainsKey(messageType))
            {
                logs.Add(messageType, new List <LoggedMessage>());
            }
            LoggedMessage loggedMessage = logs[messageType].Find(x => x.MessageName == messageName);

            if (loggedMessage == null)
            {
                loggedMessage = new LoggedMessage(messageName);
                logs[messageType].Add(loggedMessage);
            }
            if (!loggedMessage.AssociatedActors.Contains(associatedActor))
            {
                loggedMessage.AssociatedActors.Add(associatedActor);
            }
        }
Exemple #8
0
 public ContainedMessageActorWidget(MessageActorWidget actor, Vector2 localPosition)
 {
     LocalGridPosition = localPosition;
     Actor             = actor;
 }
 public bool ContainsUnrelatedActors(MessageActorWidget actor)
 {
     return(messageChains.Count > 1);
 }
        public bool ContainsIndirectActors(MessageActorWidget actor)
        {
            MessageChain chain = GetChainOfActor(actor);

            return(messageLines.FindAll(x => x.HandlerActor != actor && x.CallerActor != actor && chain == GetChainOfActor(x.CallerActor)).Count > 0);
        }
        public void RemoveIndirectActors(MessageActorWidget actor)
        {
            MessageChain chain = GetChainOfActor(actor);

            FilterLinesAndActors(x => x.CallerActor == actor || x.HandlerActor == actor || !chain.Lines.Contains(x));
        }
 public void RemoveActor(MessageActorWidget actor)
 {
     FilterLinesAndActors(x => x.CallerActor != actor && x.HandlerActor != actor);
 }
 private MessageChain GetChainOfActor(MessageActorWidget actor)
 {
     return(messageChains.Find(x => x.Lines.Find(y => y.CallerActor == actor || y.HandlerActor == actor) != null));
 }
 public void LogHandledMessage(MessageActorWidget trigger, Type messageType, string messageName)
 {
     LogMessage(handledMessageLogs, trigger, messageType, messageName);
 }
 public void LogSentMessage(MessageActorWidget handler, Type messageType, string messageName)
 {
     LogMessage(sentMessageLogs, handler, messageType, messageName);
 }