예제 #1
0
        public void Handle(ConnectFlowClientPackage package)
        {
            if (FlowServer.clients.TryGetValue(package.clientId, out FlowClientServer client))
            {
                Debug.Log($"Client ({client.id}) was acknowledged");

                SpawnFlowServerAction spawnAction = FlowActions.GetActionByName("Spawn") as SpawnFlowServerAction;
                // Todo: replace the vector and rotation with the values of an actual spawnpoint
                spawnAction.SendFrom(client.id, new Vector3(0, 4f, 0), Quaternion.identity);
            }
        }
예제 #2
0
        /// <summary>
        /// Returns an action by its name
        /// </summary>
        /// <param name="actionName"></param>
        /// <returns></returns>
        static public FlowAction GetActionByName(string actionName)
        {
            actionName = FlowActions.CleanName(actionName, true);

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

            return(null);
        }
예제 #3
0
 private void Awake()
 {
     if (instance == null)
     {
         OnStartedEvent = new UnityEvent();
         instance       = this;
     }
     else if (instance != this)
     {
         Logger.Debug("Instance already exists, destroying object!");
         Destroy(this);
     }
 }
예제 #4
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();
        }