{"id":13662635,"url":"https://github.com/jozzzzep/CooldownAPI","last_synced_at":"2025-04-25T10:32:49.817Z","repository":{"id":48620975,"uuid":"303369518","full_name":"jozzzzep/CooldownAPI","owner":"jozzzzep","description":"Simple and easy tool for handling and managing cooldowns in UnityEngine efficiently.","archived":false,"fork":false,"pushed_at":"2022-12-26T11:32:07.000Z","size":128,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-13T10:02:38.026Z","etag":null,"topics":["api","cd","cooldown","cooldowns","managing-cooldowns","system","tutorial","unity","unity3d","unityengine","wiki"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jozzzzep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-12T11:25:59.000Z","updated_at":"2023-11-23T01:26:21.000Z","dependencies_parsed_at":"2023-01-31T00:01:27.957Z","dependency_job_id":null,"html_url":"https://github.com/jozzzzep/CooldownAPI","commit_stats":null,"previous_names":["josepedev/cooldownapi"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozzzzep%2FCooldownAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozzzzep%2FCooldownAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozzzzep%2FCooldownAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jozzzzep%2FCooldownAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jozzzzep","download_url":"https://codeload.github.com/jozzzzep/CooldownAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250798379,"owners_count":21489069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cd","cooldown","cooldowns","managing-cooldowns","system","tutorial","unity","unity3d","unityengine","wiki"],"created_at":"2024-08-02T05:02:03.934Z","updated_at":"2025-04-25T10:32:49.516Z","avatar_url":"https://github.com/jozzzzep.png","language":"C#","readme":"![img](https://i.imgur.com/cSOJR5d.png)  \n \u003cp align=\"center\"\u003e\n        \u003cimg src=\"https://img.shields.io/codefactor/grade/github/jozzzzep/CooldownAPI/main\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/languages/code-size/jozzzzep/CooldownAPI\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/jozzzzep/CooldownAPI\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/v/release/jozzzzep/CooldownAPI\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/followers/jozzzzep?style=social\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/watchers/jozzzzep/CooldownAPI?style=social\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/stars/jozzzzep/CooldownAPI?style=social\"\u003e\n\u003c/p\u003e\n\n### Content\n- [**Setup \u0026 Examples**](#setup-and-examples)\n- [**Documentations**](#documentations)\n- [**Importing**](#importing)\n\n# Setup And Examples\nLet's say we have an **attack method** in our game for the **player**.  When the player **presses** a key, we want to **attack**.  But we also want to **apply a cooldown** when the player **attacks** to **prevent** the player from attacking too quickly.  \n\nFirst let's **declare** a **Cooldown** for the attack and call it \"**attackCooldown**\"   \nAlso, let's declare a **float** variable for the **amount of seconds** between attacks. \nLet's say we want the duration of the cooldown to be 3.25 seconds.\n```csharp\nfloat attackCoodldownDuration = 3.25f;\nCooldown attackCooldown;\n```\nNow to **initialize** it. All you got to to is to **call** its constructor.  \nWhen you **initialize** a Cooldown object, you set its **default duration** value.  \nAnd it's the float variable we declared before.  \nMake sure you initialize your cooldowns inside **Start()** or **Awake()**  \n```csharp\nvoid Awake()\n{\n  attackCooldown = new Cooldown(attackCooldownDuration);\n}\n```\nDone. The cooldown is ready.  \nLet's activate it when we attack. We just need to use the method **Activate()**  \n```csharp\nvoid Attack()\n{\n  // some attack behaviour\n  ...\n  // cooldown activation\n  attackCooldown.Activate();\n}\n```\nNow, let's **prevent** the player from attacking **if** the cooldown **is active**.  \nWe can do this by checking the value **IsActive** in the cooldown.  \n```csharp\nif (//player is pressing the attack button)\n{\n  if (attackCooldown.IsActive == false)\n  {\n    Attack();\n  }\n}\n```\nA **Cooldown** object contains **two** properties. A **timer** and a default **duration**.  \nThe Cooldown is considered \"**active**\" when its **timer** equal to **zero**.  \nThe timer is always **decreasing** until it reaches zero.  \nLet's say we want to add a special, shorter attack, and apply a **short cooldown** for it with a **different duration**.  \nWe can do it with the **Activate()** method by **inputting** a **custom duration** to it.  \n```csharp\nvoid SpecialAttack()\n{\n  // some attack behaviour\n  ...\n  // cooldown activation\n  attackCooldown.Activate(1.7f); // cooldown applied with a custom duration.\n}\n```\nYou can also **change** the **default duration** at any time with the method **ChangeDuration()**\n```csharp\nattackCooldown.ChangeDuration(8f);\n```\nYou can also **manually** deactivate the cooldown and reset its timer to zero.  \nUse the method **Deactivate()**  \n```csharp\nattackCooldown.Deactivate();\n```\n# Documentations\n### Cooldown\nA class for handling a cooldown in Unity using a timer.   \n\n- Properties\n  - **IsActive**  \n  Determines if the cooldown is currently active.  \n  Returns true if the timer is higher than zero.  \n  \n  - **Duration**  \n  Returns the default duration value of the Cooldown object.  \n  The default duration is set upon initialization.  \n  It used when you call the Activate() method without inputting parameters.  \n\n  - **Timer**  \n  Returns the current value from the cooldown's timer\n  \n- Methods\n  - **Activate()**  \n  Activates the cooldown with the default duration.  \n  You can get the default duration's value form the Duration propertie.  \n  \n  - **Activate(float customDuration)**  \n  Activates the cooldown with a custom duration.  \n  \n  - **Deactivate()**  \n  Deactivates the cooldown manually.  \n  Resets the timer's value to zero.  \n  \n  - **ChangeDuration(float duration)**  \n  For changing the default duration's value.  \n\n- Constructors\n  - **Cooldown(float duration)**  \n  Used for creating a new cooldown  \n  Input the default duration of the cooldown\n\n- Events\n  - **BecameInactive**  \n  An event that is raised when the cooldown becomes inactive\n  \n\n# Importing\n[**Click here to download**](https://github.com/jozzzzep/CooldownAPI/raw/main/packages/CooldownAPI.unitypackage), or go to the packages folder of the repository and download the package file.  \nThen import the package directly to your project like any other Unity package. \nThis is he fastest and easiest way.  \n**Done!**\n","funding_links":[],"categories":["C\\#"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjozzzzep%2FCooldownAPI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjozzzzep%2FCooldownAPI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjozzzzep%2FCooldownAPI/lists"}