local ACTIONS = GLOBAL.ACTIONS 
local ActionHandler = GLOBAL.ActionHandler


local HANDCHOP = Action(10,true)
HANDCHOP.id = "HANDCHOP"  
HANDCHOP.str = "劈柴" 
HANDCHOP.fn = function(act)
 if act.target.components.workable ~= nil 
 and act.target.components.workable:CanBeWorked() 
 and act.target.components.workable.action == ACTIONS.CHOP 
 then
 act.target.components.workable:WorkedBy(act.doer,1) 
 return 
 true 
 end 
 end
AddAction(HANDCHOP) -- 将上面编写的内容传入MOD API,添加动作 。

local state = "combat_lunge_start" -- 设定要绑定的state  
AddStategraphActionHandler("wilson",ActionHandler(ACTIONS.HANDCHOP, state)) 
-----------------------------------------------------
------------------------------------------
local HANDMINE = Action(10,true)
HANDMINE.id = "HANDMINE"  
HANDMINE.name = "手挖" 
HANDMINE.fn = function(act) 
 if act.target.components.workable ~= nil 
 and act.target.components.workable:CanBeWorked() 
 and act.target.components.workable.action == ACTIONS.MINE
 then
 act.target.components.workable:WorkedBy(act.doer,1) 
 return 
 true 
 end 
 end
AddAction(HANDMINE) 

local state = "combat_lunge_start" -- 设定要绑定的state 
AddStategraphActionHandler("wilson",ActionHandler(ACTIONS.HANDMINE, state)) 

AddComponentPostInit("catcher",function(component) 
	local old = component.CollectSceneActions
		 component.CollectSceneActions = function(doer, actions)
		 local target = TheInput:GetHUDEntityUnderMouse()
			print(doer,target,actions,"Ahhhhhhh!")
		if target.components.workable.action==ACTIONS.CHOP and doer.prefab ==CHARID
			then
			table.insert(actions, ACTIONS.HANDCHOP) 
		end 
		if true --target:HasTag("MINE_workable") and doer.prefab ==CHARID
			then
			table.insert(actions, ACTIONS.HANDMINE) 
		end 
	  old(doer,actions)
  end
 
end  )

