Esempio n. 1
0
    private void CreateShape(Microbe parent)
    {
        float pilusSize = 4.6f;

        // Scale the size down for bacteria
        if (organelle.ParentMicrobe.Species.IsBacteria)
        {
            pilusSize *= 0.5f;
        }

        // TODO: Godot doesn't have Cone shape.
        // https://github.com/godotengine/godot-proposals/issues/610
        // So this uses a cylinder for now
        // Create the shape
        var shape = new CylinderShape();

        shape.Radius = pilusSize / 10.0f;
        shape.Height = pilusSize;

        var ownerId = parent.CreateShapeOwner(shape);

        parent.ShapeOwnerAddShape(ownerId, shape);
        parent.AddPilus(ownerId);
        addedChildShapes.Add(ownerId);
    }
Esempio n. 2
0
    public override void OnShapeParentChanged(Microbe newShapeParent, Vector3 offset)
    {
        // Check if the pilus exists
        if (NeedsUpdateAnyway())
        {
            // Send the organelle positions to the membrane then update the pilus
            currentShapesParent.SendOrganellePositionsToMembrane();
            Update(0);
        }
        else
        {
            // Firstly the rotation relative to the master.
            var position = organelle.RotatedPositionInsideColony(lastCalculatedPosition);

            // Then the position
            position += offset;
            Vector3 middle = offset;
            Vector3 membranePointDirection = (position - middle).Normalized();
            position += membranePointDirection * Constants.DEFAULT_HEX_SIZE * 2;

            // Pilus rotation
            var angle     = GetAngle(middle - position);
            var rotation  = MathUtils.CreateRotationForPhysicsOrganelle(angle);
            var transform = new Transform(rotation, position);

            // New ownerId
            var ownerId = currentShapesParent.CreateNewOwnerId(newShapeParent, transform, addedChildShapes[0]);
            newShapeParent.AddPilus(ownerId);

            // Destroy the old shape owner
            DestroyShape();
            addedChildShapes.Add(ownerId);
        }

        currentShapesParent = newShapeParent;
    }