public void QueueAction(MyAction cmd) { bool needNew = true; ClientConcurrentObjectPool <MyActionCommandHelper> pool; m_CommandPools.GetOrNewData(out pool); if (null != pool) { MyActionCommandHelper helper = pool.Alloc(); if (null != helper) { helper.Init(cmd); m_Commands.Enqueue(helper); needNew = false; } } if (needNew) { var helper = new MyActionCommandHelper(); helper.Init(cmd); m_Commands.Enqueue(helper); LogSystem.Warn("QueueAction {0}() use new expression, maybe out of memory.", cmd.Method.ToString()); } }
internal bool StartSkill(int actorId, TableConfig.Skill configData, int seq, params Dictionary <string, object>[] locals) { bool ret = false; if (null == configData) { LogSystem.Error("{0} can't cast skill, config is null !", actorId, seq); Helper.LogCallStack(); return(false); } if (!m_Scene.EntityController.CanCastSkill(actorId, configData, seq)) { m_Scene.EntityController.CancelCastSkill(actorId); LogSystem.Warn("{0} can't cast skill {1} {2}, cancel.", actorId, configData.id, seq); m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); return(false); } GfxSkillSenderInfo senderInfo = m_Scene.EntityController.BuildSkillInfo(actorId, configData, seq, m_Scene); if (null != senderInfo && null != senderInfo.GfxObj) { int skillId = senderInfo.SkillId; EntityInfo obj = senderInfo.GfxObj; SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq); if (logicInfo != null) { LogSystem.Warn("{0} is casting skill {1} {2}, cancel.", actorId, skillId, seq); m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); return(false); } SkillInstanceInfo inst = null; SkillInstance innerInstance = null; if (skillId == PredefinedSkill.c_EmitSkillId) { for (int i = 0; i < locals.Length; ++i) { object instObj; if (locals[i].TryGetValue("emitskill", out instObj)) { innerInstance = instObj as SkillInstance; } } if (null == innerInstance) { LogSystem.Warn("{0} use predefined skill {1} {2} but not found emitskill, cancel.", actorId, skillId, seq); //m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); //return false; } } else if (skillId == PredefinedSkill.c_HitSkillId) { for (int i = 0; i < locals.Length; ++i) { object instObj; if (locals[i].TryGetValue("hitskill", out instObj)) { innerInstance = instObj as SkillInstance; } } if (null == innerInstance) { LogSystem.Warn("{0} use predefined skill {1} {2} but not found hitskill, cancel.", actorId, skillId, seq); //m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); //return false; } } if (null == innerInstance) { inst = NewSkillInstance(skillId, senderInfo.ConfigData); } else { inst = NewInnerSkillInstance(skillId, innerInstance); } if (null != inst) { m_SkillLogicInfos.Add(new SkillLogicInfo(senderInfo, inst)); } else { LogSystem.Warn("{0} cast skill {1} {2}, alloc failed.", actorId, skillId, seq); m_Scene.EntityController.CancelIfImpact(actorId, configData, seq); return(false); } logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq); if (null != logicInfo) { if (null != locals) { int localCount = locals.Length; for (int i = 0; i < localCount; ++i) { foreach (KeyValuePair <string, object> pair in locals[i]) { logicInfo.SkillInst.SetVariable(pair.Key, pair.Value); } } } EntityInfo target = senderInfo.TargetGfxObj; if (null != target && target != obj && configData.type == (int)SkillOrImpactType.Skill) { TriggerUtil.Lookat(m_Scene, obj, target.GetMovementStateInfo().GetPosition3D()); } m_Scene.EntityController.ActivateSkill(actorId, skillId, seq); logicInfo.SkillInst.Context = m_Scene; logicInfo.SkillInst.Start(logicInfo.Sender); ret = true; } } return(ret); }