*
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class AiUseItem : AiBehavior {
|
||||
private GameObject obj;
|
||||
private HumanController selfController;
|
||||
|
||||
protected override BehaviorStatus OnExecute(AiBlackboard blackboard) {
|
||||
if (obj == null) {
|
||||
obj = blackboard.Obj;
|
||||
selfController = obj.GetComponent<HumanController>();
|
||||
}
|
||||
|
||||
var item = selfController.GetSocket(ItemSocketType.Hands).AttachedItem;
|
||||
if (item == null) {
|
||||
return BehaviorStatus.Fail;
|
||||
}
|
||||
|
||||
bool shouldCrouch = false;
|
||||
blackboard.GetValue<bool>("crouchToShoot", out shouldCrouch);
|
||||
|
||||
selfController.Crouch = shouldCrouch;
|
||||
|
||||
|
||||
item.OnBeginUse();
|
||||
item.OnEndUse();
|
||||
return BehaviorStatus.Success;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user