mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-04 23:38:28 +07:00
Added support for getting a stat from Attributes into a provided tuple
This commit is contained in:
@ -224,13 +224,23 @@ public final class Attributes implements Iterable<StatRef> {
|
||||
return agg.containsAny(stat);
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: This method returns a reused StatRef tuple which should not be
|
||||
* saved. Consecutive calls to this method will change the state of the
|
||||
* tuple, so only use this if you want to retrieve the value as a temp
|
||||
* cache. If you want to retrieve multiple stats,
|
||||
* {@link #get(short, StatRef)} should be used instead.
|
||||
*/
|
||||
public StatRef get(final short stat) {
|
||||
return agg.get(stat);
|
||||
}
|
||||
|
||||
public StatRef getCopy(final short stat) {
|
||||
final StatRef ref = agg.get(stat);
|
||||
return ref != null ? ref.copy() : null;
|
||||
/**
|
||||
* @see #get(short)
|
||||
*/
|
||||
public StatRef get(final short stat, final StatRef dst) {
|
||||
assert dst != null : "dst is null when it is asserted that you should have created one to reuse!";
|
||||
return agg.get(stat, dst);
|
||||
}
|
||||
|
||||
public StatRef set(final short stat, final short srcStat) {
|
||||
|
@ -90,6 +90,12 @@ public final class StatListRef implements Iterable<StatRef> {
|
||||
return tuple.update(index);
|
||||
}
|
||||
|
||||
public StatRef get(final short stat, final StatRef dst) {
|
||||
final int index = indexOf(stat);
|
||||
if (index < 0) return null;
|
||||
return dst.update(stats, list, index);
|
||||
}
|
||||
|
||||
StatRef first(final short stat) {
|
||||
final int index = stats.firstIndexOf(list, stat);
|
||||
if (index < 0) return null;
|
||||
|
@ -3,6 +3,10 @@ package com.riiablo.attributes;
|
||||
import com.riiablo.codec.excel.ItemStatCost;
|
||||
|
||||
public final class StatRef {
|
||||
public static StatRef obtain() {
|
||||
return new StatRef();
|
||||
}
|
||||
|
||||
StatList stats;
|
||||
int list;
|
||||
int index;
|
||||
|
Reference in New Issue
Block a user