Ejemplo n.º 1
0
		public void SetPerspective(Name newPerspective)
		{
			if(!newPerspective.IsPrimitive)
				throw new ArgumentException("Only primitive symbols are allowed to be perspectives.");

			if(newPerspective == Name.NIL_SYMBOL)
				throw new ArgumentException("NIL symbol cannot be used as a perspective.");

			if (newPerspective == Name.SELF_SYMBOL)
				throw new ArgumentException("SELF symbol cannot be set as a default a perspectives.");

			if (newPerspective==Perspective)
				return;

			if(GetAllPerspectives().Contains(newPerspective))
				throw new ArgumentException($"The is already beliefs containing perspectives for {newPerspective}. Changing to the requested perspective would result in belief conflicts.");

			//Modify believes to reflect perspective changes
			var newStorage = new NameSearchTree<KnowledgeEntry>();
			foreach (var entry in m_knowledgeStorage)
			{
				var newProperty = entry.Key.SwapTerms(Perspective, newPerspective);
				newStorage.Add(newProperty,entry.Value);
			}
			m_knowledgeStorage.Clear();
			m_knowledgeStorage = newStorage;
			Perspective = newPerspective;
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Load a Social Importance Asset definition from a DTO object.
        /// </summary>
        /// <remarks>
        /// Use this to procedurally configure the asset.
        /// </remarks>
        /// <param name="dto">
        /// The DTO containing the data to load
        /// </param>
        public void LoadFromDTO(SocialImportanceDTO dto)
        {
            m_attributionRules.Clear();
            m_attributionRules.UnionWith(dto.AttributionRules.Select(adto => new AttributionRule(adto)));

            m_claimTree.Clear();
        }
Ejemplo n.º 3
0
        public void SetObjectData(ISerializationData dataHolder, ISerializationContext context)
        {
            AppraisalWeight = dataHolder.GetValue <short>("AppraisalWeight");
            var rules = dataHolder.GetValue <AppraisalRule[]>("Rules");

            if (Rules == null)
            {
                Rules = new NameSearchTree <HashSet <AppraisalRule> >();
            }
            else
            {
                Rules.Clear();
            }

            foreach (var r in rules)
            {
                r.Id = Guid.NewGuid();
                if (r.Desirability == null)
                {
                    r.Desirability = (Name)"0";
                }
                if (r.Praiseworthiness == null)
                {
                    r.Praiseworthiness = (Name)"0";
                }
                AddEmotionalReaction(r);
            }
        }
Ejemplo n.º 4
0
        public void SetObjectData(ISerializationData dataHolder)
        {
            AppraisalWeight = dataHolder.GetValue <short>("AppraisalWeight");
            var rules = dataHolder.GetValue <AppraisalRule[]>("Rules");

            Rules.Clear();
            foreach (var r in rules)
            {
                r.Id = Guid.NewGuid();
                AddEmotionalReaction(r);
            }
        }
        public void LoadFromDTO(SocialImportanceDTO dto)
        {
            m_attributionRules = dto.AttributionRules.Select(adto => new AttributionRule(adto)).ToArray();

            m_claimTree.Clear();
            if (dto.Claims != null)
            {
                foreach (var c in dto.Claims)
                {
                    var n = Name.BuildName(c.ActionTemplate);
                    m_claimTree.Add(n, c.ClaimSI);
                }
            }

            //TODO load the rest
        }
Ejemplo n.º 6
0
        public void SetObjectData(ISerializationData dataHolder, ISerializationContext context)
        {
            Tick = dataHolder.GetValue <ulong>("Tick");

            m_eventGUIDCounter = 0;
            if (m_registry == null)
            {
                m_registry = new Dictionary <uint, BaseEvent>();
            }
            else
            {
                m_registry.Clear();
            }

            if (m_typeIndexes == null)
            {
                m_typeIndexes = new NameSearchTree <List <uint> >();
            }
            else
            {
                m_typeIndexes.Clear();
            }

            var recs = dataHolder.GetValue <BaseEvent[]>("records");

            if (recs == null)
            {
                return;
            }

            foreach (var r in recs)
            {
                if (m_eventGUIDCounter < r.Id)
                {
                    m_eventGUIDCounter = r.Id;
                }

                AddRecord(r);
            }
            m_eventGUIDCounter++;
        }
 public void Clear()
 {
     m_dictionary.Clear();
 }
 /// <summary>
 /// Clears all cached Social Importance values, allowing new values to be recalculated uppon request.
 /// </summary>
 public void InvalidateCachedSI()
 {
     m_cachedSI.Clear();
 }
Ejemplo n.º 9
0
 public void Clear()
 {
     m_dynamicProperties.Clear();
 }