From ff1f873fa5d8c7f02399b4bd5a3d7a199a644071 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Wed, 1 Jun 2016 16:19:33 -0400 Subject: [PATCH] Updated forcefield upgrades (wip) --- .../warpdrive/data/EnumForceFieldUpgrade.java | 2 +- .../cr0s/warpdrive/data/ForceFieldSetup.java | 33 ++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java b/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java index f470775c..b14313be 100644 --- a/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java +++ b/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java @@ -8,6 +8,7 @@ public enum EnumForceFieldUpgrade { CAMOUFLAGE ("camouflage" , false, true ), COOL ("cool" , true , true ), FUSION ("fusion" , true , true ), + INVERT ("invert" , true , false), MUTE ("mute" , true , false), RANGE ("range" , true , true ), ROTATION ("rotation" , true , false), @@ -17,7 +18,6 @@ public enum EnumForceFieldUpgrade { THICKNESS ("thickness" , true , true ), TRANSLATION ("translation" , true , false), WARM ("warm" , true , true ), - // reserved 13 // reserved 14 // reserved 15 ; diff --git a/src/main/java/cr0s/warpdrive/data/ForceFieldSetup.java b/src/main/java/cr0s/warpdrive/data/ForceFieldSetup.java index 72bb6c60..7e2f1c98 100644 --- a/src/main/java/cr0s/warpdrive/data/ForceFieldSetup.java +++ b/src/main/java/cr0s/warpdrive/data/ForceFieldSetup.java @@ -20,7 +20,15 @@ public class ForceFieldSetup extends GlobalPosition { public ItemStack itemStackCamouflage; private Block blockCamouflage_cache; private static final List ALLOWED_RENDER_TYPES = Arrays.asList(0, 1, 4, 5, 6, 8, 7, 12, 13, 14, 16, 17, 20, 23, 29, 30, 31, 39); - private final HashMap upgrades = new HashMap<>(EnumForceFieldUpgrade.length); + private final HashMap mapUpgradeValues = new HashMap<>(EnumForceFieldUpgrade.length); + private final HashMap mapUpgradeObjects = new HashMap<>(EnumForceFieldUpgrade.length); + public boolean hasFusion; + public boolean isInverted; + public float startupEnergyCost; + public float scanEnergyCost; + public float placeEnergyCost; + public float scanSpeed = 100000; + public float placeSpeed = 100000; // TODO public Set projectors = new HashSet<>(); @@ -28,8 +36,6 @@ public class ForceFieldSetup extends GlobalPosition { public int disintegrationLevel; public int temperatureLevel; public boolean hasStabilize; - public boolean isInverted = false; - public boolean hasFusion; // Projector provided properties public float rotationYaw; @@ -94,6 +100,7 @@ public class ForceFieldSetup extends GlobalPosition { vTranslation = new VectorI(projector); // TODO vMin = projector.vMin; // TODO vMax = projector.vMax; + // TODO item upgrades } else { if ((((TileEntityProjector) tileEntity).isEnabled) && (((TileEntityProjector) tileEntity).isCalculated()) @@ -106,16 +113,26 @@ public class ForceFieldSetup extends GlobalPosition { if (tileEntity instanceof IForceFieldUpgrade) { String upgradeKey = ((IForceFieldUpgrade)tileEntity).getUpgradeKey(); if (!upgradeKey.isEmpty()) { - Integer count = upgrades.get(upgradeKey); - if (count == null) { - count = 0; + Integer value = mapUpgradeValues.get(upgradeKey); + if (value == null) { + value = 0; + mapUpgradeObjects.put(upgradeKey, (IForceFieldUpgrade)tileEntity); } - upgrades.put(upgradeKey, count + ((IForceFieldUpgrade)tileEntity).getUpgradeValue()); + mapUpgradeValues.put(upgradeKey, value + ((IForceFieldUpgrade)tileEntity).getUpgradeValue()); } } } - hasFusion = upgrades.containsKey(EnumForceFieldUpgrade.FUSION.unlocalizedName); + // compute results + hasFusion = mapUpgradeObjects.containsKey(EnumForceFieldUpgrade.FUSION.unlocalizedName); + isInverted = mapUpgradeObjects.containsKey(EnumForceFieldUpgrade.INVERT.unlocalizedName); + for (Map.Entry entry : mapUpgradeObjects.entrySet()) { + startupEnergyCost += entry.getValue().getStartupEnergyCost(entry.getKey(), mapUpgradeValues.get(entry.getKey())); + scanEnergyCost += entry.getValue().getScanEnergyCost(entry.getKey(), mapUpgradeValues.get(entry.getKey())); + placeEnergyCost += entry.getValue().getPlaceEnergyCost(entry.getKey(), mapUpgradeValues.get(entry.getKey())); + scanSpeed = Math.min(scanSpeed, entry.getValue().getMaxScanSpeed(entry.getKey(), mapUpgradeValues.get(entry.getKey()))); + placeSpeed = Math.min(placeSpeed, entry.getValue().getMaxPlaceSpeed(entry.getKey(), mapUpgradeValues.get(entry.getKey()))); + } } @Override