Пример #1
0
        public EntityDefinition Create(EntityDefinition create)
        {
            if (!allowDuplicates && RepositoryContains(create.contentName))
            {
                UnityEngine.Debug.Log("Entity Definition Repository already contains a definition for " + create.contentName);
                return(null);
            }

            EntityDefinitionBuilder builder    = new EntityDefinitionBuilder();
            EntityDefinition        definition = builder.Create(create.contentName, create.requiredBehaviourTypes);

            definition.Load(create);
            Add(definition);

            return(definition);
        }
Пример #2
0
        public override void Load(EntityDefinition load)
        {
            contentName = load.contentName;
            for (int i = 0; i < load.requiredBehaviours.Count; i++)
            {
                EntityBehaviourDefinition behaviourRequired = load.requiredBehaviours[i];
                for (int j = 0; j < requiredBehaviours.Count; j++)
                {
                    EntityBehaviourDefinition existingBehaviour = requiredBehaviours[j];
                    if (behaviourRequired.behaviourType == existingBehaviour.behaviourType)
                    {
                        existingBehaviour.Load(behaviourRequired);
                        break;
                    }
                }

                // create the behaviour
                EntityDefinitionBuilder   builder            = new EntityDefinitionBuilder();
                EntityBehaviourDefinition behaviourDefintion = builder.AddBehaviourToEntityDefinition(this, behaviourRequired.behaviourType);
                behaviourDefintion.Load(behaviourRequired);
            }
        }