Skip to content

Commit

Permalink
Add additional entry documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Dec 10, 2023
1 parent 02ed772 commit 284e55e
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 5 deletions.
2 changes: 1 addition & 1 deletion documentation/docs/develop/01-index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Lastly there is the UI. This is written in Flutter and is the most complex part

:::danger important
This part of the documentation is still under construction. If you want to help, please contact us on [Discord](https://discord.gg/HtbKyuDDBw).
:::
:::
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ purpose in crafting immersive player experiences.
This documentation explains the roles and functionalities of these entry types, providing clear guidance for developers on how to effectively use them.

## Base Entry Interfaces
There are three base interfaces that all entries extend atleast one of. These are:
There are three base interfaces that all entries extend one of. These are:
1. **StaticEntry**: Represents static pages. These are used for content that does not change dynamically or trigger any actions. Examples include static text or images.
2. **TriggerEntry**: Designed for entries that initiate other actions or events. These entries can trigger one or more additional entries, making them crucial for interactive sequences.
3. **CinematicEntry**: Used for cinematic experiences. These entries are ideal for creating immersive story-driven sequences that engage players in a more visually dynamic way.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ArtifactEntry

The `ArtifactEntry` is a specialized interface derived from `AssetEntry`.
Its primary purpose is to handle artifacts, which are assets generated by the plugins/adapters itself.
Unlike standard assets, artifacts are usually dynamic and created during runtime.
This makes them particularly useful for storing data that changes based on player interactions or game events.

An essential feature of `ArtifactEntry` is its unique `artifactId`.
This identifier must remain constant once assigned and is used to reference the artifact within the plugin.

## Usage

Here's a generic example of creating and using an `ArtifactEntry`:

### Defining an ArtifactEntry

```kotlin
@Entry("example_artifact", "An example artifact entry.", Colors.BLUE, Icons.ARROW)
class ExampleArtifactEntry(
override val id: String = "",
override val name: String = "",
override val artifactId: String = "",
) : ArtifactEntry
```

### Accessing the Artifact's Content
```kotlin
import org.koin.java.KoinJavaComponent.get

val assetManager = get<AssetManager>(AssetManager::class.java)

val id = // ID of the entry
val entry = Query.findById<ExampleArtifactEntry>(id)
val content: String = assetManager.fetchAsset(entry)
```

In this example, `ExampleArtifactEntry` is defined as an artifact with a unique identifier. The `assetManager.fetchAsset` method is then used to retrieve the content of the artifact, based on its `artifactId`.

13 changes: 11 additions & 2 deletions documentation/docs/develop/02-adapters/03-entries/static/asset.mdx
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# AssetEntry
The AssetEntry is a specialized interface that extends the StaticEntry in the TypeWriter Spigot plugin.
The AssetEntry is a specialized interface that extends the `StaticEntry`.
It is primarily used for handling static assets within the game.
Assets can include various types of files such as images, sounds, or other external resources that are crucial to enhancing the game environment and player experience.
The key attribute of AssetEntry is the path, which specifies the location of the asset.

## Usage
Here's a generic example of creating and using an `AssetEntry`:

### Defining an AssetEntry
```kotlin
@Entry("example_asset", "An example asset entry.", Colors.PINK, Icons.PERSON_WALKING)
class ExampleAssetEntry(
override val path: String = "",
): AssetEntry
```

### Accessing the Artifact's Content

To get the asset from the entry, you can use the following code:
```kotlin
import org.koin.java.KoinJavaComponent.get

val assetManager = get<AssetManager>(AssetManager::class.java)

val id = // ID of the entry
val entry = Query.findById<ExampleAssetEntry>(id)
val path = entry.path
val content: String = assetManager.fetchAsset(entry)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SoundIdEntry

The `SoundIdEntry` is an interface derived from `StaticEntry`, specifically designed for managing custom sounds within the TypeWriter Spigot plugin.
If a server is using a custom resource pack, the `SoundIdEntry` can be used to add a reference to a custom sound within the resource pack.

## Usage
```kotlin
@Entry("example_sound", "An example sound entry.", Colors.GREEN, Icons.VOLUME_HIGH)
class ExampleSoundIdEntry(
override val id: String,
override val name: String,
override val soundId: String,
) : SoundIdEntry
```

Normally a `SoundIdEntry` handled by the interface when an entry needs a sound.
If you ever would need to access the sound ID directly, it can be done like this:

```kotlin
val id = // ID of the custom sound
val entry = Query.findById<ExampleSoundIdEntry>(id)
val customSound = entry.soundId
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SpeakerEntry

The `SpeakerEntry` is a specialized interface extending the `EntityEntry`.
It is designed to enhance dialogues in the game by associating non-player characters (NPCs) with specific names and sounds.
This feature is pivotal for creating more immersive and interactive storytelling experiences in Minecraft.

## Usage
```kotlin
@Entry("example_speaker", "An example speaker entry.", Colors.BLUE, Icons.PERSON_TALKING)
class ExampleSpeakerEntry(
override val id: String = "",
override val name: String = "",
override val displayName: String = "",
override val sound: Sound = Sound.EMPTY,
) : SpeakerEntry
```

This speaker can be used by users in various dialogues and interactions within the game.
Normally, you never need to access the `SpeakerEntry` directly, as it is automatically handled by the `DialogueSequence`.
If you ever do need to access the `SpeakerEntry`, you can do so:

```kotlin
val id = // ID of the speaker
val entry = Query.findById<ExampleSpeakerEntry>(id)
val name = entry.displayName
val sound = entry.sound
```
2 changes: 1 addition & 1 deletion documentation/docs/develop/02-adapters/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
TypeWriter is a dynamic platform that supports the development of adapters, which are modular components enhancing the overall functionality. Adapters are self-contained, easily shareable, and integrate smoothly into the TypeWriter system. This guide is tailored to guide you through the process of creating an adapter, suitable for both beginners and experienced developers.

:::info
It is highly recommended to write adapters in Kotlin, as it is the primary language of TypeWriter. However, it is also possible to write adapters in Java, as long as the adapter is compiled into a `.jar` file.
It is highly recommended to write adapters in Kotlin, as it is the primary language of TypeWriter. Though, it is possible to write adapters in Java, not all features are usable in Java.
:::

## Guides
Expand Down

0 comments on commit 284e55e

Please sign in to comment.