2 using Microsoft.Xna.Framework;
18 private readonly
Hull targetHull;
26 this.targetHull = targetHull;
47 float distanceFactor = 1.0f;
54 targetHull.WorldPosition,
55 verticalDistanceMultiplier: 3,
57 factorAtMaxDistance: 0.1f);
60 if (severity > 0.75f && !isOrder &&
61 targetHull.RoomName !=
null &&
62 !targetHull.RoomName.Contains(
"reactor", StringComparison.OrdinalIgnoreCase) &&
63 !targetHull.RoomName.Contains(
"engine", StringComparison.OrdinalIgnoreCase) &&
64 !targetHull.RoomName.Contains(
"command", StringComparison.OrdinalIgnoreCase))
81 private float sinTime;
82 protected override void Act(
float deltaTime)
87 TryAddSubObjective(ref getExtinguisherObjective, () =>
91 character.Speak(TextManager.Get(
"DialogFindExtinguisher").Value, null, 2.0f,
"findextinguisher".ToIdentifier(), 30.0f);
101 getItemObjective.Abandoned += () => character.Speak(TextManager.Get(
"dialogcannotfindfireextinguisher").Value, null, 0.0f,
"dialogcannotfindfireextinguisher".ToIdentifier(), 10.0f);
103 return getItemObjective;
108 var extinguisher = extinguisherItem.GetComponent<
RepairTool>();
109 if (extinguisher ==
null)
112 DebugConsole.ThrowError($
"{character.Name}: AIObjectiveExtinguishFire failed - the item \"" + extinguisherItem +
"\" has no RepairTool component but is tagged as an extinguisher");
117 foreach (
FireSource fs
in targetHull.FireSources)
119 if (fs ==
null) {
continue; }
128 float dist = xDist + yDist;
129 bool inRange = dist < extinguisher.Range;
132 bool operateExtinguisher = !moveCloser || (dist < extinguisher.Range * 1.2f &&
character.
CanSeeTarget(targetHull));
133 if (operateExtinguisher)
137 character.
CursorPosition += VectorExtensions.Forward(extinguisherItem.body.TransformedRotation + (
float)Math.Sin(sinTime) / 2, fromCharacterToFireSource.Length() / 2);
138 if (extinguisherItem.RequireAimToUse)
141 sinTime += deltaTime * 10;
145 if (!targetHull.FireSources.Contains(fs))
147 character.
Speak(TextManager.GetWithVariable(
"DialogPutOutFire",
"[roomname]", targetHull.DisplayName,
FormatCapitals.Yes).Value,
null, 0,
"putoutfire".ToIdentifier(), 10.0f);
156 DialogueIdentifier =
"dialogcannotreachfire".ToIdentifier(),
159 onAbandon: () =>
Abandon =
true,
160 onCompleted: () => RemoveSubObjective(ref gotoObjective)))
165 else if (!operateExtinguisher || isInDamageRange)
168 RemoveSubObjective(ref gotoObjective);
180 getExtinguisherObjective =
null;
181 gotoObjective =
null;
IEnumerable< Hull > VisibleHulls
Returns hulls that are visible to the character, including the current hull. Note that this is not an...
override float GetPriority()
override bool AllowInAnySub
override void OnAbandon()
override void Act(float deltaTime)
override bool AllowWhileHandcuffed
override bool KeepDivingGearOn
AIObjectiveExtinguishFire(Character character, Hull targetHull, AIObjectiveManager objectiveManager, float priorityModifier=1)
override bool CheckObjectiveState()
Should return whether the objective is completed or not.
override Identifier Identifier
override bool ConcurrentObjectives
override void OnCompleted()
static float GetFireSeverity(Hull hull)
0-1 based on the horizontal size of all of the fires in the hull.
float Priority
Final priority value after all calculations.
readonly Character character
readonly AIObjectiveManager objectiveManager
static float GetDistanceFactor(Vector2 selfPos, Vector2 targetWorldPos, float factorAtMaxDistance, float verticalDistanceMultiplier=3, float maxDistance=10000.0f, float factorAtMinDistance=1.0f)
Get a normalized value representing how close the target position is. The value is a rough estimation...
AIObjective CurrentObjective
Includes orders.
const float MaxObjectivePriority
Highest possible priority for any objective. Used in certain cases where the character needs to react...
void SetInput(InputType inputType, bool hit, bool held)
void Speak(string message, ChatMessageType? messageType=null, float delay=0.0f, Identifier identifier=default, float minDurationBetweenSimilar=0.0f)
bool HasEquippedItem(Item item, InvSlotType? slotType=null, Func< InvSlotType, bool > predicate=null)
static readonly List< Character > CharacterList
CharacterInventory Inventory
bool CanSeeTarget(ISpatialEntity target, ISpatialEntity seeingEntity=null, bool seeThroughWindows=false, bool checkFacing=false)
virtual Vector2 WorldPosition
bool IsInDamageRange(Character c, float damageRange)
virtual float DamageRange
LocalizedString DisplayName
static bool IsActive(Character c)
static bool IsFriendly(Character me, Character other, bool onlySameTeam=false)
readonly HashSet< Hull > UnsafeHulls
Item FindItemByTag(Identifier tag, bool recursive=false)