v1.4.4.1 (Blood in the Water Update)
This commit is contained in:
+21
-12
@@ -1,39 +1,43 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Items.Components;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
/// <summary>
|
||||
/// Makes an NPC select an item, and operate it if it's something AI characters can operate.
|
||||
/// </summary>
|
||||
class NPCOperateItemAction : EventAction
|
||||
{
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "Tag of the NPC(s) that should operate the item.")]
|
||||
public Identifier NPCTag { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "Tag of the item to operate. If it's not something AI characters can or know how to operate, such as a cabinet or an engine, the NPC will just select it.")]
|
||||
public Identifier TargetTag { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
[Serialize("Controller", IsPropertySaveable.Yes, description: "Name of the component to operate. For example, the Controller component of a periscope or the Reactor component of a nuclear reactor.")]
|
||||
public Identifier ItemComponentName { get; set; }
|
||||
|
||||
[Serialize("", IsPropertySaveable.Yes)]
|
||||
[Serialize("", IsPropertySaveable.Yes, description: "Identifier of the option, if there are several ways the item can be operated. For example, \"powerup\" or \"shutdown\" when operating a reactor.")]
|
||||
public Identifier OrderOption { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.Yes)]
|
||||
[Serialize(false, IsPropertySaveable.Yes, description: "Should the character equip the item before attempting to operate it (only valid if the item is equippable).")]
|
||||
public bool RequireEquip { get; set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes)]
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "Should the character start or stop operating the item.")]
|
||||
public bool Operate { get; set; }
|
||||
|
||||
[Serialize(-1, IsPropertySaveable.Yes)]
|
||||
[Serialize(-1, IsPropertySaveable.Yes, description: "Maximum number of NPCs the action can target. For example, you could only make a specific number of security officers man a periscope.")]
|
||||
public int MaxTargets { get; set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.Yes)]
|
||||
[Serialize(true, IsPropertySaveable.Yes, description: "The event actions reset when a GoTo action makes the event jump to a different point. Should the NPC stop operating the item when the event resets?")]
|
||||
public bool AbandonOnReset { get; set; }
|
||||
|
||||
private bool isFinished = false;
|
||||
|
||||
|
||||
public NPCOperateItemAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element) { }
|
||||
|
||||
|
||||
private List<Character> affectedNpcs = null;
|
||||
private Item target = null;
|
||||
|
||||
@@ -41,7 +45,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (isFinished) { return; }
|
||||
|
||||
target = ParentEvent.GetTargets(TargetTag).FirstOrDefault() as Item;
|
||||
var potentialTargets = ParentEvent.GetTargets(TargetTag).OfType<Item>();
|
||||
var nonSelectedItems = potentialTargets.Where(it => it.GetComponent<Controller>()?.User == null);
|
||||
|
||||
target =
|
||||
nonSelectedItems.Any() ?
|
||||
nonSelectedItems.GetRandomUnsynced() :
|
||||
potentialTargets.GetRandomUnsynced();
|
||||
if (target == null) { return; }
|
||||
|
||||
int targetCount = 0;
|
||||
@@ -53,7 +63,6 @@ namespace Barotrauma
|
||||
|
||||
if (Operate)
|
||||
{
|
||||
ItemComponentName = "Controller".ToIdentifier();
|
||||
var itemComponent = target.Components.FirstOrDefault(ic => ItemComponentName == ic.Name);
|
||||
if (itemComponent == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user