/// <summary> /// Create an uninitialized RTSAgent /// </summary> /// <returns>The raw agent.</returns> /// <param name="agentCode">Agent code.</param> /// <param name="isBare">If set to <c>true</c> is bare.</param> public static RTSAgent CreateRawAgent(string agentCode, Vector2d startPosition = default(Vector2d), Vector2d startRotation = default(Vector2d)) { if (!GameResourceManager.IsValidAgentCode(agentCode)) { throw new System.ArgumentException(string.Format("Agent code '{0}' not found.", agentCode)); } FastStack <RTSAgent> cache = CachedAgents[agentCode]; RTSAgent curAgent = null; if (cache.IsNotNull() && cache.Count > 0) { curAgent = cache.Pop(); ushort agentCodeID = GameResourceManager.GetAgentCodeIndex(agentCode); Debug.Log(curAgent.TypeIndex); TypeAgentsActive[agentCodeID][curAgent.TypeIndex] = true; } else { IAgentData interfacer = GameResourceManager.AgentCodeInterfacerMap[agentCode]; Vector3 pos = startPosition.ToVector3(); Quaternion rot = new Quaternion(0, startRotation.y, 0, startRotation.x); curAgent = GameObject.Instantiate(GameResourceManager.GetAgentTemplate(agentCode).gameObject, pos, rot).GetComponent <RTSAgent>(); curAgent.Setup(interfacer); RegisterRawAgent(curAgent); } return(curAgent); }
/// <summary> /// Create an uninitialized LSAgent /// </summary> /// <returns>The raw agent.</returns> /// <param name="agentCode">Agent code.</param> /// <param name="isBare">If set to <c>true</c> is bare.</param> public static LSAgent CreateRawAgent(string agentCode) { if (!ResourceManager.IsValidAgentCode(agentCode)) { throw new System.ArgumentException(string.Format("Agent code '{0}' not found.", agentCode)); } FastStack <LSAgent> cache = CachedAgents[agentCode]; LSAgent curAgent = null; if (cache.IsNotNull() && cache.Count > 0) { curAgent = cache.Pop(); ushort agentCodeID = ResourceManager.GetAgentCodeIndex(agentCode); Debug.Log(curAgent.TypeIndex); TypeAgentsActive[agentCodeID][curAgent.TypeIndex] = true; } else { IAgentData interfacer = ResourceManager.AgentCodeInterfacerMap[agentCode]; curAgent = GameObject.Instantiate(ResourceManager.GetAgentTemplate(agentCode).gameObject).GetComponent <LSAgent>(); curAgent.Setup(interfacer); RegisterRawAgent(curAgent); } return(curAgent); }