Quest system base
This commit is contained in:
parent
37cd28d611
commit
8a40de576e
20 changed files with 178 additions and 9 deletions
|
|
@ -41,11 +41,11 @@ enum Status{
|
|||
var progress : int = 0:
|
||||
set(value):
|
||||
if value >= progress_max:
|
||||
quest_ended.emit(true)
|
||||
end()
|
||||
@export var reward_money : float
|
||||
@export var restrictions : Array[Restriction] = []
|
||||
@export var data : Dictionary = {}
|
||||
@export var status: Status
|
||||
var status: Status = Status.Idle
|
||||
|
||||
## Emits when quest was given to player
|
||||
signal quest_added
|
||||
|
|
@ -55,7 +55,7 @@ signal quest_ended
|
|||
signal quest_failed
|
||||
|
||||
## Creates quest with given parameters
|
||||
static func create(type : Type, progress_max : int, reward_money : float, restrictions : Array[Restriction] = [], data : Dictionary = {}) -> void:
|
||||
static func create(type : Type, progress_max : int, reward_money : float, restrictions : Array[Restriction] = [], data : Dictionary = {}) -> Quest:
|
||||
var quest = Quest.new()
|
||||
quest.type = type
|
||||
quest.progress_max = progress_max
|
||||
|
|
@ -64,6 +64,7 @@ static func create(type : Type, progress_max : int, reward_money : float, restri
|
|||
quest.data = data
|
||||
quest.status = Status.Taken
|
||||
quest.quest_added.emit(quest)
|
||||
return quest
|
||||
|
||||
## Progress by quest
|
||||
func do_progress() -> void:
|
||||
|
|
@ -74,6 +75,14 @@ func fail() -> void:
|
|||
quest_failed.emit(false)
|
||||
status = Status.Idle
|
||||
|
||||
func end() -> void:
|
||||
quest_ended.emit(true)
|
||||
status = Status.Reward
|
||||
|
||||
func reward() -> float:
|
||||
status = Status.Idle
|
||||
return reward_money
|
||||
|
||||
## Trigger restriction
|
||||
func trigger_restriction(restriction: Restriction) -> void:
|
||||
if restrictions.has(restriction):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue