public void ActivateChip(string id, AbstractChip chip, bool autoActivate = true)
        {
            if (HasChip(id))
            {
                //TODO do we need to disable the old chip first
                chips[id] = chip;
            }
            else
            {
                //TODO fixed bug here but need to make sure we don't need to do this above
                chips.Add(id, chip);

                if (chip is IUpdate)
                {
                    updateChips.Add(chip as IUpdate);
                }

                if (chip is IDraw)
                {
                    drawChips.Add(chip as IDraw);
                }
            }

            if (autoActivate)
            {
                chip.Activate(this);
            }
        }
        public AbstractChip GetChip(string id, bool activeOnCreate = true)
        {
            //Debug.Log("Chip Manager: Get Chip " + id);

            if (HasChip(id))
            {
                return(chips[id]);
            }

            var type = Type.GetType(id);

            if (type != null)
            {
                AbstractChip chipInstance = null;

                try
                {
                    chipInstance = Activator.CreateInstance(type) as AbstractChip;
                    ActivateChip(id, chipInstance, activeOnCreate);
                }
                catch // (Exception)
                {
                    //Console.WriteLine("Chip '" + id + "' could not be created.");
                }

                return(chipInstance);
            }

            return(null);
        }
        public void DeactivateChip(string id, AbstractChip chip)
        {
            chip.Deactivate();

            if (chip is IUpdate)
            {
                updateChips.Remove(chip as IUpdate);
            }

            if (chip is IDraw)
            {
                drawChips.Remove(chip as IDraw);
            }

            chips.Remove(id);
        }