mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 17:28:52 -04:00
Added annotation that can be added to architectures, to mark them as not requiring memory (e.g. to allow assembling MCUs with CPUs configured to those architectures without memory being present). Closes #1201.
This commit is contained in:
parent
bc29a0b70d
commit
a028beadec
@ -148,7 +148,22 @@ public interface Architecture {
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
static @interface Name {
|
||||
@interface Name {
|
||||
String value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Architectures flagged with this annotation can potentially run without
|
||||
* any additional memory installed in the computer.
|
||||
* <p/>
|
||||
* Use this to allow assembly of devices such as microcontrollers without
|
||||
* any memory being installed in them while your architecture is being
|
||||
* used by the CPU being installed. Note to actually make the machine
|
||||
* start up you only need to always return <tt>true</tt> from
|
||||
* {@link #recomputeMemory}.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@interface NoMemoryRequirements {
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import li.cil.oc.api.driver.item.Container
|
||||
import li.cil.oc.api.driver.item.Inventory
|
||||
import li.cil.oc.api.driver.item.Memory
|
||||
import li.cil.oc.api.driver.item.Processor
|
||||
import li.cil.oc.api.machine.Architecture
|
||||
import li.cil.oc.common.Slot
|
||||
import li.cil.oc.common.Tier
|
||||
import net.minecraft.inventory.IInventory
|
||||
@ -40,10 +41,11 @@ abstract class Template {
|
||||
val hasCase = caseTier(inventory) != Tier.None
|
||||
val hasCPU = this.hasCPU(inventory)
|
||||
val hasRAM = this.hasRAM(inventory)
|
||||
val requiresRAM = this.requiresRAM(inventory)
|
||||
val complexity = this.complexity(inventory)
|
||||
val maxComplexity = this.maxComplexity(inventory)
|
||||
|
||||
val valid = hasCase && hasCPU && hasRAM && complexity <= maxComplexity
|
||||
val valid = hasCase && hasCPU && (hasRAM || !requiresRAM) && complexity <= maxComplexity
|
||||
|
||||
val progress =
|
||||
if (!hasCPU) Localization.Assembler.InsertCPU
|
||||
@ -56,7 +58,7 @@ abstract class Template {
|
||||
warnings += Localization.Assembler.Warning(name)
|
||||
}
|
||||
}
|
||||
if (warnings.length > 0) {
|
||||
if (warnings.nonEmpty) {
|
||||
warnings.prepend(Localization.Assembler.Warnings)
|
||||
}
|
||||
|
||||
@ -80,6 +82,15 @@ abstract class Template {
|
||||
case _ => false
|
||||
})
|
||||
|
||||
protected def requiresRAM(inventory: IInventory) = !(0 until inventory.getSizeInventory).
|
||||
map(inventory.getStackInSlot).
|
||||
exists(stack => api.Driver.driverFor(stack, hostClass) match {
|
||||
case driver: Processor =>
|
||||
val architecture = driver.architecture(stack)
|
||||
architecture != null && architecture.getAnnotation(classOf[Architecture.NoMemoryRequirements]) != null
|
||||
case _ => false
|
||||
})
|
||||
|
||||
protected def hasComponent(name: String)(inventory: IInventory) = exists(inventory, stack => Option(api.Items.get(stack)) match {
|
||||
case Some(descriptor) => descriptor.name == name
|
||||
case _ => false
|
||||
|
Loading…
x
Reference in New Issue
Block a user