feat: add more home mark point (#2323)

This commit is contained in:
hamusuke
2023-08-31 08:32:47 +09:00
committed by GitHub
parent 7049cfdb58
commit e8f4949836
10 changed files with 257 additions and 54 deletions

View File

@@ -4,12 +4,15 @@ import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Id;
import emu.grasscutter.data.binout.HomeworldDefaultSaveData;
import emu.grasscutter.net.proto.HomeBlockArrangementInfoOuterClass.HomeBlockArrangementInfo;
import java.util.List;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
@Entity
@Data
@Builder(builderMethodName = "of")
@@ -77,6 +80,8 @@ public class HomeBlockItem {
.setIsUnlocked(unlocked)
.setComfortValue(calComfort());
this.reassignIfNull();
this.deployFurnitureList.forEach(f -> proto.addDeployFurniureList(f.toProto()));
this.persistentFurnitureList.forEach(f -> proto.addPersistentFurnitureList(f.toProto()));
this.deployAnimalList.forEach(f -> proto.addDeployAnimalList(f.toProto()));
@@ -84,4 +89,26 @@ public class HomeBlockItem {
return proto.build();
}
// TODO add more types (farm field and suite)
public List<? extends HomeMarkPointProtoFactory> getMarkPointProtoFactories() {
this.reassignIfNull();
return Stream.of(this.deployFurnitureList, this.persistentFurnitureList, this.deployNPCList).flatMap(Collection::stream).toList();
}
public void reassignIfNull() {
if (this.deployFurnitureList == null) {
this.deployFurnitureList = List.of();
}
if (this.persistentFurnitureList == null) {
this.persistentFurnitureList = List.of();
}
if (this.deployAnimalList == null) {
this.deployAnimalList = List.of();
}
if (this.deployNPCList == null) {
this.deployNPCList = List.of();
}
}
}