public virtual ICollection <Property> Properties() { return(new Property[] { new Property("tar", "Target", () => new BehaviorTargetProperty(targetEntity, targetEntityIsActivator), v => { var prop = (BehaviorTargetProperty)v; // selfEntity will be null if multiple entities are selected Entity selfEntity = EntityReferencePropertyManager.CurrentEntity(); var oldTargetEntity = targetEntity.entity; var newTargetEntity = prop.targetEntity.entity; if (oldTargetEntity == null && !targetEntityIsActivator) { oldTargetEntity = selfEntity; } if (newTargetEntity == null && !prop.targetEntityIsActivator) { newTargetEntity = selfEntity; } if (oldTargetEntity != null) { // replace all property values referencing the old target with the new target // the new target could be null foreach (Property _selfProp in this.Properties()) { var selfProp = _selfProp; selfProp.value = PropertiesObjectType.PropertyValueReplaceEntity( selfProp.value, oldTargetEntity, newTargetEntity); } } targetEntity = prop.targetEntity; targetEntityIsActivator = prop.targetEntityIsActivator; }, PropertyGUIs.BehaviorTarget), new Property("con", "Condition", () => condition, v => condition = (Condition)v, (Property property) => { if (targetEntityIsActivator) { PropertyGUIs.ActivatorBehaviorCondition(property); } else { PropertyGUIs.BehaviorCondition(property); } }) }); }
public override IEnumerable <Property> Properties() { return(new Property[] { new Property("tar", "Target", () => target, v => { var prop = (BehaviorTargetProperty)v; // selfEntity will be null if multiple entities are selected Entity selfEntity = EntityReferencePropertyManager.CurrentEntity(); var oldTargetEntity = target.GetEntity(selfEntity); var newTargetEntity = prop.GetEntity(selfEntity); if (oldTargetEntity != null) { // replace all property values referencing the old target with the new target // the new target could be null foreach (Property _selfProp in this.Properties()) { var selfProp = _selfProp; selfProp.value = PropertiesObject.PropertyValueReplaceEntity( selfProp.value, oldTargetEntity, newTargetEntity); } } target = prop; }, PropertyGUIs.BehaviorTarget), new Property("con", "Condition", () => condition, v => condition = (Condition)v, (Property property) => { if (target.targetEntityIsActivator) { PropertyGUIs.ActivatorBehaviorCondition(property); } else { PropertyGUIs.BehaviorCondition(property); } }) }); }