public LSAgent CreateAgent( string agentCode, Vector2d?position = null, //nullable position Vector2d?rotation = null //Nullable rotation for default parametrz ) { Vector2d pos = position != null ? position.Value : new Vector2d(0, 0); Vector2d rot = rotation != null ? rotation.Value : Vector2d.radian0; if (!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(); } else { IAgentData interfacer = AgentController.CodeInterfacerMap [agentCode]; curAgent = GameObject.Instantiate(interfacer.GetAgent().gameObject).GetComponent <LSAgent>(); curAgent.Setup(interfacer); } InitializeAgent(curAgent, pos, rot); return(curAgent); }
public LSAgent CreateAgent( string agentCode, Vector2d?position = null, //nullable position Vector2d?rotation = null //Nullable rotation for default parametrz ) { Vector2d pos = position != null ? position.Value : new Vector2d(0, 0); Vector2d rot = rotation != null ? rotation.Value : Vector2d.radian0; if (!IsValidAgentCode(agentCode)) { throw new System.ArgumentException(string.Format("Agent code '{0}' not found.", agentCode)); } FastStack <LSAgent> cache = CachedAgents [agentCode]; LSAgent curAgent = null; ushort agentCodeID = AgentController.GetAgentCodeIndex(agentCode); if (cache.IsNotNull() && cache.Count > 0) { curAgent = cache.Pop(); TypeAgentsActive[agentCodeID][curAgent.TypeIndex] = true; } else { IAgentData interfacer = AgentController.CodeInterfacerMap [agentCode]; curAgent = GameObject.Instantiate(interfacer.GetAgent().gameObject).GetComponent <LSAgent>(); curAgent.Setup(interfacer); FastList <bool> typeActive; if (!AgentController.TypeAgentsActive.TryGetValue(agentCodeID, out typeActive)) { typeActive = new FastList <bool>(); TypeAgentsActive.Add(agentCodeID, typeActive); } FastList <LSAgent> typeAgents; if (!TypeAgents.TryGetValue(agentCodeID, out typeAgents)) { typeAgents = new FastList <LSAgent>(); TypeAgents.Add(agentCodeID, typeAgents); } curAgent.TypeIndex = (ushort)typeAgents.Count; typeAgents.Add(curAgent); typeActive.Add(true); } InitializeAgent(curAgent, pos, rot); return(curAgent); }
public static LSAgent GetAgentSource(string agentCode) { IAgentData interfacer = AgentController.CodeInterfacerMap [agentCode]; return(interfacer.GetAgent()); }
public static LSAgent GetAgentSource(string agentCode) { IAgentData interfacer = ResourceManager.AgentCodeInterfacerMap[agentCode]; return(interfacer.GetAgent()); }