private void ReplaceSelectedIfReceiver(Collider2D collider)
        {
            if (collider == null || collider.gameObject == null)
            {
                return;
            }

            GameEntity entity = GameLinkUtils.GetEntity(collider.gameObject);

            if (entity == null)
            {
                return;
            }

            if (!entity.hasReceiver)
            {
                return;
            }

            if (!ReceiverUtils.Filter(entity.receiver, m_ComponentIndex))
            {
                return;
            }

            GameEntity selectedEntity = m_Context.CreateEntity();

            selectedEntity.isSelected = true;
            ReceiverUtils.AddOccupant(entity, selectedEntity.id.value);
        }
Example #2
0
        public void Filter_ExcludesNonConsumable()
        {
            GameEntity mountain = m_Context.CreateEntity();

            ReceiverComponent consumableReceiver = new ReceiverComponent();
            int consumableIndex = GameComponentsLookup.Consumable;

            consumableReceiver.filterComponentIndexes.Add(consumableIndex);

            Assert.IsFalse(ReceiverUtils.Filter(consumableReceiver, mountain));
        }
Example #3
0
 protected override void Execute(List <GameEntity> entities)
 {
     GameEntity[] transmitters = m_TransmitterGroup.GetEntities();
     foreach (GameEntity transmitter in transmitters)
     {
         var trans = transmitter.transmitter;
         ReceiverUtils.TryTransmit(m_Context,
                                   trans.inputIds,
                                   trans.outputIds);
     }
 }
Example #4
0
        public void Filter_IncludesConsumable()
        {
            GameEntity grape = m_Context.CreateEntity();

            grape.AddConsumable("Grape");

            ReceiverComponent consumableReceiver = new ReceiverComponent();
            int consumableIndex = GameComponentsLookup.Consumable;

            consumableReceiver.filterComponentIndexes.Add(consumableIndex);

            Assert.IsTrue(ReceiverUtils.Filter(consumableReceiver, grape));
        }
Example #5
0
        public void Filter_ExcludesNonGlucoseConsumable()
        {
            GameEntity grape = m_Context.CreateEntity();

            grape.AddConsumable("Grape");

            ReceiverComponent glucoseReceiver = new ReceiverComponent();
            int glucoseIndex = GameComponentsLookup.Glucose;

            glucoseReceiver.filterComponentIndexes.Add(glucoseIndex);

            Assert.IsFalse(ReceiverUtils.Filter(glucoseReceiver, grape));
        }
Example #6
0
        public void Filter_IncludesGlucose()
        {
            GameEntity glucose = m_Context.CreateEntity();

            glucose.AddConsumable("Glucose");
            glucose.isGlucose = true;

            ReceiverComponent glucoseReceiver = new ReceiverComponent();
            int glucoseIndex = GameComponentsLookup.Glucose;

            glucoseReceiver.filterComponentIndexes.Add(glucoseIndex);

            Assert.IsTrue(ReceiverUtils.Filter(glucoseReceiver, glucose));
        }
        protected override bool Filter(GameEntity entity)
        {
            var        trigger = entity.triggerEnter;
            GameEntity other   = m_Context.GetEntityWithId(trigger.otherId);

            if (other == null)
            {
                return(false);
            }

            if (!entity.hasReceiver)
            {
                return(false);
            }

            return(ReceiverUtils.Filter(entity.receiver, other));
        }
Example #8
0
        private void InitializeOccupants()
        {
            Debug.Assert(m_OccupantObjects != null,
                         "Expected Unity Editor serializes occupant objects as an empty collection.");

            if (m_OccupantObjects == null)
            {
                return;
            }

            Array.Resize(ref m_Component.occupantIds, m_OccupantObjects.Length);
            int index = -1;

            foreach (GameObject occupantObject in m_OccupantObjects)
            {
                GameEntity occupantEntity = GameLinkUtils.TryLink(occupantObject);
                m_Component.occupantIds[++index] = occupantEntity == null ? ReceiverUtils.kEmpty :
                                                   occupantEntity.id.value;
            }

            m_Component.availableIndex = ReceiverUtils.GetNextAvailableIndex(m_Component);
        }
 private void SetComponentIndex()
 {
     m_ComponentIndex = ReceiverUtils.ToComponentIndex(m_ComponentName);
 }