public static void Postfix(ProtobufSerializer.GameObjectData goData, UniqueIdentifier uid) { if (Multiplayer.Active && SerializationHelper.BLOCK_HAND_PLACED_DESERIALIZATION && SpawnedWithoutServersPermission(goData, uid.gameObject) && uid.gameObject.name != "CellRoot(Clone)") { Object.Destroy(uid.gameObject); } }
public static void Postfix(ProtobufSerializer.GameObjectData goData, UniqueIdentifier uid) { if (blacklistedHandPlacedClassIds.Contains(goData.ClassId) && Multiplayer.Main != null && Multiplayer.Main.IsMultiplayer()) { UnityEngine.Object.Destroy(uid.gameObject); } }
private static bool SpawnedWithoutServersPermission(ProtobufSerializer.GameObjectData goData, GameObject gameObject) { if (!HAND_PLACED_ITEMS_ONLY_SPAWNABLE_BY_SERVER.Contains(goData.ClassId)) { // If these items are not in the blacklist then the server is fine with it being spawned. return(false); } NitroxEntity serverEntity = gameObject.GetComponent <NitroxEntity>(); if (serverEntity) { // if we have a NitroxEntity then the server is aware of this entity. return(false); } UniqueIdentifier identifier = gameObject.GetComponent <UniqueIdentifier>(); Entities entities = NitroxServiceLocator.LocateService <Entities>(); if (identifier != null && entities.WasSpawnedByServer(identifier.Id)) { // Looks like this ran through the main entity spawning code - the server knows about it. return(true); } // We've exhausted all mechanisms of entity detection - this doesn't appear to be an entity that the server is aware of. return(true); }
public static bool Prefix(ProtobufSerializer.GameObjectData goData) { if (blacklistedHandPlacedClassIds.Contains(goData.ClassId) && Multiplayer.Main != null && Multiplayer.Main.IsMultiplayer()) { return(false); } return(true); }
public static void Postfix(ProtobufSerializer.GameObjectData goData, UniqueIdentifier uid) { bool isMultiplayer = (Multiplayer.Main != null && Multiplayer.Main.IsMultiplayer()); if (isMultiplayer && SerializationHelper.BLOCK_HAND_PLACED_DESERIALIZATION && SpawnedWithoutServersPermission(goData, uid.gameObject) && uid.gameObject.name != "CellRoot(Clone)") { UnityEngine.Object.Destroy(uid.gameObject); } }
public GameObject(ProtobufSerializer.GameObjectData goData) { IsActive = goData.IsActive; Layer = goData.Layer; Tag = goData.Tag; Id = goData.Id; ClassId = goData.ClassId; Parent = goData.Parent; }
public static void Postfix(ProtobufSerializer.GameObjectData goData, UniqueIdentifier uid) { bool isMultiplayer = (Multiplayer.Main != null && Multiplayer.Main.IsMultiplayer()); if (isMultiplayer && SpawnedWithoutServersPermission(goData, uid.gameObject)) { UnityEngine.Object.Destroy(uid.gameObject); } }
private GameObject DeserializeGameObject(Stream stream) { ProtobufSerializer.GameObjectData goData = serializer.Deserialize <ProtobufSerializer.GameObjectData>(stream); GameObject gameObject = new GameObject(goData); DeserializeComponents(stream, gameObject); return(gameObject); }
// calling this instead of InstantiatePrefabAsync in ProtobufSerializer.DeserializeObjectsAsync private static IEnumerator _InstantiatePrefabAsync(ProtobufSerializer.GameObjectData gameObjectData, IOut <UniqueIdentifier> result) { if (GetModPrefabAsync(gameObjectData.ClassId) is IPrefabRequest request) { yield return(request); if (request.TryGetPrefab(out GameObject prefab)) { result.Set(UnityEngine.Object.Instantiate(prefab).GetComponent <UniqueIdentifier>()); yield break; } } yield return(ProtobufSerializer.InstantiatePrefabAsync(gameObjectData, result)); }
private static bool SpawnedWithoutServersPermission(ProtobufSerializer.GameObjectData goData, GameObject gameObject) { NitroxEntity serverEntity = gameObject.GetComponent <NitroxEntity>(); if (serverEntity) { // if we have a NitroxEntity then the server is aware of this entity. return(false); } UniqueIdentifier identifier = gameObject.GetComponent <UniqueIdentifier>(); Entities entities = NitroxServiceLocator.LocateService <Entities>(); if (identifier != null && entities.WasSpawnedByServer(identifier.Id)) { // Looks like this ran through the main entity spawning code - the server knows about it. return(false); } // We've exhausted all mechanisms of entity detection - this doesn't appear to be an entity that the server is aware of. return(true); }
private static bool SpawnedWithoutServersPermission(ProtobufSerializer.GameObjectData goData, GameObject gameObject) { NitroxEntity serverEntity = gameObject.GetComponent <NitroxEntity>(); return(serverEntity == null && HAND_PLACED_ITEMS_ONLY_SPAWNABLE_BY_SERVER.Contains(goData.ClassId)); }