flatBlockedBy
This commit is contained in:
parent
65dd7cead9
commit
017e9dee7f
@ -141,8 +141,8 @@ abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability:
|
||||
isResearched = nbt.getBoolean("researched")
|
||||
}
|
||||
|
||||
inline val prerequisites get() = type.definedPrerequisites
|
||||
inline val prerequisites get() = type.flatPrerequisites
|
||||
inline val unlocks get() = type.flatUnlocks
|
||||
inline val blockedBy get() = type.definedBlockedBy
|
||||
inline val blockedBy get() = type.flatBlockedBy
|
||||
inline val blocking get() = type.flatBlocking
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ class AndroidResearchBuilder(
|
||||
))
|
||||
}
|
||||
|
||||
for (value in this.type.definedBlockedBy) {
|
||||
for (value in this.type.flatBlockedBy) {
|
||||
builder.add(TranslatableComponent("android_research.status.blocked_by", capability.getResearch(value).screenTooltipHeader).withStyle(ChatFormatting.DARK_RED))
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ open class AndroidResearchType<R : AndroidResearch>(
|
||||
/**
|
||||
* Prerequisites as-is.
|
||||
*
|
||||
* Please avoid having more than one prerequisite as this case don't have proper research tree
|
||||
* Please avoid having more than one prerequisite, as this case doesn't have proper research tree
|
||||
* rendering code (yet).
|
||||
*/
|
||||
open val definedPrerequisites: List<AndroidResearchType<*>> get() = emptyList()
|
||||
@ -217,6 +217,42 @@ open class AndroidResearchType<R : AndroidResearch>(
|
||||
ListSet(list.build())
|
||||
}
|
||||
|
||||
/**
|
||||
* Flat list of research blocking this research.
|
||||
*
|
||||
* This list won't contain any research blocked by this' research parents.
|
||||
*
|
||||
* E.g.
|
||||
*
|
||||
* * C depends on B
|
||||
* * B is blocked by A
|
||||
* * C is blocked by A
|
||||
*
|
||||
* Both B and C are blocked by A, but C requires B, so C's [flatBlockedBy] will not contain A, but B's will.
|
||||
*
|
||||
* Returns list which also doubles as set (for contains method).
|
||||
*/
|
||||
val flatBlockedBy: List<AndroidResearchType<*>> by lazy {
|
||||
val list = ImmutableList.builder<AndroidResearchType<*>>()
|
||||
|
||||
for (blocker in definedBlockedBy) {
|
||||
var hit = false
|
||||
|
||||
for (research in allPrerequisites) {
|
||||
if (blocker in research.flatBlockedBy) {
|
||||
hit = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!hit) {
|
||||
list.add(blocker)
|
||||
}
|
||||
}
|
||||
|
||||
ListSet(list.build())
|
||||
}
|
||||
|
||||
/**
|
||||
* All research directly unlocked by this research.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user