mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-02-14 03:36:10 -08:00
ItemBuffer struct
This commit is contained in:
parent
01f759a992
commit
5b27f4786d
1 changed files with 12 additions and 3 deletions
|
|
@ -2,6 +2,8 @@ package mindustry.world;
|
|||
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
|
@ -20,7 +22,7 @@ public class ItemBuffer{
|
|||
|
||||
public void accept(Item item, short data){
|
||||
//if(!accepts()) return;
|
||||
buffer[index++] = Pack.longInt(Float.floatToIntBits(Time.time), Pack.shortInt(item.id, data));
|
||||
buffer[index++] = TimeItem.get(data, item.id, Time.time);
|
||||
}
|
||||
|
||||
public void accept(Item item){
|
||||
|
|
@ -30,10 +32,10 @@ public class ItemBuffer{
|
|||
public Item poll(float speed){
|
||||
if(index > 0){
|
||||
long l = buffer[0];
|
||||
float time = Float.intBitsToFloat(Pack.leftInt(l));
|
||||
float time = TimeItem.time(l);
|
||||
|
||||
if(Time.time >= time + speed || Time.time < time){
|
||||
return content.item(Pack.leftShort(Pack.rightInt(l)));
|
||||
return content.item(TimeItem.item(l));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
@ -63,4 +65,11 @@ public class ItemBuffer{
|
|||
}
|
||||
index = Math.min(index, length - 1);
|
||||
}
|
||||
|
||||
@Struct
|
||||
class TimeItemStruct{
|
||||
short data;
|
||||
short item;
|
||||
float time;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue