From 264264ee338cb6fe099a76108055834cebf7c2df Mon Sep 17 00:00:00 2001 From: Marquis Kurt Date: Sun, 20 Aug 2023 21:03:46 -0400 Subject: [PATCH] :sparkles: Add character switcher Also renames the Character.sky case to Character.obel. --- .../AnthroBase/AnthroCharacterBody2D+ClassProps.swift | 1 + .../Sources/AnthroBase/AnthroCharacterBody2D.swift | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D+ClassProps.swift b/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D+ClassProps.swift index d1acd7e..4665ed3 100644 --- a/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D+ClassProps.swift +++ b/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D+ClassProps.swift @@ -69,6 +69,7 @@ extension AnthroCharacterBody2D { func setCharacter(args: [Variant]) -> Variant? { ClassInfo.withCheckedProperty(named: "character", in: args) { arg in character = Character(rawValue: Int(arg) ?? 0) ?? .chelsea + changeSprites() } } diff --git a/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D.swift b/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D.swift index c23d255..84d7d99 100644 --- a/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D.swift +++ b/AnthroBase/Sources/AnthroBase/AnthroCharacterBody2D.swift @@ -22,7 +22,7 @@ public class AnthroCharacterBody2D: CharacterBody2D { @PickerNameProvider public enum Character: Int { case chelsea - case sky + case obel } @SceneTree(path: "Sprite") @@ -75,6 +75,15 @@ public class AnthroCharacterBody2D: CharacterBody2D { super._physicsProcess(delta: delta) } + func changeSprites() { + switch character { + case .chelsea: + sprite?.texture = #texture2DLiteral("res://resources/sprt_chelsea.png") + case .obel: + sprite?.texture = #texture2DLiteral("res://resources/sprt_obel.png") + } + } + private func updateBlendingProperties(with vector: Vector2) { guard let animationTree else { GD.pushError("Animation tree is missing.")