初始化提交
This commit is contained in:
		
							
								
								
									
										29
									
								
								Content/Lua/GamePlay/Utils/BuildUtils.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Content/Lua/GamePlay/Utils/BuildUtils.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| local BuildUtils = {} | ||||
| local BusyActorManagerSubSystem = import("BusyActorManagerSubSystem") | ||||
|  | ||||
|  | ||||
| local function BuildBonfire(wco) | ||||
|     local sub_system = BusyActorManagerSubSystem.Get(wco) | ||||
|     local role = sub_system.current_role | ||||
|     local bonfire = sub_system:GetNearestBonfire() | ||||
|     local role_pos = role:K2_GetActorLocation() | ||||
|     local bonfire_pos = bonfire:K2_GetActorLocation() | ||||
|  | ||||
|     local distance = (role_pos.X - bonfire_pos.X)^2 + (role_pos.Y - bonfire_pos.Y)^2 | ||||
|     if distance >= 90000 then | ||||
|         sub_system:SpawnBonfire(role_pos) | ||||
|         return true | ||||
|     end | ||||
|     return false | ||||
| end | ||||
|  | ||||
| local build_mapping = { | ||||
|     [200001] = BuildBonfire | ||||
| } | ||||
| function BuildUtils.Build(wco, item_id) | ||||
|     local build_function = build_mapping[item_id] | ||||
|     return build_function and build_function(wco) or false | ||||
| end | ||||
|  | ||||
|  | ||||
| return BuildUtils | ||||
							
								
								
									
										58
									
								
								Content/Lua/GamePlay/Utils/RoleUtils.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								Content/Lua/GamePlay/Utils/RoleUtils.lua
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| 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 | ||||
		Reference in New Issue
	
	Block a user