static void PatchedSplitStack(Stackable __instance, Interaction interaction, int quantity) { if (!GameManager.IsServer || quantity > __instance.Quantity) { return; } __instance.NetworkQuantity = __instance.Quantity - quantity; Human parent = interaction.SourceSlot.Parent as Human; if (parent == null) { return; } Stackable newStack = OnServer.Create( __instance.Prefab as DynamicThing, __instance.GetSafeDropPosition( interaction.SourceSlot.Parent.CenterPosition, parent.HelmetSlot.Location.forward, interaction.SourceThing.Bounds.size.z + 0.6f ), interaction.SourceThing.ThingTransform.rotation, __instance.OwnerSteamId, __instance.GridController.ParentMothership != null ? __instance.GridController.ParentMothership.RigidBody : null ) as Stackable; if (newStack != null) { if (__instance.CustomColor.IsSet) { OnServer.SetCustomColor(newStack, __instance.CustomColor.Index); } newStack.NetworkQuantity = Mathf.Min(quantity, newStack.MaxQuantity); __instance.OnSplitStack(newStack); Slot destinationSlot = parent.LeftHandSlot == interaction.SourceSlot ? parent.RightHandSlot : parent.LeftHandSlot; var occupantStackable = destinationSlot.Occupant as Stackable; if (occupantStackable != null && occupantStackable.PrefabHash == newStack.PrefabHash) { occupantStackable.Merge(newStack); } else if (destinationSlot.Occupant == null) { // Stationeers orignal code: //newStack.MoveToSlot(destinationSlot, newStack, false); // Bug fix for clients not seeing stack moves: OnServer.MoveToSlot(newStack, destinationSlot); } } }
private static bool Prefix(NetworkInstanceId parentId, ulong ownerSteamId, string prefabName) { DynamicThing dynamicThing = NetworkThing.Find(parentId) as DynamicThing; DynamicThing dynamicThing2 = (DynamicThing)Thing.FindPrefab(prefabName); bool flag = !dynamicThing2; if (!flag) { Vector3 vector = dynamicThing.RigidBody.worldCenterOfMass + dynamicThing.ThingTransform.forward * 1f; Quaternion rotation = Quaternion.AngleAxis(180f, dynamicThing.ThingTransform.up); DynamicThing dynamicThing3 = OnServer.Create(dynamicThing2, vector, rotation, ownerSteamId, null); Stackable stackable = dynamicThing3 as Stackable; bool flag2 = stackable; if (flag2) { stackable.NetworkQuantity = stackable.MaxQuantity; } BatteryCell batteryCell = dynamicThing3 as BatteryCell; bool flag3 = batteryCell; if (flag3) { batteryCell.PowerStored = batteryCell.PowerMaximum; } Ingot ingot = dynamicThing3 as Ingot; bool flag4 = ingot; if (flag4) { ingot.NetworkQuantity = ingot.MaxQuantity; } CreditCard creditCard = dynamicThing3 as CreditCard; bool flag5 = creditCard; if (flag5) { creditCard.Currency = 8000f; } DirtCanister dirtCanister = dynamicThing3 as DirtCanister; bool flag6 = dirtCanister; if (flag6) { dirtCanister.AddDirtCheat(8000f); } //Creative mode addition if (WorldManager.Instance.GameMode == GameMode.Creative) { int colorcan = -1; foreach (var chel in Human.AllHumans) //catch idea of search in lists from liz's AtomicBatteryPatch { if (chel.OwnerSteamId == dynamicThing3.OwnerSteamId) { Human parentHuman = null; parentHuman = chel; bool suitis = (parentHuman.Suit == null || parentHuman == null); if (!suitis) { //Debug.LogError("Builder catched"); colorcan = (int)(Math.Round(parentHuman.Suit.OutputSetting - 51f)); //pressure 50 = CustomColorIndex -1 default if (colorcan > 11) { colorcan = 11; } else if (colorcan < -1) { colorcan = -1; } } } } if (dynamicThing3.PaintableMaterial != null) { OnServer.SetCustomColor(dynamicThing3, colorcan); } } } return(false); }