1. Assuming your existing minimap system has a way to turn icons on and off, your quests can use a Scene Event action or custom quest action to turn them on and off.
2. Or you can hook into the existing quest indicator system.
For #1:
For discussion, let's say your minimap system has a script named MinimapEntity that controls whether the GameObject's minimap icon is visible or invisible.
To use a Scene Event action, find the point in the quest where you want to change the minimap icon, such as the main quest's Active state > Actions, which run when the quest goes active:
minimapMainActiveActions.png (34.37 KiB) Viewed 2077 times
Add a "Scene Event" action. This is a UnityEvent that's tied to GameObject(s) in a specific scene. You could configure it, for example, to call the MinimapEntity's method to change the icon's visibility:
minimapSceneEvent.png (32.05 KiB) Viewed 2077 times
If you don't know ahead of time which scene the GameObject will be in, or if you don't want to use a Scene Event, you can write your own custom actions. Make a copy of Plugins / Pixel Crushers / Quest Machine / Templates / QuestActionTemplate.cs. Move it outside the Plugins folder so it can access your minimap system. Then customize it where the comments indicate. For example, your script might look like:
namespace PixelCrushers.QuestMachine
{
public class MinimapIconQuestAction : QuestAction
{
// These values will appear in the quest editor's inspector:
public string gameObjectName;
public bool on;
public override void Execute()
{
// Find the GameObject even if it's inactive:
var gameObject = GameObjectUtility.GameObjectHardFind(gameObjectName);
// Set its minimap icon on or off:
gameObject.GetComponent<MinimapEntity>().SetMinimapIcon(on);
}
}
}
Then add that action:
minimapCustomAction.png (23.99 KiB) Viewed 2077 times
For #2:
Quest Machine has 5 built-in types of UIs:
Quest Dialogue UI: Used by quest givers to show offer text, quest hand-ins, etc.
Quest Journal UI: Window showing the details of the player's active and completed quests.
Quest HUD: Onscreen summary of active quests.
Quest Alert UI: Informational messages that pop up onscreen for a duration, such as "Task completed. Return to NPC."
Quest Indicators: Typically shown as overhead images to indicate that a quest giver wants to talk.
You can use quest indicators for other things, such as showing an overhead image on kill quest targets.
When a GameObject (e.g., quest giver) has a quest indicator, it's managed by a QuestIndicatorManager script that figures out what indicator image to show. The QuestIndicatorManager manages another script called QuestIndicatorUI that actually shows the indicator image. Look at any of the NPCs, such as the Villager, in the Demo scene, to see how it's set up. Both of these scripts are subclassable. You can make a subclass of QuestIndicatorUI that also sets your minimap icon. For example, the subclass might look like:
public class CustomQuestIndicatorUI : QuestIndicatorUI
{
public override void SetIndicator(int index, bool value)
{
base.SetIndicator(index, value);
// If requested to set the "Interact" indicator, also set the minimap icon:
if (index == (int)QuestIndicatorState.Interact)
{
GetComponentInParent<MinimapEntity>().SetMinimapIcon(value);
}
}
}
A GameObject's QuestIndicatorManager typically points to a prefab that has a QuestIndicatorUI script. At runtime, it instantiates the prefab. (It's also fine if the QuestIndicatorManager points to a scene object instead of a prefab.) Replace the prefab/scene object's QuestIndicatorUI with your custom subclass.
The second part of this is making sure that minimap icons are turned back on/off when the player leaves the scene and returns; or saves the game, quits, and loads the saved game.
The easiest way to do this is to save the minimap icon's state. Quest Machine's save system is fairly easily extended. To save data, write a small "Saver" script. You can find a starter template in Plugins / Pixel Crushers / Common / Templates. Example:
namespace PixelCrushers
{
public class MinimapEntitySaver : Saver
{
public override string RecordData()
{ // Return "Y" if the icon is on:
return GetComponent<MinimapEntity>().isOn ? "Y" : "N";
}
public override void ApplyData(string data)
{ // Set the icon state based on the saved data:
GetComponent<MinimapEntity>().SetMinimapIcon(data == "Y");
}
}
}
Well, my entire game is in a single scene at all times, so that part is easy enough to not worry about. But im still stumblin around trying to figure out the first steps mentioned. I'm a real knuclehead of sorts, i never import demo scenes, and i note that you specifaclly mentioned it as reference. I think i may break my rule of thumb this once. Thanks Tony.
You could import the demo scene into a separate project just to see how it works. No need to keep it in your main project if you don't want to.
Since I don't know how your minimap system is designed, I tried to supply a few different options. A basic Scene Event action is probably the easiest way to go.