Unstable v0.15.17.0 (Hex is out of town edition)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Xml.Linq;
|
||||
using NLog.Targets;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
|
||||
@@ -92,6 +92,11 @@ namespace Barotrauma
|
||||
ParentEvent.AddTargetPredicate(Tag, e => e is Item it && SubmarineTypeMatches(it.Submarine) && it.HasTag(tag));
|
||||
}
|
||||
|
||||
private void TagHullsByName(string name)
|
||||
{
|
||||
ParentEvent.AddTargetPredicate(Tag, e => e is Hull h && SubmarineTypeMatches(h.Submarine) && h.RoomName.Contains(name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private bool SubmarineTypeMatches(Submarine sub)
|
||||
{
|
||||
if (SubmarineType == SubType.Any) { return true; }
|
||||
@@ -144,6 +149,9 @@ namespace Barotrauma
|
||||
case "itemtag":
|
||||
if (kvp.Length > 1) { TagItemsByTag(kvp[1].Trim()); }
|
||||
break;
|
||||
case "hullname":
|
||||
if (kvp.Length > 1) { TagHullsByName(kvp[1].Trim()); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -34,6 +35,9 @@ namespace Barotrauma
|
||||
[Serialize(false, true, description: "If true, one target must interact with the other to trigger the action.")]
|
||||
public bool WaitForInteraction { get; set; }
|
||||
|
||||
[Serialize(false, true, description: "If true, the action can be triggered by interacting with any matching target (not just the 1st one).")]
|
||||
public bool AllowMultipleTargets { get; set; }
|
||||
|
||||
private float distance;
|
||||
|
||||
public TriggerAction(ScriptedEvent parentEvent, XElement element) : base(parentEvent, element)
|
||||
@@ -55,7 +59,7 @@ namespace Barotrauma
|
||||
|
||||
public bool isRunning = false;
|
||||
|
||||
private Either<Character, Item> npcOrItem = null;
|
||||
private readonly List<Either<Character, Item>> npcsOrItems = new List<Either<Character, Item>>();
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
@@ -93,12 +97,16 @@ namespace Barotrauma
|
||||
Character player = null;
|
||||
Character npc = null;
|
||||
Item item = null;
|
||||
npcOrItem?.TryGet(out npc);
|
||||
npcOrItem?.TryGet(out item);
|
||||
if (e1 is Character char1)
|
||||
{
|
||||
if (char1.IsBot) { npc ??= char1; }
|
||||
else { player = char1; }
|
||||
if (char1.IsBot)
|
||||
{
|
||||
npc ??= char1;
|
||||
}
|
||||
else
|
||||
{
|
||||
player = char1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -106,8 +114,14 @@ namespace Barotrauma
|
||||
}
|
||||
if (e2 is Character char2)
|
||||
{
|
||||
if (char2.IsBot) { npc ??= char2; }
|
||||
else { player = char2; }
|
||||
if (char2.IsBot)
|
||||
{
|
||||
npc ??= char2;
|
||||
}
|
||||
else
|
||||
{
|
||||
player = char2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,7 +134,10 @@ namespace Barotrauma
|
||||
{
|
||||
if (npc.CampaignInteractionType != CampaignMode.InteractionType.Examine)
|
||||
{
|
||||
npcOrItem = npc;
|
||||
if (!npcsOrItems.Any(n => n.TryGet(out Character npc2) && npc2 == npc))
|
||||
{
|
||||
npcsOrItems.Add(npc);
|
||||
}
|
||||
npc.CampaignInteractionType = CampaignMode.InteractionType.Examine;
|
||||
npc.RequireConsciousnessForCustomInteract = DisableIfTargetIncapacitated;
|
||||
#if CLIENT
|
||||
@@ -134,12 +151,14 @@ namespace Barotrauma
|
||||
GameMain.NetworkMember.CreateEntityEvent(npc, new object[] { NetEntityEvent.Type.AssignCampaignInteraction });
|
||||
#endif
|
||||
}
|
||||
|
||||
return;
|
||||
if (!AllowMultipleTargets) { return; }
|
||||
}
|
||||
else if (item != null)
|
||||
{
|
||||
npcOrItem = item;
|
||||
if (!npcsOrItems.Any(n => n.TryGet(out Item item2) && item2 == item))
|
||||
{
|
||||
npcsOrItems.Add(item);
|
||||
}
|
||||
item.CampaignInteractionType = CampaignMode.InteractionType.Examine;
|
||||
if (player.SelectedConstruction == item ||
|
||||
player.Inventory != null && player.Inventory.Contains(item) ||
|
||||
@@ -170,19 +189,21 @@ namespace Barotrauma
|
||||
|
||||
private void ResetTargetIcons()
|
||||
{
|
||||
if (npcOrItem == null) { return; }
|
||||
if (npcOrItem.TryGet(out Character npc))
|
||||
foreach (var npcOrItem in npcsOrItems)
|
||||
{
|
||||
npc.CampaignInteractionType = CampaignMode.InteractionType.None;
|
||||
npc.SetCustomInteract(null, null);
|
||||
npc.RequireConsciousnessForCustomInteract = true;
|
||||
#if SERVER
|
||||
GameMain.NetworkMember.CreateEntityEvent(npc, new object[] { NetEntityEvent.Type.AssignCampaignInteraction });
|
||||
#endif
|
||||
}
|
||||
else if (npcOrItem.TryGet(out Item item))
|
||||
{
|
||||
item.CampaignInteractionType = CampaignMode.InteractionType.None;
|
||||
if (npcOrItem.TryGet(out Character npc))
|
||||
{
|
||||
npc.CampaignInteractionType = CampaignMode.InteractionType.None;
|
||||
npc.SetCustomInteract(null, null);
|
||||
npc.RequireConsciousnessForCustomInteract = true;
|
||||
#if SERVER
|
||||
GameMain.NetworkMember.CreateEntityEvent(npc, new object[] { NetEntityEvent.Type.AssignCampaignInteraction });
|
||||
#endif
|
||||
}
|
||||
else if (npcOrItem.TryGet(out Item item))
|
||||
{
|
||||
item.CampaignInteractionType = CampaignMode.InteractionType.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +290,7 @@ namespace Barotrauma
|
||||
return
|
||||
$"{ToolBox.GetDebugSymbol(isFinished, isRunning)} {nameof(TriggerAction)} -> (" +
|
||||
(WaitForInteraction ?
|
||||
$"Selected non-player target: {(npcOrItem?.ToString() ?? "<null>").ColorizeObject()}, " :
|
||||
$"Selected non-player target: {(npcsOrItems?.ToString() ?? "<null>").ColorizeObject()}, " :
|
||||
$"Distance: {((int)distance).ColorizeObject()}, ") +
|
||||
$"Radius: {Radius.ColorizeObject()}, " +
|
||||
$"TargetTags: {Target1Tag.ColorizeObject()}, " +
|
||||
|
||||
Reference in New Issue
Block a user