예제 #1
0
 public override ICollection <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("loc", "To",
                      () => target,
                      v => target = (EntityReference)v,
                      PropertyGUIs.EntityReference),
         new Property("rel", "Relative to",
                      () => origin,
                      v => origin = (EntityReference)v,
                      (Property property) => {
             var reference = (EntityReference)property.value;
             if (reference.entity == null)
             {
                 if (targetEntity.entity != null)
                 {
                     property.value = targetEntity;
                 }
                 else if (!targetEntityIsActivator)
                 {
                     // TODO: this is not a good solution
                     property.value = new EntityReference(
                         EntityReferencePropertyManager.CurrentEntity());
                 }
             }
             PropertyGUIs._EntityReferenceCustom(property, targetEntityIsActivator,
                                                 targetEntityIsActivator ? "Activator" : "None");
         })
     }));
 }
예제 #2
0
 public static void BehaviorTarget(Property property)
 {
     var value = (EntityBehavior.BehaviorTargetProperty)(property.value);
     Entity behaviorTarget = value.targetEntity.entity;
     string text;
     if (value.targetEntityIsActivator)
     {
         text = "Activators";
     }
     else if (behaviorTarget != null)
     {
         // only temporarily, so the name won't be "Target":
         EntityReferencePropertyManager.SetBehaviorTarget(null);
         EntityReferencePropertyManager.Next(behaviorTarget);
         text = EntityReferencePropertyManager.GetName();
         EntityReferencePropertyManager.SetBehaviorTarget(behaviorTarget); // put it back
     }
     else
     {
         return;
     }
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     GUILayout.Label(GUIIconSet.instance.target, alignedLabelStyle.Value, GUILayout.ExpandWidth(false));
     if (GUILayout.Button("<i>" + text + "</i>", GUILayout.ExpandWidth(false)))
     {
         BehaviorTargetPicker(GUIPanel.guiGameObject, VoxelArrayEditor.instance,
             EntityReferencePropertyManager.CurrentEntity(), newValue =>
             {
                 property.value = newValue;
             });
     }
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
 }
예제 #3
0
 public override IEnumerable <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("loc", "To",
                      () => dest,
                      v => dest = (EntityReference)v,
                      PropertyGUIs.EntityReference),
         new Property("rel", "Relative to",
                      () => origin,
                      v => origin = (EntityReference)v,
                      (Property property) => {
             var reference = (EntityReference)property.value;
             // TODO: this is not a good solution
             Entity targetEntity = target.GetEntity(
                 EntityReferencePropertyManager.CurrentEntity());
             if (reference.entity == null && targetEntity != null)
             {
                 property.value = new EntityReference(targetEntity);
             }
             PropertyGUIs._EntityReferenceCustom(property, targetEntity == null,
                                                 targetEntity == null ? "Activator" : "None");
         })
     }));
 }
예제 #4
0
    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);
                }
            })
        });
    }
예제 #5
0
    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);
                }
            })
        });
    }