InitEntityEngine()
CreateEntityType("Door")
AddPropertyToEntType("Door", "Dynamic", "Bool", "True")
do
DisplayAllEntTypes()
loop
Type EntityProperty
Name as string
Type as string
Value as string
EndType
Type Entity
Type as string
PropertyCount as integer
EndType
Type EntityType
Type as string
PropertyCount as integer
EndType
Function InitEntityEngine()
Global EntityTypeCount as integer
Global EntityCount as integer
MaxEntities = 1000:MaxEntityTypes = 100:MaxProperties = 100
Dim Entity(MaxEntities) as entity
Dim EntityProperty(MaxEntities, MaxProperties) as EntityProperty
Dim EntityTypeProperty(MaxEntityTypes, MaxProperties) as EntityProperty
Dim EntityType(MaxEntityTypes) as EntityType
EndFunction
`Creates an entity type
Function CreateEntityType(EntType as string)
`Get entity type num
Inc EntityTypeCount
EntTypeNum = EntityTypeCount
`Create the entity type
EntityType(EntTypeNum).Type = EntType
EndFunction
`Adds a property to an entity type
Function AddPropertyToEntType(EntType as string, PropertyName as string, PropertyType as string, PropertyValue as string)
`Find the entity number
TypeNum = GetEntityTypeNum(EntType)
`Now set the property to that type
Inc EntityType(TypeNum).PropertyCount
EntityTypeProperty(TypeNum, EntityType(TypeNum).PropertyCount).Name = PropertyName
EntityTypeProperty(TypeNum, EntityType(TypeNum).PropertyCount).Type = PropertyType
EntityTypeProperty(TypeNum, EntityType(TypeNum).PropertyCount).Value = PropertyValue
EndFunction
`Sets an entity to be of a type (Actualy syncronises the properties from the specified type to the entity)
Function SetEntityType(Entity as integer, EntityTypeName as string)
EndFunction
`Gets the entity type name
Function GetEntityTypeNum(TypeName as string)
`Loop through all the possible types
For TypeNum = 1 to EntityTypeCount
`Check if the type name entered int the function is the same as this types
If EntityType(TypeNum).Type = TypeName
`Found the type number
TypeNumber = TypeNum
EndIf
Next TypeNum
EndFunction TypeNumber
Function DisplayAllEntTypes()
For i = 1 to EntityTypeCount
If EntityType(i).Type <> ""
X1 = X1 + 15
Text 1, X1, EntityType(i).Type
For x = 1 to EntityType(i).PropertyCount
X1 = X1 + 15
Text 4, X1, EntityTypeProperty(i, x).Name + " : " +EntityTypeProperty(i, x).Value
Next x
EndIf
next i
EndFunction
Beware, Killing chavs is not a crime, but is the only way to cure the earth
Vist www.scratchyrice-dev.co.uk