コード例 #1
0
        private void AddEnterExitEvent(Actions.BaseDelegateAction action, FsmStateModel state)
        {
            if (action == null)
            {
                return;
            }
            if (!(action is Actions.OnEntryAction || action is Actions.OnExitAction))
            {
                return;
            }

            var ls    = action is Actions.OnEntryAction ? state.onEnter : state.onExit;
            var label = action is Actions.OnEntryAction ? "OnEnter" : "OnExit";

            var _delegate = new FsmDelegateMethod();

            FillInMethodInfo(state, action, label, _delegate);

            ls.Add(new FsmOnEnterExitModel {
                _delegate = _delegate,
            });
        }
コード例 #2
0
        private void FillInMethodInfo(FsmStateModel state, Actions.BaseDelegateAction action, string label, FsmDelegateMethod model)
        {
            if (action.delegateInterface == null || string.IsNullOrEmpty(action.delegateInterface.Value))
            {
                throw new System.Exception(string.Format("State '{0}' has action '{1}' that is missing delegate or method", state.name, label));
            }

            if (action.methodSignature == null || string.IsNullOrEmpty(action.methodSignature.Value))
            {
                throw new System.Exception(string.Format("State '{0}' has action '{1}' that is missing delegate or method", state.name, label));
            }

            var _delegate = TypeCache.FindDelegate(action.delegateInterface.Value, action.methodSignature.Value);

            if (_delegate == null)
            {
                throw new System.Exception(string.Format("State '{0}' has action '{1}' that has a non-existant interface '{2}'", state.name, label, action.delegateInterface.Value));
            }
            if (_delegate.method == null)
            {
                throw new System.Exception(string.Format("State '{0}' has action '{1}' for  interface '{2}' that is missing method signature '{3}'", state.name, label, action.delegateInterface.Value, action.methodSignature.Value));
            }

            model._interface          = _delegate.type;
            model.method              = _delegate.method;
            model.delegateDisplayName = action.delegateInterface.Value + "." + action.methodSignature.Value;

            if (options.verbose)
            {
                Debug.LogFormat("For action '{0}' found delegate: {1}", label, model.delegateDisplayName);
            }
        }