void DeployableRemove(DeployableObject deployable, RemoveHandler rplayer) { if (!canRemoveDeployable(deployable, rplayer.removeType)) { SendReply(rplayer.playerclient.netUser, noRemoveAccess); return; } if (canRefund) { TryRefund(deployableCloneToGood[deployable.gameObject.name], rplayer); } TakeDamage.KillSelf(deployable.GetComponent <IDMain>()); }
public static bool CheckOwner(DeployableObject obj, Controllable controllable) { DoorEvent de = new DoorEvent(new Entity(obj)); if (obj.ownerID == controllable.playerClient.userID) { de.Open = true; } if ((obj.GetComponent <BasicDoor>() != null) && (OnDoorUse != null)) { OnDoorUse(Magma.Player.FindByPlayerClient(controllable.playerClient), de); } return(de.Open); }
public static bool CheckOwner(DeployableObject obj, Controllable controllable) { DoorEvent doorEvent = new DoorEvent(new Entity(obj)); if (obj.ownerID == controllable.playerClient.userID) { doorEvent.Open = true; } if (obj.GetComponent <BasicDoor>() != null && Hooks.OnDoorUse != null) { Hooks.OnDoorUse(Player.FindByPlayerClient(controllable.playerClient), doorEvent); } return(doorEvent.Open); }
///////////////////////////////////////// // OnItemDeployed(Deployer deployer, BaseEntity deployedEntity) // Called when an item was deployed ///////////////////////////////////////// void OnItemDeployedByPlayer(DeployableObject deployedEntity, IDeployableItem deployableItem) { if (deployableItem.controllable == null) { return; } if (hasTag(deployableItem.controllable.playerClient, "nodeploy")) { if (!hasPermission(deployableItem.controllable.playerClient, "candeploy")) { timer.Once(0.01f, () => DestroyObject(deployedEntity.gameObject)); SendMessage(deployableItem.controllable.playerClient, "You are not allowed to deploy here"); } } else if (deployedEntity.GetComponent <TimedExplosive>()) { timer.Once(4f, () => CheckPositionExplosive(deployedEntity, deployableItem)); } }
void PasteDeployables(List <object> deployablesData, Vector3 targetPoint, float targetRot, float heightAdjustment, NetUser player) { Vector3 OriginRotation = new Vector3(0f, targetRot, 0f); Quaternion OriginRot = Quaternion.EulerRotation(OriginRotation); foreach (Dictionary <string, object> deployable in deployablesData) { Dictionary <string, object> structPos = deployable["pos"] as Dictionary <string, object>; Dictionary <string, object> structRot = deployable["rot"] as Dictionary <string, object>; string prefabname = (string)deployable["prefabname"]; Quaternion newAngles = Quaternion.EulerRotation((new Vector3(Convert.ToSingle(structRot["x"]), Convert.ToSingle(structRot["y"]), Convert.ToSingle(structRot["z"]))) + OriginRotation); Vector3 TempPos = OriginRot * (new Vector3(Convert.ToSingle(structPos["x"]), Convert.ToSingle(structPos["y"]), Convert.ToSingle(structPos["z"]))); Vector3 NewPos = TempPos + targetPoint; DeployableObject block = SpawnDeployable(prefabname, NewPos, newAngles); if (block != null) { block.SetupCreator(player.playerClient.controllable); block.GrabCarrier(); LootableObject lootobject = block.GetComponent <LootableObject>(); if (lootobject == null) { continue; } List <object> itemlist = deployable["items"] as List <object>; if (itemlist == null || itemlist.Count == 0) { continue; } foreach (Dictionary <string, object> item in itemlist) { lootobject._inventory.AddItemAmount(displaynameToDataBlock[item["name"].ToString()], (displaynameToDataBlock[item["name"].ToString()])._splittable? Convert.ToInt32(item["amount"]) : 1); } } } }
///////////////////////////////////////// // OnItemDeployed(Deployer deployer, BaseEntity deployedEntity) // Called when an item was deployed ///////////////////////////////////////// void OnItemDeployedByPlayer(DeployableObject deployedEntity, IDeployableItem deployableItem) { if (deployableItem.controllable == null) return; if (hasTag(deployableItem.controllable.playerClient, "nodeploy")) { if (!hasPermission(deployableItem.controllable.playerClient, "candeploy")) { timer.Once(0.01f, () => DestroyObject(deployedEntity.gameObject)); SendMessage(deployableItem.controllable.playerClient, "You are not allowed to deploy here"); } } else if(deployedEntity.GetComponent<TimedExplosive>()) { timer.Once(4f, () => CheckPositionExplosive(deployedEntity, deployableItem)); } }
void cmdChatProd(NetUser netuser, string command, string[] args) { if (!hasAccess(netuser)) { SendReply(netuser, "You don't have access to this command"); return; } cachedCharacter = netuser.playerClient.rootControllable.idMain.GetComponent <Character>(); if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { SendReply(netuser, "Are you looking at the sky?"); return; } //Debug.Log(cachedRaycast.collider.ToString()); //Debug.Log(LayerMask.LayerToName(cachedRaycast.collider.gameObject.layer)); //Debug.Log(cachedRaycast.collider.transform.position.y.ToString()); //Debug.Log(cachedCharacter.origin.y.ToString()); //GameObject.Destroy(cachedRaycast.collider.GetComponent<UnityEngine.MeshCollider>()); /* * * var components = cachedRaycast.collider.GetComponents<UnityEngine.Component>(); * foreach (var comp in components) * { * Debug.Log(comp.ToString()); * } * Debug.Log("============= COMPONENTS IN PARENT ============="); * components = cachedRaycast.collider.GetComponentsInParent<UnityEngine.Component>(); * foreach (var comp in components) * { * Debug.Log(comp.ToString()); * } * Debug.Log("============= COMPONENTS IN CHILDREN ============="); * components = cachedRaycast.collider.GetComponentsInChildren<UnityEngine.Component>(); * foreach (var comp in components) * { * Debug.Log(comp.ToString()); * }*/ if (cachedhitInstance != null) { cachedCollider = cachedhitInstance.physicalColliderReferenceOnly; if (cachedCollider == null) { SendReply(netuser, "Can't prod what you are looking at"); return; } cachedStructure = cachedCollider.GetComponent <StructureComponent>(); if (cachedStructure != null && cachedStructure._master != null) { cachedMaster = cachedStructure._master; var name = PlayerDatabase?.Call("GetPlayerData", cachedMaster.ownerID.ToString(), "name"); SendReply(netuser, string.Format("{0} - {1} - {2}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "UnknownPlayer" : name.ToString())); return; } } else { cachedDeployable = cachedRaycast.collider.GetComponent <DeployableObject>(); if (cachedDeployable != null) { var name = PlayerDatabase?.Call("GetPlayerData", cachedDeployable.ownerID.ToString(), "name"); SendReply(netuser, string.Format("{0} - {1} - {2}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString())); if (cachedDeployable.GetComponent <PasswordLockableObject>()) { SendReply(netuser, "Players with access to this door:"); int count = 0; foreach (ulong userid in (HashSet <ulong>)accessUsers.GetValue(cachedDeployable.GetComponent <PasswordLockableObject>())) { count++; name = PlayerDatabase?.Call("GetPlayerData", userid.ToString(), "name"); SendReply(netuser, string.Format("{0} - {1}", userid.ToString(), name == null ? "Unknown" : name.ToString())); } if (count == 0) { SendReply(netuser, "No one exept the owner."); } } return; } } SendReply(netuser, string.Format("Can't prod what you are looking at: {0}", cachedRaycast.collider.gameObject.name)); }
void cmdchatbancheck(NetUser netuser, string command, string[] args) { if (!hasAccess(netuser, "Rbb.checkbase")) { SendReply(netuser, GetMessage("not allowed to use command")); return; } cachedCharacter = netuser.playerClient.rootControllable.idMain.GetComponent <Character>(); if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { SendReply(netuser, "Are you looking at the sky?"); return; } //Debug.Log(cachedRaycast.collider.ToString()); //Debug.Log(LayerMask.LayerToName(cachedRaycast.collider.gameObject.layer)); //Debug.Log(cachedRaycast.collider.transform.position.y.ToString()); //Debug.Log(cachedCharacter.origin.y.ToString()); //GameObject.Destroy(cachedRaycast.collider.GetComponent<UnityEngine.MeshCollider>()); /* * * var components = cachedRaycast.collider.GetComponents<UnityEngine.Component>(); * foreach (var comp in components) * { * Debug.Log(comp.ToString()); * } * Debug.Log("============= COMPONENTS IN PARENT ============="); * components = cachedRaycast.collider.GetComponentsInParent<UnityEngine.Component>(); * foreach (var comp in components) * { * Debug.Log(comp.ToString()); * } * Debug.Log("============= COMPONENTS IN CHILDREN ============="); * components = cachedRaycast.collider.GetComponentsInChildren<UnityEngine.Component>(); * foreach (var comp in components) * { * Debug.Log(comp.ToString()); * }*/ if (cachedhitInstance != null) { cachedCollider = cachedhitInstance.physicalColliderReferenceOnly; if (cachedCollider == null) { SendReply(netuser, GetMessage("cant tell what you are looking at")); return; } cachedStructure = cachedCollider.GetComponent <StructureComponent>(); if (cachedStructure != null && cachedStructure._master != null) { cachedMaster = cachedStructure._master; var owner = GetPlayerdata(cachedMaster.ownerID.ToString()); var gg = owner["StaticNickname"].ToString(); var q = owner["LastSeenNickname"].ToString(); var name = (q); rust.SendChatMessage(netuser, GetMessage("systemname"), "StaticNickName " + gg); rust.SendChatMessage(netuser, GetMessage("systemname"), string.Format("{0} - {1} - {2}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "Unknown" : name.ToString())); if (BanList.Contains(Convert.ToUInt64(cachedMaster.ownerID.ToString()))) { rust.SendChatMessage(netuser, GetMessage("systemname"), GetMessage("isinbanllist")); if (removeall) { foreach (StructureComponent comp in (HashSet <StructureComponent>)structureComponents.GetValue(cachedMaster)) { TakeDamage.KillSelf(comp.GetComponent <IDMain>()); } } return; } if (!BanList.Contains(Convert.ToUInt64(cachedMaster.ownerID.ToString()))) { rust.SendChatMessage(netuser, GetMessage("systemname"), GetMessage("isnotinbanllist")); return; } } } else { cachedDeployable = cachedRaycast.collider.GetComponent <DeployableObject>(); if (cachedDeployable != null) { var owner2 = GetPlayerdata(cachedDeployable.ownerID.ToString()); var gg2 = owner2["StaticNickname"].ToString(); var q2 = owner2["LastSeenNickname"].ToString(); var name = (q2); rust.SendChatMessage(netuser, GetMessage("systemname"), "StaticNickName " + gg2); rust.SendChatMessage(netuser, GetMessage("systemname"), string.Format("{0} - {1} - {2}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? "Unknown" : name.ToString())); if (cachedDeployable.GetComponent <PasswordLockableObject>()) { SendReply(netuser, GetMessage("access to door")); int count = 0; foreach (ulong userid in (HashSet <ulong>)accessUsers.GetValue(cachedDeployable.GetComponent <PasswordLockableObject>())) { count++; SendReply(netuser, string.Format("{0} - {1}", userid.ToString(), name == null ? "Unknown" : name.ToString())); } if (count == 0) { SendReply(netuser, GetMessage("no one except the owner")); } } if (BanList.Contains(Convert.ToUInt64(cachedDeployable.ownerID.ToString()))) { var cachedcarrier = cachedDeployable._carrier; rust.SendChatMessage(netuser, GetMessage("systemname"), GetMessage("isinbanllist")); if (removeall) { foreach (DeployableObject comp in (HashSet <DeployableObject>)structureComponents.GetValue(cachedcarrier)) { TakeDamage.KillSelf(comp.GetComponent <IDMain>()); } } } rust.SendChatMessage(netuser, GetMessage("systemname"), GetMessage("isnotinbanllist")); return; } } SendReply(netuser, string.Format(GetMessage("cantprod what you are looking at phase 2")), cachedRaycast.collider.gameObject.name); }