Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using RedCatEngine.Quests.Mechanics.Data;
using RedCatEngine.Quests.Mechanics.Factories;
using RedCatEngine.Quests.Mechanics.Quests;

Expand All @@ -19,6 +20,7 @@ int dailyTimeLiveSeconds
{
_countQuests = countQuests;
_dailyTimeLiveSeconds = dailyTimeLiveSeconds;
LoadData(QuestsDataContainer.Empty);
}

protected override void DoAfterLoadData()
Expand Down Expand Up @@ -48,8 +50,11 @@ Func<IQuest, bool> PredicateForRemoveQuests()
var toRemove = ActiveQuests.Where(PredicateForRemoveQuests()).ToArray();
foreach (var quest in toRemove)
{
quest.Disable();
quest.ChangeQuestStateEvent -= OnChangeQuestState;

if (quest.QuestState == QuestState.InProgress)
quest.Disable();

ActiveQuests.Remove(quest);
}

Expand Down Expand Up @@ -79,4 +84,4 @@ private void AddNewQuest()
ActiveQuests.Add(newQuest);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,37 @@ namespace RedCatEngine.Quests.Tests.SpecialSubClasses
[Serializable]
public class TestQuestData : IQuestData
{
public ConfigID<QuestConfig> Config => ConfigID<QuestConfig>.Invalid;
public DateTime CreateTime { get; }
public QuestState QuestState { get; }
private ConfigID<QuestConfig> _config = ConfigID<QuestConfig>.Invalid;
private DateTime _createTime = DateTime.UtcNow;
private QuestState _questState = QuestState.InProgress;

public ConfigID<QuestConfig> Config
=> _config;

public DateTime CreateTime
=> _createTime;

public QuestState QuestState
=> _questState;

public ConfigID<QuestConfig> GetConfig()
{
return Config;
}

public DateTime GetCreateTime()
{
throw new NotImplementedException();
return CreateTime;
}

public QuestState GetQuestState()
{
throw new NotImplementedException();
return QuestState;
}

public void SetQuestState(QuestState newQuestState)
{
throw new NotImplementedException();
_questState = newQuestState;
}

public void ConstructSerialization(
Expand All @@ -38,7 +48,9 @@ public void ConstructSerialization(
QuestState questState
)
{
throw new NotImplementedException();
_config = config;
_createTime = createTime;
_questState = questState;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public IQuest MakeFromConfig(ConfigID<QuestConfig> questId)

public IQuest MakeNewQuest(List<IQuest> currentActiveQuests)
{
throw new System.NotImplementedException();
return MakeNewQuest();
}

public IQuest LoadFrom(IQuestData saveData)
Expand Down Expand Up @@ -48,4 +48,4 @@ public IQuest MakeNewQuest()
return result;
}
}
}
}
Loading