public void SetProperty(string propertyName, PropEditor value) { using (this.assignedBrain.StartUndo($"Set {propertyName}")) { var assigns = GetUse().propertyAssignments.DeepClone(); int i = assigns.IndexOfWhere(pa => pa.propertyName == propertyName); if (i == -1) { // Add new prop i = assigns.Length; var assignList = assigns.ToList(); assignList.Add(new PropertyAssignment()); assigns = assignList.ToArray(); } assigns[i] = PropUtil.ToAssignment(value); Debug.Assert(assigns[i].propertyName == propertyName); assignedBrain.SetProperties(this, assigns); } }
bool IsRelevantField(PropEditor fieldData) { return(implementedTypes.Contains(fieldData.propType)); }
// HACK: I don't like making this public. This is used from CardPanel. // The right way to do this would be for this logic to be implemented at a lower level, // not at the UI level. public bool ShouldShowField(PropEditor editor) { PropDefRequirement[] requires = editor.requires; return(AreRequirementsFulfilled(requires)); }
void SpawnField(PropEditor propEditor) { PropertyField newField = null; switch (propEditor.propType) { case PropType.Number: NumberPropertyField numberPropertyField = Instantiate(numberPropertyFieldPrefab, fieldParent); numberPropertyField.onValueChanged += (n) => HandleValueChange(PropType.Number); newField = numberPropertyField; break; case PropType.Decimal: DecimalField decimalField = Instantiate(decimalFieldPrefab, fieldParent); decimalField.onValueChanged += (n) => HandleValueChange(PropType.Decimal); newField = decimalField; break; case PropType.Boolean: BooleanField booleanField = Instantiate(booleanFieldPrefab, fieldParent); booleanField.onValueChanged += (b) => HandleValueChange(PropType.Boolean); newField = booleanField; break; case PropType.String: StringPropertyField stringPropertyField = Instantiate(stringPropertyFieldPrefab, fieldParent); stringPropertyField.onValueChanged += (s) => HandleValueChange(PropType.String); newField = stringPropertyField; break; case PropType.Actor: ActorPropertyField actorPropertyField = Instantiate(actorPropertyFieldPrefab, fieldParent); actorPropertyField.onValueChanged += (a) => HandleValueChange(PropType.Actor); newField = actorPropertyField; break; case PropType.Sound: SoundField soundField = Instantiate(soundFieldPrefab, fieldParent); soundField.onValueChanged += (a) => HandleValueChange(PropType.Sound); newField = soundField; break; case PropType.ParticleEffect: ParticleField particleField = Instantiate(particleFieldPrefab, fieldParent); particleField.onValueChanged += (a) => HandleValueChange(PropType.ParticleEffect); newField = particleField; break; case PropType.ActorGroup: ActorGroupField actorGroupField = Instantiate(actorGroupFieldPrefab, fieldParent); actorGroupField.onValueChanged += (a) => HandleValueChange(PropType.ActorGroup); newField = actorGroupField; break; case PropType.Image: ImageField imageField = Instantiate(imageFieldPrefab, fieldParent); imageField.onValueChanged += (a) => HandleValueChange(PropType.Image); newField = imageField; break; case PropType.Color: ColorProp colorField = Instantiate(colorFieldPrefab, fieldParent); colorField.onValueChanged += (a) => HandleValueChange(PropType.Color); newField = colorField; break; case PropType.Enum: EnumPropertyField enumPropertyField = Instantiate(enumPropertyFieldPrefab, fieldParent); enumPropertyField.onValueChanged += (a) => HandleValueChange(PropType.Enum); newField = enumPropertyField; break; case PropType.NumberArray: NumberArrayPropertyField numberArrayPropertyField = Instantiate(numberArrayPropertyFieldPrefab, fieldParent); numberArrayPropertyField.onValueChanged += (n) => HandleValueChange(PropType.NumberArray); newField = numberArrayPropertyField; break; case PropType.StringArray: StringArrayPropertyField stringArrayPropertyField = Instantiate(stringArrayPropertyFieldPrefab, fieldParent); stringArrayPropertyField.onValueChanged += (s) => HandleValueChange(PropType.StringArray); newField = stringArrayPropertyField; break; case PropType.EnumArray: EnumArrayPropertyField enumArrayPropertyField = Instantiate(enumArrayPropertyFieldPrefab, fieldParent); enumArrayPropertyField.onValueChanged += (s) => HandleValueChange(PropType.EnumArray); newField = enumArrayPropertyField; break; case PropType.ActorArray: ActorArrayPropertyField actorArrayPropertyField = Instantiate(actorArrayPropertyFieldPrefab, fieldParent); actorArrayPropertyField.onValueChanged += (s) => HandleValueChange(PropType.ActorArray); newField = actorArrayPropertyField; break; } // if(newField == null) fieldList.Add(newField); newField?.Setup(propEditor); if (previewOverlay != null) { previewOverlay.transform.SetAsLastSibling(); } UpdateFieldVisibility(); }
// Ie. represents the same property, but maybe has a different value. public bool IsSameProperty(PropEditor other) { return(this.propDef.variableName == other.propDef.variableName && this.propType == other.propType); }
public void Setup(PropEditor editor) { this.editor = editor; Initialize(); }
// TODO rewrite as just.. ToAssignment(PropEditor editable) public static PropertyAssignment ToAssignment(PropEditor editable) { var assign = new PropertyAssignment(); assign.propertyName = editable.propDef.variableName; switch (editable.propType) { case PropType.Number: assign.SetValue <int>((int)editable.data); break; case PropType.Decimal: assign.SetValue <float>((float)editable.data); break; case PropType.Boolean: assign.SetValue <bool>((bool)editable.data); break; case PropType.String: assign.SetValue <string>((string)editable.data); break; case PropType.CardDeck: assign.SetValue <string[]>((string[])editable.data); break; case PropType.Actor: if (editable.data == null) { assign.SetValue <string>(null); } else { assign.SetValue <string>((string)editable.data); } break; case PropType.Sound: assign.SetValue <string>((string)editable.data); break; case PropType.ParticleEffect: assign.SetValue <string>((string)editable.data); break; case PropType.Prefab: assign.SetValue <string>((string)editable.data); break; case PropType.ActorGroup: assign.SetValue <string>((string)editable.data); break; case PropType.Image: assign.SetValue <string>((string)editable.data); break; case PropType.Color: assign.SetValue <string>((string)editable.data); break; case PropType.Enum: assign.SetValue <string>((string)editable.data); break; case PropType.NumberArray: assign.SetValue <int[]>((int[])editable.data); break; case PropType.StringArray: case PropType.EnumArray: case PropType.ActorArray: assign.SetValue <string[]>((string[])editable.data); break; default: throw new System.NotImplementedException(); } return(assign); }
public Deck(PropEditor deckEditor, ActorBehaviorsEditor actorBehaviorsEditor, BehaviorCards.ManagerImpl manager) { this.deckEditor = deckEditor; this.actorBehaviorsEditor = actorBehaviorsEditor; this.manager = manager; }