protected override void DoSetData(PointerData data) { var entityId = CommonCastData.EntityId(data.IdList); var key = CommonCastData.Key(data.IdList); var tip = CommonCastData.Tip(data); var entity = _sceneObjectContext.GetEntityWithEntityKey(new EntityKey(entityId, (short)EEntityType.SceneObject)); if (null == entity) { return; } var player = _playerContext.flagSelfEntity; if (null == player) { return; } if (!entity.IsCanPickUpByPlayer(player)) { return; } if (IsUntouchableOffGround(player, data.Position, entity.rawGameObject.Value)) { return; } if (player.hasRaycastTarget) { player.raycastTarget.Key = key; } else { player.AddRaycastTarget(key); } Tip = tip; }
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); } }
public virtual void DestroyEquipmentEntity(int entityKey) { var entity = _sceneObjectContext.GetEntityWithEntityKey(new EntityKey(entityKey, (short)EEntityType.SceneObject)); entity.isFlagDestroy = true; }
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); } }
public virtual void DestroySceneWeaponObjectEntity(EntityKey key) { var entity = _sceneObjectContext.GetEntityWithEntityKey(key); entity.isFlagDestroy = true; }
protected override void DoSetData(PointerData data) { _pointerData = data; var entityId = SceneObjCastData.EntityId(_pointerData.IdList); var sceneObj = _sceneObjectContext.GetEntityWithEntityKey(new Core.EntityComponent.EntityKey(entityId, (short)EEntityType.SceneObject)); if (null != sceneObj) { if (!sceneObj.hasPosition) { Logger.Error("sceneobject has no postion"); return; } var player = _playerContext.flagSelfEntity; if (!player.hasPosition) { Logger.Error("player has no position"); return; } if (IsUntouchable(sceneObj, player)) { return; } if (!sceneObj.IsCanPickUpByPlayer(player)) { return; } if (player.hasGamePlay && !player.gamePlay.CanAutoPick()) { return; } } else { return; } var itemId = SceneObjCastData.ItemId(_pointerData.IdList); var count = SceneObjCastData.Count(_pointerData.IdList); var category = SceneObjCastData.Category(_pointerData.IdList); switch ((ECategory)category) { case ECategory.Weapon: var itemCfg = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(itemId); if (null != itemCfg) { if (itemCfg.Type == (int)EWeaponType_Config.ThrowWeapon) { Tip = string.Format(ScriptLocalization.client_actiontip.pickup, itemCfg.Name, string.Format("({0})", count)); } else { Tip = string.Format(ScriptLocalization.client_actiontip.pickandequip, itemCfg.Name); } } else { Tip = string.Format("weapon {0} doesn't exist ", itemId); } break; case ECategory.Avatar: var equip = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(itemId); if (null != equip) { Tip = string.Format(ScriptLocalization.client_actiontip.pickandequip, equip.Name); } else { Tip = string.Format("avatar {0} doesn't exist ", itemId); } break; case ECategory.WeaponPart: var part = SingletonManager.Get <WeaponPartSurvivalConfigManager>().FindConfigBySetId(itemId); if (null != part) { Tip = string.Format(ScriptLocalization.client_actiontip.pickup, part.Name, ""); } else { Tip = string.Format("part {0} doesn't exist", itemId); } break; case ECategory.GameItem: var item = SingletonManager.Get <GameItemConfigManager>().GetConfigById(itemId); if (null != item) { Tip = string.Format(ScriptLocalization.client_actiontip.pickup, item.Name, string.Format("({0})", count)); } else { Tip = string.Format("item {0} doesn't exist", itemId); } break; default: Tip = string.Format("EntityId {0} ItemId {1} do not exist in config ", entityId, itemId); break; } }