extends Node2D var rng = RandomNumberGenerator.new() var itemBurning var timeToBurn = 10 var endXP = 0 var xpPerTick = 0 var tickDuration = 0.8 var tickTimer = 0.8 func _ready(): $FireSprite.play("default") var audioStartDelay = rng.randf_range(0, 2) $AudioStreamPlayer2D.play(audioStartDelay) func set_item_burning(item): itemBurning = item if item.weight < 0.5: timeToBurn = 0.9 elif item.weight < 2: timeToBurn = item.weight + 1 else: timeToBurn = item.weight if timeToBurn < 3: timeToBurn = 3 if timeToBurn > 30: timeToBurn = 30 endXP = 5 endXP += ((100-item.flammability) * 0.05) + (item.value * 0.7) endXP += item.weight * 0.5 endXP = floor(endXP) if Item.modifications.Sugared in item.itemModifications: endXP -= (item.value * 0.5) endXP = floor(endXP) xpPerTick = 1 xpPerTick += int(endXP/40) func _process(delta): timeToBurn -= delta if timeToBurn <= 0: burn_out() return tickTimer -= delta if tickTimer <= 0: tickTimer = tickDuration LevelManager.add_XP("arson", xpPerTick) func burn_out(): var ashItem = null if Item.modifications.Sugared in itemBurning.itemModifications: ashItem = itemBurning.duplicate() ashItem.itemModifications.erase(Item.modifications.Sugared) ashItem.itemModifications.append(Item.modifications.Caramelized) LevelManager.get_skill("appreciating").experience_item(itemBurning, "caramelized") else: ashItem = AshGenerator.generate_ash(itemBurning) LevelManager.get_skill("appreciating").experience_item(ashItem, "burnedTo") if ashItem.get_name(true) == "Popcorn": AchievementManager.complete_achievement("Pop Pop Pop") var groundItem = load("res://Objects/GroundItems/GroundItem.tscn").instantiate() groundItem.set_item(ashItem) get_parent().add_child(groundItem) groundItem.global_position = global_position LevelManager.add_XP("arson", endXP) queue_free()