26 protected override void Act(
float deltaTime)
30 if (deconstructor ==
null)
32 deconstructor = FindDeconstructor();
33 if (deconstructor ==
null)
40 TryAddSubObjective(ref decontainObjective,
45 RemoveExistingWhenNecessary = true
49 if (character.CanInteractWith(deconstructor.Item))
51 StartDeconstruction();
55 TryAddSubObjective(ref gotoObjective,
56 constructor: () => new AIObjectiveGoTo(Item, character, objectiveManager, priorityModifier: PriorityModifier),
59 StartDeconstruction();
60 RemoveSubObjective(ref gotoObjective);
67 RemoveSubObjective(ref decontainObjective);
75 private void StartDeconstruction()
79 if (deconstructor.Item.Submarine is { Info.IsOutpost: true })
81 HumanAIController.HandleRelocation(Item);
82 deconstructor.RelocateOutputToMainSub =
true;
90 float bestDistFactor = 0;
91 foreach (var otherItem
in Item.ItemList)
93 var potentialDeconstructor = otherItem.GetComponent<
Deconstructor>();
94 if (potentialDeconstructor?.InputContainer ==
null) {
continue; }
95 if (!potentialDeconstructor.InputContainer.Inventory.CanBePut(Item)) {
continue; }
96 if (!potentialDeconstructor.Item.HasAccess(character)) {
continue; }
97 float distFactor = GetDistanceFactor(
Item.WorldPosition, potentialDeconstructor.Item.WorldPosition, factorAtMaxDistance: 0.2f);
98 if (distFactor > bestDistFactor)
100 closestDeconstructor = potentialDeconstructor;
101 bestDistFactor = distFactor;
104 return closestDeconstructor;
107 private void StartDeconstructor()
109 deconstructor.
SetActive(active:
true, user: character, createNetworkEvent:
true);
118 else if (deconstructor !=
null && deconstructor.Item.IgnoreByAI(character))
122 return !Abandon && IsCompleted;
128 decontainObjective =
null;
133 if (
Item !=
null && character.HasItem(
Item))
override bool AllowInFriendlySubs
AIObjectiveDeconstructItem(Item item, Character character, AIObjectiveManager objectiveManager, float priorityModifier=1)
override bool AllowWhileHandcuffed
override Identifier Identifier
override void Act(float deltaTime)
override bool CheckObjectiveState()
Should return whether the objective is completed or not.
readonly Character character
readonly List< AIObjective > subObjectives
readonly AIObjectiveManager objectiveManager
void Drop(Character dropper, bool createNetworkEvent=true, bool setTransform=true)
bool IgnoreByAI(Character character)
void SetActive(bool active, Character user=null, bool createNetworkEvent=false)
ItemContainer InputContainer