public SceneLogicInfo AddSceneLogicInfo(int id, int logicId) { SceneLogicInfo info = NewSceneLogicInfo(id); info.SceneContext = m_SceneContext; info.SceneLogicConfig = new SceneLogicConfig(); info.SceneLogicConfig.m_LogicId = logicId; if (m_SceneLogicInfos.Contains(id)) { SceneLogicInfo oldInfo = GetSceneLogicInfo(id); LogSystem.Error("AddSceneLogicInfo error, Id={0} was exist, LogicId={1}, NewLogicId={2}", id, oldInfo.LogicId, logicId); } m_SceneLogicInfos.Add(info.GetId(), info); return(info); }
// 脚本里控制怪物的真实死亡时间。 private void OnNpcDead(int characterId) { CharacterInfo info = WorldSystem.Instance.GetCharacterById(characterId); if (info.Hp > 0) { LogSystem.Error("Npc {0} receive dead command while hp > 0", characterId); } else if (info.DeadTime > 0) { LogSystem.Error("Npc {0} has received dead command already", characterId); } else { info.DeadTime = TimeUtility.GetServerMilliseconds(); } }
public void Tick() { if (!c_ProfilerEnable) { return; } if (m_AllProfilers.Count > 200) { LogSystem.Error("ProfilerMgr m_AllProfilers Count too much!"); } m_DeltaTime = handlerDeltatime(); m_TotalTime += m_DeltaTime; m_Fps = 1 / m_DeltaTime; if ((DateTime.Now - m_tLastProfiler).TotalMilliseconds > c_ProfilerInterval && m_DeltaTime >= c_ProfilerMinFps) { m_tLastProfiler = DateTime.Now; } else { return; } handlerOutput("---------------------------------Profiler(Last Frame)----------------------------------------"); string info = string.Format("[Profiler]:Fps:{0,-40:F3} Total:{1,-5:F3} Delta:{2,-5:F3} Logic:{3,-5:F3}", m_Fps, m_TotalTime, m_DeltaTime, m_LogicTime); handlerOutput(info); foreach (Profiler profiler in m_AllProfilers.Values) { if (profiler.IsValid && profiler.CurElapsedTime >= c_ProfilerMinElapsed) { profiler.Print(m_TotalTime, m_DeltaTime, m_Fps, handlerOutput); profiler.IsValid = false; } } }
public void HandleActions(int maxCount) { try { for (int i = 0; i < maxCount; ++i) { if (m_Actions.Count > 0) { MyAction action = null; lock (m_Lock) { action = m_Actions.Dequeue(); } if (null != action) action(); } else { break; } } } catch (Exception ex) { LogSystem.Error("AsyncActionProcessor.HandleActions throw exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
public void Init(string filename) { if (!FileReaderProxy.Exists(filename)) { return; } try { float w = 1, h = 1; using (MemoryStream fs = FileReaderProxy.ReadFileAsMemoryStream(filename)) { using (BinaryReader br = new BinaryReader(fs)) { w = (float)br.ReadDouble(); h = (float)br.ReadDouble(); br.Close(); } } Init(w, h); } catch (Exception e) { LogSystem.Error("{0}\n{1}", e.Message, e.StackTrace); } }
private SkillInstanceInfo NewSkillInstance(int skillId) { SkillInstanceInfo instInfo = GetUnusedSkillInstanceInfoFromPool(skillId); if (null == instInfo) { SkillLogicData skillData = SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_SKILL, skillId) as SkillLogicData; if (null != skillData) { string filePath = HomePath.GetAbsolutePath(FilePathDefine_Server.C_SkillDslPath + skillData.SkillDataFile); SkillConfigManager.Instance.LoadSkillIfNotExist(skillId, filePath); SkillInstance inst = SkillConfigManager.Instance.NewSkillInstance(skillId); if (null != inst) { SkillInstanceInfo res = new SkillInstanceInfo(); res.m_SkillId = skillId; res.m_SkillInstance = inst; res.m_IsUsed = true; AddSkillInstanceInfoToPool(skillId, res); return(res); } else { LogSystem.Error("Can't find skill dsl or skill dsl error, skill:{0} !", skillId); return(null); } } else { LogSystem.Error("Can't find skill config, skill:{0} !", skillId); return(null); } } else { instInfo.m_IsUsed = true; return(instInfo); } }
private void Loop() { try { if (OnStartEvent != null) { OnStartEvent(); } else { OnStart(); } while (m_IsRun) { try { HandleActions(); if (OnTickEvent != null) { OnTickEvent(); } else { OnTick(); } } catch (Exception ex) { LogSystem.Error("MyThread.Tick throw exception:{0}\n{1}", ex.Message, ex.StackTrace); } Thread.Sleep(m_TickSleepTime); } if (OnQuitEvent != null) { OnQuitEvent(); } else { OnQuit(); } } catch (Exception ex) { LogSystem.Error("MyThread.Loop throw exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
private void BuildImpl() { m_BuildStack.Push(0); m_BuildStack.Push(m_ObjectNum); m_BuildStack.Push(0); while (m_BuildStack.Count >= 3) { int begin = m_BuildStack.Pop(); int end = m_BuildStack.Pop(); int node = m_BuildStack.Pop(); m_KdTree[node].m_Begin = begin; m_KdTree[node].m_End = end; float minX = m_Objects[begin].MinX; float maxX = m_Objects[begin].MaxX; float minZ = m_Objects[begin].MinZ; float maxZ = m_Objects[begin].MaxZ; for (int i = begin + 1; i < end; ++i) { float newMaxX = m_Objects[i].MaxX; float newMinX = m_Objects[i].MinX; float newMaxZ = m_Objects[i].MaxZ; float newMinZ = m_Objects[i].MinZ; if (minX > newMinX) { minX = newMinX; } if (maxX < newMaxX) { maxX = newMaxX; } if (minZ > newMinZ) { minZ = newMinZ; } if (maxZ < newMaxZ) { maxZ = newMaxZ; } } m_KdTree[node].m_MinX = minX; m_KdTree[node].m_MaxX = maxX; m_KdTree[node].m_MinZ = minZ; m_KdTree[node].m_MaxZ = maxZ; if (end - begin > c_MaxLeafSize) { bool isVertical = (maxX - minX > maxZ - minZ); float splitValue = (isVertical ? 0.5f * (maxX + minX) : 0.5f * (maxZ + minZ)); int left = begin; int right = end; while (left < right) { while (left < right && (isVertical ? m_Objects[left].Position.X : m_Objects[left].Position.Z) < splitValue) { ++left; } while (right > left && (isVertical ? m_Objects[right - 1].Position.X : m_Objects[right - 1].Position.Z) >= splitValue) { --right; } if (left < right) { KdTreeObject tmp = m_Objects[left]; m_Objects[left] = m_Objects[right - 1]; m_Objects[right - 1] = tmp; ++left; --right; } } if (left == end) { --left; } int leftSize = left - begin; if (leftSize == 0) { ++leftSize; ++left; } m_KdTree[node].m_Left = node + 1; m_KdTree[node].m_Right = node + 1 + (2 * leftSize - 1); if (m_KdTree[node].m_Left >= m_MaxNodeNum || m_KdTree[node].m_Right >= m_MaxNodeNum) { LogSystem.Error("KdTree Error, node:{0} left:{1} right:{2} leftSize:{3} begin:{4} end:{5} maxNodeNum:{6}", node, left, right, leftSize, begin, end, m_MaxNodeNum); } m_BuildStack.Push(m_KdTree[node].m_Left); m_BuildStack.Push(left); m_BuildStack.Push(begin); m_BuildStack.Push(m_KdTree[node].m_Right); m_BuildStack.Push(end); m_BuildStack.Push(left); } } }
internal void StartSkill(int objId, int skillId) { CharacterInfo obj = CurScene.SceneContext.GetCharacterInfoById(objId); if (null != obj) { SkillInstanceInfo inst = NewSkillInstance(skillId); if (null != inst) { obj.GetSkillStateInfo().SetCurSkillInfo(skillId); SkillInfo skillInfo = obj.GetSkillStateInfo().GetCurSkillInfo(); if (null != skillInfo) { if (MakeSkillCast(obj, skillInfo)) { ArkCrossEngineMessage.Msg_RC_SyncProperty propBuilder = DataSyncUtility.BuildSyncPropertyMessage(obj); Scene scene = obj.SceneContext.CustomData as Scene; if (null != scene) { scene.NotifyAllUser(propBuilder); } } else { skillInfo.m_EnableImpactsToMyself = null; skillInfo.m_EnableImpactsToOther = null; skillInfo.m_LeftEnableMoveCount = 0; skillInfo.m_LeftEnableImpactsToMyself.Clear(); skillInfo.m_LeftEnableImpactsToOther.Clear(); return; } skillInfo.IsSkillActivated = true; m_SkillLogicInfos.Add(new SkillLogicInfo(objId, inst)); SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.SenderId == objId && info.SkillId == skillId); if (null != logicInfo) { //目前没有与技能释放者相关的分析属性,对每个技能暂时只需要分析一次 if (null == skillInfo.m_EnableImpactsToMyself || null == skillInfo.m_EnableImpactsToOther) { if (!logicInfo.SkillInst.AlreadyAnalyzed) { logicInfo.SkillInst.Analyze(obj); foreach (int skill in logicInfo.SkillInst.SummonNpcSkills) { List <int> impacts = AnalyzeNpcSkills(skill, logicInfo.SkillInst); logicInfo.SkillInst.EnableImpactsToOther.AddRange(impacts); } } skillInfo.m_EnableMoveCount = logicInfo.SkillInst.EnableMoveCount; skillInfo.m_MaxMoveDistance = logicInfo.SkillInst.MaxMoveDelta; skillInfo.m_EnableImpactsToOther = logicInfo.SkillInst.EnableImpactsToOther; skillInfo.m_EnableImpactsToMyself = logicInfo.SkillInst.EnableImpactsToMyself; skillInfo.m_EnableSummonNpcs = logicInfo.SkillInst.SummonNpcs; /* * LogSys.Log(LOG_TYPE.WARN, "Skill {0} EnableMoveCount {1} MaxMoveDistanceSqr {2}\n\tEnableImpactsToOther {3}\n\tEnableImpactsToMyself {4}\n\tSummonNpcSkills {5}", skillId, skillInfo.m_EnableMoveCount, skillInfo.m_MaxMoveDistanceSqr, * string.Join<int>(",", skillInfo.m_EnableImpactsToOther), * string.Join<int>(",", skillInfo.m_EnableImpactsToMyself), * string.Join<int>(",", logicInfo.SkillInst.SummonNpcSkills)); */ } skillInfo.m_LeftEnableMoveCount = skillInfo.m_EnableMoveCount; skillInfo.m_LeftEnableImpactsToMyself.AddRange(skillInfo.m_EnableImpactsToMyself); skillInfo.m_LeftEnableImpactsToOther.Clear(); if (logicInfo.SkillInst.IsSimulate) { obj.GetSkillStateInfo().SimulateEndTime = TimeUtility.GetServerMilliseconds() + logicInfo.SkillInst.MaxSkillLifeTime; } logicInfo.SkillInst.Start(obj); /* * DashFire.LogSystem.Warn("StartSkill {0} {1} EnableMoveCount {2} MaxMoveDistance {3}\n\tEnableImpactsToOther {4}\n\tEnableImpactsToMyself {5}\n\tSummonNpcSkills {6}", objId, skillId, skillInfo.m_LeftEnableMoveCount, skillInfo.m_MaxMoveDistanceSqr, * string.Join<int>(",", skillInfo.m_EnableImpactsToOther), * string.Join<int>(",", skillInfo.m_EnableImpactsToMyself), * string.Join<int>(",", logicInfo.SkillInst.SummonNpcSkills)); */ } } else { LogSystem.Error("{0} StartSkill can't find skill {1}", objId, skillId); } } } else { LogSystem.Debug("not find game obj by id " + objId); } }