Skip to content

MuharremTozan/Agentic-Duel / .agent/skills/unity-memento-pattern

unity-memento-pattern

Verified

Implements the Memento pattern for capturing and restoring object states. Perfect for Loadout managers, Checkpoints, and Undo/Redo systems.

assets/code/HotbarMementoExample.cs.txt

View on GitHub
using System.Collections.Generic;
using UnityEngine;

namespace Standard.Patterns.Memento.Examples {
    /// <summary>
    /// Represents an Item/Ability that can be in a Hotbar.
    /// </summary>
    public class HotbarItem : ScriptableObject {
        public string Name;
        public Sprite Icon;
    }

    /// <summary>
    /// The Originator: A Hotbar system that can snapshot its slots.
    /// </summary>
    public class HotbarSystem : MonoBehaviour, IOriginator<List<HotbarItem>> {
        [SerializeField] private List<HotbarItem> currentSlots = new();

        public IMemento<List<HotbarItem>> Save() {
            // Important: Create a new list to ensure the snapshot is immutable
            return new Memento<List<HotbarItem>>(new List<HotbarItem>(currentSlots));
        }

        public void Restore(IMemento<List<HotbarItem>> memento) {
            currentSlots = new List<HotbarItem>(memento.State);
            UpdateUI();
        }

        private void UpdateUI() {
            Debug.Log("[Hotbar] Status: UI Updated with restored state.");
        }
    }
}
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall