29 lines
		
	
	
		
			959 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
		
		
			
		
	
	
			29 lines
		
	
	
		
			959 B
		
	
	
	
		
			Lua
		
	
	
	
	
	
| 
								 | 
							
								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)
							 |