public LSAgent CreateAgent(AgentCode agentCode)
        {
            FastStack <LSAgent> cache = CachedAgents[(int)agentCode];

            if (cache != null && cache.Count > 0)
            {
                curAgent = cache.Pop();
            }
            else
            {
                curAgent = GameObject.Instantiate(AgentObjects[(int)agentCode]).GetComponent <LSAgent> ();
            }

            localID              = GenerateLocalID();
            curAgent.LocalID     = localID;
            Agents[localID]      = curAgent;
            AgentActive[localID] = true;

            globalID          = GenerateGlobalID();
            curAgent.GlobalID = globalID;

            curAgent.Initialize();

            RingController ringController = GameObject.Instantiate(LockstepManager.Instance.SelectionRing).GetComponent <RingController> ();

            ringController.Initialize(curAgent);
            curAgent.ringController = ringController;

            return(curAgent);
        }
        public static RingController Create()
        {
            GameObject     go     = GameObject.Instantiate <GameObject> (ringTemplate);
            RingController ringer = go.GetComponent <RingController> ();

            return(ringer);
        }
Example #3
0
        public void Setup(IAgentData interfacer)
        {
            gameObject.SetActive(true);
            LoadComponents();

            GameObject.DontDestroyOnLoad(gameObject);

            setupAbilitys.FastClear();

            MyAgentCode  = interfacer.Name;
            Data         = interfacer;
            SpawnVersion = 1;
            CheckCasting = true;

            Influencer = new LSInfluencer();
            if (_visualCenter == null)
            {
                _visualCenter = CachedTransform;
            }

            if (Animator.IsNotNull())
            {
                Animator.Setup();
            }


            abilityManager.Setup(this);
            Ringer = RingController.Create();
            if (Ringer.IsNotNull())
            {
                Ringer.Setup(this);
            }

            Influencer.Setup(this);
            Body.Setup(this);

            SelectionRadiusSquared = _selectionRadius * _selectionRadius;
            if (StatsBarer != null)
            {
                StatsBarer.Setup(this);
            }

            this.RegisterLockstep();
        }