30 lines
803 B
C#
30 lines
803 B
C#
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;
|
|
}
|
|
}
|