Skip to content

Commit

Permalink
Merge pull request #3 from prooheckcp/Version-1-1-0
Browse files Browse the repository at this point in the history
Version 0.1.1 [BETA]
  • Loading branch information
prooheckcp committed Jun 16, 2024
2 parents 13466ba + 8123e30 commit a275ca0
Show file tree
Hide file tree
Showing 10 changed files with 569 additions and 88 deletions.
29 changes: 26 additions & 3 deletions RoQuest/Client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ RoQuestClient.OnQuestCancelled = Signal.new() -- Event(questId: string)
@within RoQuestClient
]=]
RoQuestClient.OnQuestAvailable = Signal.new()
--[=[
This gets called when a quest becomes unavailable. Usually only happens when a quest
gets disabled at run-time or when the quest's end time has passed
```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RoQuest = require(ReplicatedStorage.RoQuest).Server
RoQuest.OnQuestUnavailable:Connect(function(questId: string)
print("The player's quest has just been cancelled: ", RoQuest:GetStaticQuest(questId).Name)
end)
```
@client
@prop OnQuestUnavailable Signal
@within RoQuestClient
]=]
RoQuestClient.OnQuestUnavailable = Signal.new()
--[=[
This gets called whenever the quests that are unavailable changes.
This means that either a quest just became available OR that a quest became
Expand Down Expand Up @@ -511,7 +530,6 @@ function RoQuestClient:Init(lifeCycles: {QuestLifeCycle}?): ()
end

self:_OnPlayerDataChanged(net:Call("GetPlayerData"):Await())

net:On("OnPlayerDataChanged", function(playerQuestData: PlayerQuestData)
self:_OnPlayerDataChanged(playerQuestData)
end)
Expand Down Expand Up @@ -959,8 +977,9 @@ end
@return ()
]=]
function RoQuestClient:_OnPlayerDataChanged(playerQuestData: PlayerQuestData)
self._Quests = {}
self._PlayerQuestData = playerQuestData

for questId: string, questProgress: QuestProgress in playerQuestData.InProgress do
self:_GiveQuest(questId, questProgress)
end
Expand Down Expand Up @@ -1129,6 +1148,8 @@ function RoQuestClient:_ChangeAvailableState(questId: string, state: true?): ()

if state then
self.OnQuestAvailable:Fire(questId)
else
self.OnQuestUnavailable:Fire(questId)
end
end

Expand Down Expand Up @@ -1276,7 +1297,9 @@ function RoQuestClient:_GiveQuest(questId: string, questProgress: QuestProgress?
self:_ChangeDeliveredQuest(questId, nil)

self._Quests[questId] = questClone
self:_ChangeInProgressQuest(questId, questClone:_GetQuestProgress())
if STATUS_CHANGED_REFERENCE[questClone:GetQuestStatus()] then
self[STATUS_CHANGED_REFERENCE[questClone:GetQuestStatus()]](self, questId, questClone:_GetQuestProgress())
end

return true
end
Expand Down
Loading

0 comments on commit a275ca0

Please sign in to comment.