internal Behavior createProduct(SimObjectBase instance, BehaviorManager behaviorManager, bool copyBehavior) { Behavior behavior; if (copyBehavior) { behavior = MemberCopier.CreateCopy <Behavior>(behaviorTemplate); } else { behavior = behaviorTemplate; } behavior.setAttributes(Name, behaviorManager); instance.addElement(behavior); return(behavior); }
/// <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); }