static bool CheckEnabled(byte[] msg, CustomClientState state) { var enabled = _magicString.SequenceEqual(msg); if (enabled) { state.APIEnabled = true; MyModAPIHelper.MyMultiplayer.Static.SendMessageTo(_channel, _magicString, state.EndpointId.Id.Value, true); #if DEBUG Plugin.Log.Warn("got magic message"); #endif } else { Plugin.Warn("Got unexpected data from client"); } return(false); }
static void SubscribeInventories(CustomClientState state, SubscribeInventories msg) { #if DEBUG Plugin.Log.Warn($"Got inventories subscribe {msg.EntityId?.Length ?? 0}"); #endif state.ClearInventorySubscriptions(); if (msg.EntityId == null) { return; } foreach (var entityId in msg.EntityId) { try { var entity = MyEntities.GetEntityById(entityId); if (entity == null) { Plugin.Warn($"Attempting to subscribe to unknown inventory entity"); continue; } for (int i2 = 0; i2 < entity.InventoryCount; i2++) { var inv = entity.GetInventory(i2); if (inv != null) { state.SubscribeInventory(inv); } } } catch (Exception e) { Plugin.Error("Inventory subscription error", e); } } }