create all the model needed

This commit is contained in:
Giovanni committed 2026-09-07 16:15:36 +02:00
1 parent ce7bdfde2e
commit 6100b9ebac
8 files changed
+178

No files matched your search

@@ -0,0 +1,27 @@
//
// AttributeDefinition.swift
// WorldBuilder
//
// Created by Giovanni Josserand on 06/09/2026.
//
import SwiftData
import Foundation
@Model
class AttributeDefinition {
var id: UUID
var createdAt: Date
var updatedAt: Date
var name : String
var type : AttributeType
init(name: String, type: AttributeType){
self.id = UUID()
self.createdAt = Date()
self.updatedAt = Date()
self.name = name
self.type = type
}
}
+14
View File
@@ -0,0 +1,14 @@
//
// AttributeType.swift
// WorldBuilder
//
// Created by Giovanni Josserand on 06/09/2026.
//
enum AttributeType : nonisolated Codable {
case string
case int
case double
case bool
case date
}
+33
View File
@@ -0,0 +1,33 @@
//
// Entity.swift
// WorldBuilder
//
// Created by Giovanni Josserand on 05/09/2026.
//
import SwiftData
import Foundation
@Model
class Entity {
var id : UUID
var createdAt : Date
var updatedAt : Date
var name : String
var world : World
var worldEntityType : WorldEntityType
@Relationship var enabledLocalAttributeDefinitions = [AttributeDefinition]()
@Relationship var personalAttributeDefinitions = [AttributeDefinition]()
init(name: String, world: World, worldEntityType: WorldEntityType){
self.id = UUID()
self.createdAt = Date()
self.updatedAt = Date()
self.name = name
self.world = world
self.worldEntityType = worldEntityType
}
}
+27
View File
@@ -0,0 +1,27 @@
//
// EntityType.swift
// WorldBuilder
//
// Created by Giovanni Josserand on 05/09/2026.
//
import SwiftData
import Foundation
@Model
class EntityType {
var id : UUID
var createdAt : Date
var updatedAt : Date
var name : String
@Relationship var globalAttributeDefinitions = [AttributeDefinition]()
init(name: String) {
self.id = UUID()
self.createdAt = Date()
self.updatedAt = Date()
self.name = name
}
}
+31
View File
@@ -0,0 +1,31 @@
//
// Relation.swift
// WorldBuilder
//
// Created by Giovanni Josserand on 06/09/2026.
//
import SwiftData
import Foundation
@Model
class Relation{
var id : UUID
var createdAt : Date
var updatedAt : Date
var label : String
var source : RelationEndpoint
var target : RelationEndpoint
var world : World
init(label: String, source : RelationEndpoint, target : RelationEndpoint, world : World){
self.id = UUID()
self.createdAt = Date()
self.updatedAt = Date()
self.label = label
self.source = source
self.target = target
self.world = world
}
}
@@ -0,0 +1,14 @@
//
// RelationEndpoint.swift
// WorldBuilder
//
// Created by Giovanni Josserand on 06/09/2026.
//
import Foundation
enum RelationEndpoint : nonisolated Codable, Equatable {
case entityType(id: UUID)
case worldEntityType(id: UUID)
case entity(id: UUID)
}
+3
View File
@@ -13,9 +13,12 @@ class World {
var id : UUID
var createdAt : Date
var updatedAt : Date
var name : String
var overview : String
@Attribute(.externalStorage) var illustrationData : Data?
@Relationship var relations = [Relation]()
init(name: String, overview: String, illustrationData: Data?) {
self.id = UUID()
+29
View File
@@ -0,0 +1,29 @@
//
// WorldEntityType.swift
// WorldBuilder
//
// Created by Giovanni Josserand on 06/09/2026.
//
import SwiftData
import Foundation
@Model
class WorldEntityType {
var id : UUID
var createdAt : Date
var updatedAt : Date
var world : World
var entityType : EntityType
@Relationship var enabledGlobalAttributeDefinitions = [AttributeDefinition]()
@Relationship var localAttributeDefinitions = [AttributeDefinition]()
init(world: World, entityType: EntityType){
self.id = UUID()
self.createdAt = Date()
self.updatedAt = Date()
self.world = world
self.entityType = entityType
}
}