Пример #1
0
    public void CreateData(CSPersonnelData data)
    {
        bool isNew = m_Creator.m_DataInst.AddData(data);

        m_Data = data;

        if (isNew && (!PeGameMgr.IsMulti))
        {
        }
        else
        {
            Dwellings = m_Creator.GetCommonEntity(m_Data.m_DwellingsID) as CSDwellings;
            if (Dwellings != null)
            {
                Dwellings.AddNpcs(this);
            }
            CSCommon workRoom = m_Creator.GetCommonEntity(m_Data.m_WorkRoomID);
            //if (workRoom != null && workRoom.AddWorker(this))
            //m_BrainMemory.Add(workRoom);
            if (workRoom != null)
            {
                WorkRoom = workRoom;
            }
            //_createGuardTriggerGo ();
            //m_GuardTrigger.Pos = Data.m_GuardPos;


            if (processingIndex >= 0)
            {
                if (m_ProcessingIndexInitListenner != null)
                {
                    m_ProcessingIndexInitListenner(this);
                }
            }
            //if (m_Dwellings != null && m_Dwellings.Assembly != null)
            //{
            //    if ( !m_Dwellings.Assembly.InRange(m_Pos) )
            //        _state = CSConst.pstUnknown;
            //}
        }

        //--to do: wait
        //m_Skill.RegisterListener(OnNPCEventTrigger);
    }
Пример #2
0
    public void CreateData()
    {
        CSDefaultData ddata = null;
        bool          isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtPersonnel, ref ddata);

        m_Data = ddata as CSPersonnelData;

        if (isNew)
        {
        }
        else
        {
            Dwellings = m_Creator.GetCommonEntity(m_Data.m_DwellingsID) as CSDwellings;
            Dwellings.AddNpcs(this);
            CSCommon workRoom = m_Creator.GetCommonEntity(m_Data.m_WorkRoomID);
            //if (workRoom != null && workRoom.AddWorker(this))
            WorkRoom = workRoom;

//			_createGuardTriggerGo ();
//			m_GuardTrigger.Pos = Data.m_GuardPos;

            //init processor
            if (processingIndex >= 0)
            {
                if (m_ProcessingIndexChangeListenner != null)
                {
                    m_ProcessingIndexChangeListenner(this, -1, processingIndex);
                }
            }

//			if (m_Dwellings.m_Assembly != null)
//			{
////				_updateWorkType(-1, Data.m_WorkMode);
//
//				// Add Soldier to all Entities and set the guard pos
//				// if the new work mode is Guard.
//				if (m_WorkMode == CSConst.pwtGuard )
//				{
//					if (Data.m_GuardPos == Vector3.zero)
//						SetGuardAttr(m_Pos);
//					else
//						SetGuardAttr(Data.m_GuardPos);
//				}
//
//				// Add Soldier to all Entities if the new work mode is Patrol
//				if (m_WorkMode == CSConst.pwtPatrol)
//				{
//					m_Dwellings.m_Assembly.AddSoldier(this);
//
////					Dictionary<int, CSCommon> commons = mgCreator.GetCommonEntities();
//					List<CSCommon>  commons = m_Dwellings.m_Assembly .GetBelongCommons();
//
////					foreach (KeyValuePair<int, CSCommon> kvp in commons)
////						kvp.Value.AddSoldier(this);
//					foreach (CSCommon common in commons)
//						common.AddSoldier(this);
//				}
//			}



            //if (m_Dwellings != null && m_Dwellings.Assembly != null)
            //{
            //    if ( !m_Dwellings.Assembly.InRange(m_Pos) )
            //        _state = CSConst.pstUnknown;
            //}
        }

        //--to do: wait
        //m_Npc.RegisterListener(OnNPCEventTrigger);
    }