Optimize a bit
This commit is contained in:
parent
339494f8c3
commit
d111a4f130
1 changed files with 13 additions and 7 deletions
|
@ -82,18 +82,24 @@ public class GT_UndergroundOil {
|
||||||
|
|
||||||
//do stuff on it if needed
|
//do stuff on it if needed
|
||||||
if(drainSpeedCoefficient>=0){
|
if(drainSpeedCoefficient>=0){
|
||||||
if(fluidInChunk.amount<DIVIDER || fluidInChunk.amount<=(uoFluid.DecreasePerOperationAmount*(double)drainSpeedCoefficient)+1){
|
int fluidExtracted=(int)Math.floor(fluidInChunk.amount * (double) drainSpeedCoefficient / DIVIDER);
|
||||||
|
double averageDecrease=uoFluid.DecreasePerOperationAmount * (double)drainSpeedCoefficient;
|
||||||
|
int decrease=(int)Math.ceil(averageDecrease);
|
||||||
|
if(fluidExtracted<=0 || fluidInChunk.amount<=decrease){//decrease - here it is max value of extraction for easy check
|
||||||
fluidInChunk=null;
|
fluidInChunk=null;
|
||||||
tInts[GTOIL]=0;//so in next access it will stop way above
|
tInts[GTOIL]=0;//so in next access it will stop way above
|
||||||
}else{
|
}else{
|
||||||
fluidInChunk.amount = (int)(fluidInChunk.amount*(double)drainSpeedCoefficient/DIVIDER);//give appropriate amount
|
fluidInChunk.amount = fluidExtracted;//give appropriate amount
|
||||||
double avrDecrease=uoFluid.DecreasePerOperationAmount * (double)drainSpeedCoefficient;
|
if(random.nextFloat()<(decrease-averageDecrease)) decrease--;//use random to "subtract double from int"
|
||||||
int decrease=(int)Math.floor(avrDecrease);
|
//ex.
|
||||||
decrease+=random.nextFloat()<(avrDecrease-decrease)?1:0;
|
// averageDecrease=3.9
|
||||||
tInts[GTOIL]-=decrease;//diminish amount
|
// decrease= ceil from 3.9 = 4
|
||||||
|
// decrease-averageDecrease=0.1 -> chance to subtract 1
|
||||||
|
// if random is < chance then subtract 1
|
||||||
|
tInts[GTOIL]-=decrease;//diminish amount, "randomly" adjusted to double value (averageDecrease)
|
||||||
}
|
}
|
||||||
}else{//just get info
|
}else{//just get info
|
||||||
if(fluidInChunk.amount<DIVIDER || fluidInChunk.amount<=(uoFluid.DecreasePerOperationAmount*(double)drainSpeedCoefficient)+1){
|
if(fluidInChunk.amount<=DIVIDER){
|
||||||
fluidInChunk.amount=0;//return informative stack
|
fluidInChunk.amount=0;//return informative stack
|
||||||
tInts[GTOIL]=0;//so in next access it will stop way above
|
tInts[GTOIL]=0;//so in next access it will stop way above
|
||||||
}else{
|
}else{
|
||||||
|
|
Loading…
Reference in a new issue