public static void Visualize() { SelectionManager.Update (); if (Input.GetMouseButtonDown(1)) { Command com = new Command(agentControllers[0].ControllerID,InputCode.M); Selection select = new Selection(); select.SerializeFromSelectionManager (); com.Select = select; com.Position = new Vector2d(SelectionManager.MouseWorldPosition); NetworkManager.SendCommand (com); } }
/// <summary> /// Reconstructs this command from a serialized command and returns the size of the command. /// </summary> public int Reconstruct(byte[] Source, int StartIndex) { reader.Initialize (Source, StartIndex); ControllerID = reader.ReadByte (); LeInput = (InputCode)reader.ReadByte (); ValuesMask = reader.ReadUInt (); HasPosition = GetMaskBool (ValuesMask, DataType.Position); HasTarget = GetMaskBool (ValuesMask, DataType.Target); HasFlag = GetMaskBool (ValuesMask, DataType.Flag); HasCoord = GetMaskBool (ValuesMask, DataType.Coord); HasCount = GetMaskBool (ValuesMask, DataType.Count); HasSelect = GetMaskBool (ValuesMask, DataType.Select); if (HasPosition) { _position.x = reader.ReadInt (); _position.y = reader.ReadInt (); } if (HasTarget) { _target = reader.ReadUShort (); } if (HasFlag) { _flag = reader.ReadBool (); } if (HasCoord) { _coord.x = reader.ReadInt (); _coord.y = reader.ReadInt (); } if (HasCount) { _count = reader.ReadInt (); } if (HasSelect) { Select = new Selection(); reader.count += Select.Reconstruct ( AgentController.InstanceManagers[ControllerID], reader.source, reader.count); } return reader.count - StartIndex; }
public void Execute(Command com) { if (com.LeInput == InputCode.Spawn) { for (int i = 0; i < com.Count; i++) { LSAgent agent = CreateAgent((AgentCode)com.Target, com.Position); } return; } if (com.HasGroupID) { /*var group = AgentGroupController.GetGroup(com.GroupID); if (group .IsNotNull ()) { for (i = 0; i < group.Agents.Count; i++) { group.Agents[i].Execute(com); } }*/ } else { if (com.HasSelect == false) com.Select = previousSelection; previousSelection = com.Select; } BehaviourHelper.GlobalExecute (com); for (int i = 0; i < com.Select.selectedAgentLocalIDs.Count; i++) { ushort selectedAgentID = com.Select.selectedAgentLocalIDs[i]; if (LocalAgentActive[selectedAgentID]) { LocalAgents[selectedAgentID].Execute(com); } } }