Files
MetalGear2D.Unity/Assets/Scripts/AI/Jobs/AiEquipGun.cs
T
2025-05-13 05:19:58 +03:00

31 lines
991 B
C#

using UnityEngine;
using System.Collections;
public class AiEquipGun : AiBehavior {
private GameObject obj;
private Inventory inventory;
private HumanController selfController;
protected override BehaviorStatus OnExecute(AiBlackboard blackboard) {
if (obj == null) {
blackboard.GetValue<GameObject>("gameobject", out obj);
inventory = obj.GetComponent<Inventory>();
selfController = obj.GetComponent<HumanController>();
}
if (selfController.GetSocket(ItemSocketType.Hands).AttachedItem == null) {
var weapon = inventory.QueryItem(null, "Gun", null);
if (weapon != null) {
//Debug.LogFormat("Character {0} equipped weapon {1}", obj.name, weapon.description.Name);
inventory.EquipItem(weapon);
}
else {
return BehaviorStatus.Fail;
}
}
return BehaviorStatus.Success;
}
}