public void Target_UCE_PrepareSpawnPlaceableObjectClient(NetworkConnection target, int itemHash) { ScriptableItem item; if (ScriptableItem.dict.TryGetValue(itemHash, out item)) { UCE_myPlaceableObjectItem = (UCE_Item_PlaceableObject)item; if (UCE_CanSpawnPlaceableObject(UCE_myPlaceableObjectItem)) { Vector3 vBuildPosition = UCE_getSpawnDestination(); SetIndicatorViaPosition(vBuildPosition); if (UCE_myPlaceableObjectItem.previewObject != null) UCE_BuildSystem_PreviewObject = (GameObject)Instantiate(UCE_myPlaceableObjectItem.previewObject, vBuildPosition, Quaternion.identity); if (UCE_myPlaceableObjectItem.gridObject != null) UCE_BuildSystem_GridObject = (GameObject)Instantiate(UCE_myPlaceableObjectItem.gridObject, vBuildPosition, Quaternion.identity); if (!_UCE_UI_PlaceableObjectSpawn) _UCE_UI_PlaceableObjectSpawn = FindObjectOfType<UCE_UI_PlaceableObjectSpawn>(); _UCE_UI_PlaceableObjectSpawn.Show(); } else { UCE_PopupShow(UCE_myPlaceableObjectItem.cannotBePlaced); } } }
public void Target_UCE_StartSpawnPlaceableObjectClient(NetworkConnection target, int itemHash) { ScriptableItem item; if (ScriptableItem.dict.TryGetValue(itemHash, out item)) { UCE_myPlaceableObjectItem = (UCE_Item_PlaceableObject)item; UCE_setTimer(UCE_myPlaceableObjectItem.placementTime); UCE_CastbarShow(UCE_myPlaceableObjectItem.name, UCE_myPlaceableObjectItem.placementTime); } }
// ----------------------------------------------------------------------------------- // UCE_CanSpawnPlaceableObject // ----------------------------------------------------------------------------------- public bool UCE_CanSpawnPlaceableObject(UCE_Item_PlaceableObject item) { return (item != null && canInteract && isAlive && UCE_checkSpawnDestination(item.doNotSpawnAt) && (item.placementAreaId == 0 || (UCE_myPlaceableObjectAreaId == item.placementAreaId)) && (item.restrictedAreaId == 0 || (UCE_myPlaceableObjectAreaId != item.restrictedAreaId)) && (!item.onlyPersonalArea || (item.onlyPersonalArea && UCE_myPlaceableObjectAreaOwner)) && (!item.onlyGuildArea || (item.onlyGuildArea && UCE_myPlaceableObjectAreaGuild)) && (!item.guildRankRequired || (item.guildRankRequired && UCE_CheckGuildRank(item.guildRank))) #if _iMMOPVP && (!item.onlyPVPZone || item.onlyPVPZone && UCE_getInPvpRegion()) #endif ); }
// ----------------------------------------------------------------------------------- // Cmd_CancelSpawnPlaceableObject // @Client // ----------------------------------------------------------------------------------- public void UCE_CancelSpawnPlaceableObject() { if (UCE_BuildSystem_PreviewObject != null) Destroy(UCE_BuildSystem_PreviewObject); if (UCE_BuildSystem_GridObject != null) Destroy(UCE_BuildSystem_GridObject); UCE_BuildSystem_PreviewObject = null; UCE_myPlaceableObject = null; UCE_myPlaceableObjectItem = null; UCE_removeTask(); UCE_stopTimer(); UCE_CastbarHide(); Destroy(indicator); }
public void Target_UCE_PrepareSpawnPlaceableObjectClient(NetworkConnection target, int itemHash) { ScriptableItem item; if (ScriptableItem.dict.TryGetValue(itemHash, out item)) { UCE_myPlaceableObjectItem = (UCE_Item_PlaceableObject)item; if (UCE_CanSpawnPlaceableObject(UCE_myPlaceableObjectItem)) { Vector3 vBuildPosition = UCE_getSpawnDestination(); indicator.SetViaPosition(vBuildPosition); if (UCE_myPlaceableObjectItem.previewObject != null) { UCE_BuildSystem_PreviewObject = (GameObject)Instantiate(UCE_myPlaceableObjectItem.previewObject, vBuildPosition, Quaternion.identity); } if (UCE_myPlaceableObjectItem.gridObject != null) { UCE_BuildSystem_GridObject = (GameObject)Instantiate(UCE_myPlaceableObjectItem.gridObject, vBuildPosition, Quaternion.identity); } if (!_UCE_UI_PlaceableObjectSpawn) { _UCE_UI_PlaceableObjectSpawn = FindObjectOfType <UCE_UI_PlaceableObjectSpawn>(); } _UCE_UI_PlaceableObjectSpawn.Show(); if (UCE_myPlaceableObjectItem.placementObject.name == "Ownership Placement Area Structure") { _UCE_UI_PlaceableObjectSpawn.GetComponentInChildren <Text>().text = "Place ownership over this area?"; } else { _UCE_UI_PlaceableObjectSpawn.GetComponentInChildren <Text>().text = "Place object here?"; } } else { UCE_PopupShow(UCE_myPlaceableObjectItem.cannotBePlaced); } } }
protected IEnumerator SpawnPlaceableObject() { UCE_PlaceableObject o = null; int level = 0; Vector3 vBuildPosition = UCE_getSpawnDestination(); if (UCE_myPlaceableObjectItem.placementObject) { GameObject SimpleObject = (GameObject)Instantiate(UCE_myPlaceableObjectItem.placementObject, vBuildPosition, Quaternion.identity); NetworkServer.Spawn(SimpleObject); o = SimpleObject.GetComponent <UCE_PlaceableObject>(); if (o) { o.permanent = UCE_myPlaceableObjectItem.isPermanent; o.ownerCharacter = this.name; o.ownerGuild = this.guild.name; o.itemName = UCE_myPlaceableObjectItem.name; Entity e = SimpleObject.GetComponent <Entity>(); if (e) { level = e.level; } } } if (o != null && UCE_myPlaceableObjectItem.isPermanent) { Database.singleton.UCE_SavePlaceableObject(this.name, this.guild.name, o.gameObject, level, UCE_myPlaceableObjectItem.name, o.id); } InventoryRemove(new Item(UCE_myPlaceableObjectItem), UCE_myPlaceableObjectItem.decreaseAmount); UCE_myPlaceableObjectItem = null; yield return(new WaitForEndOfFrame()); }
private void OnDamageDealt_UCE_cancelStartSpawnPlaceableObject() { UCE_myPlaceableObjectItem = null; UCE_removeTask(); }
// ====================================== SPAWN ====================================== // ----------------------------------------------------------------------------------- // PrepareSpawnPlaceableObject // @Server // ----------------------------------------------------------------------------------- public void PrepareSpawnPlaceableObject(UCE_Item_PlaceableObject item) { UCE_myPlaceableObjectItem = item; Target_UCE_PrepareSpawnPlaceableObjectClient(connectionToClient, item.name.GetStableHashCode()); }