You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ts/handler.ts
+21Lines changed: 21 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,19 @@
1
1
import{StringifiedIdentifier}from"./helper.js";
2
2
3
+
/**
4
+
* Handlers are the core feature for all content in the game. They store and manage different types of objects, such as buildings, upgrades, mods, and more.
5
+
*
6
+
* Each handler uses {@link Identifier}s to uniquely identify and retrieve objects (with the exception of {@link UniqueKeyHandler}s).
7
+
*
8
+
* Globally accessible handlers are stored in the {@link Handlers} class. These handlers are treated specially throughout the codebase to manage their respective content types. Generally, you will not create your own handlers if you are making a mod that does not drastically modify the game's core systems.
9
+
*
10
+
* Handlers can also be iterated over like so:
11
+
* ```ts
12
+
* for (const obj of handler) {
13
+
* console.log(obj);
14
+
* }
15
+
* ```
16
+
*/
3
17
exportclassHandler<T>implementsIterable<T>{
4
18
/** This stores the stringified Identifier as the key and then the values is obviously T. We store the identifier stringified because objects are never equal so we can't `get()` from the Map without using the same obj reference. */
@@ -123,6 +137,13 @@ export class UniqueKeyHandler<T> implements Iterable<T> {
123
137
}
124
138
}
125
139
140
+
/**
141
+
* A unique identifier, usually for objects registered to {@link Handler}s.
142
+
*
143
+
* Identifiers are core to avoiding name collisions. If two mods were to register a building with the name `farm` then they would conflict with each other. The solution is to add a "namespace" such that these identifiers become `mod1:farm` and `mod2:farm`.
144
+
*
145
+
* If you are familiar with Minecraft mods these are functionally identical to how they are implemented there.
146
+
*/
126
147
exportclassIdentifier{
127
148
/**
128
149
* Constructs a new {@link Identifier} from a stringified Identifier (from {@link Identifier.toString()}). If the string is not valid then a warning will be logged and `undefined` will be returned.
Copy file name to clipboardExpand all lines: src/ts/helper.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,8 @@ export function commaify(toComma: number): string {
49
49
returncommaifyed;
50
50
}
51
51
52
-
/** Oftentimes, because JS is a pain in the butt hole, number such as 128.2 may instead be 128.2000000000013. This is not very friendly to look at. This makes that number better.
52
+
/**
53
+
* Oftentimes, because CPUs are annoying, number such as 128.2 may instead be 128.2000000000013. This is not very friendly to look at. This makes that number better.
53
54
*
54
55
* Historically, we would use a seperate object for numbers that would be impacted by this that would automatically apply the calculations in this function (variableView), but I prefer this method instead.
* Koohs ("hooks" spelled backwards) serve as events that mods can register functions to be called on. Register functions using {@link Mod.registerKooh}.
7
+
*
8
+
* These will all automatically be called by {@link Game} at the appropriate times. Usually, you should not need to call these manually.
9
+
*
10
+
* | Kooh | When is it called? |
11
+
* | --------------- | ------------- |
12
+
* | click | When the cookie is clicked ({@link Game.cookieClicked()}) |
13
+
* | cps | When CPS is given ({@link Game.cookiesPerSecondUpdate()}) |
14
+
* | loop | Called in game loop ({@link Game.gameLoop()}) |
15
+
* | personalization | Whenever a personalization option is changed ({@link BackgroundHandler.setBackground()}, {@link CurrentlyClickedHandler.setCurrentlyClicked()}) |
16
+
*/
17
+
typeKooh="click"|"cps"|"loop"|"personalization";
5
18
6
19
interfaceModMetadata{
7
20
name: string;
@@ -12,7 +25,7 @@ interface ModMetadata {
12
25
}
13
26
14
27
/**
15
-
* Provides high-level abstractions for mod developers to work with
28
+
* Provides high-level abstractions for mod developers to work with. [Read the docs.](https://github.com/clickercookie/clickercookie.github.io/wiki/Modding)
16
29
*/
17
30
exportclassMod<T>implementsSaveProvider<T>{
18
31
// ------------------
@@ -44,7 +57,7 @@ export class Mod<T> implements SaveProvider<T> {
44
57
/** Mod namespace used for saving */
45
58
publicreadonlyNAMESPACE: string;
46
59
47
-
constructor(namespace: string,metadata: ModMetadata={name: undefined,description: undefined,img: undefined}){//? should namespace be a param?
0 commit comments