Refactor out some EntrySets

This commit is contained in:
AnimeGitB
2022-10-17 20:40:07 +10:30
parent b5f356ce4f
commit 85f44ebdf3
16 changed files with 59 additions and 136 deletions

View File

@@ -247,13 +247,7 @@ public class EntityAvatar extends GameEntity {
entityInfo.setMotionInfo(this.getMotionInfo());
}
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
if (entry.getIntKey() == 0) {
continue;
}
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
entityInfo.addFightPropList(fightProp);
}
this.addAllFightPropsToEntityInfo(entityInfo);
PropPair pair = PropPair.newBuilder()
.setType(PlayerProperty.PROP_LEVEL.getId())

View File

@@ -217,7 +217,7 @@ public class EntityGadget extends EntityBaseGadget {
// We do not use the getter to null check because the getter will create a fight prop map if it is null
if (this.fightProp != null) {
this.addAllFightPropsToEntityInfo(entityInfo);
addAllFightPropsToEntityInfo(entityInfo);
}
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()

View File

@@ -255,13 +255,7 @@ public class EntityMonster extends GameEntity {
.setEntityAuthorityInfo(authority)
.setLifeState(this.getLifeState().getValue());
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
if (entry.getIntKey() == 0) {
continue;
}
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
entityInfo.addFightPropList(fightProp);
}
this.addAllFightPropsToEntityInfo(entityInfo);
PropPair pair = PropPair.newBuilder()
.setType(PlayerProperty.PROP_LEVEL.getId())

View File

@@ -122,14 +122,7 @@ public class EntityVehicle extends EntityBaseGadget {
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 47))
.build();
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
if (entry.getIntKey() == 0) {
continue;
}
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
entityInfo.addFightPropList(fightProp);
}
this.addAllFightPropsToEntityInfo(entityInfo);
entityInfo.addPropList(pair);
return entityInfo.build();

View File

@@ -113,13 +113,10 @@ public abstract class GameEntity {
}
public void addAllFightPropsToEntityInfo(SceneEntityInfo.Builder entityInfo) {
for (Int2FloatMap.Entry entry : this.getFightProperties().int2FloatEntrySet()) {
if (entry.getIntKey() == 0) {
continue;
}
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
entityInfo.addFightPropList(fightProp);
}
this.getFightProperties().forEach((key, value) -> {
if (key == 0) return;
entityInfo.addFightPropList(FightPropPair.newBuilder().setPropType(key).setPropValue(value).build());
});
}
protected MotionInfo getMotionInfo() {

View File

@@ -93,14 +93,7 @@ public class EntityPlatform extends EntityBaseGadget {
.setGadget(gadgetInfo)
.setLifeState(1);
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
if (entry.getIntKey() == 0) {
continue;
}
FightPropPairOuterClass.FightPropPair fightProp = FightPropPairOuterClass.FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
entityInfo.addFightPropList(fightProp);
}
this.addAllFightPropsToEntityInfo(entityInfo);
return entityInfo.build();
}

View File

@@ -89,16 +89,7 @@ public class EntitySolarIsotomaElevatorPlatform extends EntityPlatform {
Grasscutter.getLogger().warn("Why gadget owner doesn't exist?");
}
for (var entry : getFightProperties().int2FloatEntrySet()) {
if (entry.getIntKey() == 0) {
continue;
}
var fightProp = FightPropPairOuterClass.FightPropPair.newBuilder()
.setPropType(entry.getIntKey())
.setPropValue(entry.getFloatValue())
.build();
info.addFightPropList(fightProp);
}
this.addAllFightPropsToEntityInfo(info);
info.setLifeState(1)
.setGadget(gadget)