58 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
		
		
			
		
	
	
			58 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| 
								 | 
							
								local _M = {}
							 | 
						||
| 
								 | 
							
								local GameplayEventData = import("GameplayEventData")
							 | 
						||
| 
								 | 
							
								local GetGameplayTag = require("GamePlay.Utils").GetGameplayTag
							 | 
						||
| 
								 | 
							
								local BusyGamePlayLibrary = import("BusyGamePlayLibrary")
							 | 
						||
| 
								 | 
							
								local BusyActorManagerSubSystem = import("BusyActorManagerSubSystem")
							 | 
						||
| 
								 | 
							
								local AbilitySystemBlueprintLibrary = import("AbilitySystemBlueprintLibrary")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function _M.ChangeHealth(role, value)
							 | 
						||
| 
								 | 
							
								    local asc = AbilitySystemBlueprintLibrary.GetAbilitySystemComponent(role)
							 | 
						||
| 
								 | 
							
								    local ge = asc.AbilityEffectConfigs:Get("ChangeHealth")
							 | 
						||
| 
								 | 
							
								    local cost_handle = asc:MakeOutgoingSpec(ge, 1, asc:MakeEffectContext())
							 | 
						||
| 
								 | 
							
								    AbilitySystemBlueprintLibrary.AssignTagSetByCallerMagnitude(
							 | 
						||
| 
								 | 
							
								        cost_handle, GetGameplayTag("Change.Role.Health"),
							 | 
						||
| 
								 | 
							
								        role:CalcRealChangeByHealth(value)
							 | 
						||
| 
								 | 
							
								    )
							 | 
						||
| 
								 | 
							
								    asc:BP_ApplyGameplayEffectSpecToSelf(cost_handle)
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function _M.ChangeHunger(role, value)
							 | 
						||
| 
								 | 
							
								    local asc = AbilitySystemBlueprintLibrary.GetAbilitySystemComponent(role)
							 | 
						||
| 
								 | 
							
								    local ge = asc.AbilityEffectConfigs:Get("ChangeHunger")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    local hunger_cost, health_cost = role:CalcRealChangeByHunger(value)
							 | 
						||
| 
								 | 
							
								    local cost_handle = asc:MakeOutgoingSpec(ge, 1, asc:MakeEffectContext())
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    AbilitySystemBlueprintLibrary.AssignTagSetByCallerMagnitude(
							 | 
						||
| 
								 | 
							
								        cost_handle, GetGameplayTag("Change.Role.Health"), health_cost
							 | 
						||
| 
								 | 
							
								    )
							 | 
						||
| 
								 | 
							
								    AbilitySystemBlueprintLibrary.AssignTagSetByCallerMagnitude(
							 | 
						||
| 
								 | 
							
								        cost_handle, GetGameplayTag("Change.Role.Hunger"), hunger_cost
							 | 
						||
| 
								 | 
							
								    )
							 | 
						||
| 
								 | 
							
								    asc:BP_ApplyGameplayEffectSpecToSelf(cost_handle)
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function _M.GetRole(wco)
							 | 
						||
| 
								 | 
							
								    local mgr = BusyActorManagerSubSystem.Get(wco)
							 | 
						||
| 
								 | 
							
								    return mgr.current_role
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function _M.EatFood(wco, item_id)
							 | 
						||
| 
								 | 
							
								    local role = _M.GetRole(wco)
							 | 
						||
| 
								 | 
							
								    local EventData = GameplayEventData()
							 | 
						||
| 
								 | 
							
								    EventData.EventMagnitude = item_id
							 | 
						||
| 
								 | 
							
								    role:TryActiveAbility("Ability.Role.EatFood", EventData)
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								function _M.GetRoleConfig(role_id)
							 | 
						||
| 
								 | 
							
								    local data_table = BusyGamePlayLibrary.GetGameDataTable("RoleConfig")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    local row_data = data_table:FindRow(role_id, "error in here")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    print(row_data)
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								return _M
							 |