Пример #1
0
    void OnTriggerEnter(Collider collider)
    {
        Logger.Log("PhenoFickContact::OnTriggerEnter collider=" + collider, Logger.Level.DEBUG);
        PhysicalMedium PMext = collider.gameObject.GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter collider.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    colliderMediumIdExt = PMext.MediumId;
        Medium colliderMediumExt   = ReactionEngine.getMediumFromId(colliderMediumIdExt, _reactionEngine.getMediumList());

        if (colliderMediumExt == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter The collided medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        PhysicalMedium PM = GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter this.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    mediumId = PM.MediumId;
        Medium medium   = ReactionEngine.getMediumFromId(mediumId, _reactionEngine.getMediumList());

        if (medium == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter The medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        float        surface  = Math.Min(PM.Size, PMext.Size);
        Fick         fick     = _reactionEngine.getFick();
        FickReaction reaction = Fick.getFickReactionFromIds(colliderMediumIdExt, mediumId, fick.getFickReactions());

        if (reaction == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter This FickReaction does not exist.", Logger.Level.WARN);
            return;
        }
        reaction.setSurface(surface);

        // set medium as medium of collider
        Logger.Log("colliderMediumIdExt : " + colliderMediumIdExt, Logger.Level.INFO);
        configureExternalDisplays(colliderMediumIdExt);
        _collidedMediumIds.AddLast(colliderMediumIdExt);

        /*
         * Logger.Log("PhenoFickContact::OnTriggerEnter"
         +" reaction.setSurface("+surface+")"
         +" _collidedMediumIds.Count="+_collidedMediumIds.Count
         +" _collidedMediumIds.Last.Value="+_collidedMediumIds.Last.Value
         * ,Logger.Level.);
         */
    }
Пример #2
0
    public static IReaction        buildFickReactionFromProps(FickProperties props, LinkedList <Medium> mediums)
    {
        FickReaction reaction = new FickReaction();
        Medium       med1     = ReactionEngine.getMediumFromId(props.MediumId1, mediums);
        Medium       med2     = ReactionEngine.getMediumFromId(props.MediumId2, mediums);

        if (med1 == null || med2 == null)
        {
            Debug.Log("failed to build FickReaction from FickProperties beacause one or all the medium id don't exist");
            return(null);
        }
        reaction.setSurface(props.surface);
        reaction.setPermCoef(props.P);
        reaction.setMedium1(med1);
        reaction.setMedium2(med2);
        reaction.setEnergyCost(props.energyCost);

        return(reaction);
    }
Пример #3
0
    public static IReaction buildFickReactionFromProps(FickProprieties props, LinkedList<Medium> mediums)
    {
        FickReaction reaction = new FickReaction();
        Medium med1 = ReactionEngine.getMediumFromId(props.MediumId1, mediums);
        Medium med2 = ReactionEngine.getMediumFromId(props.MediumId2, mediums);

        if (med1 == null || med2 == null)
          {
        Debug.Log("failed to build FickReaction from FickProprieties beacause one or all the medium id don't exist");
        return null;
          }
        reaction.setSurface(props.surface);
        reaction.setPermCoef(props.P);
        reaction.setMedium1(med1);
        reaction.setMedium2(med2);
        reaction.setEnergyCost(props.energyCost);

        return reaction;
    }
Пример #4
0
    public void OnTriggerExit(Collider collider)
    {
        Logger.Log("PhenoFickContact::OnTriggerExit collider=" + collider, Logger.Level.DEBUG);
        PhysicalMedium PMext = collider.gameObject.GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit collider.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    colliderMediumIdExt = PMext.MediumId;
        Medium colliderMediumExt   = ReactionEngine.getMediumFromId(colliderMediumIdExt, _reactionEngine.getMediumList());

        if (colliderMediumExt == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit The collided medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        PhysicalMedium PM = GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit this.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    mediumId = PM.MediumId;
        Medium medium   = ReactionEngine.getMediumFromId(mediumId, _reactionEngine.getMediumList());

        if (medium == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerExit The medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        // un-set medium as medium of collider
        _collidedMediumIds.Remove(colliderMediumIdExt);

        //string nullLast = (null != _collidedMediumIds.Last)?_collidedMediumIds.Last.Value.ToString():"null";

        /*
         * Logger.Log("PhenoFickContact::OnTriggerExit"
         +" _collidedMediumIds.Count="+_collidedMediumIds.Count
         +" _collidedMediumIds.Last.Value="+nullLast
         * ,Logger.Level.);
         */
        //Logger.Log("PhenoFickContact::OnTriggerExit _collidedMediumIds.Last.Value="+nullLast, Logger.Level.);

        if (null != _collidedMediumIds.Last)
        {
            // TODO consider the current medium as superposition of mediums the ids of which are _collidedMediumIds
            configureExternalDisplays(_collidedMediumIds.Last.Value);
        }
        else
        {
            //not in any Fick contact anymore
            configureExternalDisplays(_vectroPanelInitMediumId);

            Fick         fick     = _reactionEngine.getFick();
            FickReaction reaction = Fick.getFickReactionFromIds(colliderMediumIdExt, mediumId, fick.getFickReactions());
            if (reaction == null)
            {
                Logger.Log("PhenoFickContact::OnTriggerExit This FickReaction does not exist.", Logger.Level.WARN);
            }
            reaction.setSurface(0);
        }
    }