private static bool SpawnPickup(ItemPickupBase ipb) { try { if (ipb == null) { return(false); } NetworkServer.Spawn(ipb.gameObject); var serial = InventorySystem.Items.ItemSerialGenerator.GenerateNext(); var info = new PickupSyncInfo { ItemId = ipb.Info.ItemId, Position = ipb.transform.position, Rotation = new LowPrecisionQuaternion(ipb.transform.rotation), Serial = serial, Weight = ipb.Info.Weight, Locked = ipb.Info.Locked }; //So for some Reason Mirror just f***s up when spawning the pickups after a door was opened so I have to set both to ensure the Serial is stored - vanilla bug? ipb.NetworkInfo = info; ipb.Info = info; ipb.InfoReceived(default, info);
private static bool ServerThrow(ThrowableItem __instance, float forceAmount, float upwardFactor, Vector3 torque, Vector3 startVel) { try { __instance._destroyTime = Time.timeSinceLevelLoad + __instance._postThrownAnimationTime; __instance._alreadyFired = true; var newpickup = UnityEngine.Object.Instantiate(__instance.Projectile, __instance.Owner.PlayerCameraReference.position, __instance.Owner.PlayerCameraReference.rotation); var info = new PickupSyncInfo { ItemId = __instance.ItemTypeId, Locked = !__instance._repickupable, Serial = __instance.ItemSerial, Weight = __instance.Weight, Position = newpickup.transform.position, Rotation = new LowPrecisionQuaternion(newpickup.transform.rotation), }; newpickup.NetworkInfo = info; newpickup.PreviousOwner = new Footprinting.Footprint(__instance.Owner); NetworkServer.Spawn(newpickup.gameObject); newpickup.InfoReceived(default, info);
private static bool ServerCreatePickupPatch(ref ItemPickupBase __result, Inventory inv, ItemBase item, PickupSyncInfo psi, bool spawn = true) { try { __result = null; if (item == null) { return(false); } var pickup = UnityEngine.Object.Instantiate(item.PickupDropModel, inv.transform.position, ReferenceHub.GetHub(inv.gameObject).PlayerCameraReference.rotation * item.PickupDropModel.transform.rotation); if (!SynapseItem.AllItems.TryGetValue(psi.Serial, out var sitem)) { Logger.Get.Warn($"Found unregistered ItemSerial: {psi.Serial}"); return(false); } pickup.NetworkInfo = psi; pickup.Info = psi; if (sitem == null) { sitem = new SynapseItem(pickup); } else { sitem.PickupBase = pickup; } pickup.transform.localScale = sitem.Scale; if (spawn) { NetworkServer.Spawn(pickup.gameObject); } pickup.InfoReceived(default, psi);