//[RPC] //void RPC_S2C_AddAssemblyMask(uLink.BitStream stream) //{ // return; // int _teamNum = stream.Read<int>(); // if (this.teamNum == _teamNum) // { // WorldMapManager.Instance.AddColony(transform.position); // } //} void RPC_S2C_CounterTick(uLink.BitStream stream, uLink.NetworkMessageInfo info) { float upgradeTime = stream.Read <float>(); CSAssembly csAssembly = m_Entity as CSAssembly; csAssembly.SetCounter(upgradeTime); }
public override bool SupplySth(PeEntity entity, CSAssembly asAssembly) { // check self float _curOwn = entity.GetAttribute(AttribType.Energy); if (_curOwn > Energy_Percent_min) { return(false); } //check package List <ItemObject> objs = entity.GetEquipObjs(EeqSelect.energy); if (objs != null && objs.Count > 0) { for (int i = 0; i < objs.Count; i++) { Energy energy = objs[i].GetCmpt <Energy>(); if (energy != null && energy.floatValue.percent > Energy_Percent_min) { return(false); } } } //find In csstorage return(NpcSupply.CsStrargeSupplyExchangeBattery(entity, asAssembly, objs, costId, Energy_num)); }
public void SetEntity(CSEntity enti) { if (enti == null) { Debug.LogWarning("Reference Entity is null."); return; } if (m_Assembly != null) { m_Assembly.RemoveEventListener(AssemblyEventHandler); } m_Assembly = enti as CSAssembly; m_Assembly.AddEventListener(AssemblyEventHandler); if (m_Assembly == null) { Debug.LogWarning("Reference Entity is not a Assembly Entity."); return; } m_Entity = enti; UpdateUpgradeMat(); UpdateBuildingNum(); m_HideShieldCB.isChecked = !m_Assembly.bShowShield; }
public override bool DoSupply(PeEntity entity, CSAssembly csAssembly) { if (csAssembly == null || csAssembly.Storages == null) { return(false); } if (entity.packageCmpt == null) { return(false); } List <ItemObject> _atkObjs = entity.GetAtkEquipObjs(AttackType.Ranged); if (_atkObjs == null || _atkObjs.Count <= 0) { return(false); } for (int i = 0; i < _atkObjs.Count; i++) { AmmoExpend expend = MatchExpend(_atkObjs[i]); if (expend == null) { continue; } expend.SupplySth(entity, csAssembly); } return(true); }
/****************************************************** * 基地仓库给特定npc补给(从仓库移除,添加到NPC背包) * ***************************************************/ public static bool CsStorageSupply(PeEntity npc, CSAssembly assembly, int protoId, int count) { if (assembly == null || assembly.Storages == null || npc.packageCmpt == null) { return(false); } int curCount = CSUtils.GetItemCounFromFactoryAndAllStorage(protoId, assembly); if (curCount > count) { if (CSUtils.CountDownItemFromAllStorage(protoId, count, assembly)) { return(npc.packageCmpt.Add(protoId, count)); } } else if (curCount > 0) { if (CSUtils.CountDownItemFromAllStorage(protoId, curCount, assembly)) { return(npc.packageCmpt.Add(protoId, curCount)); } } return(false); }
public static bool AgentSupply(PeEntity npc, CSAssembly csAssembly, ESupplyType type) { if (m_Agent == null) { m_Agent = new NpcSupplyAgent(); } return(m_Agent.Supply(type, npc, csAssembly)); }
// Dwellings change state call back void OnDwellingsChangeState(int event_type, CSEntity entiy, object arg) { if (event_type == CSConst.eetDwellings_ChangeState) { bool state = (bool)arg; if (state) // Add { CSAssembly assem = Dwellings.Assembly; // if (m_WorkMode == CSConst.pwtPatrol) // { // Dwellings.Assembly.AddSoldier(this); // List<CSCommon> commons = Dwellings.Assembly.GetBelongCommons(); // // foreach (CSCommon common in commons) // common.AddSoldier(this); // } // else if (m_WorkMode == CSConst.pwtGuard) // { // if ( CSUtils.SphereContainsAndIntersectBound(m_GuardTrigger.Pos, m_GuardTrigger.Radius, assem.Bound)) // assem.AddSoldier(this); // // List<CSCommon> commons = assem.GetBelongCommons(); // foreach (CSCommon common in commons) // { // if (CSUtils.SphereContainsAndIntersectBound(m_GuardTrigger.Pos, m_GuardTrigger.Radius, common.Bound)) // common.AddSoldier(this); // } // } assem.AddEventListener(OnAssemblyEventHandler); m_Assembly = assem; } else // Remove { // if (m_WorkMode == CSConst.pwtPatrol || m_WorkMode == CSConst.pwtGuard) // { // CSMgCreator mgCreator = m_Creator as CSMgCreator; // if (mgCreator != null) // { // mgCreator.Assembly.RemoveSoldier(this); // Dictionary<int, CSCommon> commons = mgCreator.GetCommonEntities(); // // foreach (KeyValuePair<int, CSCommon> kvp in commons) // kvp.Value.RemoveSoldier(this); // } // } if (m_Assembly != null) { m_Assembly.RemoveEventListener(OnAssemblyEventHandler); m_Assembly = null; } } m_Running = state; } }
public static void SupplyNpcsByCSAssembly(List <PeEntity> npcs, CSAssembly assembly, ESupplyType type) { if (npcs == null) { return; } for (int i = 0; i < npcs.Count; i++) { AgentSupply(npcs[i], assembly, type); } }
public override bool SupplySth(PeEntity entity, CSAssembly asAssembly) { // find in package int _curOwn = entity.GetItemCount(costId); if (_curOwn > BULLET_Supply_min) { return(false); } //find In csstorage return(NpcSupply.CsStorageSupply(entity, asAssembly, costId, BULLET_Supply_once)); }
void RPC_S2C_ASB_HideShield(uLink.BitStream stream, uLink.NetworkMessageInfo info) { bool showShield = stream.Read <bool>(); if (m_Entity == null) { Debug.LogError("entity not ready"); return; } CSAssembly csAssembly = m_Entity as CSAssembly; csAssembly.bShowShield = showShield; }
public static CSBuildingLogic GetAssemblyLogic() { CSAssembly csa = s_MgCreator.Assembly; if (csa == null) { return(null); } if (csa.gameLogic == null) { return(null); } return(csa.gameLogic.GetComponent <CSBuildingLogic>()); }
public CSEntity _createEntity(CSEntityAttr attr) { // Assembly if (attr.m_Type == CSConst.etAssembly) { m_Assembly = new CSAssembly(); m_Assembly.m_Info = CSInfoMgr.m_AssemblyInfo; m_Assembly.ID = attr.m_InstanceId; m_Assembly.gameLogic = attr.m_LogicObj; m_Assembly.gameObject = attr.m_Obj; m_Assembly.m_Creator = this; //multiMode only m_Assembly._ColonyObj = attr.m_ColonyBase; m_Assembly.CreateData(); m_Assembly.Position = attr.m_Pos; m_Assembly.ItemID = attr.m_protoId; m_Assembly.Bound = attr.m_Bound; m_Assembly.Data.m_Alive = true; m_Assembly.InitErodeMap(attr.m_Pos, m_Assembly.Radius); m_Timer.Tick = m_Assembly.Data.m_TimeTicks; return(m_Assembly); } else { CSCommon csc = _CreateCommon(attr.m_Type); csc.ID = attr.m_InstanceId; //multiMode only csc._ColonyObj = attr.m_ColonyBase; csc.CreateData(); csc.Position = attr.m_Pos; csc.m_Power = attr.m_Power; csc.gameLogic = attr.m_LogicObj; csc.gameObject = attr.m_Obj; csc.ItemID = attr.m_protoId; csc.Bound = attr.m_Bound; csc.BaseData.m_Alive = true; m_CommonEntities.Add(csc.ID, csc); return(csc); } }
void OnDestroy() { if (_airborne != null) { MonsterAirborne.DestroyAirborne(_airborne, false); } #if DestroyLeftMonster if (!isSweep) { for (int i = 0; i < _agents.Count; i++) { MonEscape(_agents [i] as SceneEntityPosAgent, transform.position); } } #endif SceneMan.RemoveSceneObjs(_agents); _agents.Clear(); if (UITowerInfo.Instance != null && _uiData != null) { UITowerInfo.Instance.Hide(); } s_Beacons.Remove(this); if (!PeGameMgr.IsMulti && null != m_Mark) { PeMap.LabelMgr.Instance.Remove(m_Mark); m_Mark = null; } if (null != CSMain.Instance) { List <CSAssembly> assemblyList = CSMain.Instance.GetAllAssemblies(); if (0 < assemblyList.Count) { for (int i = 0; i < assemblyList.Count; ++i) { CSAssembly assembly = assemblyList[i]; if (null != assembly && assembly.InRange(_position)) { DigTerrainManager.ClearColonyBlockInfo(assembly); } } } } }
public void UpgradeStartSuccuss(CSAssembly entity, string rolename) { if (m_Assembly == null && m_Assembly != entity) { return; } //popup material decreased if (PeCreature.Instance.mainPlayer.GetCmpt <EntityInfoCmpt>().characterName.givenName == rolename) { foreach (CSUI_MaterialGrid mg in m_MatGrids) { if (mg.ItemID > 0) { CSUI_MainWndCtrl.CreatePopupHint(mg.transform.position, this.transform, new Vector3(10, -2, -5), " - " + mg.NeedCnt.ToString(), false); } } } CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToUpgrade.GetString(), m_Entity.Name)); }
void RPC_S2C_ASB_LevelUp(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int level = stream.Read <int>(); CSAssemblyData recordData = (CSAssemblyData)_ColonyObj._RecordData; recordData.m_UpgradeTime = -1; if (m_Entity == null) { Debug.LogError("entity not ready"); return; } CSAssembly csAssembly = m_Entity as CSAssembly; csAssembly.StopCounter(); csAssembly.SetLevel(level); csAssembly.ChangeState(); csAssembly.RefreshErodeMap(); csAssembly.RefreshAssemblyObject(); csAssembly.ExcuteEvent(CSConst.eetAssembly_Upgraded); }
/************************************************ * 与仓库交换电池 * *********************************************/ public static bool CsStrargeSupplyExchangeBattery(PeEntity npc, CSAssembly assembly, List <ItemObject> objs, int protoId, int count = 1) { if (assembly == null || assembly.Storages == null || npc.packageCmpt == null) { return(false); } List <ItemObject> curObjs = CSUtils.GetItemListInStorage(protoId, assembly); //当前背包里不可以用的item if (objs != null) { for (int i = 0; i < objs.Count; i++) { //put back if (CSUtils.AddItemObjToStorage(objs[i].instanceId, assembly)) { npc.packageCmpt.Remove(objs[i]); } } } if (curObjs.Count <= 0) { return(false); } for (int i = 0; i < curObjs.Count; i++) { Energy energy = curObjs[i].GetCmpt <Energy>(); if (energy != null && energy.floatValue.percent > 0) { if (CSUtils.RemoveItemObjFromStorage(curObjs[i].instanceId, assembly)) { return(npc.packageCmpt.Add(curObjs[i])); } } } return(false); }
void RPC_S2C_ASB_LevelUpStart(uLink.BitStream stream, uLink.NetworkMessageInfo info) { CSAssemblyData recordData = (CSAssemblyData)_ColonyObj._RecordData; recordData.m_CurUpgradeTime = stream.Read <float>(); recordData.m_UpgradeTime = stream.Read <float>(); string roleName = stream.Read <string>(); bool success = stream.Read <bool>(); if (m_Entity == null) { Debug.LogWarning("entity not ready"); return; } CSAssembly csAssembly = m_Entity as CSAssembly; csAssembly.StartUpgradeCounter(recordData.m_CurUpgradeTime, recordData.m_UpgradeTime); if (CSUI_MainWndCtrl.Instance.AssemblyUI != null && success) { CSUI_MainWndCtrl.Instance.AssemblyUI.UpgradeStartSuccuss(csAssembly, roleName); } }
protected void FindElectrics() { foreach (KeyValuePair <CSConst.ObjectType, List <CSCommon> > kvp in Assembly.m_BelongObjectsMap) { if (CSAssembly.IsPowerPlant(kvp.Key)) { continue; } foreach (CSCommon tempCsc in kvp.Value) { CSElectric cse = tempCsc as CSElectric; if (cse == null) { break; } if (!cse.IsRunning) { AttachElectric(cse); } } } }
/// <summary> /// Read assemblies to list members /// </summary> public void Read() { foreach (ProjectInfo projectInfo in ProjectInfos) { if (!projectInfo.BuildConfigurations.ContainsKey(BuildConfiguration)) { // TODO Logs warn continue; } BuildConfiguration config = projectInfo.BuildConfigurations[BuildConfiguration]; if (string.IsNullOrWhiteSpace(config.OutputPath)) { // TODO Logs warn continue; } // Read assembly Assembly assembly = Assembly.LoadFile(Path.GetFullPath(config.OutputPath)); // Set full path in BuildConfiguration object // Create doc object XmlDoc doc = default; if (!string.IsNullOrWhiteSpace(config.DocumentationFilePath)) { doc = XmlDocDeserializer.Deserialize(config.DocumentationFilePath); } // Create assembly object CSAssembly csAssembly = new CSAssembly(assembly); CSMembers.Add(csAssembly); // Run through all the types foreach (TypeInfo type in assembly.DefinedTypes) { // Get the namespace object from the list of members CSNamespace csNamespace = CSMembers.Namespaces.FirstOrDefault(n => n.Name == type.Namespace); // If the namespace object does not exist, create it if (csNamespace == null) { csNamespace = new CSNamespace(type.Namespace); CSMembers.Add(csNamespace); } // Create type object CSType csType = default; if (type.IsClass) { // TODO Create class object csType = new CSClass(csAssembly, csNamespace, type); } // Create type object if (type.IsInterface) { // TODO Create interface object csType = new CSInterface(csAssembly, csNamespace, type); } // Create type object if (type.IsEnum) { // TODO Create enumeration object csType = new CSEnumeration(csAssembly, csNamespace, type); } // Read doc to get type summary csType.Summary = doc?.Members.FirstOrDefault(m => m.Name == csType.XmlFullName)?.Summary.Value; csAssembly.Types.Add(csType); csNamespace.Types.Add(csType); CSMembers.Add(csType); } } }
public static List <ItemIdCount> ResolveItemsToProcess(List <ItemIdCount> itemsNeedToGet, CSAssembly core = null, CSFactory factory = null) { List <ItemIdCount> resourceItems = new List <ItemIdCount> (); List <ItemIdCount> ItemsOwnRecord = new List <ItemIdCount> (); foreach (ItemIdCount iic in itemsNeedToGet) { if (CSProcessing.CanProcessItem(iic.protoId)) { resourceItems.Add(iic); continue; } List <ItemIdCount> needReplicate = new List <ItemIdCount> (); needReplicate.Add(iic); do { List <ItemIdCount> tempNeed = new List <ItemIdCount> (); tempNeed.AddRange(needReplicate); foreach (ItemIdCount tempIic in tempNeed) { Replicator.KnownFormula[] msList = UIGraphControl.GetReplicator().GetKnowFormulasByProductItemId(tempIic.protoId); if (msList == null || msList.Length == 0) { needReplicate.Remove(tempIic); //Debug.LogError("can't get "+tempIic.protoId+"for colony"); continue; } //--to do: temp_ only use script 01 Replicator.Formula ms = Replicator.Formula.Mgr.Instance.Find(msList[0].id); foreach (Replicator.Formula.Material mt in ms.materials) { int needCount = mt.itemCount * Mathf.CeilToInt(tempIic.count * 1.0f / ms.m_productItemCount); if (core != null) { int ownMaterialCount = CSUtils.GetItemCountFromAllStorage(mt.itemId, core); if (factory != null) { ownMaterialCount += factory.GetAllCompoundItemCount(mt.itemId); } ItemIdCount ownRecord = ItemsOwnRecord.Find(it => it.protoId == mt.itemId); if (ownMaterialCount > 0) { if (ownRecord == null || ownRecord.count < ownMaterialCount) { int leftRecordCount = 0; if (ownRecord == null) { leftRecordCount = ownMaterialCount; } else { leftRecordCount = ownMaterialCount - ownRecord.count; } int addRecordCount = 0; if (needCount > leftRecordCount) { needCount -= leftRecordCount; addRecordCount = leftRecordCount; } else { needCount = 0; addRecordCount = needCount; } if (ownRecord == null) { ItemsOwnRecord.Add(new ItemIdCount(mt.itemId, addRecordCount)); } else { ownRecord.count += addRecordCount; } if (needCount == 0) { continue; } } } } if (CSProcessing.CanProcessItem(mt.itemId)) { CSUtils.AddItemIdCount(resourceItems, mt.itemId, needCount); } else { CSUtils.AddItemIdCount(needReplicate, mt.itemId, needCount); } } needReplicate.Remove(tempIic); } }while(needReplicate.Count > 0); } return(resourceItems); }
public abstract bool DoSupply(PeEntity entity, CSAssembly CsAssembly);
void OnCreatorEventListener(int event_type, CSEntity entity) { RefreshMenu(); if (event_type == CSConst.cetAddEntity) { if (entity.m_Type == CSConst.etAssembly) { CSAssembly assem = entity as CSAssembly; MapMaskData data = new MapMaskData(); data.mDescription = "Colony"; data.mId = -1; data.mIconId = 15; data.mPosition = new Vector3(entity.Position.x, entity.Position.y + 4f, entity.Position.z); data.mRadius = assem.Radius; } else if (entity.m_Type == CSConst.etCheck) {//检查 m_Windows.m_HospitalUI.SetCheckIcon(); } else if (entity.m_Type == CSConst.etTreat) {//治疗 m_Windows.m_HospitalUI.SetTreatIcon(); } else if (entity.m_Type == CSConst.etTent) {//住院 m_Windows.m_HospitalUI.SetTentIcon(); } if (this.isShow) { this.ShowWndPart(entity); } } else if (event_type == CSConst.cetRemoveEntity) { if (entity.m_Type == CSConst.etAssembly) { } else if (entity.m_Type == CSConst.etCheck) {//检查 m_Windows.m_HospitalUI.ClearCheckIcon(); } else if (entity.m_Type == CSConst.etTreat) {//治疗 m_Windows.m_HospitalUI.ClearTreatIcon(); } else if (entity.m_Type == CSConst.etTent) {//住院 m_Windows.m_HospitalUI.ClearTentIcon(); } if (this.isShow) { //log:lz-2016.05.26 Hospital中三个医疗设备没有移完就还是显示Hospital if (((entity.m_Type == CSConst.etCheck || entity.m_Type == CSConst.etTreat || entity.m_Type == CSConst.etTent) && m_Menu.m_HospitalMI.m_EntityList.Count > 0)) { ShowWndPart(m_Menu.m_HospitalMI, m_Menu.m_HospitalMI.m_Type); } //lz-2016.10.17 如果Engineering中的机器移除完,就继续显示Engineering else if ((entity.m_Type == CSConst.dtEnhance || entity.m_Type == CSConst.dtRepair || entity.m_Type == CSConst.dtRecyle) && m_Menu.m_EngineeringlMI.m_EntityList.Count > 0) { ShowWndPart(m_Menu.m_EngineeringlMI, m_Menu.m_EngineeringlMI.m_Type); } //lz-2016.10.17 如果PPCoal中的机器移除完,就继续显示PPCoal else if ((entity.m_Type == CSConst.dtPowerPlant || entity.m_Type == CSConst.dtppCoal || entity.m_Type == CSConst.dtppSolar || entity.m_Type == CSConst.dtppFusion) && m_Menu.m_PPCoalMI.m_EntityList.Count > 0) { ShowWndPart(m_Menu.m_PPCoalMI, m_Menu.m_PPCoalMI.m_Type); } else { ShowWndPart(m_Menu.m_PersonnelMI, m_Menu.m_PersonnelMI.m_Type); } } } m_Windows.m_PersonnelUI.m_NPCOccupaUI.UpdatePopupList(); }
/***************************** * 补给物品 * *****************************/ public abstract bool SupplySth(PeEntity entity, CSAssembly asAssembly);
public void AddDataToCreator(ColonyNetwork colonyNetwork, int teamNum) { CSMgCreator creator; if (teamNum == BaseNetwork.MainPlayer.TeamId) { creator = CSMain.s_MgCreator; } else { creator = CSMain.Instance.MultiGetOtherCreator(teamNum) as CSMgCreator; } creator.teamNum = teamNum; CSObjectData objData = colonyNetwork._ColonyObj._RecordData as CSObjectData; if (objData != null //&& objData.ID != CSConst.etID_Farm//--to do:? ) { //if (!objData.m_Alive) // return; CSEntityAttr attr = new CSEntityAttr(); attr.m_InstanceId = objData.ID; attr.m_Type = objData.dType; attr.m_Pos = objData.m_Position; attr.m_protoId = objData.ItemID; attr.m_Bound = objData.m_Bounds; attr.m_ColonyBase = colonyNetwork._ColonyObj; CSEntity cse = creator._createEntity(attr); colonyNetwork.m_Entity = cse; if (objData.dType == CSConst.dtAssembly) { CSAssembly csa = cse as CSAssembly; csa.ChangeState(); } else { CSCommon csc = cse as CSCommon; if (creator.Assembly != null) { creator.Assembly.AttachCommonEntity(csc); } if (cse as CSDwellings != null) { cse._Net.RPCServer(EPacketType.PT_CL_DWL_SyncNpc); } foreach (CSPersonnel csp in creator.GetNpcs()) { if (csp.Data.m_WorkRoomID == attr.m_InstanceId && csp.WorkRoom != csc) { csp.WorkRoom = csc; } } } //init worker creator.ExecuteEvent(CSConst.cetAddEntity, cse); } }
public bool Supply(ESupplyType type, PeEntity entity, CSAssembly assembly) { return(mCsSupplies[(int)type] != null ? mCsSupplies[(int)type].DoSupply(entity, assembly) : false); }
public IEnumerator SearchVaildClodForAssembly(CSAssembly assem) { if (assem == null) { yield break; } if (assem.isSearchingClod) { yield break; } assem.isSearchingClod = true; CSMgCreator mgCreator = assem.m_Creator as CSMgCreator; mgCreator.m_Clod.Clear(); int width = Mathf.RoundToInt(assem.LargestRadius); // - 10; int length = width; int height = width; Vector3 int_pos = new Vector3(Mathf.FloorToInt(assem.Position.x), Mathf.FloorToInt(assem.Position.y), Mathf.FloorToInt(assem.Position.z)); Vector3 min_pos = int_pos - new Vector3(width, length, height); //Vector3 max_pos = int_pos + new Vector3(width, length, height); Vector3 pos = min_pos; float sqrRadius = assem.LargestRadius * assem.LargestRadius; length *= 2; width *= 2; height *= 2; int raycast_count = 0; int break_count = 0; for (int i = 0; i < width; i++) { for (int j = 0; j < length; j++, break_count++) { Vector3 prv_pos = Vector3.zero; VFVoxel prv_voxel = new VFVoxel(); for (int k = 0; k < height; k++) { pos = min_pos + new Vector3(i, k, j); if ((pos - int_pos).sqrMagnitude > sqrRadius) { continue; } VFVoxel voxel = VFVoxelTerrain.self.Voxels.SafeRead((int)pos.x, (int)pos.y, (int)pos.z); if (voxel.Volume < 128) { if (prv_voxel.Volume > 128 && (prv_voxel.Type == 19 || prv_voxel.Type == 63)) { RaycastHit rch; Vector3 clod_pos = Vector3.zero; if (Physics.Raycast(new Vector3(prv_pos.x, prv_pos.y + 1, prv_pos.z), Vector3.down, out rch, 2, 1 << Pathea.Layer.VFVoxelTerrain)) { raycast_count++; clod_pos = rch.point; } else { clod_pos = new Vector3(prv_pos.x, prv_pos.y + 0.4f, prv_pos.z); } #if NEW_CLOD_MGR if (!FarmManager.Instance.mPlantHelpMap.ContainsKey(new IntVec3(prv_pos))) { mgCreator.m_Clod.AddClod(clod_pos, false); } else { mgCreator.m_Clod.AddClod(clod_pos, true); } #else if (!FarmManager.mPlantHelpMap.ContainsKey(new IntVec3(prv_pos))) { CSClodMgr.AddClod(clod_pos, false); } else { CSClodMgr.AddClod(clod_pos, true); } #endif } } prv_pos = pos; prv_voxel = voxel; } if (break_count >= 30 || raycast_count >= 30) { raycast_count = 0; break_count = 0; yield return(0); if (assem == null) { yield break; } } } } if (assem != null) { assem.isSearchingClod = false; } yield return(0); }
public override CSEntity RemoveEntity(int id, bool bRemoveData = true) { //if (!GameConfig.IsMultiMode) //{ CSEntity cse = null; if (m_Assembly != null && m_Assembly.ID == id) { cse = m_Assembly; m_Assembly.Data.m_Alive = false; m_Assembly.RemoveErodeMap(); if (bRemoveData) { m_Assembly.RemoveData(); } if (CSMain.s_MgCreator == this) { Vector3 travelPos = Vector3.zero; CSBuildingLogic csb = m_Assembly.gameLogic.GetComponent <CSBuildingLogic>(); //lz-2017.01.17 基地逻辑预制物体加载成功并且有传送点就用配置的传送点的位置 if (csb != null && csb.travelTrans != null) { travelPos = csb.travelTrans.position; ColonyLabel.Remove(travelPos); } else { //lz-2017.01.17 否则就用基地核心向上偏移两米的位置 travelPos = m_Assembly.Position + new Vector3(0, 2, 0); ColonyLabel.Remove(travelPos); } } m_Assembly.DestroySelf(); m_Assembly = null; ExecuteEvent(CSConst.cetRemoveEntity, cse); } else if (m_CommonEntities.ContainsKey(id)) { cse = m_CommonEntities[id]; cse.BaseData.m_Alive = false; if (bRemoveData) { m_CommonEntities[id].RemoveData(); } m_CommonEntities.Remove(id); ExecuteEvent(CSConst.cetRemoveEntity, cse); cse.DestroySelf(); } else { Debug.LogWarning("The Common Entity that you want to Remove is not contained!"); } // Simulator // if (!GameConfig.IsMultiMode) // m_SimulatorMgr.RemoveSimulator(id, true); return(cse); //} //else //{ //} }
public override bool DoSupply(PeEntity entity, CSAssembly CsAssembly) { throw new System.NotImplementedException(); }
// Use this for initialization void Start() { if (!GameConfig.IsMultiMode) { // Create Simulator object // GameObject go = new GameObject("Simulator Mgr"); // m_SimulatorMgr = go.gameObject.AddComponent<CSSimulatorMgr>(); // m_SimulatorMgr.transform.parent = transform; // m_SimulatorMgr.Init(ID); // Create colony object if has Dictionary <int, CSDefaultData> objRecords = m_DataInst.GetObjectRecords(); foreach (CSDefaultData defData in objRecords.Values) { CSObjectData objData = defData as CSObjectData; if (objData != null && objData.ID != CSConst.etID_Farm) { if (!objData.m_Alive) { continue; } CSEntityAttr attr = new CSEntityAttr(); attr.m_InstanceId = objData.ID; attr.m_Type = objData.dType; attr.m_Pos = objData.m_Position; attr.m_protoId = objData.ItemID; attr.m_Bound = objData.m_Bounds; CSEntity cse = _createEntity(attr); if (objData.dType == CSConst.dtAssembly) { CSAssembly csa = cse as CSAssembly; csa.ChangeState(); } else { CSCommon csc = cse as CSCommon; if (m_Assembly != null) { m_Assembly.AttachCommonEntity(csc); } } // Create Simulator First // CSSimulator sim = null; // bool isNew = m_SimulatorMgr.CreateSimulator(objData.ID, out sim); // if (isNew) // { // CSSimulatorAttr cssAttr = new CSSimulatorAttr(); // cssAttr.m_Hp = cse.m_Info.m_Durability / 0.6f; // // sim.Init(cssAttr); // } // // sim.Hp = sim.MaxHp * cse.DuraPercent; // sim.Position = cse.Position; // sim.noticeHpChanged = cse.OnLifeChanged; } } //delay load colony npc StartCoroutine(InitColonyNpc()); } else { Debug.Log("<color=red>Creator start! Desc:" + gameObject.name + "</color>"); } }