-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ns4: Add data stores, cursor, player events.
- Loading branch information
Showing
5 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ns | ||
|
||
type StorageType interface { | ||
isStorageType() | ||
} | ||
|
||
// Session is a game session storage with a given name. It will persist as long as a single game session runs. | ||
type Session struct { | ||
Name string | ||
} | ||
|
||
func (Session) isStorageType() {} | ||
|
||
// Persistent returns a persistent storage with a given name. It will persist between OpenNox restarts. | ||
type Persistent struct { | ||
Name string | ||
} | ||
|
||
func (Persistent) isStorageType() {} | ||
|
||
// Store returns a global storage with a given type. | ||
func Store(typ StorageType) Storage { | ||
if impl == nil { | ||
return nil | ||
} | ||
return impl.Store(typ) | ||
} | ||
|
||
type Storage interface { | ||
// Get fetches a custom object or value from the storage with a given key. | ||
// Argument must be a pointer to a value of the same type as used during Set. | ||
Get(key string, obj any) error | ||
// Set stores a custom object or value into the storage with a given key. | ||
Set(key string, obj any) error | ||
} |