예제 #1
0
        public static Result CheckOutAsset(Asset _asset)
        {
            if (_asset.IsOneOfStates(OUTDATED))
            {
                PuppeteerLogger.Log(string.Format("[Puppeteer Version Control] The asset you are overriding" +
                                                  "is outdated. asset: {0}", _asset.name), LogType.Warning);
            }

            if (_asset.IsOneOfStates(USED_REMOTE))
            {
                PuppeteerLogger.Log(string.Format("[Puppeteer Version Control] The asset you are overriding " +
                                                  "is being modified by another user. asset: {0}", _asset.name), LogType.Warning);
            }

            if (_asset.IsOneOfStates(LOCKED))
            {
                PuppeteerLogger.Log(string.Format("[Puppeteer Version Control] The asset you are overriding " +
                                                  "is locked. asset: {0}", _asset.name), LogType.Warning);
                return(Result.Locked);
            }

            Provider.Checkout(_asset, CheckoutMode.Asset).Wait();

            return(Result.Controlled);
        }
예제 #2
0
        public bool InitialiseAgentUsingArchetype(PuppeteerAgent _agent, Guid _archetypeGuid)
        {
            if (_archetypeGuid == Guid.Empty)
            {
                PuppeteerLogger.Log(string.Format("Agent {0} has no Archetype configured.", _agent), LogType.Warning);
            }

            m_DescriptionCache.ArchetypeDesc = GetArchetypeDescription(_archetypeGuid);
            if (m_DescriptionCache.ArchetypeDesc == null)
            {
                PuppeteerLogger.Log(string.Format("Archetype with GUID [{0}] couldn't be loaded", _archetypeGuid.ToString()), LogType.Error);
                return(false);
            }

            _agent.ClearGoals();

            for (int i = 0; i < m_DescriptionCache.ArchetypeDesc.GoalGUIDs.Length; ++i)
            {
                m_DescriptionCache.GoalDesc = GetGoalDescription(m_DescriptionCache.ArchetypeDesc.GoalGUIDs[i]);

                if (m_DescriptionCache.GoalDesc != null)
                {
                    _agent.AddGoal(m_DescriptionCache.GoalDesc);
                }
            }

            _agent.ClearActions();

            for (int i = 0; i < m_DescriptionCache.ArchetypeDesc.ActionGUIDs.Length; ++i)
            {
                m_DescriptionCache.ActionDesc = GetActionDescription(m_DescriptionCache.ArchetypeDesc.ActionGUIDs[i]);

                if (m_DescriptionCache.ActionDesc != null)
                {
                    _agent.AddAction(m_DescriptionCache.ActionDesc);
                }
            }

            _agent.ClearSensors();

            for (int i = 0; i < m_DescriptionCache.ArchetypeDesc.SensorGUIDs.Length; ++i)
            {
                m_DescriptionCache.SensorDesc = GetSensorDescription(m_DescriptionCache.ArchetypeDesc.SensorGUIDs[i]);

                if (m_DescriptionCache.SensorDesc != null)
                {
                    _agent.AddSensor(m_DescriptionCache.SensorDesc);
                }
            }

            _agent.SortSensors();

            return(true);
        }
예제 #3
0
 private static bool Serialise(object _item, string _path)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(_item.GetType());
         StreamWriter  writer     = new StreamWriter(_path);
         serializer.Serialize(writer.BaseStream, _item);
         writer.Close();
         return(true);
     }
     catch (System.Exception e)
     {
         PuppeteerLogger.Log(string.Format("Serialise {0}", e.Message));
         return(false);
     }
 }
예제 #4
0
        private static T Deserialise <T>(string _path) where T : new()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            T             deserialized;

            try
            {
                StreamReader reader = new StreamReader(_path);
                deserialized = (T)serializer.Deserialize(reader.BaseStream);
                reader.Close();
            }
            catch (System.Exception e)
            {
                PuppeteerLogger.Log(string.Format("Deserialise: {0}", e.Message));

                deserialized = new T();
            }

            return(deserialized);
        }
예제 #5
0
 public override void Enter(PuppeteerAgent _executingAgent)
 {
     PuppeteerLogger.Log(string.Format("{0} tries to use the PuppeteerDefault action. This won't have any effect.", _executingAgent), Core.Debug.LogType.Warning);
 }