-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
828 additions
and
568 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...yAdapter/src/main/kotlin/me/gabber235/typewriter/entries/activity/AudienceActivityPair.kt
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,65 @@ | ||
package me.gabber235.typewriter.entries.activity | ||
|
||
import me.gabber235.typewriter.adapters.Colors | ||
import me.gabber235.typewriter.adapters.Entry | ||
import me.gabber235.typewriter.adapters.modifiers.Help | ||
import me.gabber235.typewriter.entry.Ref | ||
import me.gabber235.typewriter.entry.emptyRef | ||
import me.gabber235.typewriter.entry.entity.EntityActivity | ||
import me.gabber235.typewriter.entry.entity.IndividualActivityContext | ||
import me.gabber235.typewriter.entry.entity.LocationProperty | ||
import me.gabber235.typewriter.entry.entity.SingleChildActivity | ||
import me.gabber235.typewriter.entry.entries.AudienceEntry | ||
import me.gabber235.typewriter.entry.entries.EntityActivityEntry | ||
import me.gabber235.typewriter.entry.entries.IndividualEntityActivityEntry | ||
import me.gabber235.typewriter.entry.inAudience | ||
import java.util.* | ||
|
||
@Entry( | ||
"audience_activity", | ||
"Select activity based on the audience a player is in", | ||
Colors.BLUE, | ||
"fluent:people-audience-32-filled" | ||
) | ||
/** | ||
* The `Audience Activity` is an activity that filters an audience based on the audience a player is in. | ||
* The activity will go through the audiences in order and the first one | ||
* where the player is part of the audience will have the activity selected. | ||
* | ||
* This can only be used on an individual entity instance. | ||
* | ||
* ## How could this be used? | ||
* This could be used to make a bodyguard distracted by something and walk away just for the player. | ||
*/ | ||
class AudienceActivityEntry( | ||
override val id: String = "", | ||
override val name: String = "", | ||
val activities: List<AudienceActivityPair> = emptyList(), | ||
@Help("The activity that will be used when the player is not in any audience.") | ||
val defaultActivity: Ref<out EntityActivityEntry> = emptyRef(), | ||
override val priorityOverride: Optional<Int> = Optional.empty(), | ||
) : IndividualEntityActivityEntry { | ||
override fun create( | ||
context: IndividualActivityContext, | ||
currentLocation: LocationProperty | ||
): EntityActivity<IndividualActivityContext> { | ||
return AudienceActivity(activities, defaultActivity, currentLocation) | ||
} | ||
} | ||
|
||
class AudienceActivityPair( | ||
val audience: Ref<out AudienceEntry>, | ||
val activity: Ref<out IndividualEntityActivityEntry>, | ||
) | ||
|
||
class AudienceActivity( | ||
private val activities: List<AudienceActivityPair>, | ||
private val defaultActivity: Ref<out EntityActivityEntry>, | ||
startLocation: LocationProperty, | ||
) : SingleChildActivity<IndividualActivityContext>(startLocation) { | ||
override fun currentChild(context: IndividualActivityContext): Ref<out EntityActivityEntry> { | ||
val player = context.viewer | ||
|
||
return activities.firstOrNull { player.inAudience(it.audience) }?.activity ?: defaultActivity | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
...Adapter/src/main/kotlin/me/gabber235/typewriter/entries/activity/FixedLocationActivity.kt
This file was deleted.
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
Oops, something went wrong.