Ejemplo n.º 1
0
    public void init()
    {
        //populate lists from profile. Profile has archetypes.
        //DO NOT USE ARCHETYPES. I will hurt you!
        //Make copies for use

        Debug.Log("Initializing agent");

        List <Inventory> inventories = profile.getComponents <Inventory>();

        List <MAction> acts = profile.getComponent <ActionListComponent>().list;
        List <MGoal>   gls  = profile.getComponent <GoalListComponent>().list;
        List <MNorm>   nrms = profile.getComponent <NormListComponent>().list;

        List <mEntity> ents = new List <mEntity>();

        foreach (Inventory inv in inventories)
        {
            if (inv.name.Contains("Entities"))
            {
                ents = inv.list;
            }
        }

        entities.Clear();

        Debug.Log("Populating entities");

        foreach (mEntity entity in ents)
        {
            Debug.Log("Copying " + entity.entityName);
            mEntity e = ECUtils.DeepCopyEntity(entity);//entity.copy();
            entities.Add(e);
        }

        actions.Clear();
        Debug.Log("Populating actions");
        foreach (MAction action in actions)
        {
            //  MAction act = ECUtils.DeepCopy<MAction>(action);
            //   actions.Add(act);
        }

        goals.Clear();
        Debug.Log("Populating goals");
        foreach (MGoal goal in gls)
        {
            //goals.Add(ECUtils.DeepCopy<MGoal>(goal));
        }

        norms.Clear();
        Debug.Log("Populating norms");
        foreach (MNorm norm in nrms)
        {
            // norms.Add(ECUtils.DeepCopy<MNorm>(norm));
        }
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        initResource();
        initCommunities();


        othertest = ECUtils.DeepCopyEntity(test);
        othertest.components.Add(new ColorComponent());

        Debug.Log(test.components.Count);
        Debug.Log(othertest.components.Count);
    }
Ejemplo n.º 3
0
    public void OnEndDay()
    {
        if (entities.getEntity <Catch>().getComponent <isAvailable>() == null)
        {
            entities.getEntity <Catch>().components.Add(new isAvailable());
        }

        if (entities.getEntity <Catch>().getComponent <isAvailable>() != null)
        {
            gameObject.transform.parent.GetComponent <AgentBehavior>().OnVesselReturns(ECUtils.DeepCopyEntity(entities.getEntity <Catch>()));
            // test = ECUtils.DeepCopyEntity(entities.getEntity<Catch>());

            entities.getEntity <Profit>().getComponent <Profit>().profit += entities.getEntity <Catch>().getComponent <Catch>().size;
            entities.getEntity <Catch>().getComponent <Catch>().size      = 0;
            entities.getEntity <Catch>().getComponent <ByCatch>().size    = 0;
        }

        Debug.Log("... and it's done.");
        //  StartCoroutine("goHome");
        // OnVesselReturns();
    }
Ejemplo n.º 4
0
    public virtual void loadProfile(mEntity profile)
    {
        //populate lists from profile. Profile has archetypes.
        //DO NOT USE ARCHETYPES. I will hurt you!
        //Make copies for use

        Debug.Log("Initializing agent");

        List <Inventory> inventories = profile.getComponents <Inventory>();

        List <MAction> acts = profile.getComponent <ActionListComponent>().list;
        List <MGoal>   gls  = profile.getComponent <GoalListComponent>().list;
        List <MNorm>   nrms = profile.getComponent <NormListComponent>().list;

        List <mEntity> ents = new List <mEntity>();

        foreach (Inventory inv in inventories)
        {
            if (inv.name.Contains("Entities"))
            {
                ents = inv.list;
            }
        }

        entities.Clear();

        //  Debug.Log("Populating entities");

        foreach (mEntity entity in ents)
        {
            // Debug.Log("Copying " + entity.entityName);
            mEntity e = ECUtils.DeepCopyEntity(entity);//entity.copy();
            entities.Add(e);
        }

        actions.Clear();
        //  Debug.Log("Populating actions");
        ActionListComponent actionlist = profile.components.First(item => item is ActionListComponent) as ActionListComponent;

        foreach (MAction action in actionlist.list)
        {
            // Debug.Log("Now adding action " + action.GetType());
            Type type = action.GetType();
            var  act  = ECUtils.DeepCopyAction(action);
            act.owner = this;
            act.init();
            //  act.initReferences();
            act.initCached(act.owner);
            // act = Convert.ChangeType(act, type);
            actions.Add(act);

            // Debug.Log("Action list now contains: " + actions.getAction(act));
        }



        goals.Clear();
        // Debug.Log("Populating goals");
        foreach (MGoal goal in gls)
        {
            //    Debug.Log("Now adding goal " + goal.GetType());
            var g = ECUtils.DeepCopyGoal(goal);
            g.owner = this;
            g.init();
            goals.Add(g);
        }

        norms.Clear();
        //  Debug.Log("Populating norms");
        foreach (MNorm norm in nrms)
        {
            var n = ECUtils.DeepCopyNorm(norm);
            n.owner = this;
            n.init(this);
            norms.Add(n);
        }

        initReasoner(reasonerTemplate);
    }