public override void OnInspectorGUI()
    {
        data = target as TravelingStoryData;

        data.use = EditorGUILayout.Toggle("Use", data.use);
        data.rarityDiscardChance = EditorGUILayout.FloatField("Rarity Discard Chance", data.rarityDiscardChance);
        data.dataName            = EditorGUILayout.TextField("Name", data.dataName);
        data.description         = EditorGUILayout.TextField("Description", data.description);
        data.spawnMessage        = EditorGUILayout.TextField("Spawn Message", data.spawnMessage);
        data.art           = EditorGUILayout.ObjectField("Art", data.art, typeof(Sprite), false) as Sprite;
        data.ai            = EditorGUILayout.ObjectField("AI", data.ai, typeof(TravelingStoryAIData), false) as TravelingStoryAIData;
        data.stealthRating = EditorGUILayout.IntField("Stealth Rating", data.stealthRating);
        data.difficulty    = (EncounterDifficulty)EditorGUILayout.EnumPopup("Difficulty", data.difficulty);
        data.stepInAction  = (TravelingStoryData.StepInAction)EditorGUILayout.EnumPopup("Step In Action", data.stepInAction);
        switch (data.stepInAction)
        {
        case TravelingStoryData.StepInAction.BeginStory:
            ShowBeginStory(); break;

        case TravelingStoryData.StepInAction.Combat:
            ShowCombat(); break;

        case TravelingStoryData.StepInAction.RandomEncounter:
            ShowRandomEncounter(); break;
        }

        Editor.CreateEditor(data).serializedObject.ApplyModifiedProperties();
        EditorUtility.SetDirty(data);
    }
    public TravelingStory CreateSpecificStory(Vector2 position, TravelingStoryData data, TravelingStoryAIData aiOverride = null)
    {
        spriteToUse = data.art;

        var travelingStory = DesertContext.StrangeNew <TravelingStoryController>();

        travelingStory.PopupText = "<u>" + data.dataName + "</u>\n" + data.difficulty + " difficulty";
        travelingStory.action    = CreateAction(data);
        if (aiOverride != null)
        {
            travelingStory.ai = aiOverride.Create();
        }
        else
        {
            travelingStory.ai = data.ai.Create();
        }
        travelingStory.stealthRating = data.stealthRating;

        DesertContext.QuickBind <TravelingStoryMediated>(travelingStory);
        var travelingStoryGO = GameObject.Instantiate(PrefabGetter.travelingStoryPrefab, parent);

        DesertContext.FinishQuickBind <TravelingStoryMediated>();

        travelingStoryGO.GetComponent <TravelingStoryVisuals>().Setup(spriteToUse);
        travelingStory.TeleportToPosition(position);
        travelingStory.Setup();

        return(travelingStory);
    }
    TravelingStoryBeginCombatAction CreateCombatAction(TravelingStoryData data)
    {
        var combatAction = DesertContext.StrangeNew <TravelingStoryBeginCombatAction>();

        combatAction.combatData = data.combatData;
        return(combatAction);
    }
    TravelingStoryBeginStoryAction CreateStoryAction(TravelingStoryData data)
    {
        var storyAction = DesertContext.StrangeNew <TravelingStoryBeginStoryAction>();

        storyAction.story = data.story;
        return(storyAction);
    }
    TravelingStoryAction CreateRandomEncounter(TravelingStoryData data)
    {
        var combatData = ScriptableObject.CreateInstance <CombatEncounterData>();

        combatData.characters    = encounterGenerator.CreateEncounterGroupForFactions(data.encounterFactions, data.encounterCost);
        combatData.ambushAbility = data.ambushAbility;
        var combatAction = DesertContext.StrangeNew <TravelingStoryBeginCombatAction>();

        combatAction.combatData = combatData;

        spriteToUse = combatData.characters[Random.Range(0, combatData.characters.Count)].visuals;
        return(combatAction);
    }
    TravelingStoryAction CreateAction(TravelingStoryData data)
    {
        switch (data.stepInAction)
        {
        case TravelingStoryData.StepInAction.BeginStory:
            return(CreateStoryAction(data));

        case TravelingStoryData.StepInAction.Combat:
            return(CreateCombatAction(data));

        case TravelingStoryData.StepInAction.RandomEncounter:
            return(CreateRandomEncounter(data));
        }

        return(CreateCombatAction(data));
    }