diff --git a/Assets/Base/CustomTexture.cs b/Assets/Base/CustomTexture.cs index 71170f90..450ec4a6 100644 --- a/Assets/Base/CustomTexture.cs +++ b/Assets/Base/CustomTexture.cs @@ -5,7 +5,11 @@ public class CustomTexture : PropertiesObject { public static PropertiesObjectType objectType = new PropertiesObjectType( - "Custom Texture", s => s.CustomTextureDesc, "image", typeof(CustomTexture)); + "Custom Texture", typeof(CustomTexture)) + { + description = s => s.CustomTextureDesc, + iconName = "image", + }; public PropertiesObjectType ObjectType => objectType; public enum CustomFilter diff --git a/Assets/Base/Entity.cs b/Assets/Base/Entity.cs index 78d7f7eb..514bf01b 100644 --- a/Assets/Base/Entity.cs +++ b/Assets/Base/Entity.cs @@ -47,19 +47,24 @@ public static IEnumerable JoinProperties( // with all the missing data (this is done by Filter) public class PropertiesObjectType { - public static readonly PropertiesObjectType NONE = - new PropertiesObjectType("None", GUIStringSet.Empty, "cancel", null); + public static readonly PropertiesObjectType NONE = new PropertiesObjectType("None", null) + { iconName = "cancel" }; - public string fullName; // not readonly so it can be serialized + // This name is used for identifying types and for error messages if a type is not recognized. + // It is always in English (not localized) and can never change. + public string fullName; + + [XmlIgnore] + public readonly Type type; [XmlIgnore] - public readonly Localizer description; + public Func constructor; + [XmlIgnore] - public readonly Localizer longDescription; + public Localizer description = GUIStringSet.Empty; [XmlIgnore] - public readonly string iconName; + public Localizer longDescription = GUIStringSet.Empty; [XmlIgnore] - public readonly Type type; - private readonly Func constructor; + public string iconName = ""; private Texture _icon; public Texture icon @@ -73,47 +78,25 @@ public Texture icon } // empty constructor for deserialization - public PropertiesObjectType() { } - - public PropertiesObjectType(string fullName, Type type) + public PropertiesObjectType() { - this.fullName = fullName; - description = GUIStringSet.Empty; - longDescription = GUIStringSet.Empty; - iconName = ""; - this.type = type; constructor = DefaultConstructor; } - public PropertiesObjectType(string fullName, Localizer description, string iconName, - Type type, Func constructor = null) - { - this.fullName = fullName; - this.description = description; - longDescription = GUIStringSet.Empty; - this.iconName = iconName; - this.type = type; - this.constructor = constructor ?? DefaultConstructor; - } - - public PropertiesObjectType(string fullName, Localizer description, Localizer longDescription, - string iconName, Type type, Func constructor = null) + public PropertiesObjectType(string fullName, Type type) { this.fullName = fullName; - this.description = description; - this.longDescription = longDescription; - this.iconName = iconName; this.type = type; - this.constructor = constructor ?? DefaultConstructor; + constructor = DefaultConstructor; } public PropertiesObjectType(PropertiesObjectType baseType, Func newConstructor) { - this.fullName = baseType.fullName; - this.description = baseType.description; - this.longDescription = baseType.longDescription; - this.iconName = baseType.iconName; - this.type = baseType.type; + fullName = baseType.fullName; + description = baseType.description; + longDescription = baseType.longDescription; + iconName = baseType.iconName; + type = baseType.type; constructor = newConstructor; } @@ -190,7 +173,8 @@ public interface PropertiesObject public abstract class Entity : PropertiesObject { public static PropertiesObjectType objectType = new PropertiesObjectType( - "Anything", GUIStringSet.Empty, "circle-outline", typeof(Entity)); + "Anything", typeof(Entity)) + { iconName = "circle-outline" }; public EntityComponent component; public Sensor sensor; @@ -562,27 +546,11 @@ public virtual void LastBehaviorDisabled() { } public class BehaviorType : PropertiesObjectType { - public readonly Predicate rule; + public Predicate rule = DefaultRule; public BehaviorType(string fullName, Type type) : base(fullName, type) - { - this.rule = DefaultRule; - } - - public BehaviorType(string fullName, Localizer description, string iconName, Type type, - Predicate rule = null) - : base(fullName, description, iconName, type) - { - this.rule = rule ?? DefaultRule; - } - - public BehaviorType(string fullName, Localizer description, Localizer longDescription, - string iconName, Type type, Predicate rule = null) - : base(fullName, description, longDescription, iconName, type) - { - this.rule = rule ?? DefaultRule; - } + { } private static bool DefaultRule(Entity checkEntity) => true; diff --git a/Assets/Base/Object.cs b/Assets/Base/Object.cs index e5ec0a71..afb45933 100644 --- a/Assets/Base/Object.cs +++ b/Assets/Base/Object.cs @@ -4,7 +4,11 @@ public abstract class ObjectEntity : DynamicEntity { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Object", s => s.ObjectDesc, "circle", typeof(ObjectEntity)); + "Object", typeof(ObjectEntity)) + { + description = s => s.ObjectDesc, + iconName = "circle", + }; public override PropertiesObjectType ObjectType => objectType; public ObjectMarker marker; diff --git a/Assets/Base/Substance.cs b/Assets/Base/Substance.cs index 3b9de954..b182e760 100644 --- a/Assets/Base/Substance.cs +++ b/Assets/Base/Substance.cs @@ -10,8 +10,12 @@ public enum Pos { Min, Center, Max }; public class Substance : DynamicEntity { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Substance", s => s.SubstanceDesc, s => s.SubstanceLongDesc, "cube-outline", - typeof(Substance)); + "Substance", typeof(Substance)) + { + description = s => s.SubstanceDesc, + longDescription = s => s.SubstanceLongDesc, + iconName = "cube-outline", + }; public override PropertiesObjectType ObjectType => objectType; public Pivot pivot = new Pivot { x = Pivot.Pos.Center, y = Pivot.Pos.Center, z = Pivot.Pos.Center }; diff --git a/Assets/Base/WorldProperties.cs b/Assets/Base/WorldProperties.cs index 377562f3..6cb05e8b 100644 --- a/Assets/Base/WorldProperties.cs +++ b/Assets/Base/WorldProperties.cs @@ -13,7 +13,11 @@ public class WorldProperties : PropertiesObject }; public static PropertiesObjectType objectType = new PropertiesObjectType( - "World", s => s.WorldDesc, "earth", typeof(WorldProperties)); + "World", typeof(WorldProperties)) + { + description = s => s.WorldDesc, + iconName = "earth", + }; public PropertiesObjectType ObjectType => objectType; public void SetSky(Material sky) diff --git a/Assets/Behaviors/Carryable.cs b/Assets/Behaviors/Carryable.cs index 53c060e1..2121341c 100644 --- a/Assets/Behaviors/Carryable.cs +++ b/Assets/Behaviors/Carryable.cs @@ -5,11 +5,15 @@ public class CarryableBehavior : GenericEntityBehavior { public static new BehaviorType objectType = new BehaviorType( - "Carryable", s => s.CarryableDesc, s => s.CarryableLongDesc, "coffee", - typeof(CarryableBehavior), - BehaviorType.AndRule( + "Carryable", typeof(CarryableBehavior)) + { + description = s => s.CarryableDesc, + longDescription = s => s.CarryableLongDesc, + iconName = "coffee", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; public float throwSpeed = 0; diff --git a/Assets/Behaviors/CharacterComponent.cs b/Assets/Behaviors/CharacterComponent.cs index 1b8aba09..b1d23b30 100644 --- a/Assets/Behaviors/CharacterComponent.cs +++ b/Assets/Behaviors/CharacterComponent.cs @@ -4,11 +4,15 @@ public class CharacterBehavior : BasePhysicsBehavior { public static new BehaviorType objectType = new BehaviorType( - "Character", s => s.CharacterDesc, s => s.CharacterLongDesc, "human", - typeof(CharacterBehavior), - BehaviorType.AndRule( + "Character", typeof(CharacterBehavior)) + { + description = s => s.CharacterDesc, + longDescription = s => s.CharacterLongDesc, + iconName = "human", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; public override IEnumerable Properties() => diff --git a/Assets/Behaviors/Clone.cs b/Assets/Behaviors/Clone.cs index d4f38fc2..217c2d11 100644 --- a/Assets/Behaviors/Clone.cs +++ b/Assets/Behaviors/Clone.cs @@ -2,11 +2,15 @@ public class CloneBehavior : TeleportBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Clone", s => s.CloneDesc, s => s.CloneLongDesc, "content-copy", typeof(CloneBehavior), - BehaviorType.AndRule( + public static new BehaviorType objectType = new BehaviorType("Clone", typeof(CloneBehavior)) + { + description = s => s.CloneDesc, + longDescription = s => s.CloneLongDesc, + iconName = "content-copy", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; public override Behaviour MakeComponent(GameObject gameObject) diff --git a/Assets/Behaviors/Force.cs b/Assets/Behaviors/Force.cs index 10452370..bc672116 100644 --- a/Assets/Behaviors/Force.cs +++ b/Assets/Behaviors/Force.cs @@ -8,9 +8,13 @@ public enum ForceBehaviorMode IMPULSE, CONTINUOUS } - public static new BehaviorType objectType = new BehaviorType( - "Force", s => s.ForceDesc, s => s.ForceLongDesc, "rocket", typeof(ForceBehavior), - BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + public static new BehaviorType objectType = new BehaviorType("Force", typeof(ForceBehavior)) + { + description = s => s.ForceDesc, + longDescription = s => s.ForceLongDesc, + iconName = "rocket", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public ForceBehaviorMode mode = ForceBehaviorMode.CONTINUOUS; diff --git a/Assets/Behaviors/HaloComponent.cs b/Assets/Behaviors/HaloComponent.cs index a8411dc6..ea4c6d62 100644 --- a/Assets/Behaviors/HaloComponent.cs +++ b/Assets/Behaviors/HaloComponent.cs @@ -4,8 +4,12 @@ [EditorPreviewBehavior] public class HaloBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Halo", s => s.HaloDesc, s => s.HaloLongDesc, "blur", typeof(HaloBehavior)); + public static new BehaviorType objectType = new BehaviorType("Halo", typeof(HaloBehavior)) + { + description = s => s.HaloDesc, + longDescription = s => s.HaloLongDesc, + iconName = "blur", + }; public override BehaviorType BehaviorObjectType => objectType; public float size = 3; diff --git a/Assets/Behaviors/HurtHeal.cs b/Assets/Behaviors/HurtHeal.cs index 04cf2b08..a5d55f9e 100644 --- a/Assets/Behaviors/HurtHeal.cs +++ b/Assets/Behaviors/HurtHeal.cs @@ -4,8 +4,13 @@ public class HurtHealBehavior : GenericEntityBehavior { public static new BehaviorType objectType = new BehaviorType( - "Hurt/Heal", s => s.HurtHealDesc, s => s.HurtHealLongDesc, "heart", - typeof(HurtHealBehavior), BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + "Hurt/Heal", typeof(HurtHealBehavior)) + { + description = s => s.HurtHealDesc, + longDescription = s => s.HurtHealLongDesc, + iconName = "heart", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public float amount = -30; diff --git a/Assets/Behaviors/Joystick.cs b/Assets/Behaviors/Joystick.cs index ca53ecec..c7085679 100644 --- a/Assets/Behaviors/Joystick.cs +++ b/Assets/Behaviors/Joystick.cs @@ -8,10 +8,14 @@ public class JoystickBehavior public enum JoystickAlignment { HORIZONTAL, VERTICAL } public static new BehaviorType objectType = new BehaviorType( - "Joystick", s => s.JoystickDesc, "joystick", typeof(JoystickBehavior), - BehaviorType.AndRule( + "Joystick", typeof(JoystickBehavior)) + { + description = s => s.JoystickDesc, + iconName = "joystick", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; public float speed = 1; diff --git a/Assets/Behaviors/LightComponent.cs b/Assets/Behaviors/LightComponent.cs index 193f38e1..8696b0b0 100644 --- a/Assets/Behaviors/LightComponent.cs +++ b/Assets/Behaviors/LightComponent.cs @@ -4,8 +4,12 @@ [EditorPreviewBehavior] public class LightBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Light", s => s.LightDesc, s => s.LightLongDesc, "lightbulb-on", typeof(LightBehavior)); + public static new BehaviorType objectType = new BehaviorType("Light", typeof(LightBehavior)) + { + description = s => s.LightDesc, + longDescription = s => s.LightLongDesc, + iconName = "lightbulb-on", + }; public override BehaviorType BehaviorObjectType => objectType; public float size = 10, intensity = 1; diff --git a/Assets/Behaviors/LookAt.cs b/Assets/Behaviors/LookAt.cs index 552a9702..5eeb43db 100644 --- a/Assets/Behaviors/LookAt.cs +++ b/Assets/Behaviors/LookAt.cs @@ -3,9 +3,13 @@ public class LookAtBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Look At", s => s.LookAtDesc, s => s.LookAtLongDesc, "compass", typeof(LookAtBehavior), - BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + public static new BehaviorType objectType = new BehaviorType("Look At", typeof(LookAtBehavior)) + { + description = s => s.LookAtDesc, + longDescription = s => s.LookAtLongDesc, + iconName = "compass", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public Target target = new Target(Target.EAST); diff --git a/Assets/Behaviors/Move.cs b/Assets/Behaviors/Move.cs index e335efac..621f8610 100644 --- a/Assets/Behaviors/Move.cs +++ b/Assets/Behaviors/Move.cs @@ -4,8 +4,13 @@ public class MoveBehavior : GenericEntityBehavior { public static new BehaviorType objectType = new BehaviorType( - "Move", s => s.MoveDesc, s => s.MoveLongDesc, "arrow-right-bold-box-outline", - typeof(MoveBehavior), BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + "Move", typeof(MoveBehavior)) + { + description = s => s.MoveDesc, + longDescription = s => s.MoveLongDesc, + iconName = "arrow-right-bold-box-outline", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public Target target = new Target(Target.NORTH); diff --git a/Assets/Behaviors/MoveWith.cs b/Assets/Behaviors/MoveWith.cs index a4c86568..f62a34c8 100644 --- a/Assets/Behaviors/MoveWith.cs +++ b/Assets/Behaviors/MoveWith.cs @@ -4,9 +4,13 @@ public class MoveWithBehavior : GenericEntityBehavior { public static new BehaviorType objectType = new BehaviorType( - "Move With", s => s.MoveWithDesc, s => s.MoveWithLongDesc, "move-resize-variant", - typeof(MoveWithBehavior), - BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + "Move With", typeof(MoveWithBehavior)) + { + description = s => s.MoveWithDesc, + longDescription = s => s.MoveWithLongDesc, + iconName = "move-resize-variant", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public EntityReference target = new EntityReference(null); diff --git a/Assets/Behaviors/PhysicsComponent.cs b/Assets/Behaviors/PhysicsComponent.cs index 47378785..9b06cd90 100644 --- a/Assets/Behaviors/PhysicsComponent.cs +++ b/Assets/Behaviors/PhysicsComponent.cs @@ -10,10 +10,15 @@ public abstract class BasePhysicsBehavior : EntityBehavior public class PhysicsBehavior : BasePhysicsBehavior { public static new BehaviorType objectType = new BehaviorType( - "Physics", s => s.PhysicsDesc, s => s.PhysicsLongDesc, "soccer", typeof(PhysicsBehavior), - BehaviorType.AndRule( + "Physics", typeof(PhysicsBehavior)) + { + description = s => s.PhysicsDesc, + longDescription = s => s.PhysicsLongDesc, + iconName = "soccer", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; public override IEnumerable Properties() => diff --git a/Assets/Behaviors/Reflector.cs b/Assets/Behaviors/Reflector.cs index 63b7fa3f..b5634c58 100644 --- a/Assets/Behaviors/Reflector.cs +++ b/Assets/Behaviors/Reflector.cs @@ -6,8 +6,12 @@ public class ReflectorBehavior : GenericEntityBehavior { public static new BehaviorType objectType = new BehaviorType( - "Reflector", s => s.ReflectorDesc, s => s.ReflectorLongDesc, "mirror", - typeof(ReflectorBehavior)); + "Reflector", typeof(ReflectorBehavior)) + { + description = s => s.ReflectorDesc, + longDescription = s => s.ReflectorLongDesc, + iconName = "mirror", + }; public override BehaviorType BehaviorObjectType => objectType; public float size = 35, intensity = 1; diff --git a/Assets/Behaviors/Scale.cs b/Assets/Behaviors/Scale.cs index 2080f214..4178928a 100644 --- a/Assets/Behaviors/Scale.cs +++ b/Assets/Behaviors/Scale.cs @@ -4,10 +4,15 @@ public class ScaleBehavior : GenericEntityBehavior { public static new BehaviorType objectType = new BehaviorType( - "Scale", s => s.ScaleDesc, s => s.ScaleLongDesc, "resize", typeof(ScaleBehavior), - BehaviorType.AndRule( + "Scale", typeof(ScaleBehavior)) + { + description = s => s.ScaleDesc, + longDescription = s => s.ScaleLongDesc, + iconName = "resize", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; public Vector3 scale = Vector3.one; diff --git a/Assets/Behaviors/Score.cs b/Assets/Behaviors/Score.cs index 2eabd38c..f3a5474c 100644 --- a/Assets/Behaviors/Score.cs +++ b/Assets/Behaviors/Score.cs @@ -2,8 +2,11 @@ public class ScoreBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Score", s => s.ScoreDesc, "counter", typeof(ScoreBehavior)); + public static new BehaviorType objectType = new BehaviorType("Score", typeof(ScoreBehavior)) + { + description = s => s.ScoreDesc, + iconName = "counter" + }; public override BehaviorType BehaviorObjectType => objectType; public int amount = 10; diff --git a/Assets/Behaviors/Solid.cs b/Assets/Behaviors/Solid.cs index 3c9b7e75..7089d737 100644 --- a/Assets/Behaviors/Solid.cs +++ b/Assets/Behaviors/Solid.cs @@ -2,11 +2,14 @@ public class SolidBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Solid", s => s.SolidDesc, "wall", typeof(SolidBehavior), - BehaviorType.AndRule( + public static new BehaviorType objectType = new BehaviorType("Solid", typeof(SolidBehavior)) + { + description = s => s.SolidDesc, + iconName = "wall", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; } diff --git a/Assets/Behaviors/Sound.cs b/Assets/Behaviors/Sound.cs index d9940967..1ed12008 100644 --- a/Assets/Behaviors/Sound.cs +++ b/Assets/Behaviors/Sound.cs @@ -16,8 +16,12 @@ public abstract class BaseSoundBehavior : EntityBehavior public class SoundBehavior : BaseSoundBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Sound", s => s.SoundDesc, s => s.SoundLongDesc, "volume-high", typeof(SoundBehavior)); + public static new BehaviorType objectType = new BehaviorType("Sound", typeof(SoundBehavior)) + { + description = s => s.SoundDesc, + longDescription = s => s.SoundLongDesc, + iconName = "volume-high", + }; public override BehaviorType BehaviorObjectType => objectType; public override IEnumerable Properties() => diff --git a/Assets/Behaviors/Sound3D.cs b/Assets/Behaviors/Sound3D.cs index a6e6bf4b..f8d50f5a 100644 --- a/Assets/Behaviors/Sound3D.cs +++ b/Assets/Behaviors/Sound3D.cs @@ -9,8 +9,13 @@ public enum SpatialSoundMode public class Sound3DBehavior : BaseSoundBehavior { public static new BehaviorType objectType = new BehaviorType( - "3D Sound", s => s.Sound3DDesc, s => s.Sound3DLongDesc, "headphones", - typeof(Sound3DBehavior), BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + "3D Sound", typeof(Sound3DBehavior)) + { + description = s => s.Sound3DDesc, + longDescription = s => s.Sound3DLongDesc, + iconName = "headphones", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public (float, float) distanceRange = (1, 30); diff --git a/Assets/Behaviors/Spin.cs b/Assets/Behaviors/Spin.cs index a3d5ccaa..de8fd00b 100644 --- a/Assets/Behaviors/Spin.cs +++ b/Assets/Behaviors/Spin.cs @@ -3,9 +3,13 @@ public class SpinBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Spin", s => s.SpinDesc, s => s.SpinLongDesc, "format-rotate-90", typeof(SpinBehavior), - BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + public static new BehaviorType objectType = new BehaviorType("Spin", typeof(SpinBehavior)) + { + description = s => s.SpinDesc, + longDescription = s => s.SpinLongDesc, + iconName = "format-rotate-90", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public float speed = 50; diff --git a/Assets/Behaviors/Teleport.cs b/Assets/Behaviors/Teleport.cs index 5ba705c9..d4fec97c 100644 --- a/Assets/Behaviors/Teleport.cs +++ b/Assets/Behaviors/Teleport.cs @@ -4,8 +4,13 @@ public class TeleportBehavior : GenericEntityBehavior { public static new BehaviorType objectType = new BehaviorType( - "Teleport", s => s.TeleportDesc, s => s.TeleportLongDesc, "send", typeof(TeleportBehavior), - BehaviorType.BaseTypeRule(typeof(DynamicEntity))); + "Teleport", typeof(TeleportBehavior)) + { + description = s => s.TeleportDesc, + longDescription = s => s.TeleportLongDesc, + iconName = "send", + rule = BehaviorType.BaseTypeRule(typeof(DynamicEntity)), + }; public override BehaviorType BehaviorObjectType => objectType; public EntityReference target = new EntityReference(null); diff --git a/Assets/Behaviors/Visible.cs b/Assets/Behaviors/Visible.cs index c6c38e49..effc3249 100644 --- a/Assets/Behaviors/Visible.cs +++ b/Assets/Behaviors/Visible.cs @@ -3,11 +3,14 @@ public class VisibleBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Visible", s => s.VisibleDesc, "eye", typeof(VisibleBehavior), - BehaviorType.AndRule( + public static new BehaviorType objectType = new BehaviorType("Visible", typeof(VisibleBehavior)) + { + description = s => s.VisibleDesc, + iconName = "eye", + rule = BehaviorType.AndRule( BehaviorType.BaseTypeRule(typeof(DynamicEntity)), - BehaviorType.NotBaseTypeRule(typeof(PlayerObject)))); + BehaviorType.NotBaseTypeRule(typeof(PlayerObject))), + }; public override BehaviorType BehaviorObjectType => objectType; } diff --git a/Assets/Behaviors/Water.cs b/Assets/Behaviors/Water.cs index c6f3bb1d..5061a0c4 100644 --- a/Assets/Behaviors/Water.cs +++ b/Assets/Behaviors/Water.cs @@ -2,9 +2,13 @@ public class WaterBehavior : GenericEntityBehavior { - public static new BehaviorType objectType = new BehaviorType( - "Water", s => s.WaterDesc, s => s.WaterLongDesc, "water", typeof(WaterBehavior), - BehaviorType.BaseTypeRule(typeof(Substance))); + public static new BehaviorType objectType = new BehaviorType("Water", typeof(WaterBehavior)) + { + description = s => s.WaterDesc, + longDescription = s => s.WaterLongDesc, + iconName = "water", + rule = BehaviorType.BaseTypeRule(typeof(Substance)), + }; public override BehaviorType BehaviorObjectType => objectType; public float density = 1.0f; diff --git a/Assets/GameScripts.cs b/Assets/GameScripts.cs index ef616133..1f543054 100644 --- a/Assets/GameScripts.cs +++ b/Assets/GameScripts.cs @@ -13,37 +13,48 @@ public static PropertiesObjectType FindTypeWithName(PropertiesObjectType[] types public static PropertiesObjectType[] entityTemplates = new PropertiesObjectType[] { - new PropertiesObjectType("Solid Substance", s => s.SolidSubstanceDesc, "wall", - typeof(Substance), - () => { + new PropertiesObjectType("Solid Substance", typeof(Substance)) + { + description = s => s.SolidSubstanceDesc, + iconName = "wall", + constructor = () => { Substance substance = new Substance(); substance.behaviors.Add(new VisibleBehavior()); substance.behaviors.Add(new SolidBehavior()); return substance; - }), - new PropertiesObjectType("Water", s => s.WaterSubstanceDesc, "water", - typeof(Substance), - () => { + }, + }, + new PropertiesObjectType("Water", typeof(Substance)) + { + description = s => s.WaterSubstanceDesc, + iconName = "water", + constructor = () => { Substance substance = new Substance(); substance.behaviors.Add(new VisibleBehavior()); substance.behaviors.Add(new WaterBehavior()); substance.defaultPaint = new VoxelFace(); substance.defaultPaint.overlay = ResourcesDirectory.FindMaterial("WaterBasicDaytime", true); return substance; - }), - new PropertiesObjectType("Trigger", s => s.TriggerDesc, "vector-combine", - typeof(Substance), - () => { + }, + }, + new PropertiesObjectType("Trigger", typeof(Substance)) + { + description = s => s.TriggerDesc, + iconName = "vector-combine", + constructor = () => { Substance substance = new Substance(); substance.sensor = new TouchSensor(); substance.xRay = true; substance.defaultPaint = new VoxelFace(); substance.defaultPaint.overlay = ResourcesDirectory.FindMaterial("Invisible", true); return substance; - }), - new PropertiesObjectType("Glass", s => s.GlassDesc, "window-closed-variant", - typeof(Substance), - () => { + }, + }, + new PropertiesObjectType("Glass", typeof(Substance)) + { + description = s => s.GlassDesc, + iconName = "window-closed-variant", + constructor = () => { Substance substance = new Substance(); substance.behaviors.Add(new VisibleBehavior()); substance.behaviors.Add(new SolidBehavior()); @@ -52,7 +63,8 @@ public static PropertiesObjectType FindTypeWithName(PropertiesObjectType[] types ResourcesDirectory.FindMaterial("GLASS_overlay", true)); substance.defaultPaint.overlay.color = new Color(1, 1, 1, 0.25f); return substance; - }) + }, + }, }; public static PropertiesObjectType[] sensors = new PropertiesObjectType[] @@ -191,19 +203,24 @@ public static string[] BehaviorTabNames(GUIStringSet s) => ball.behaviors.Add(new SolidBehavior()); return ball; }), - new PropertiesObjectType("Empty", s => s.EmptyDesc, "scan-helper", - typeof(BallObject), - () => { + new PropertiesObjectType("Empty", typeof(BallObject)) + { + description = s => s.EmptyDesc, + iconName = "scan-helper", + constructor = () => { var ball = new BallObject(); ball.paint.material = null; ball.paint.overlay = ResourcesDirectory.InstantiateMaterial( ResourcesDirectory.FindMaterial("MATTE_overlay", true)); ball.paint.overlay.color = new Color(1, 0, 0, 0.5f); return ball; - }), - new PropertiesObjectType("Light", s => s.LightObjectDesc, "lightbulb-on", - typeof(BallObject), - () => { + }, + }, + new PropertiesObjectType("Light", typeof(BallObject)) + { + description = s => s.LightObjectDesc, + iconName = "lightbulb-on", + constructor = () => { var ball = new BallObject(); ball.paint.material = null; ball.paint.overlay = ResourcesDirectory.InstantiateMaterial( @@ -212,17 +229,21 @@ public static string[] BehaviorTabNames(GUIStringSet s) => ball.xRay = true; ball.behaviors.Add(new LightBehavior()); return ball; - }), - new PropertiesObjectType("Reflector", ReflectorBehavior.objectType.description, "mirror", - typeof(BallObject), - () => { + }, + }, + new PropertiesObjectType("Reflector", typeof(BallObject)) + { + description = ReflectorBehavior.objectType.description, + iconName = "mirror", + constructor = () => { var ball = new BallObject(); ball.paint.material = ResourcesDirectory.InstantiateMaterial( ResourcesDirectory.FindMaterial("METAL", true)); ball.paint.material.color = Color.white; ball.behaviors.Add(new ReflectorBehavior()); return ball; - }), + }, + }, }; public static PropertiesObjectType[] entityFilterTypes = new PropertiesObjectType[] diff --git a/Assets/Objects/Ball.cs b/Assets/Objects/Ball.cs index 1bd07adf..aa33c314 100644 --- a/Assets/Objects/Ball.cs +++ b/Assets/Objects/Ball.cs @@ -4,7 +4,12 @@ public class BallObject : ObjectEntity { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Ball", s => s.BallDesc, s => s.BallLongDesc, "circle-outline", typeof(BallObject)); + "Ball", typeof(BallObject)) + { + description = s => s.BallDesc, + longDescription = s => s.BallLongDesc, + iconName = "circle-outline", + }; public override PropertiesObjectType ObjectType => objectType; public BallObject() diff --git a/Assets/Objects/Player.cs b/Assets/Objects/Player.cs index 9ba1f033..a55a3fae 100644 --- a/Assets/Objects/Player.cs +++ b/Assets/Objects/Player.cs @@ -4,7 +4,11 @@ public class PlayerObject : ObjectEntity { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Player", s => s.PlayerDesc, "human-greeting", typeof(PlayerObject)); + "Player", typeof(PlayerObject)) + { + description = s => s.PlayerDesc, + iconName = "human-greeting", + }; public override PropertiesObjectType ObjectType => objectType; private bool footstepSounds = true; diff --git a/Assets/Sensors/CheckScore.cs b/Assets/Sensors/CheckScore.cs index 3c968456..e59af2be 100644 --- a/Assets/Sensors/CheckScore.cs +++ b/Assets/Sensors/CheckScore.cs @@ -3,8 +3,11 @@ public class CheckScoreSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Check Score", s => s.CheckScoreDesc, "code-greater-than-or-equal", - typeof(CheckScoreSensor)); + "Check Score", typeof(CheckScoreSensor)) + { + description = s => s.CheckScoreDesc, + iconName = "code-greater-than-or-equal", + }; public override PropertiesObjectType ObjectType => objectType; public enum AboveOrBelow diff --git a/Assets/Sensors/Delay.cs b/Assets/Sensors/Delay.cs index ec16cab6..228064d6 100644 --- a/Assets/Sensors/Delay.cs +++ b/Assets/Sensors/Delay.cs @@ -4,7 +4,12 @@ public class DelaySensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Delay", s => s.DelayDesc, s => s.DelayLongDesc, "timer", typeof(DelaySensor)); + "Delay", typeof(DelaySensor)) + { + description = s => s.DelayDesc, + longDescription = s => s.DelayLongDesc, + iconName = "timer", + }; public override PropertiesObjectType ObjectType => objectType; public EntityReference input = new EntityReference(null); diff --git a/Assets/Sensors/InCamera.cs b/Assets/Sensors/InCamera.cs index 2b9c2200..0460c3ad 100644 --- a/Assets/Sensors/InCamera.cs +++ b/Assets/Sensors/InCamera.cs @@ -4,7 +4,12 @@ public class InCameraSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "In Camera", s => s.InCameraDesc, s => s.InCameraLongDesc, "eye", typeof(InCameraSensor)); + "In Camera", typeof(InCameraSensor)) + { + description = s => s.InCameraDesc, + longDescription = s => s.InCameraLongDesc, + iconName = "eye", + }; public override PropertiesObjectType ObjectType => objectType; public float maxDistance = 100; diff --git a/Assets/Sensors/InRange.cs b/Assets/Sensors/InRange.cs index ea8eb394..6aaeeb0a 100644 --- a/Assets/Sensors/InRange.cs +++ b/Assets/Sensors/InRange.cs @@ -5,7 +5,12 @@ public class InRangeSensor : BaseTouchSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "In Range", s => s.InRangeDesc, s => s.InRangeLongDesc, "radar", typeof(InRangeSensor)); + "In Range", typeof(InRangeSensor)) + { + description = s => s.InRangeDesc, + longDescription = s => s.InRangeLongDesc, + iconName = "radar", + }; public override PropertiesObjectType ObjectType => objectType; private float distance = 5; diff --git a/Assets/Sensors/InputThreshold.cs b/Assets/Sensors/InputThreshold.cs index c87dfe16..4a46ca54 100644 --- a/Assets/Sensors/InputThreshold.cs +++ b/Assets/Sensors/InputThreshold.cs @@ -5,8 +5,12 @@ public class InputThresholdSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Threshold", s => s.ThresholdDesc, s => s.ThresholdLongDesc, "altimeter", - typeof(InputThresholdSensor)); + "Threshold", typeof(InputThresholdSensor)) + { + description = s => s.ThresholdDesc, + longDescription = s => s.ThresholdLongDesc, + iconName = "altimeter", + }; public override PropertiesObjectType ObjectType => objectType; // public so it can be serialized diff --git a/Assets/Sensors/MotionSensor.cs b/Assets/Sensors/MotionSensor.cs index f15a2336..cbb4d7f6 100644 --- a/Assets/Sensors/MotionSensor.cs +++ b/Assets/Sensors/MotionSensor.cs @@ -4,7 +4,12 @@ public class MotionSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Motion", s => s.MotionDesc, s => s.MotionLongDesc, "speedometer", typeof(MotionSensor)); + "Motion", typeof(MotionSensor)) + { + description = s => s.MotionDesc, + longDescription = s => s.MotionLongDesc, + iconName = "speedometer", + }; public override PropertiesObjectType ObjectType => objectType; public float minVelocity = 1; diff --git a/Assets/Sensors/Pulse.cs b/Assets/Sensors/Pulse.cs index c7757d17..932937bc 100644 --- a/Assets/Sensors/Pulse.cs +++ b/Assets/Sensors/Pulse.cs @@ -4,7 +4,12 @@ public class PulseSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Pulse", s => s.PulseDesc, s => s.PulseLongDesc, "pulse", typeof(PulseSensor)); + "Pulse", typeof(PulseSensor)) + { + description = s => s.PulseDesc, + longDescription = s => s.PulseLongDesc, + iconName = "pulse", + }; public override PropertiesObjectType ObjectType => objectType; public bool startOn = true; diff --git a/Assets/Sensors/RandomPulse.cs b/Assets/Sensors/RandomPulse.cs index a7e044d8..3ed32332 100644 --- a/Assets/Sensors/RandomPulse.cs +++ b/Assets/Sensors/RandomPulse.cs @@ -4,8 +4,12 @@ public class RandomPulseSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Rand. Pulse", s => s.RandomPulseDesc, s => s.RandomPulseLongDesc, "progress-question", - typeof(RandomPulseSensor)); + "Rand. Pulse", typeof(RandomPulseSensor)) + { + description = s => s.RandomPulseDesc, + longDescription = s => s.RandomPulseLongDesc, + iconName = "progress-question", + }; public override PropertiesObjectType ObjectType => objectType; public (float, float) offTimeRange = (1, 5); diff --git a/Assets/Sensors/Tap.cs b/Assets/Sensors/Tap.cs index d01ec10f..f5161c45 100644 --- a/Assets/Sensors/Tap.cs +++ b/Assets/Sensors/Tap.cs @@ -3,7 +3,12 @@ public class TapSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Tap", s => s.TapDesc, s => s.TapLongDesc, "gesture-tap", typeof(TapSensor)); + "Tap", typeof(TapSensor)) + { + description = s => s.TapDesc, + longDescription = s => s.TapLongDesc, + iconName = "gesture-tap", + }; public override PropertiesObjectType ObjectType => objectType; public float maxDistance = 3; diff --git a/Assets/Sensors/Toggle.cs b/Assets/Sensors/Toggle.cs index d0cfde33..5eb5b0c6 100644 --- a/Assets/Sensors/Toggle.cs +++ b/Assets/Sensors/Toggle.cs @@ -3,7 +3,12 @@ public class ToggleSensor : GenericSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Toggle", s => s.ToggleDesc, s => s.ToggleLongDesc, "toggle-switch", typeof(ToggleSensor)); + "Toggle", typeof(ToggleSensor)) + { + description = s => s.ToggleDesc, + longDescription = s => s.ToggleLongDesc, + iconName = "toggle-switch", + }; public override PropertiesObjectType ObjectType => objectType; public EntityReference offInput = new EntityReference(null); diff --git a/Assets/Sensors/Touch.cs b/Assets/Sensors/Touch.cs index ad7f45aa..0df4f2c8 100644 --- a/Assets/Sensors/Touch.cs +++ b/Assets/Sensors/Touch.cs @@ -10,7 +10,12 @@ public abstract class BaseTouchSensor : ActivatedSensor public class TouchSensor : BaseTouchSensor { public static new PropertiesObjectType objectType = new PropertiesObjectType( - "Touch", s => s.TouchDesc, s => s.TouchLongDesc, "vector-combine", typeof(TouchSensor)); + "Touch", typeof(TouchSensor)) + { + description = s => s.TouchDesc, + longDescription = s => s.TouchLongDesc, + iconName = "vector-combine", + }; public override PropertiesObjectType ObjectType => objectType; public override IEnumerable Properties() =>