Example #1
0
        public override void Pickup(ent character, ent loot)
        {
            base.Pickup(character, loot);

            var hasAmmo = loot.Has <ComponentWeapon>();

            ref var cWeapon     = ref character.Get <ComponentWeapon>();
Example #2
0
        public void TickFixed(float delta)
        {
            foreach (var character in _characters)
            {
                var col       = character.GetMono <CapsuleCollider>();
                var transform = character.transform;

                var(top, bottom) = GetCapsuleBounds(col, transform);

                var hits = Physics.OverlapCapsuleNonAlloc(top, bottom, 2.5f, _lootColliders,
                                                          LayerMask.GetMask("Collectable"));

                if (hits == 0)
                {
                    if (_lootEntity.id != -1)
                    {
                        _lootEntity.RemoveAll(Tag.Lootable);
                    }

                    _lootEntity = new ent(-1);

                    continue;
                }

                var newEntity = _lootColliders[0].gameObject.GetEntity();

                if (_lootEntity.id == newEntity.id)
                {
                    return;
                }

                if (!newEntity.Has(Tag.Lootable))
                {
                    newEntity.Set(Tag.Lootable);
                }

                if (_lootEntity.id != -1 && _lootEntity.Has(Tag.Lootable))
                {
                    _lootEntity.RemoveAll(Tag.Lootable);
                }

                _lootEntity = newEntity;
            }
        }