예제 #1
0
 public bool RemoveClient(IUtilityAIClient client)
 {
     IUtilityAIClient[] utilityAIClientArray = this.clients;
     for (int i = 0; i < (int)utilityAIClientArray.Length; i++)
     {
         if (utilityAIClientArray[i] != null && utilityAIClientArray[i].Equals(client))
         {
             this.RemoveClientAt(i);
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
        /// <summary>
        /// Removes the AI client.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <returns></returns>
        public bool RemoveClient(IUtilityAIClient client)
        {
            var c = this.clients;

            for (int i = 0; i < c.Length; i++)
            {
                if (c[i] != null && c[i].Equals(client))
                {
                    RemoveClientAt(i);
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public void AddClient(IUtilityAIClient newClient, Entity owner)
        {
            var go = owner.Wrapper.gameObject;

            if (UtilityAiMappings.ContainsKey(go))
            {
                UtilityAiMappings[go].Add(newClient);
            }
            else
            {
                var list = new List <IUtilityAIClient>(1)
                {
                    newClient
                };
                UtilityAiMappings.Add(go, list);
            }
        }
예제 #4
0
        private int AddClient(IUtilityAIClient client)
        {
            IUtilityAIClient[] utilityAIClientArray = this.clients;
            if (this._usedClients == (int)utilityAIClientArray.Length)
            {
                this.Resize <IUtilityAIClient>(ref this._clients, Mathf.Max(2, (int)utilityAIClientArray.Length * 2));
            }
            IUtilityAIClient[] utilityAIClientArray1 = this._clients;
            int num = this._usedClients;

            this._usedClients          = num + 1;
            utilityAIClientArray1[num] = client;
            if (this.OnNewAI != null)
            {
                this.OnNewAI(client);
            }
            return(this._usedClients - 1);
        }
예제 #5
0
        private int AddClient(IUtilityAIClient client)
        {
            var c = this.clients;

            if (_usedClients == c.Length)
            {
                Resize(ref _clients, Mathf.Max(2, c.Length * 2));
            }

            _clients[_usedClients++] = client;

            if (OnNewAI != null)
            {
                OnNewAI(client);
            }

            return(_usedClients - 1);
        }
예제 #6
0
        public static void Unregister(IUtilityAIClient client)
        {
            List <IUtilityAIClient> utilityAIClients;

            if (AIManager._aiClients == null)
            {
                return;
            }
            Guid guid = client.ai.id;

            if (!AIManager._aiClients.TryGetValue(guid, out utilityAIClients))
            {
                return;
            }
            utilityAIClients.Remove(client);
            if (Application.isEditor && VisualizationManager.isVisualizing && client.ai is UtilityAIVisualizer)
            {
                ((UtilityAIVisualizer)client.ai).Reset();
            }
        }
예제 #7
0
        public static void Register(IUtilityAIClient client)
        {
            List <IUtilityAIClient> utilityAIClients;
            Guid guid = client.ai.id;

            if (AIManager._aiClients == null)
            {
                AIManager._aiClients = new Dictionary <Guid, List <IUtilityAIClient> >();
            }
            if (!AIManager._aiClients.TryGetValue(guid, out utilityAIClients))
            {
                utilityAIClients = new List <IUtilityAIClient>(1);
                AIManager._aiClients.Add(guid, utilityAIClients);
            }
            utilityAIClients.Add(client);
            if (Application.isEditor && VisualizationManager.isVisualizing && !(client.ai is UtilityAIVisualizer))
            {
                client.ai = new UtilityAIVisualizer(client.ai);
            }
        }
예제 #8
0
        /// <summary>
        /// Unregisters the specified client.
        /// </summary>
        /// <param name="client">The client.</param>
        public static void Unregister(IUtilityAIClient client)
        {
            if (_aiClients == null)
            {
                return;
            }

            var id = client.ai.id;
            List <IUtilityAIClient> clients;

            if (!_aiClients.TryGetValue(id, out clients))
            {
                return;
            }

            clients.Remove(client);

            if (Application.isEditor && VisualizationManager.isVisualizing && (client.ai is UtilityAIVisualizer))
            {
                ((UtilityAIVisualizer)client.ai).Reset();
            }
        }
예제 #9
0
        /// <summary>
        /// Registers the specified client.
        /// </summary>
        /// <param name="client">The client.</param>
        public static void Register(IUtilityAIClient client)
        {
            var id = client.ai.id;
            List <IUtilityAIClient> clients;

            if (_aiClients == null)
            {
                _aiClients = new Dictionary <Guid, List <IUtilityAIClient> >();
            }

            if (!_aiClients.TryGetValue(id, out clients))
            {
                clients = new List <IUtilityAIClient>(1);
                _aiClients.Add(id, clients);
            }

            clients.Add(client);

            if (Application.isEditor && VisualizationManager.isVisualizing && !(client.ai is UtilityAIVisualizer))
            {
                client.ai = new UtilityAIVisualizer(client.ai);
            }
        }
예제 #10
0
 public void RemoveClient(IUtilityAIClient clientToRemove, Entity owner)
 {
     UtilityAiMappings[owner.Wrapper.gameObject].Remove(clientToRemove);
 }
예제 #11
0
 private void UtilityAIComponent_OnNewAI(IUtilityAIClient client)
 {
     Init();
 }