warnIf() private method

private warnIf ( bool condition, string format ) : void
condition bool
format string
return void
Beispiel #1
0
        /// <summary>
        /// removes an Entity from the list. All lifecycle methods will be called in the next frame.
        /// </summary>
        /// <param name="entity">Entity.</param>
        public void remove(Entity entity)
        {
            Debug.warnIf(_entitiesToRemove.Contains(entity), "You are trying to remove an entity ({0}) that you already removed", entity.name);

            if (!_entitiesToRemove.Contains(entity))
            {
                _entitiesToRemove.Add(entity);
            }
        }
Beispiel #2
0
        public TiledMapComponent(TiledMap tiledmap, string collisionLayerName = null)
        {
            this.tiledmap = tiledmap;

            if (collisionLayerName != null)
            {
                _collisionLayer = tiledmap.getLayer <TiledTileLayer>(collisionLayerName);
            }

            Debug.warnIf(tiledmap.renderOrder != TiledRenderOrder.RightDown, "The TiledMap render order is not RightDown. Bad things might happen because of that.");
        }
Beispiel #3
0
        public void remove(Component component)
        {
            Debug.warnIf(_componentsToRemove.Contains(component), "You are trying to remove a Component ({0}) that you already removed", component);

            // this may not be a live Component so we have to watch out for if it hasnt been processed yet but it is being removed in the same frame
            if (_componentsToAdd.Contains(component))
            {
                _componentsToAdd.Remove(component);
                return;
            }

            _componentsToRemove.Add(component);
        }
        /// <summary>
        /// removes an Entity from the list. All lifecycle methods will be called in the next frame.
        /// </summary>
        /// <param name="entity">Entity.</param>
        public void remove(Entity entity)
        {
            Debug.warnIf(_entitiesToRemove.Contains(entity), "You are trying to remove an entity ({0}) that you already removed", entity.name);

            // guard against adding and then removing an Entity in the same frame
            if (_entitiesToAdd.Contains(entity))
            {
                _entitiesToAdd.Remove(entity);
                return;
            }

            if (!_entitiesToRemove.Contains(entity))
            {
                _entitiesToRemove.Add(entity);
            }
        }
Beispiel #5
0
        public override void onAddedToEntity()
        {
            if (_colliderRequiresAutoSizing)
            {
                // we only deal with boxes and circles here
                Assert.isTrue(
                    this is BoxCollider || this is CircleCollider,
                    "Only box and circle colliders can be created automatically");

                var renderable = entity.getComponent <RenderableComponent>();
                Debug.warnIf(
                    renderable == null,
                    "Collider has no shape and no RenderableComponent. Can't figure out how to size it.");
                if (renderable != null)
                {
                    var renderableBounds = renderable.bounds;

                    // we need the size * inverse scale here because when we autosize the Collider it needs to be without a scaled Renderable
                    var width  = renderableBounds.width / entity.transform.scale.X;
                    var height = renderableBounds.height / entity.transform.scale.Y;

                    // circle colliders need special care with the origin
                    if (this is CircleCollider)
                    {
                        var circleCollider = this as CircleCollider;
                        circleCollider.radius = Math.Max(width, height) * 0.5f;

                        // fetch the Renderable's center, transfer it to local coordinates and use that as the localOffset of our collider
                        localOffset = renderableBounds.center - entity.transform.position;
                    }
                    else
                    {
                        var boxCollider = this as BoxCollider;
                        boxCollider.width  = width;
                        boxCollider.height = height;

                        // fetch the Renderable's center, transfer it to local coordinates and use that as the localOffset of our collider
                        localOffset = renderableBounds.center - entity.transform.position;
                    }
                }
            }

            _isParentEntityAddedToScene = true;
            registerColliderWithPhysicsSystem();
        }
Beispiel #6
0
        /// <summary>
        /// Called when the parent entity is added to a scene
        /// </summary>
        public virtual void onEntityAddedToScene()
        {
            if (shape == null)
            {
                // we only deal with boxes and circles here
                Assert.isTrue(this is BoxCollider || this is CircleCollider, "Only box and circle colliders can be created automatically");

                var renderable = entity.getComponent <RenderableComponent>();
                Debug.warnIf(renderable == null, "Collider has no shape and no RenderableComponent. Can't figure out how to size it.");
                if (renderable != null)
                {
                    var renderableBounds = renderable.bounds;

                    var width  = renderableBounds.width;
                    var height = renderableBounds.height;

                    // circle colliders need special care with the origin
                    if (this is CircleCollider)
                    {
                        var circle = this as CircleCollider;
                        circle.shape  = new Circle(width * 0.5f);
                        circle.radius = width * 0.5f;

                        // fetch the Renderable's center, transfer it to local coordinates and use that as the origin of our collider
                        var localCenter = renderableBounds.center - entity.transform.position;
                        origin = localCenter;
                    }
                    else
                    {
                        var box = this as BoxCollider;
                        box.shape        = new Box(width, height);
                        box.width        = width;
                        box.height       = height;
                        originNormalized = renderable.originNormalized;
                    }

                    shape.position = entity.transform.position;
                }
            }
            _isParentEntityAddedToScene = true;
            registerColliderWithPhysicsSystem();
        }
 public override void onAddedToEntity()
 {
     _collider = entity.getComponent <Collider>();
     Debug.warnIf(_collider == null, "ArcadeRigidbody has no Collider. ArcadeRigidbody requires a Collider!");
 }
 public override void onAddedToEntity()
 {
     _collider = entity.getComponent <Collider>();
     Debug.warnIf(_collider == null, "ProjectileMover has no Collider. ProjectilMover requires a Collider!");
 }