public void CmdRequestThrow(string slot, Vector3 worldTargetPos, int aim) { if (playerScript.canNotInteract() || slot != "leftHand" && slot != "rightHand" || !SlotNotEmpty(slot)) { RollbackPrediction(slot); return; } GameObject throwable = Inventory[slot]; Vector3 playerPos = playerScript.PlayerSync.ServerState.WorldPosition; EquipmentPool.DisposeOfObject(gameObject, throwable); ClearInventorySlot(slot); var throwInfo = new ThrowInfo { ThrownBy = gameObject, Aim = (BodyPartType)aim, OriginPos = playerPos, TargetPos = worldTargetPos, //Clockwise spin from left hand and Counterclockwise from the right hand SpinMode = slot == "leftHand" ? SpinMode.Clockwise : SpinMode.CounterClockwise, }; throwable.GetComponent <CustomNetTransform>().Throw(throwInfo); //Simplified counter-impulse for players in space if (playerScript.PlayerSync.IsInSpace) { playerScript.PlayerSync.Push(Vector2Int.RoundToInt(-throwInfo.Trajectory.normalized)); } }
public void OnRemoveFromPool() { if (CurrentMagazine != null) { EquipmentPool.DisposeOfObject(NetworkServer.FindLocalObject(ControlledByPlayer).gameObject, CurrentMagazine.gameObject); } ControlledByPlayer = NetworkInstanceId.Invalid; }
public void Consume(GameObject item) { foreach (var slot in Inventory) { if (item == slot.Value) { ClearInventorySlot(slot.Key); break; } } EquipmentPool.DisposeOfObject(gameObject, item); }
public void DisposeOfChildItem(GameObject obj) { EquipmentPool.DisposeOfObject(gameObject, obj); }