/// <summary> /// Tries to spawn at the specified position, does not spawn if position is not valid (impassable) /// </summary> private void TrySpawn() { Vector3Int position = cursorObject.transform.position.RoundToInt(); position.z = 0; if (MatrixManager.IsPassableAt(position, true)) { if (CustomNetworkManager.IsServer) { if (clothingData != null) { ClothFactory.CreateCloth(clothingData, position); } else { PoolManager.PoolNetworkInstantiate(prefab, position); } } else { if (clothingData != null) { DevSpawnMessage.Send(clothingData.name, true, (Vector3)position); } else { DevSpawnMessage.Send(prefab.name, false, (Vector3)position); } } } }
public override IEnumerator Process() { //TODO: Validate if player is allowed to spawn things, check if they have admin privs. //For now we will let anyone spawn. if (MatrixManager.IsPassableAt(WorldPosition.RoundToInt())) { if (!IsUniCloth) { PoolManager.PoolNetworkInstantiate(Name, WorldPosition); } else { ClothFactory.CreateCloth(Name, WorldPosition); } } yield return(null); }
public override IEnumerator Process() { //TODO: Validate if player is allowed to spawn things, check if they have admin privs. //For now we will let anyone spawn. var pos = WorldPosition.RoundToInt(); var isPassable = MatrixManager.IsPassableAt(pos, true); var isTableAt = MatrixManager.IsTableAt(pos, true); if (isPassable || isTableAt) { if (IsUniCloth) { var clothData = ClothFactory.Instance.ClothingStoredData[Name]; ClothFactory.CreateCloth(clothData, WorldPosition); } else { PoolManager.PoolNetworkInstantiate(Name, WorldPosition); } } yield return(null); }
public void SetPlayerLoadOuts() { JobOutfit standardOutfit = GameManager.Instance.StandardOutfit.GetComponent <JobOutfit>(); JobOutfit jobOutfit = GameManager.Instance.GetOccupationOutfit(playerScript.mind.jobType); //Create collection of all the new items to add to the gear slots Dictionary <EquipSlot, ClothOrPrefab> gear = new Dictionary <EquipSlot, ClothOrPrefab>(); gear.Add(EquipSlot.uniform, standardOutfit.uniform); gear.Add(EquipSlot.feet, standardOutfit.shoes); gear.Add(EquipSlot.eyes, standardOutfit.glasses); gear.Add(EquipSlot.hands, standardOutfit.gloves); Backpack = standardOutfit.backpack; Ears = standardOutfit.ears; gear.Add(EquipSlot.exosuit, standardOutfit.suit); gear.Add(EquipSlot.head, standardOutfit.head); gear.Add(EquipSlot.mask, standardOutfit.mask); gear.Add(EquipSlot.suitStorage, standardOutfit.suit_store); AddifPresent(gear, EquipSlot.exosuit, jobOutfit.suit); AddifPresent(gear, EquipSlot.head, jobOutfit.head); AddifPresent(gear, EquipSlot.uniform, jobOutfit.uniform); AddifPresent(gear, EquipSlot.feet, jobOutfit.shoes); AddifPresent(gear, EquipSlot.hands, jobOutfit.gloves); AddifPresent(gear, EquipSlot.eyes, jobOutfit.glasses); AddifPresent(gear, EquipSlot.mask, jobOutfit.mask); if (jobOutfit.backpack?.Backpack?.Sprites?.Equipped?.Texture != null || jobOutfit.backpack.Prefab != null) { Backpack = jobOutfit.backpack; } if (jobOutfit.ears?.Headset?.Sprites?.Equipped?.Texture != null || jobOutfit.ears.Prefab != null) { Ears = jobOutfit.ears; } foreach (KeyValuePair <EquipSlot, ClothOrPrefab> gearItem in gear) { if (gearItem.Value.Clothing != null) { if (gearItem.Value.Clothing.PrefabVariant != null) { var obj = ClothFactory.CreateCloth(gearItem.Value.Clothing, TransformState.HiddenPos, transform.parent, PrefabOverride: gearItem.Value.Clothing.PrefabVariant); //Where it is made ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(gearItem.Key, itemAtts.gameObject, true); } else { var obj = ClothFactory.CreateCloth(gearItem.Value.Clothing, TransformState.HiddenPos, transform.parent); ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(gearItem.Key, itemAtts.gameObject, true); } } else if (gearItem.Value.Prefab != null) { var obj = PoolManager.PoolNetworkInstantiate(gearItem.Value.Prefab, TransformState.HiddenPos, transform.parent); ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(gearItem.Key, itemAtts.gameObject, true); } } if (Backpack.Backpack != null) { if (Backpack.Backpack.PrefabVariant != null) { var obj = ClothFactory.CreateBackpackCloth(Backpack.Backpack, TransformState.HiddenPos, transform.parent, PrefabOverride: Backpack.Backpack.PrefabVariant); //Where it is made ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(EquipSlot.back, itemAtts.gameObject, true); } else { var obj = ClothFactory.CreateBackpackCloth(Backpack.Backpack, TransformState.HiddenPos, transform.parent); ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(EquipSlot.back, itemAtts.gameObject, true); } } else if (Backpack.Prefab) { var obj = PoolManager.PoolNetworkInstantiate(Backpack.Prefab, TransformState.HiddenPos, transform.parent); ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(EquipSlot.back, itemAtts.gameObject, true); } if (Ears.Headset != null) { if (Ears.Headset.PrefabVariant != null) { var obj = ClothFactory.CreateHeadsetCloth(Ears.Headset, TransformState.HiddenPos, transform.parent, PrefabOverride: Ears.Headset.PrefabVariant); //Where it is made ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(EquipSlot.ear, itemAtts.gameObject, true); } else { var obj = ClothFactory.CreateHeadsetCloth(Ears.Headset, TransformState.HiddenPos, transform.parent); ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(EquipSlot.ear, itemAtts.gameObject, true); } } else if (Ears.Prefab) { var obj = PoolManager.PoolNetworkInstantiate(Backpack.Prefab, TransformState.HiddenPos, transform.parent); ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(EquipSlot.ear, itemAtts.gameObject, true); } SpawnID(jobOutfit); }
public IEnumerator SetPlayerLoadOuts() { //Waiting for player name resolve yield return(WaitUntilInControl()); // Null Job players dont get a loadout if (playerScript.JobType == JobType.NULL) { yield break; } PlayerScript pS = GetComponent <PlayerScript>(); pS.JobType = playerScript.JobType; JobOutfit standardOutfit = GameManager.Instance.StandardOutfit.GetComponent <JobOutfit>(); JobOutfit jobOutfit = GameManager.Instance.GetOccupationOutfit(playerScript.JobType); Dictionary <string, string> gear = new Dictionary <string, string>(); gear.Add("uniform", standardOutfit.uniform); gear.Add("ears", standardOutfit.ears); gear.Add("belt", standardOutfit.belt); gear.Add("back", standardOutfit.backpack); gear.Add("shoes", standardOutfit.shoes); gear.Add("glasses", standardOutfit.glasses); gear.Add("gloves", standardOutfit.gloves); gear.Add("suit", standardOutfit.suit); gear.Add("head", standardOutfit.head); //gear.Add("accessory", standardOutfit.accessory); gear.Add("mask", standardOutfit.mask); //gear.Add("backpack", standardOutfit.backpack); //gear.Add("satchel", standardOutfit.satchel); //gear.Add("duffelbag", standardOutfit.duffelbag); //gear.Add("box", standardOutfit.box); //gear.Add("l_hand", standardOutfit.l_hand); //gear.Add("l_pocket", standardOutfit.l_pocket); //gear.Add("r_pocket", standardOutfit.r_pocket); //gear.Add("suit_store", standardOutfit.suit_store); if (!string.IsNullOrEmpty(jobOutfit.uniform)) { gear["uniform"] = jobOutfit.uniform; } /*if (!String.IsNullOrEmpty(jobOutfit.id)) * gear["id"] = jobOutfit.id;*/ if (!string.IsNullOrEmpty(jobOutfit.ears)) { gear["ears"] = jobOutfit.ears; } if (!string.IsNullOrEmpty(jobOutfit.belt)) { gear["belt"] = jobOutfit.belt; } if (!string.IsNullOrEmpty(jobOutfit.backpack)) { gear["back"] = jobOutfit.backpack; } if (!string.IsNullOrEmpty(jobOutfit.shoes)) { gear["shoes"] = jobOutfit.shoes; } if (!string.IsNullOrEmpty(jobOutfit.glasses)) { gear["glasses"] = jobOutfit.glasses; } if (!string.IsNullOrEmpty(jobOutfit.gloves)) { gear["gloves"] = jobOutfit.gloves; } if (!string.IsNullOrEmpty(jobOutfit.suit)) { gear["suit"] = jobOutfit.suit; } if (!string.IsNullOrEmpty(jobOutfit.head)) { gear["head"] = jobOutfit.head; } /*if (!String.IsNullOrEmpty(jobOutfit.accessory)) * gear["accessory"] = jobOutfit.accessory;*/ if (!string.IsNullOrEmpty(jobOutfit.mask)) { gear["mask"] = jobOutfit.mask; } /*if (!String.IsNullOrEmpty(jobOutfit.backpack)) * gear["backpack"] = jobOutfit.backpack; * if (!String.IsNullOrEmpty(jobOutfit.satchel)) * gear["satchel"] = jobOutfit.satchel; * if (!String.IsNullOrEmpty(jobOutfit.duffelbag)) * gear["duffelbag"] = jobOutfit.duffelbag; * if (!String.IsNullOrEmpty(jobOutfit.box)) * gear["box"] = jobOutfit.box; * if (!String.IsNullOrEmpty(jobOutfit.l_hand)) * gear["l_hand"] = jobOutfit.l_hand; * if (!String.IsNullOrEmpty(jobOutfit.l_pocket)) * gear["l_pocket"] = jobOutfit.l_pocket; * if (!String.IsNullOrEmpty(jobOutfit.r_pocket)) * gear["r_pocket"] = jobOutfit.r_pocket; * if (!String.IsNullOrEmpty(jobOutfit.suit_store)) * gear["suit_store"] = jobOutfit.suit_store;*/ foreach (KeyValuePair <string, string> gearItem in gear) { if (gearItem.Value.Contains(UniItemUtils.ClothingHierIdentifier) || gearItem.Value.Contains(UniItemUtils.HeadsetHierIdentifier) || gearItem.Value.Contains(UniItemUtils.BackPackHierIdentifier) || gearItem.Value.Contains(UniItemUtils.BagHierIdentifier)) { GameObject obj = ClothFactory.CreateCloth(gearItem.Value, TransformState.HiddenPos, transform.parent); //if ClothFactory does not return an object then move on to the next clothing item if (!obj) { Logger.LogWarning("Trying to instantiate clothing item " + gearItem.Value + " failed!", Category.Equipment); continue; } ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(GetLoadOutEventName(gearItem.Key), itemAtts.gameObject); } else if (!string.IsNullOrEmpty(gearItem.Value)) { // Logger.Log(gearItem.Value + " creation not implemented yet."); } } SpawnID(jobOutfit); yield return(new WaitForSeconds(3f)); //Wait a bit for headset to be fully setup and player to be fully spawned. if (playerScript.JobType == JobType.SYNDICATE) { //Check to see if there is a nuke and communicate the nuke code: NukeInteract nuke = FindObjectOfType <NukeInteract>(); if (nuke != null) { UpdateChatMessage.Send(gameObject, ChatChannel.Syndicate, "We have intercepted the code for the nuclear weapon: " + nuke.NukeCode); } } }
public IEnumerator SetPlayerLoadOuts() { //Waiting for player name resolve yield return(new WaitForSeconds(0.2f)); // Null Job players dont get a loadout if (playerScript.JobType == JobType.NULL) { yield break; } PlayerScript pS = GetComponent <PlayerScript>(); pS.JobType = playerScript.JobType; JobOutfit standardOutfit = GameManager.Instance.StandardOutfit.GetComponent <JobOutfit>(); JobOutfit jobOutfit = GameManager.Instance.GetOccupationOutfit(playerScript.JobType); Dictionary <string, string> gear = new Dictionary <string, string>(); gear.Add("uniform", standardOutfit.uniform); gear.Add("ears", standardOutfit.ears); gear.Add("belt", standardOutfit.belt); gear.Add("back", standardOutfit.back); gear.Add("shoes", standardOutfit.shoes); gear.Add("glasses", standardOutfit.glasses); gear.Add("gloves", standardOutfit.gloves); gear.Add("suit", standardOutfit.suit); gear.Add("head", standardOutfit.head); //gear.Add("accessory", standardOutfit.accessory); gear.Add("mask", standardOutfit.mask); //gear.Add("backpack", standardOutfit.backpack); //gear.Add("satchel", standardOutfit.satchel); //gear.Add("duffelbag", standardOutfit.duffelbag); //gear.Add("box", standardOutfit.box); //gear.Add("l_hand", standardOutfit.l_hand); //gear.Add("l_pocket", standardOutfit.l_pocket); //gear.Add("r_pocket", standardOutfit.r_pocket); //gear.Add("suit_store", standardOutfit.suit_store); if (!String.IsNullOrEmpty(jobOutfit.uniform)) { gear["uniform"] = jobOutfit.uniform; } /*if (!String.IsNullOrEmpty(jobOutfit.id)) * gear["id"] = jobOutfit.id;*/ if (!String.IsNullOrEmpty(jobOutfit.ears)) { gear["ears"] = jobOutfit.ears; } if (!String.IsNullOrEmpty(jobOutfit.belt)) { gear["belt"] = jobOutfit.belt; } if (!String.IsNullOrEmpty(jobOutfit.back)) { gear["back"] = jobOutfit.back; } if (!String.IsNullOrEmpty(jobOutfit.shoes)) { gear["shoes"] = jobOutfit.shoes; } if (!String.IsNullOrEmpty(jobOutfit.glasses)) { gear["glasses"] = jobOutfit.glasses; } if (!String.IsNullOrEmpty(jobOutfit.gloves)) { gear["gloves"] = jobOutfit.gloves; } if (!String.IsNullOrEmpty(jobOutfit.suit)) { gear["suit"] = jobOutfit.suit; } if (!String.IsNullOrEmpty(jobOutfit.head)) { gear["head"] = jobOutfit.head; } /*if (!String.IsNullOrEmpty(jobOutfit.accessory)) * gear["accessory"] = jobOutfit.accessory;*/ if (!String.IsNullOrEmpty(jobOutfit.mask)) { gear["mask"] = jobOutfit.mask; } /*if (!String.IsNullOrEmpty(jobOutfit.backpack)) * gear["backpack"] = jobOutfit.backpack; * if (!String.IsNullOrEmpty(jobOutfit.satchel)) * gear["satchel"] = jobOutfit.satchel; * if (!String.IsNullOrEmpty(jobOutfit.duffelbag)) * gear["duffelbag"] = jobOutfit.duffelbag; * if (!String.IsNullOrEmpty(jobOutfit.box)) * gear["box"] = jobOutfit.box; * if (!String.IsNullOrEmpty(jobOutfit.l_hand)) * gear["l_hand"] = jobOutfit.l_hand; * if (!String.IsNullOrEmpty(jobOutfit.l_pocket)) * gear["l_pocket"] = jobOutfit.l_pocket; * if (!String.IsNullOrEmpty(jobOutfit.r_pocket)) * gear["r_pocket"] = jobOutfit.r_pocket; * if (!String.IsNullOrEmpty(jobOutfit.suit_store)) * gear["suit_store"] = jobOutfit.suit_store;*/ foreach (KeyValuePair <string, string> gearItem in gear) { if (gearItem.Value.Contains("cloth")) { GameObject obj = ClothFactory.CreateCloth(gearItem.Value, Vector3.zero); ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(GetLoadOutEventName(gearItem.Key), itemAtts.gameObject); } } SpawnID(jobOutfit); }
public void SetPlayerLoadOuts() { JobOutfit standardOutfit = GameManager.Instance.StandardOutfit.GetComponent <JobOutfit>(); JobOutfit jobOutfit = GameManager.Instance.GetOccupationOutfit(playerScript.mind.jobType); Dictionary <EquipSlot, string> gear = new Dictionary <EquipSlot, string>(); gear.Add(EquipSlot.uniform, standardOutfit.uniform); gear.Add(EquipSlot.ear, standardOutfit.ears); gear.Add(EquipSlot.belt, standardOutfit.belt); gear.Add(EquipSlot.back, standardOutfit.backpack); gear.Add(EquipSlot.feet, standardOutfit.shoes); gear.Add(EquipSlot.eyes, standardOutfit.glasses); gear.Add(EquipSlot.hands, standardOutfit.gloves); gear.Add(EquipSlot.exosuit, standardOutfit.suit); gear.Add(EquipSlot.head, standardOutfit.head); //gear.Add(EquipSlot.accessory, standardOutfit.accessory); gear.Add(EquipSlot.mask, standardOutfit.mask); //gear.Add(EquipSlot.backpack, standardOutfit.backpack); //gear.Add(EquipSlot.satchel, standardOutfit.satchel); //gear.Add(EquipSlot.duffelbag, standardOutfit.duffelbag); //gear.Add(EquipSlot.box, standardOutfit.box); //gear.Add(EquipSlot.l_hand, standardOutfit.l_hand); //gear.Add(EquipSlot.l_pocket, standardOutfit.l_pocket); //gear.Add(EquipSlot.r_pocket, standardOutfit.r_pocket); //gear.Add(EquipSlot.suit_store, standardOutfit.suit_store); if (!string.IsNullOrEmpty(jobOutfit.uniform)) { gear[EquipSlot.uniform] = jobOutfit.uniform; } /*if (!String.IsNullOrEmpty(jobOutfit.id)) * gear[EquipSlot.id] = jobOutfit.id;*/ if (!string.IsNullOrEmpty(jobOutfit.ears)) { gear[EquipSlot.ear] = jobOutfit.ears; } if (!string.IsNullOrEmpty(jobOutfit.belt)) { gear[EquipSlot.belt] = jobOutfit.belt; } if (!string.IsNullOrEmpty(jobOutfit.backpack)) { gear[EquipSlot.back] = jobOutfit.backpack; } if (!string.IsNullOrEmpty(jobOutfit.shoes)) { gear[EquipSlot.feet] = jobOutfit.shoes; } if (!string.IsNullOrEmpty(jobOutfit.glasses)) { gear[EquipSlot.eyes] = jobOutfit.glasses; } if (!string.IsNullOrEmpty(jobOutfit.gloves)) { gear[EquipSlot.hands] = jobOutfit.gloves; } if (!string.IsNullOrEmpty(jobOutfit.suit)) { gear[EquipSlot.exosuit] = jobOutfit.suit; } if (!string.IsNullOrEmpty(jobOutfit.head)) { gear[EquipSlot.head] = jobOutfit.head; } /*if (!String.IsNullOrEmpty(jobOutfit.accessory)) * gear[EquipSlot.accessory] = jobOutfit.accessory;*/ if (!string.IsNullOrEmpty(jobOutfit.mask)) { gear[EquipSlot.mask] = jobOutfit.mask; } /*if (!String.IsNullOrEmpty(jobOutfit.backpack)) * gear[EquipSlot.backpack] = jobOutfit.backpack; * if (!String.IsNullOrEmpty(jobOutfit.satchel)) * gear[EquipSlot.satchel] = jobOutfit.satchel; * if (!String.IsNullOrEmpty(jobOutfit.duffelbag)) * gear[EquipSlot.duffelbag] = jobOutfit.duffelbag; * if (!String.IsNullOrEmpty(jobOutfit.box)) * gear[EquipSlot.box] = jobOutfit.box; * if (!String.IsNullOrEmpty(jobOutfit.l_hand)) * gear[EquipSlot.l_hand] = jobOutfit.l_hand; * if (!String.IsNullOrEmpty(jobOutfit.l_pocket)) * gear[EquipSlot.l_pocket] = jobOutfit.l_pocket; * if (!String.IsNullOrEmpty(jobOutfit.r_pocket)) * gear[EquipSlot.r_pocket] = jobOutfit.r_pocket; * if (!String.IsNullOrEmpty(jobOutfit.suit_store)) * gear[EquipSlot.suit_store] = jobOutfit.suit_store;*/ foreach (KeyValuePair <EquipSlot, string> gearItem in gear) { if (gearItem.Value.Contains(UniItemUtils.ClothingHierIdentifier) || gearItem.Value.Contains(UniItemUtils.HeadsetHierIdentifier) || gearItem.Value.Contains(UniItemUtils.BackPackHierIdentifier) || gearItem.Value.Contains(UniItemUtils.BagHierIdentifier)) { GameObject obj = ClothFactory.CreateCloth(gearItem.Value, TransformState.HiddenPos, transform.parent); //if ClothFactory does not return an object then move on to the next clothing item if (!obj) { Logger.LogWarning("Trying to instantiate clothing item " + gearItem.Value + " failed!", Category.Equipment); continue; } ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>(); SetItem(gearItem.Key, itemAtts.gameObject); } else if (!string.IsNullOrEmpty(gearItem.Value)) { // Logger.Log(gearItem.Value + " creation not implemented yet."); } } SpawnID(jobOutfit); if (playerScript.mind.jobType == JobType.SYNDICATE) { //Check to see if there is a nuke and communicate the nuke code: Nuke nuke = FindObjectOfType <Nuke>(); if (nuke != null) { UpdateChatMessage.Send(gameObject, ChatChannel.Syndicate, "We have intercepted the code for the nuclear weapon: " + nuke.NukeCode); } } }
public void SpawnCloth() { ClothFactory.CreateCloth("", transform.position); }