public void SpawnInventoryItems(Character character, Inventory inventory) { if (character == null) { throw new System.InvalidOperationException($"Failed to spawn inventory items. Character was null."); } if (itemData == null) { throw new System.InvalidOperationException($"Failed to spawn inventory items for the character \"{character.Name}\". No saved inventory data."); } character.SpawnInventoryItems(inventory, itemData); }
public void SpawnInventoryItems(Character character, Inventory inventory) { character.SpawnInventoryItems(inventory, itemData); }
public void InitRound() { characters.Clear(); List <WayPoint> spawnWaypoints = null; List <WayPoint> mainSubWaypoints = WayPoint.SelectCrewSpawnPoints(characterInfos, Submarine.MainSub).ToList(); if (Level.IsLoadedOutpost) { spawnWaypoints = WayPoint.WayPointList.FindAll(wp => wp.SpawnType == SpawnType.Human && wp.Submarine == Level.Loaded.StartOutpost && wp.CurrentHull?.OutpostModuleTags != null && wp.CurrentHull.OutpostModuleTags.Contains("airlock")); while (spawnWaypoints.Count > characterInfos.Count) { spawnWaypoints.RemoveAt(Rand.Int(spawnWaypoints.Count)); } while (spawnWaypoints.Any() && spawnWaypoints.Count < characterInfos.Count) { spawnWaypoints.Add(spawnWaypoints[Rand.Int(spawnWaypoints.Count)]); } } if (spawnWaypoints == null || !spawnWaypoints.Any()) { spawnWaypoints = mainSubWaypoints; } System.Diagnostics.Debug.Assert(spawnWaypoints.Count == mainSubWaypoints.Count); for (int i = 0; i < spawnWaypoints.Count; i++) { var info = characterInfos[i]; info.TeamID = CharacterTeamType.Team1; Character character = Character.Create(info, spawnWaypoints[i].WorldPosition, info.Name); if (character.Info != null) { if (!character.Info.StartItemsGiven && character.Info.InventoryData != null) { DebugConsole.AddWarning($"Error when initializing a round: character \"{character.Name}\" has not been given their initial items but has saved inventory data. Using the saved inventory data instead of giving the character new items."); } if (character.Info.InventoryData != null) { character.SpawnInventoryItems(character.Inventory, character.Info.InventoryData); } else if (!character.Info.StartItemsGiven) { character.GiveJobItems(mainSubWaypoints[i]); } if (character.Info.HealthData != null) { character.Info.ApplyHealthData(character, character.Info.HealthData); } character.GiveIdCardTags(spawnWaypoints[i]); character.Info.StartItemsGiven = true; } AddCharacter(character); #if CLIENT if (IsSinglePlayer && (Character.Controlled == null || character.Info.LastControlled)) { Character.Controlled = character; } #endif } //longer delay in multiplayer to prevent the server from triggering NPC conversations while the players are still loading the round conversationTimer = IsSinglePlayer ? Rand.Range(5.0f, 10.0f) : Rand.Range(45.0f, 60.0f); }