log() private method

private log ( LogType type, string format ) : void
type LogType
format string
return void
Beispiel #1
0
        /// <summary>
        /// copies the properties, components and colliders of Entity to this instance
        /// </summary>
        /// <param name="entity">Entity.</param>
        protected void copyFrom(Entity entity)
        {
            // Entity fields
            tag            = entity.tag;
            updateInterval = entity.updateInterval;
            updateOrder    = entity.updateOrder;
            enabled        = entity.enabled;

            transform.scale    = entity.transform.scale;
            transform.rotation = entity.transform.rotation;

            // clone Components
            for (var i = 0; i < entity.components.Count; i++)
            {
                addComponent(entity.components[i].clone());
            }

            // clone Colliders
            for (var i = 0; i < entity.colliders.Count; i++)
            {
                colliders.add(entity.colliders[i].clone());
            }

            // clone any children of the Entity.transform
            for (var i = 0; i < entity.transform.childCount; i++)
            {
                var child = entity.transform.getChild(i).entity;

                var childClone = child.clone();
                childClone.transform.copyFrom(child.transform);
                childClone.transform.parent = transform;

                Debug.log("child: {0}\nLog: clone: {1}", child.transform, childClone.transform);
            }
        }
Beispiel #2
0
        /// <summary>
        /// attaches an Entity that was previously detached to a new scene
        /// </summary>
        /// <param name="newScene">New scene.</param>
        public void attachToScene(Scene newScene)
        {
            scene = newScene;
            newScene.entities.add(this);
            components.registerAllComponents();

            for (var i = 0; i < transform.childCount; i++)
            {
                transform.getChild(i).entity.attachToScene(newScene);
            }

            Debug.log("attaching {0}. total children: {1}", name, transform.childCount);
        }
Beispiel #3
0
        public void copyFrom(Transform transform)
        {
            _position      = transform.position;
            _localPosition = transform._localPosition;
            _rotation      = transform._rotation;
            _localRotation = transform._localRotation;
            _scale         = transform._scale;
            _localScale    = transform._localScale;

            Debug.log("copy from: {0}, current: {1}", transform.position, _position);

//			hierarchyDirty |= DirtyType.PositionDirty;
//			hierarchyDirty |= DirtyType.RotationDirty;
//			hierarchyDirty |= DirtyType.ScaleDirty;
            setDirty(DirtyType.PositionDirty);
            setDirty(DirtyType.RotationDirty);
            setDirty(DirtyType.ScaleDirty);
        }
Beispiel #4
0
        /// <summary>
        /// gets an Inspector subclass that can handle valueType. If no default Inspector is available the memberInfo custom attributes
        /// will be checked for the CustomInspectorAttribute.
        /// </summary>
        /// <returns>The inspector for type.</returns>
        /// <param name="valueType">Value type.</param>
        /// <param name="memberInfo">Member info.</param>
        static Inspector getInspectorForType(Type valueType)
        {
            if (valueType == typeof(int))
            {
                return(new IntInspector());
            }
            if (valueType == typeof(float))
            {
                return(new FloatInspector());
            }
            if (valueType == typeof(bool))
            {
                return(new BoolInspector());
            }
            if (valueType == typeof(string))
            {
                return(new StringInspector());
            }
            if (valueType == typeof(Vector2))
            {
                return(new Vector2Inspector());
            }

            var customInspectorType = valueType.GetTypeInfo().GetCustomAttribute <CustomInspectorAttribute>();

            if (customInspectorType != null)
            {
                if (customInspectorType.inspectorType.GetTypeInfo().IsSubclassOf(typeof(Inspector)))
                {
                    return((Inspector)Activator.CreateInstance(customInspectorType.inspectorType));
                }
                Debug.log($"found CustomInspector {customInspectorType.inspectorType} but it is not a subclass of Inspector");
            }

            Debug.log($"no inspector for type {valueType}");

            return(null);
        }
        /// <summary>
        /// gets all subclasses of <paramref name="baseClassType"> optionally filtering only for those with
        /// a parameterless constructor. Abstract Types will not be returned.
        /// </summary>
        /// <param name="baseClassType"></param>
        /// <param name="onlyIncludeParameterlessConstructors"></param>
        /// <returns></returns>
        public static List <Type> getAllSubclasses(Type baseClassType, bool onlyIncludeParameterlessConstructors = false)
        {
            var typeList = new List <Type>();

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (var type in assembly.GetTypes())
                {
                    if (type.IsSubclassOf(baseClassType) && !type.IsAbstract)
                    {
                        if (onlyIncludeParameterlessConstructors)
                        {
                            if (type.GetConstructor(Type.EmptyTypes) == null)
                            {
                                Debug.log("no go: " + type.Name);
                                continue;
                            }
                        }
                        typeList.Add(type);
                    }
                }
            }
            return(typeList);
        }
Beispiel #6
0
 /// <summary>
 ///
 /// </summary>
 public void unPause()
 {
     Debug.log("Un-Paused scene: " + this.ToString());
     _paused = false;
     enableEntities();
 }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 public void pause()
 {
     Debug.log("Paused scene: " + this.ToString());
     _paused = true;
     disableEntities();
 }