You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
5.6 KiB
GDScript
108 lines
5.6 KiB
GDScript
1 year ago
|
extends Node
|
||
|
|
||
|
# Variables
|
||
|
## Other Data
|
||
|
var logic_time = 1
|
||
|
var draw_time = 1
|
||
|
## Handlers
|
||
|
#var encountered_handler = load("res://events/knowledge/Encountered.tscn").instance()
|
||
|
#var lost_handler = load("res://events/knowledge/Lost.tscn").instance()
|
||
|
#var learned_handler = load("res://events/knowledge/Learned.tscn").instance()
|
||
|
#var forgot_handler = load("res://events/knowledge/Forgot.tscn").instance()
|
||
|
## Keys
|
||
|
const bingo_knowledge = []
|
||
|
const BINGO_IT4_KEY = "smb001"
|
||
|
const BINGO_LVL_KEY = "ml1000"
|
||
|
const CHARACTER_CREATION_KEY = "smc001"
|
||
|
const ACT_GROUP = ['act100','act200','act001','act002'] # Plastic Tub
|
||
|
const IT3_GROUP = ['it3000','it3001','it3002','it3003','it3004'] # Three-Leaf Clover
|
||
|
const IT4_GROUP = ['it4000','it4001','it4002','it4003','it4004'] # Four-Leaf Clover
|
||
|
const CCB_GROUP = ['ccb000','ccb001','ccb002','ccb003'] # Bad Cat
|
||
|
const CCN_GROUP = ['ccn000','ccn001','ccn002','ccn003'] # Neighborhood Cat
|
||
|
const CMC_GROUP = ['cmc000','cmc001','cmc002','cmc003'] # Chloe
|
||
|
const CMN_GROUP = ['cmn000','cmn001','cmn002','cmn003'] # Night
|
||
|
## Knowledge Base
|
||
|
var knowledge = {
|
||
|
# code: ["title", "desc", ["tags"], "source", "learned?"]
|
||
|
'a00000': ['teacti', 'teacti', ["term"], "", false], # activator
|
||
|
'ac0000': ['tecont', 'tecont', ["term"], "", false], # container
|
||
|
'act100': ['actubb', 'deactubb', ["activator"], "", false], # blue plastic tub
|
||
|
'act200': ['actubg', 'deactubg', ["activator"], "", false], # green plastic tub
|
||
|
'act001': ['actubb', 'deactubb', ["activator","category"], "", false], # plastic tub category
|
||
|
'act002': ['actubb', 'deactubb', ["activator","subcategory"], "", false], # plastic tub subcategory
|
||
|
'c00000': ['techar', 'techar', ["term"], "", false], # character
|
||
|
'cc0000': ['facata', 'facata', ["faction"], "", false], # cat
|
||
|
'ccn000': ['chneig', 'dechneig', ["character"], "", false], # neighborhood cat
|
||
|
'ccn001': ['tecate', 'techar', ["ccb000","category"], "", true], # neighborhood cat category
|
||
|
'ccn002': ['tefact', 'facata', ["ccb000","faction"], "", false], # neighborhood cat faction
|
||
|
'ccn003': ['tehost', 'teally', ["ccb000","hostility"], "", false], # neighborhood cat hostility
|
||
|
'ccb000': ['chbadc', 'dechbadc', ["character"], "", false], # bad cat
|
||
|
'ccb001': ['tecate', 'techar', ["ccb000","category"], "", true], # bad cat category
|
||
|
'ccb002': ['tefact', 'facata', ["ccb000","faction"], "", false], # bad cat faction
|
||
|
'ccb003': ['tehost', 'tefoea', ["ccb000","hostility"], "", false], # bad cat hostility
|
||
|
'ch0000': ['fahuma', 'fahuma', ["faction"], "", false], # human
|
||
|
'cmc000': ['chchlo', 'dechchlo', ["character"], "", false], # chloe
|
||
|
'cmc001': ['tecate', 'techar', ["cmc000","category"], "", true], # chloe category
|
||
|
'cmc002': ['tefact', 'fashma', ["cmc000","faction"], "", false], # chloe faction
|
||
|
'cmc003': ['tehost', 'teally', ["cmc000","hostility"], "", false], # chloe hostility
|
||
|
'cmn000': ['chnigh', 'dechnigh', ["character"], "", false], # night
|
||
|
'cmn001': ['tecate', 'techar', ["cmc000","category"], "", true], # night category
|
||
|
'cmn002': ['tefact', 'tedoct', ["cmc000","faction"], "", false], # night faction
|
||
|
'cmn003': ['tehost', 'teally', ["cmc000","hostility"], "", false], # night hostility
|
||
|
'cmp001': ['chheli', 'dechheli', ["character"], "", false], # player
|
||
|
'i00000': ['teitem', 'teitem', ["term"], "", false], # item
|
||
|
'it0000': ['ictrin', 'ictrin', ["item_category"], "", false], # item
|
||
|
'it3000': ['it3lea', 'deit3lea', ["item"], "", false], # three-leaf clover
|
||
|
'it3001': ['tecate', 'caitem', ["it3000","category"], "", true], # three-leaf clover category
|
||
|
'it3002': ['tesubc', 'ictrin', ["it3000","subcategory"], "", false], # three-leaf clover subcategory
|
||
|
'it3003': ['terari', 'irmund', ["it3000","rarity"], "", false], # three-leaf clover rarity
|
||
|
'it3004': ['tevalu', 'tevalu', ["it3000","value"], "", false], # three-leaf clover value
|
||
|
'it4000': ['it4lea', 'deit4lea', ["item"], "", false], # four-leaf clover
|
||
|
'it4001': ['tecate', 'caitem', ["it4000","category"], "", true], # four-leaf clover category
|
||
|
'it4002': ['tesubc', 'ictrin', ["it4000","subcategory"], "", false], # four-leaf clover subcategory
|
||
|
'it4003': ['terari', 'irrare', ["it4000","rarity"], "", false], # four-leaf clover rarity
|
||
|
'it4004': ['tevalu', 'tevalu', ["it4000","value"], "", false], # four-leaf clover value
|
||
|
'ml0000': ['techlv', 'techlv', ["term"], "", true], # level
|
||
|
'ml1000': ['techle', 'techle', ["techlv"], "", false], # level 1
|
||
|
'sm0000': ['wogati', 'wogati', ["term"], "", false], # main story
|
||
|
'smb000': ['evmibi', 'evmibi', ['sm0000'], "", false], # bingo
|
||
|
'smb001': ['it4lea', 'deit4lea', ['smb001'], "", false], # bingo - four-leaf clover pickup
|
||
|
'smc000': ['evchcr', 'evchcr', ["sm0000"], "", false], # character creation
|
||
|
'smc001': ['evchcr', 'evchcr', ["smc000"], "", false] # character created
|
||
|
}
|
||
|
|
||
|
func learn(new_content):
|
||
|
knowledge[new_content[0]][3] = new_content[1] # set source
|
||
|
knowledge[new_content[0]][4] = true # set knowledge as learned
|
||
|
MessageBus.publish("learned", new_content[0]) # reap benefits
|
||
|
|
||
|
func forget(old_content):
|
||
|
print_debug("KnowledgeBase: Forgetting " + old_content)
|
||
|
knowledge[old_content][4] = false # set knowledge as learned
|
||
|
MessageBus.publish("forgot", old_content) # reap benefits
|
||
|
|
||
|
func do_know(key):
|
||
|
#print_debug(key + " is " + str(knowledge[key][4]))
|
||
|
return knowledge[key][4]
|
||
|
|
||
|
func has_tag(key,tag):
|
||
|
return tag in knowledge[key][2]
|
||
|
|
||
|
# Ready
|
||
|
func _ready():
|
||
|
return
|
||
|
# add_child(learned_handler)
|
||
|
# add_child(forgot_handler)
|
||
|
# add_child(encountered_handler)
|
||
|
# MessageBus.subscribe("learned", learned_handler)
|
||
|
# MessageBus.subscribe("forgot", lost_handler)
|
||
|
# MessageBus.subscribe("encountered", encountered_handler)
|
||
|
|
||
|
# Serialize
|
||
|
func serialize():
|
||
|
return knowledge
|
||
|
|
||
|
# Deserialize
|
||
|
func deserialize(dict):
|
||
|
knowledge = dict
|