public FCCommand(FC_COMMAND_NETSTREAM ecns) { _cmdIndex = ecns._commandIndex; if (ecns._state == AIAgent.STATE.RUN) { _cmd = CMD.ACTION_NEW_WAY; } else if (ecns._state == AIAgent.STATE.ATTACK) { _cmd = CMD.ACTION_TO_ATTACK_POS_SYNC; } else if (ecns._state == AIAgent.STATE.HURT) { _cmd = CMD.ACTION_TO_HURT_POS_SYNC; } else if (ecns._state == AIAgent.STATE.STAND) { _cmd = CMD.ACTION_TO_STAND; } else { _cmd = CMD.ACTION_TO_IDLE; } _param1 = ecns._currentPosition; _param2 = ecns._currentRotation; _param3 = ecns._state; _isRun = false; _needRunPerFrame = false; _canDrop = false; }
public FCCommand ReadCommandFromCache2(int objID) { FC_COMMAND_NETSTREAM ecns = null; FCCommand ewc = null; FCCommand ret = null; if (_commandCmdStreamCache.ContainsKey(objID)) { List <FC_COMMAND_NETSTREAM> list = _commandCmdStreamCache[objID]; if (list.Count > 0) { ecns = list[0]; } else { ecns = null; } } else { ecns = null; } if (_commandRpcCache.ContainsKey(objID)) { List <FCCommand> list = _commandRpcCache[objID]; if (list.Count > 0) { ewc = _commandRpcCache[objID][0]; if (ecns != null && ecns._commandIndex < ewc._cmdIndex) { ret = new FCCommand(ecns); _commandCmdStreamCache[objID].RemoveAt(0); } else { ret = ewc; // Debug.Log(string.Format("[rpc command] ReadCommandFromCache2 -- remove _commandIndex:{0} , _currentPosition:{1} , CMD = {2}" , // ewc._cmdIndex , ewc._commandPosition , ewc._cmd )); _commandRpcCache[objID].RemoveAt(0); } } else { ewc = null; } } else { ewc = null; } if (ecns != null && ret == null) { ret = new FCCommand(ecns); _commandCmdStreamCache[objID].RemoveAt(0); } return(ret); }
public FC_COMMAND_NETSTREAM(FC_COMMAND_NETSTREAM src) { _state = src._state; _currentPosition = src._currentPosition; _currentRotation = src._currentRotation; _commandIndex = src._commandIndex; timeStamp = src.timeStamp; }
public void ReadCommandFromCache(int objID, out FCCommand ewc, out FC_COMMAND_NETSTREAM ecns) { if (_commandCmdStreamCache.ContainsKey(objID)) { List <FC_COMMAND_NETSTREAM> list = _commandCmdStreamCache[objID]; if (list.Count > 0) { ecns = list[0]; _commandCmdStreamCache[objID].RemoveAt(0); } else { ecns = null; } } else { ecns = null; } if (_commandRpcCache.ContainsKey(objID)) { List <FCCommand> list = _commandRpcCache[objID]; if (list.Count > 0) { ewc = _commandRpcCache[objID][0]; _commandRpcCache[objID].RemoveAt(0); } else { ewc = null; } } else { ewc = null; } }
public void WriteCommandToCache(int netIndex, Vector3 commandPos, bool streamCommand, params object[] args) { OBJECT_ID objectID = ObjectManager.Instance.GetObjectByNetworkID(netIndex); if (objectID == null) { Debug.LogError(string.Format("Object ID is not exist ! netIndex = {0} , isStreamCommand = {1} ", netIndex, streamCommand)); return; } int objID = (int)objectID; ActionController ac = ObjectManager.Instance.GetObjectByNetworkID(netIndex).fcObj as ActionController; //Debug.Log("ac object id = " + ac.ObjectID + ", object ID = " + objID); //if(ac != null && ac.IsPlayer && GameManager.Instance.IsPVPMode) if (GameManager.Instance.IsPVPMode) { int cidx = (int)args[0]; //command stream idx if (streamCommand) { if (ac.AIUse.AIStateAgent.CurrentStateID == AIAgent.STATE.DEAD || ac.AIUse.AIStateAgent.CurrentStateID == AIAgent.STATE.REVIVE) { return; } if (!_commandCmdStreamCache.ContainsKey(objID)) { _commandCmdStreamCache[objID] = new List <FC_COMMAND_NETSTREAM>(); } List <FC_COMMAND_NETSTREAM> cpc = _commandCmdStreamCache[objID]; if ((cpc.Count > 0 && cpc[cpc.Count - 1]._commandIndex < cidx) || cpc.Count == 0) { FC_COMMAND_NETSTREAM ecns = new FC_COMMAND_NETSTREAM((FC_COMMAND_NETSTREAM)args[1]); ecns._commandIndex = cidx; if (ecns._state == AIAgent.STATE.HURT) { ac.AIUse.UpdateNetCommand(AIAgent.COMMAND_DONE_FLAG.IN_HURT_STATE); } //Debug.Log(string.Format("[stream command] _commandIndex:{0} , _currentPosition:{1} , _currentRotation{2} , _state{3}" , // ecns._commandIndex , ecns._currentPosition , ecns._currentRotation ,ecns._state)); cpc.Add(ecns); //Debug.Log("add stream cmd to list : _myRotation = " + ecns._currentRotation + ", cmd idx = " + ecns._commandIndex); } } else { if (!_commandRpcCache.ContainsKey(objID)) { _commandRpcCache[objID] = new List <FCCommand>(); } FCCommand ewc = new FCCommand((FCCommand)args[1]); ewc._cmdIndex = cidx; ewc._commandPosition = commandPos; ewc._isRun = false; ewc._needRunPerFrame = false; ewc._canDrop = false; //Debug.Log(string.Format("[rpc command] _commandIndex:{0} , _currentPosition:{1} , CMD = {2}" , // ewc._cmdIndex , ewc._commandPosition , ewc._cmd )); _commandRpcCache[objID].Add(ewc); if (ewc._cmd == FCCommand.CMD.CLIENT_HURT || ewc._cmd == FCCommand.CMD.ACTION_EOT || ewc._cmd == FCCommand.CMD.ATTACK_WITH_SPEC_CONTS) { //Debug.Log(Time.realtimeSinceStartup); ac.AIUse.UpdateNetCommand(); } //if find rpc command idx < player next command index or current //replace command //pre command may should return to array // all rpc command should have position param } } else { if (!streamCommand) { FCCommand ewc = (FCCommand)args[1]; ewc._cmdIndex = 0; _inputCommandList.Add(ewc); } } }