public static BaseRequest messageFromBytes(byte[] buffer) { VRage.ByteStream stream = new VRage.ByteStream(buffer, buffer.Length); TYPE t = (TYPE)stream.getUShort(); stream.Seek(0, System.IO.SeekOrigin.Begin); BaseRequest msg = null; switch (t) { case TYPE.FLEET: msg = new FleetRequest(); break; case TYPE.SETTINGS: msg = new SettingsRequest(); break; case TYPE.VIOLATIONS: msg = new ViolationsRequest(); break; case TYPE.DISOWN: msg = new DisownRequest(); break; case TYPE.STOPGRID: msg = new StopGridRequest(); break; } if (msg != null) msg.deserialize(stream); return msg; }
public bool requestDisown(string shipClass, string ID) { log("Sending Disown request", "requestDisown"); try { int classID = (int)Enum.Parse(typeof(HullClass.CLASS), shipClass.ToUpper()); int localID = Convert.ToInt32(ID); long entityID; //Some logic to decide whether or not the choice is a supported or unsupported grid, and its entityID if (localID >= m_SupportedGrids[classID].Count) { entityID = m_UnsupportedGrids[classID][localID - m_SupportedGrids[classID].Count].shipID; } else { entityID = m_SupportedGrids[classID][localID].shipID; } DisownRequest req = new DisownRequest(); req.ReturnAddress = MyAPIGateway.Session.Player.PlayerID; req.EntityID = entityID; send(req); return(true); } catch (Exception e) { log("Exception occured: " + e, "requestDisown"); return(false); } }
private void processDisownRequest(DisownRequest req) { IMyCubeGrid gridToDisown = MyAPIGateway.Entities.GetEntityById(req.EntityID) as IMyCubeGrid; List <IMySlimBlock> allBlocks = new List <IMySlimBlock>(); // Get only FatBlocks from the blocks list from the grid Func <IMySlimBlock, bool> isFatBlock = b => b.FatBlock != null; gridToDisown.GetBlocks(allBlocks, isFatBlock); foreach (IMySlimBlock block in allBlocks) { if (block.FatBlock.OwnerId == req.ReturnAddress) { // Code to disown blocks goes here // Disabled because current Space Engineer's Mod API does not have the capability to disown individual blocks //fatBlock.ChangeOwner(0, 0); } } }
public static BaseRequest messageFromBytes(byte[] buffer) { VRage.ByteStream stream = new VRage.ByteStream(buffer, buffer.Length); TYPE t = (TYPE)stream.getUShort(); stream.Seek(0, System.IO.SeekOrigin.Begin); BaseRequest msg = null; switch (t) { case TYPE.FLEET: msg = new FleetRequest(); break; case TYPE.SETTINGS: msg = new SettingsRequest(); break; case TYPE.VIOLATIONS: msg = new ViolationsRequest(); break; case TYPE.DISOWN: msg = new DisownRequest(); break; case TYPE.STOPGRID: msg = new StopGridRequest(); break; } if (msg != null) { msg.deserialize(stream); } return(msg); }
public bool requestDisown(string shipClass, string ID) { log("Sending Disown request", "requestDisown"); try { int classID = (int)Enum.Parse(typeof(HullClass.CLASS), shipClass.ToUpper()); int localID = Convert.ToInt32(ID); long entityID; //Some logic to decide whether or not the choice is a supported or unsupported grid, and its entityID if (localID >= m_SupportedGrids[classID].Count) { entityID = m_UnsupportedGrids[classID][localID - m_SupportedGrids[classID].Count].shipID; } else { entityID = m_SupportedGrids[classID][localID].shipID; } DisownRequest req = new DisownRequest(); req.ReturnAddress = MyAPIGateway.Session.Player.PlayerID; req.EntityID = entityID; send(req); return true; } catch (Exception e) { log("Exception occured: " + e, "requestDisown"); return false; } }
private void processDisownRequest(DisownRequest req) { IMyCubeGrid gridToDisown = MyAPIGateway.Entities.GetEntityById(req.EntityID) as IMyCubeGrid; List<IMySlimBlock> allBlocks = new List<IMySlimBlock>(); // Get only FatBlocks from the blocks list from the grid Func<IMySlimBlock, bool> isFatBlock = b => b.FatBlock != null; gridToDisown.GetBlocks(allBlocks, isFatBlock); foreach (IMySlimBlock block in allBlocks) { if (block.FatBlock.OwnerId == req.ReturnAddress) { // Code to disown blocks goes here // Disabled because current Space Engineer's Mod API does not have the capability to disown individual blocks //fatBlock.ChangeOwner(0, 0); } } }