/// <summary> /// Save this behavior to a definition. This function can be overwritten /// to customize the definition, but note that this will invalidate all /// the rules for saving objects. Also do not call base.saveToDefinition /// if this function is overwritten. /// </summary> /// <returns>A new BehaviorDefinition.</returns> public override sealed SimElementDefinition saveToDefinition() { BehaviorDefinition definition = new BehaviorDefinition(Name, MemberCopier.CreateCopy <Behavior>(this)); return(definition); }
/// <summary> /// Add a BehaviorDefinition to be constructed by this factory. /// </summary> /// <param name="instance">The SimObject instance to add the behavior to.</param> /// <param name="behaviorDefinition">The BehaviorDefinition to build.</param> internal void addBehaviorDefinition(SimObjectBase instance, BehaviorDefinition behaviorDefinition) { currentBehaviors.Add(new BehaviorFactoryEntry(instance, behaviorDefinition)); }
/// <summary> /// Constructor. /// </summary> /// <param name="instance">The SimObject that will have the product constructed added to it.</param> /// <param name="definition">The definition class that will build part of the sim object.</param> public BehaviorFactoryEntry(SimObjectBase instance, BehaviorDefinition definition) { this.instance = instance; this.definition = definition; this.createdBehavior = null; }