示例#1
0
        /// <summary>
        /// Registers a single action component
        /// </summary>
        /// <param name="action"></param>
        private void RegisterAction(FlowAction action)
        {
            string actionName = FlowActions.CleanName(action.GetType().Name, true);

            if (actions.TryGetValue(actionName, out FlowAction flowAction))
            {
                return;
            }

            ActionCount++;

            actions.Add(actionName, action);
            actionsByID.Add(ActionCount, action);
            action.id        = ActionCount;
            action.settings  = settings;
            action.writer    = writer;
            action.processor = processor;
            action.isClient  = isClient;
            action.SubscribePackage();
        }
示例#2
0
        /// <summary>
        /// Registers all connected actions
        /// </summary>
        private void RegisterActions()
        {
            foreach (string action in actionNames)
            {
                string actionName = CleanName(action);
                string actionType = $"{ACTION_NAME_SPACE}.{actionName}";

                Type flowAction = Type.GetType(actionType);

                if (flowAction == null)
                {
                    throw new Exception($"Action of type {actionType} not found!");
                }
                else
                {
                    FlowAction actionComponent = gameObject.AddComponent(flowAction) as FlowAction;
                    actionComponents.Add(actionName, actionComponent);
                    RegisterAction(actionComponent);
                }
            }
        }