/ src / models / cell_converter.go
cell_converter.go
 1  package models
 2  
 3  import (
 4  	"time"
 5  
 6  	"github.com/google/uuid"
 7  )
 8  
 9  // ConvertToSystemsCell converts a models.Cell to a systems.Cell-compatible structure.
10  // This function should be called when passing a cell from the Colony to any function
11  // that expects a systems.Cell.
12  func (c *Cell) ConvertToSystemsCell() *Cell {
13  	// Since the systems.Cell uses the models.Cell as its base,
14  	// we just need to ensure all fields are properly initialized
15  	if c.Thoughts == nil {
16  		c.Thoughts = make([]Thought, 0)
17  	}
18  	if c.CompressedMemories == nil {
19  		c.CompressedMemories = make([]string, 0)
20  	}
21  	if c.Neighbors == nil {
22  		c.Neighbors = make([]uuid.UUID, 0)
23  	}
24  	if c.ResearchTopics == nil {
25  		c.ResearchTopics = make([]string, 0)
26  	}
27  	if c.LastContextUpdate == nil {
28  		now := time.Now()
29  		c.LastContextUpdate = &now
30  	}
31  
32  	return c
33  }
34  
35  // Note: NeighborDistanceThreshold is already defined in constants.go