Unstable v0.19.5.0
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using Barotrauma.Tutorials;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma;
|
||||
|
||||
partial class MessageBoxAction : EventAction
|
||||
{
|
||||
partial void UpdateProjSpecific()
|
||||
{
|
||||
if (Type == ActionType.Create)
|
||||
{
|
||||
CreateMessageBox();
|
||||
if (!ObjectiveTag.IsEmpty && GameMain.GameSession?.GameMode is TutorialMode tutorialMode)
|
||||
{
|
||||
Identifier id = Identifier.IsEmpty ? Text : Identifier;
|
||||
var segment = Tutorial.Segment.CreateMessageBoxSegment(id, ObjectiveTag, CreateMessageBox);
|
||||
tutorialMode.Tutorial?.TriggerTutorialSegment(segment);
|
||||
}
|
||||
}
|
||||
else if (Type == ActionType.Close)
|
||||
{
|
||||
GUIMessageBox.Close(Tag);
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateMessageBox()
|
||||
{
|
||||
new GUIMessageBox(
|
||||
headerText: TextManager.Get(Header),
|
||||
text: RichString.Rich(TextManager.ParseInputTypes(TextManager.Get(Text).Fallback(Text.ToString()), useColorHighlight: true)),
|
||||
buttons: Array.Empty<LocalizedString>(),
|
||||
type: GUIMessageBox.Type.Tutorial,
|
||||
tag: Tag,
|
||||
iconStyle: IconStyle,
|
||||
autoCloseCondition: GetAutoCloseCondition(),
|
||||
hideCloseButton: HideCloseButton)
|
||||
{
|
||||
FlashOnAutoCloseCondition = true
|
||||
};
|
||||
}
|
||||
|
||||
private Func<bool> GetAutoCloseCondition()
|
||||
{
|
||||
var character = ParentEvent.GetTargets(TargetTag).FirstOrDefault() as Character;
|
||||
Func<bool> autoCloseCondition = null;
|
||||
if (!string.IsNullOrEmpty(CloseOnInput) && Enum.TryParse(CloseOnInput, true, out InputType closeOnInput))
|
||||
{
|
||||
autoCloseCondition = () => PlayerInput.KeyDown(closeOnInput);
|
||||
}
|
||||
else if (!CloseOnSelectTag.IsEmpty)
|
||||
{
|
||||
autoCloseCondition = () => character?.SelectedItem != null && character.SelectedItem.HasTag(CloseOnSelectTag);
|
||||
}
|
||||
else if (!CloseOnPickUpTag.IsEmpty)
|
||||
{
|
||||
autoCloseCondition = () => character?.Inventory != null && character.Inventory.FindItemByTag(CloseOnPickUpTag, recursive: true) != null;
|
||||
}
|
||||
else if (!CloseOnEquipTag.IsEmpty)
|
||||
{
|
||||
autoCloseCondition = () => character != null && character.HasEquippedItem(CloseOnEquipTag);
|
||||
}
|
||||
else if (!CloseOnExitRoomName.IsEmpty)
|
||||
{
|
||||
autoCloseCondition = () => character?.CurrentHull == null || character.CurrentHull.RoomName.ToIdentifier() != CloseOnExitRoomName;
|
||||
}
|
||||
else if (!CloseOnInRoomName.IsEmpty)
|
||||
{
|
||||
autoCloseCondition = () => character?.CurrentHull != null && character.CurrentHull.RoomName.ToIdentifier() == CloseOnInRoomName;
|
||||
}
|
||||
return autoCloseCondition;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma;
|
||||
|
||||
partial class TutorialHighlightAction : EventAction
|
||||
{
|
||||
private static readonly Color highlightColor = Color.OrangeRed;
|
||||
|
||||
partial void UpdateProjSpecific()
|
||||
{
|
||||
if (GameMain.GameSession?.GameMode is not TutorialMode) { return; }
|
||||
foreach (var target in ParentEvent.GetTargets(TargetTag))
|
||||
{
|
||||
SetHighlight(target);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetHighlight(Entity entity)
|
||||
{
|
||||
if (entity is Item i)
|
||||
{
|
||||
SetHighlight(i);
|
||||
}
|
||||
else if (entity is Structure s)
|
||||
{
|
||||
SetHighlight(s);
|
||||
}
|
||||
else if (entity is Character c)
|
||||
{
|
||||
SetHighlight(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetHighlight(Item item)
|
||||
{
|
||||
if (item.ExternalHighlight == State) { return; }
|
||||
item.SpriteColor = (State) ? highlightColor : Color.White;
|
||||
item.ExternalHighlight = State;
|
||||
}
|
||||
|
||||
private void SetHighlight(Structure structure)
|
||||
{
|
||||
structure.SpriteColor = (State) ? highlightColor : Color.White;
|
||||
structure.ExternalHighlight = State;
|
||||
}
|
||||
|
||||
private void SetHighlight(Character character)
|
||||
{
|
||||
character.ExternalHighlight = State;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using Barotrauma.Tutorials;
|
||||
|
||||
namespace Barotrauma;
|
||||
|
||||
partial class TutorialSegmentAction : EventAction
|
||||
{
|
||||
private Tutorial.Segment segment;
|
||||
|
||||
partial void UpdateProjSpecific()
|
||||
{
|
||||
// Only need to create the segment when it's being triggered (otherwise the tutorial already has the segment instance)
|
||||
if (Type == SegmentActionType.Trigger)
|
||||
{
|
||||
segment = Tutorial.Segment.CreateInfoBoxSegment(Id, ObjectiveTag, AutoPlayVideo ? Tutorials.AutoPlayVideo.Yes : Tutorials.AutoPlayVideo.No,
|
||||
new Tutorial.Segment.Text(TextTag, Width, Height, Anchor.Center),
|
||||
new Tutorial.Segment.Video(VideoFile, TextTag, Width, Height));
|
||||
}
|
||||
else if (Type == SegmentActionType.Add)
|
||||
{
|
||||
segment = Tutorial.Segment.CreateObjectiveSegment(Id, !ObjectiveTag.IsEmpty ? ObjectiveTag : Id);
|
||||
}
|
||||
if (GameMain.GameSession?.GameMode is TutorialMode tutorialMode)
|
||||
{
|
||||
if (tutorialMode.Tutorial is Tutorial tutorial)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case SegmentActionType.Trigger:
|
||||
case SegmentActionType.Add:
|
||||
tutorial.TriggerTutorialSegment(segment);
|
||||
break;
|
||||
case SegmentActionType.Complete:
|
||||
tutorial.CompleteTutorialSegment(Id);
|
||||
break;
|
||||
case SegmentActionType.Remove:
|
||||
tutorial.RemoveTutorialSegment(Id);
|
||||
break;
|
||||
case SegmentActionType.CompleteAndRemove:
|
||||
tutorial.CompleteTutorialSegment(Id);
|
||||
tutorial.RemoveTutorialSegment(Id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ShowError($"Error in event \"{ParentEvent.Prefab.Identifier}\": attempting to use TutorialSegmentAction during a non-Tutorial game mode!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user