Esempio n. 1
0
        public virtual void AutoPickupWeapon(int playerEntityId, int weaponEntityId)
        {
            var entity = _sceneObjectContext.GetEntityWithEntityKey(new EntityKey(weaponEntityId, (short)EEntityType.SceneObject));

            if (null == entity)
            {
                Logger.ErrorFormat("{0} doesn't exist in scene object context ", weaponEntityId);
                return;
            }
            var player = _playerContext.GetEntityWithEntityKey(new EntityKey(playerEntityId, (short)EEntityType.Player));

            if (null == player)
            {
                Logger.ErrorFormat("{0} doesn't exist in player context ", playerEntityId);
                return;
            }
            if (!entity.hasWeapon)
            {
                Logger.ErrorFormat("only weapon is supported in normal mode");
                return;
            }
            if (!entity.IsCanPickUpByPlayer(player))
            {
                return;
            }
            var pickupSuccess = player.playerAction.Logic.AutoPickUpWeapon(entity.weapon.ToWeaponInfo());

            if (pickupSuccess)
            {
                _sceneObjectEntityFactory.DestroyEquipmentEntity(entity.entityKey.Value.EntityId);
            }
        }
Esempio n. 2
0
        public virtual void DoPickup(int playerEntityId, int weaponEntityId)
        {
            var entity = _sceneObjectContext.GetEntityWithEntityKey(new EntityKey(weaponEntityId, (short)EEntityType.SceneObject));

            if (null == entity)
            {
                Logger.ErrorFormat("{0} doesn't exist in scene object context ", weaponEntityId);
                return;
            }
            if (entity.hasThrowing)
            {
                return;
            }
            var player = _playerContext.GetEntityWithEntityKey(new EntityKey(playerEntityId, (short)EEntityType.Player));

            if (null == player)
            {
                Logger.ErrorFormat("{0} doesn't exist in player context ", playerEntityId);
                return;
            }
            if (!entity.hasWeapon)
            {
                Logger.ErrorFormat("only weapon is supported in normal mode");
                return;
            }
            if (!entity.IsCanPickUpByPlayer(player))
            {
                return;
            }
            _sceneObjectEntityFactory.DestroyEquipmentEntity(entity.entityKey.Value.EntityId);
            var last = player.playerAction.Logic.PickUpWeapon(entity.weapon.ToWeaponInfo());

            if (last.Id > 0)
            {
                _sceneObjectEntityFactory.CreateDropWeaponEntity(last, player.position.Value, _sceneWeaponLifeTime);
            }
        }