mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 17:05:20 +01:00
feat: add more home mark point (#2323)
This commit is contained in:
@@ -11,12 +11,24 @@ import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
@Builder(builderMethodName = "of")
|
||||
public class HomeFurnitureItem {
|
||||
public class HomeFurnitureItem implements HomeMarkPointProtoFactory {
|
||||
public static final int PAIMON_FURNITURE_ID = 368134;
|
||||
public static final int TELEPORT_FURNITURE_ID = 373501;
|
||||
public static final Set<Integer> APARTMENT_FURNITURE_ID_SET = GameData.getItemDataMap().values()
|
||||
.stream()
|
||||
.filter(itemData -> itemData.getSpecialFurnitureType() == SpecialFurnitureType.Apartment)
|
||||
.map(ItemData::getId)
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
int furnitureId;
|
||||
int guid;
|
||||
int parentFurnitureIndex;
|
||||
@@ -56,17 +68,6 @@ public class HomeFurnitureItem {
|
||||
.build();
|
||||
}
|
||||
|
||||
public HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData toMarkPointProto(
|
||||
int type) {
|
||||
return HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData.newBuilder()
|
||||
.setFurnitureId(furnitureId)
|
||||
.setGuid(guid)
|
||||
.setFurnitureType(type)
|
||||
.setPos(spawnPos.toProto())
|
||||
// TODO NPC and farm
|
||||
.build();
|
||||
}
|
||||
|
||||
public ItemData getAsItem() {
|
||||
return GameData.getItemDataMap().get(this.furnitureId);
|
||||
}
|
||||
@@ -79,4 +80,29 @@ public class HomeFurnitureItem {
|
||||
}
|
||||
return item.getComfort();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData toMarkPointProto() {
|
||||
var type = this.adjustByFurnitureId();
|
||||
if (type == SpecialFurnitureType.NOT_SPECIAL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData.newBuilder()
|
||||
.setFurnitureId(this.furnitureId)
|
||||
.setFurnitureType(type.getValue())
|
||||
.setPos(this.spawnPos.toProto())
|
||||
.setGuid(this.guid)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpecialFurnitureType adjustByFurnitureId() {
|
||||
return switch (this.furnitureId) {
|
||||
case PAIMON_FURNITURE_ID -> SpecialFurnitureType.Paimon;
|
||||
case TELEPORT_FURNITURE_ID -> SpecialFurnitureType.TeleportPoint;
|
||||
default -> APARTMENT_FURNITURE_ID_SET.contains(this.furnitureId) ? SpecialFurnitureType.Apartment : SpecialFurnitureType.NOT_SPECIAL;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user