初始化提交
This commit is contained in:
		
							
								
								
									
										29
									
								
								Content/Lua/GamePlay/Ability/Common/EatFood.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Content/Lua/GamePlay/Ability/Common/EatFood.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| local EatFoodAbility = {} | ||||
| local Utils = require("GamePlay.Utils") | ||||
| local RoleUtils = require("GamePlay.Utils.RoleUtils") | ||||
|  | ||||
| local function HandleHealthChange(role, effects) | ||||
|     local tag = Utils.GetGameplayTag("Change.Role.Health") | ||||
|     local value = effects:Get(tag) | ||||
|     if value ~= nil then | ||||
|         RoleUtils.ChangeHealth(role, value) | ||||
|     end | ||||
| end | ||||
|  | ||||
| local function HandleHungerChange(role, effects) | ||||
|     local tag = Utils.GetGameplayTag("Change.Role.Hunger") | ||||
|     local value = effects:Get(tag) | ||||
|     if value ~= nil then | ||||
|         RoleUtils.ChangeHunger(role, value) | ||||
|     end | ||||
| end | ||||
|  | ||||
| function EatFoodAbility:K2_ActivateAbilityFromEvent(EventData) | ||||
|     local item_config = Utils.GetItemConfigByID(math.floor(EventData.EventMagnitude)) | ||||
|     local owner = self:GetOwningActorFromActorInfo() | ||||
|     HandleHealthChange(owner, item_config.GameplayEffects) | ||||
|     HandleHungerChange(owner, item_config.GameplayEffects) | ||||
|     self:K2_EndAbility() | ||||
| end | ||||
|  | ||||
| return Class(nil, nil, EatFoodAbility) | ||||
		Reference in New Issue
	
	Block a user