Ejemplo n.º 1
0
        void OnStructurePlaced(StructureComponent component, IStructureComponentItem structureComponentItem)
        {
            var structurecheck = component.gameObject.AddComponent <StructureCheck>();

            structurecheck.owner  = structureComponentItem.character;
            structurecheck.radius = 0f;
            if ((antiPillarStash || antiPillarBarricade) && component.IsPillar())
            {
                structurecheck.radius = 0.2f;
            }
            else if (antiFoundationGlitch && (component.type == StructureComponent.StructureComponentType.Foundation))
            {
                structurecheck.radius      = 3.0f;
                structurecheck.position.y += 2f;
            }
            else if (component.type == StructureComponent.StructureComponentType.Ramp)
            {
                if (antiRampStack)
                {
                    if (MeshBatchPhysics.Raycast(structurecheck.position + Vector3ABitUp, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
                    {
                        if (cachedhitInstance != null)
                        {
                            cachedComponent = cachedhitInstance.physicalColliderReferenceOnly.GetComponent <StructureComponent>();
                            if (cachedComponent.type == StructureComponent.StructureComponentType.Foundation || cachedComponent.type == StructureComponent.StructureComponentType.Ceiling)
                            {
                                var weight = getweight.GetValue(cachedComponent._master) as Dictionary <StructureComponent, HashSet <StructureComponent> >;
                                int ramps  = 0;
                                if (weight.ContainsKey(cachedComponent))
                                {
                                    foreach (StructureComponent structure in weight[cachedComponent])
                                    {
                                        if (structure.type == StructureComponent.StructureComponentType.Ramp)
                                        {
                                            ramps++;
                                        }
                                    }
                                }
                                if (ramps > rampstackMax)
                                {
                                    TakeDamage.KillSelf(component.GetComponent <IDMain>());
                                    if (structurecheck.owner != null && structurecheck.owner.playerClient != null)
                                    {
                                        ConsoleNetworker.SendClientCommand(structurecheck.owner.playerClient.netPlayer, "chat.add Oxide " + Facepunch.Utility.String.QuoteSafe(string.Format("You are not allowed to stack more than {0} ramps", rampstackMax.ToString())));
                                    }
                                    timer.Once(0.01f, () => GameObject.Destroy(structurecheck));
                                    return;
                                }
                            }
                        }
                    }
                }
                if (antiRampGlitch)
                {
                    structurecheck.radius      = 3.0f;
                    structurecheck.position.y += 2f;
                }
            }
            timer.Once(0.05f, () => structurecheck.CheckCollision());
        }
Ejemplo n.º 2
0
        /////////////////////////////
        // Config Management
        /////////////////////////////

        bool ifOnGround(NetUser netusery)
        {
            PlayerClient playerclient = netusery.playerClient;
            Vector3      lastPosition = playerclient.lastKnownPosition;


            Collider   cachedCollider;
            bool       cachedBoolean;
            Vector3    cachedvector3;
            RaycastHit cachedRaycast;

            Facepunch.MeshBatch.MeshBatchInstance cachedhitInstance;


            if (lastPosition == default(Vector3))
            {
                return(true);
            }
            if (!MeshBatchPhysics.Raycast(lastPosition + UnderPlayerAdjustement, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
            {
                return(true);
            }
            if (cachedhitInstance == null)
            {
                return(true);
            }
            if (cachedhitInstance.graphicalModel.ToString() == null)
            {
                //Put(cachedhitInstance.graphicalModel.ToString());
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        void BuscarParedes(NetUser Player)
        {
            if (!JugadoresenJuego.Contains(Player) && Player != PlayerExecuteCommand)
            {
                return;
            }
            AtributeRayCharacter = Player.playerClient.rootControllable.idMain.GetComponent <Character>().eyesRay;
            if (MeshBatchPhysics.Raycast(AtributeRayCharacter, out HitRayCastCharacter, out AtributeBolean, out AtributeInstance))
            {
                AtributeCollider = AtributeInstance.physicalColliderReferenceOnly;

                if (AtributeCollider.GetComponent <StructureComponent>() != null)
                {
                    this.paredMadera = AtributeCollider.GetComponent <StructureComponent>();
                    foreach (StructureComponent objs in (Colecciones::HashSet <StructureComponent>)StructureComponents.GetValue(paredMadera.gameObject.GetComponent <StructureComponent>()._master))
                    {
                        if (objs.IsWallType())
                        {
                            TakeDamage.KillSelf(objs);
                        }
                    }
                }
            }
            else
            {
                rust.Notice(Player, "You dont see a WAll Structure ¿?");
            }
        }
Ejemplo n.º 4
0
 void FixedUpdate()
 {
     lastPosition = this.playerclient.lastKnownPosition;
     if (!checkingNewPos)
     {
         this.lastTick = Time.realtimeSinceStartup;
         if (lastPosition == default(Vector3))
         {
             return;
         }
         if (!MeshBatchPhysics.Raycast(lastPosition + UnderPlayerAdjustement, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
         {
             DestroyCeilingHandler(this); return;
         }
         if (cachedhitInstance == null)
         {
             DestroyCeilingHandler(this); return;
         }
         if (!cachedhitInstance.graphicalModel.ToString().Contains("ceiling"))
         {
             DestroyCeilingHandler(this); return;
         }
         cachedceiling  = cachedRaycast.point;
         checkingNewPos = true;
     }
     else
     {
         if (Time.realtimeSinceStartup - this.lastTick < 1f)
         {
             return;
         }
         if (MeshBatchPhysics.Raycast(lastPosition, Vector3Up, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
         {
             cachedvector3 = cachedceiling - cachedRaycast.point;
             if (cachedvector3.y > 0.6f)
             {
                 cachedvector3 = cachedceiling - lastPosition;
                 if (cachedvector3.y > 1.5f && Math.Abs(cachedvector3.x) < 0.1f && Math.Abs(cachedvector3.z) < 0.1f)
                 {
                     Debug.Log(string.Format("{0} {1} - rCeilingHack ({2}) @ from {3} to {4}", playerclient.userID.ToString(), playerclient.userName.ToString(), cachedvector3.y.ToString(), cachedceiling.ToString(), lastPosition.ToString()));
                     AntiCheatBroadcastAdmins(string.Format("{0} {1} - rCeilingHack ({2}) @ from {3} to {4}", playerclient.userID.ToString(), playerclient.userName.ToString(), cachedvector3.y.ToString(), cachedceiling.ToString(), lastPosition.ToString()));
                     if (ceilinghackPunish)
                     {
                         Punish(playerclient, string.Format("rCeilingHack ({0})", cachedvector3.y.ToString()));
                     }
                 }
             }
         }
         DestroyCeilingHandler(this);
     }
 }
Ejemplo n.º 5
0
        bool TryGetClosestPoint(Vector3 sourcePos, Quaternion sourceDir, out object closestEnt, out Vector3 closestHitpoint)
        {
            closestHitpoint = default(Vector3);
            closestEnt      = null;
            Ray ray = new Ray(sourcePos, sourceDir * Vector3.forward);

            if (!MeshBatchPhysics.Raycast(ray, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
            {
                return(false);
            }
            closestHitpoint = cachedRaycast.point;
            closestEnt      = cachedRaycast.collider;
            return(true);
        }
Ejemplo n.º 6
0
        bool ifOnlootsackDeployable(NetUser userx)
        {
            PlayerClient playerclient = userx.playerClient;
            Vector3      lastPosition = playerclient.lastKnownPosition;

            Collider   cachedCollider;
            bool       cachedBoolean;
            Vector3    cachedvector3;
            RaycastHit cachedRaycast;

            Facepunch.MeshBatch.MeshBatchInstance cachedhitInstance;
            DeployableObject cachedDeployable;

            if (lastPosition == default(Vector3))
            {
                return(false);
            }
            if (!MeshBatchPhysics.Raycast(lastPosition + UnderPlayerAdjustement, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
            {
                return(false);
            }
            if (cachedhitInstance == null)
            {
                var cachedsack           = "GenericItemPickup(Clone)";
                var cachedLootableObject = cachedRaycast.collider.gameObject.name;
                if (cachedLootableObject == cachedsack)
                {
                    return(true);
                }
                return(false);
            }
            var cachedsack2 = "GenericItemPickup(clone)";

            if (cachedhitInstance.graphicalModel.ToString() == cachedsack2)
            {
                return(true);
            }
            if (cachedhitInstance.graphicalModel.ToString().Contains(cachedsack2))
            {
                return(true);
            }
            if (cachedhitInstance.graphicalModel.ToString() == null)
            {
                Debug.Log(cachedhitInstance.graphicalModel.ToString());
                return(false);
            }

            return(false);
        }
Ejemplo n.º 7
0
 bool TraceEyes(Vector3 origin, Ray ray, Vector3 directiondelta, out string objectname, out string modelname, out float distance)
 {
     modelname      = string.Empty;
     objectname     = string.Empty;
     distance       = 0f;
     ray.direction += directiondelta;
     if (!MeshBatchPhysics.Raycast(ray, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
     {
         return(false);
     }
     if (cachedhitInstance != null)
     {
         modelname = cachedhitInstance.graphicalModel.ToString();
     }
     distance   = cachedRaycast.distance;
     objectname = cachedRaycast.collider.gameObject.name;
     return(true);
 }
Ejemplo n.º 8
0
 private bool SurfaceForMeshBatchInstance(MeshBatchInstance instance, ref ExplosionHelper.Surface surface)
 {
     surface.idBase = instance;
     surface.idMain = surface.idBase.idMain;
     if ((surface.idMain == null) || (surface.idMain == this.skip))
     {
         surface = new ExplosionHelper.Surface();
         return(false);
     }
     surface.bounds = instance.physicalBounds;
     if (this.BoundsWork(ref surface.bounds, ref surface.work))
     {
         if (surface.work.rayTest)
         {
             bool flag;
             MeshBatchInstance instance2;
             if ((this.raycastLayerMask != 0) && MeshBatchPhysics.Raycast(this.point, surface.work.rayDir, surface.work.rayDistance, this.raycastLayerMask, out flag, out instance2))
             {
                 if (flag && (instance2 == instance))
                 {
                     surface.blocked = false;
                 }
                 else
                 {
                     surface.blocked = true;
                 }
             }
             else
             {
                 surface.blocked = false;
             }
         }
         else
         {
             surface.blocked = false;
         }
         return(true);
     }
     surface = new ExplosionHelper.Surface();
     return(false);
 }
Ejemplo n.º 9
0
    public void GrabCarrier()
    {
        RaycastHit        hit;
        bool              flag;
        MeshBatchInstance instance;
        Ray ray = new Ray(base.transform.position + ((Vector3)(Vector3.up * 0.01f)), Vector3.down);

        if (MeshBatchPhysics.Raycast(ray, out hit, 5f, out flag, out instance))
        {
            IDMain main = !flag?IDBase.GetMain(hit.collider) : instance.idMain;

            if (main != null)
            {
                TransCarrier local = main.GetLocal <TransCarrier>();
                if (local != null)
                {
                    local.AddObject(this);
                }
            }
        }
    }
Ejemplo n.º 10
0
    public static Hardpoint GetHardpointFromRay(Ray ray, hardpoint_type type)
    {
        RaycastHit        hit;
        bool              flag;
        MeshBatchInstance instance;

        if (MeshBatchPhysics.Raycast(ray, out hit, 10f, out flag, out instance))
        {
            IDMain main = !flag?IDBase.GetMain(hit.collider) : instance.idMain;

            if (main != null)
            {
                HardpointMaster component = main.GetComponent <HardpointMaster>();
                if (component != null)
                {
                    return(component.GetHardpointNear(hit.point, type));
                }
            }
        }
        return(null);
    }
Ejemplo n.º 11
0
 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;
     }
     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()));
             return;
         }
     }
     SendReply(netuser, string.Format("Can't prod what you are looking at: {0}", cachedRaycast.collider.gameObject.name));
 }
Ejemplo n.º 12
0
        void OnStructurePlaced(StructureComponent component, IStructureComponentItem structureComponentItem)
        {
            var currettime = Time.realtimeSinceStartup;

            if (MeshBatchPhysics.Raycast(component.transform.position + Vector3ABitUp, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
            {
                if (cachedhitInstance != null)
                {
                    cachedComponent = cachedhitInstance.physicalColliderReferenceOnly.GetComponent <StructureComponent>();
                    if (cachedComponent != null)
                    {
                        cachedMaster = cachedComponent._master;
                        CheckIfCanPlace(structureComponentItem.character.playerClient, cachedMaster.ownerID.ToString(), component);
                    }
                }
            }
            else
            {
                CheckIfCanPlace(structureComponentItem.character.playerClient, structureComponentItem.character.playerClient.userID.ToString(), component);
            }
            SendReply(structureComponentItem.character.playerClient.netUser, "Took: " + (currettime - Time.realtimeSinceStartup).ToString());
        }
Ejemplo n.º 13
0
        bool ifOnDeployable(NetUser userx)
        {
            PlayerClient playerclient = userx.playerClient;
            Vector3      lastPosition = playerclient.lastKnownPosition;


            Collider   cachedCollider;
            bool       cachedBoolean;
            Vector3    cachedvector3;
            RaycastHit cachedRaycast;

            Facepunch.MeshBatch.MeshBatchInstance cachedhitInstance;
            DeployableObject cachedDeployable;

            if (lastPosition == default(Vector3))
            {
                return(false);
            }
            if (!MeshBatchPhysics.Raycast(lastPosition + UnderPlayerAdjustement, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance))
            {
                return(false);
            }
            if (cachedhitInstance == null)
            {
                cachedDeployable = cachedRaycast.collider.GetComponent <DeployableObject>();
                if (cachedDeployable != null)
                {
                    return(true);
                }
                return(false);
            }
            if (cachedhitInstance.graphicalModel.ToString() == null)
            {
                //Put(cachedhitInstance.graphicalModel.ToString());
                return(false);
            }

            return(false);
        }
Ejemplo n.º 14
0
 bool AllowedSetHome(NetUser netuser)
 {
     MeshBatchPhysics.Raycast(netuser.playerClient.lastKnownPosition + UnderPlayerAdjustement, Vector3Down, out cachedRaycast, out cachedBoolean, out cachedhitInstance);
     if (sethomeOnlyBuildings && cachedhitInstance == null)
     {
         SendReply(netuser, onlyBuildingsMessage);
         return(false);
     }
     if (sethomeOnlyFoundation && cachedhitInstance != null)
     {
         if (!cachedhitInstance.physicalColliderReferenceOnly.gameObject.name.Contains("Foundation"))
         {
             SendReply(netuser, onlyFoundationsMessage);
             return(false);
         }
     }
     if (sethomeOnlySelf && cachedhitInstance != null)
     {
         string ownerid = cachedhitInstance.physicalColliderReferenceOnly.GetComponent <StructureComponent>()._master.ownerID.ToString();
         if (ownerid != netuser.playerClient.userID.ToString())
         {
             if (useShare && Share != null)
             {
                 if (!(bool)Share.Call("isSharing", ownerid, netuser.playerClient.userID.ToString()))
                 {
                     SendReply(netuser, onlySelfOrFriend);
                     return(false);
                 }
             }
             else
             {
                 SendReply(netuser, onlySelfMessage);
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 15
0
    public void CheckPlacementResults(Ray ray, out Vector3 pos, out Quaternion rot, out TransCarrier carrier, out DeployPlaceResults results)
    {
        RaycastHit        hit;
        Vector3           position;
        Vector3           normal;
        bool              flag6;
        MeshBatchInstance instance;
        Quaternion        rotation;
        float             placeRange = this.placeRange;
        IDMain            main       = null;
        bool              flag       = false;
        bool              flag2      = false;
        bool              flag3      = false;
        DeployableObject  obj2       = null;
        bool              flag4      = false;
        bool              flag5      = false;
        bool              flag7      = this.minCastRadius >= float.Epsilon;
        bool              flag8      = !flag7?MeshBatchPhysics.Raycast(ray, out hit, placeRange, -472317957, out flag6, out instance) : MeshBatchPhysics.SphereCast(ray, this.minCastRadius, out hit, placeRange, -472317957, out flag6, out instance);

        Vector3 point = ray.GetPoint(placeRange);

        if (!flag8)
        {
            Vector3 origin = point;
            origin.y += 0.5f;
            flag4     = MeshBatchPhysics.Raycast(origin, Vector3.down, out hit, 5f, -472317957, out flag6, out instance);
        }
        if (flag8 || flag4)
        {
            main = !flag6?IDBase.GetMain(hit.collider) : instance.idMain;

            flag3    = (main is StructureComponent) || (main is StructureMaster);
            position = hit.point;
            normal   = hit.normal;
            flag     = !flag3 && ((bool)(obj2 = main as DeployableObject));
            if (((this.carrierSphereCastMode != CarrierSphereCastMode.Allowed) && flag8) && (flag7 && !NonVariantSphereCast(ray, position)))
            {
                Ray               ray2;
                float             num2;
                RaycastHit        hit2;
                bool              flag9;
                MeshBatchInstance instance2;
                bool              flag10;
                if (this.carrierSphereCastMode == CarrierSphereCastMode.AdjustedRay)
                {
                    Vector3 vector5   = ray.origin;
                    Vector3 direction = hit.point - vector5;
                    num2 = direction.magnitude + (this.minCastRadius * 2f);
                    ray2 = new Ray(vector5, direction);
                    Debug.DrawLine(ray.origin, ray.GetPoint(num2), Color.cyan);
                }
                else
                {
                    num2 = placeRange + this.minCastRadius;
                    ray2 = ray;
                }
                if (!(flag10 = MeshBatchPhysics.Raycast(ray2, out hit2, num2, -472317957, out flag9, out instance2)))
                {
                    Vector3 vector8 = position;
                    vector8.y += 0.5f;
                    flag10     = MeshBatchPhysics.Raycast(vector8, Vector3.down, out hit2, 5f, -472317957, out flag9, out instance2);
                }
                if (flag10)
                {
                    IDMain main2 = !flag9?IDBase.GetMain(hit2.collider) : instance2.idMain;

                    carrier = (main2 == null) ? hit2.collider.GetComponent <TransCarrier>() : main2.GetLocal <TransCarrier>();
                }
                else
                {
                    carrier = null;
                }
            }
            else
            {
                carrier = ((main == null) ? hit.collider.gameObject : main.gameObject).GetComponent <TransCarrier>();
            }
            flag2 = (hit.collider is TerrainCollider) || (hit.collider.gameObject.layer == 10);
            flag5 = true;
        }
        else
        {
            position = point;
            normal   = Vector3.up;
            carrier  = null;
        }
        bool      flag11           = false;
        Hardpoint hardpointFromRay = null;

        if (this.hardpointType != Hardpoint.hardpoint_type.None)
        {
            hardpointFromRay = Hardpoint.GetHardpointFromRay(ray, this.hardpointType);
            if (hardpointFromRay != null)
            {
                flag11   = true;
                position = hardpointFromRay.transform.position;
                normal   = hardpointFromRay.transform.up;
                carrier  = hardpointFromRay.GetMaster().GetTransCarrier();
                flag5    = true;
            }
        }
        bool flag12 = false;

        if (this.spacingRadius > 0f)
        {
            foreach (Collider collider in Physics.OverlapSphere(position, this.spacingRadius))
            {
                GameObject gameObject = collider.gameObject;
                IDBase     component  = collider.gameObject.GetComponent <IDBase>();
                if (component != null)
                {
                    gameObject = component.idMain.gameObject;
                }
                if (gameObject.CompareTag(this.ObjectToPlace.gameObject.tag) && (Vector3.Distance(position, gameObject.transform.position) < this.spacingRadius))
                {
                    flag12 = true;
                    break;
                }
            }
        }
        bool flag13 = false;

        if ((flag && !this.forcePlaceable) && obj2.cantPlaceOn)
        {
            flag13 = true;
        }
        pos = position;
        if (this.orientationMode == DeployableOrientationMode.Default)
        {
            if (this.uprightOnly)
            {
                this.orientationMode = DeployableOrientationMode.Upright;
            }
            else
            {
                this.orientationMode = DeployableOrientationMode.NormalUp;
            }
        }
        switch (this.orientationMode)
        {
        case DeployableOrientationMode.NormalUp:
            rotation = TransformHelpers.LookRotationForcedUp(ray.direction, normal);
            break;

        case DeployableOrientationMode.Upright:
            rotation = TransformHelpers.LookRotationForcedUp(ray.direction, Vector3.up);
            break;

        case DeployableOrientationMode.NormalForward:
            rotation = TransformHelpers.LookRotationForcedUp(Vector3.Cross(ray.direction, Vector3.up), normal);
            break;

        case DeployableOrientationMode.HardpointPosRot:
            if (!flag11)
            {
                rotation = TransformHelpers.LookRotationForcedUp(ray.direction, Vector3.up);
                break;
            }
            rotation = hardpointFromRay.transform.rotation;
            break;

        default:
            throw new NotImplementedException();
        }
        rot = rotation * this.ObjectToPlace.transform.localRotation;
        bool flag14 = false;

        if (this.checkPlacementZones)
        {
            flag14 = NoPlacementZone.ValidPos(pos);
        }
        float num4 = Vector3.Angle(normal, Vector3.up);

        results.falseFromDeployable      = (!this.CanStackOnDeployables && flag) || flag13;
        results.falseFromTerrian         = this.TerrainOnly && !flag2;
        results.falseFromClose           = (this.spacingRadius > 0f) && flag12;
        results.falseFromHardpoint       = this.requireHardpoint && !flag11;
        results.falseFromAngle           = !this.requireHardpoint && (num4 >= this.ObjectToPlace.maxSlope);
        results.falseFromPlacementZone   = this.checkPlacementZones && !flag14;
        results.falseFromHittingNothing  = !flag5;
        results.falseFromStructure       = this.StructureOnly && !flag3;
        results.falseFromFitRequirements = (this.fitRequirements != null) && !this.fitRequirements.Test(pos, !this.fitTestForcedUp ? rot : TransformHelpers.LookRotationForcedUp(rot, Vector3.up), this.ObjectToPlace.transform.localScale);
    }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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));
        }
Ejemplo n.º 18
0
        public void Command(User pl, string cmd, string[] args)
        {
            if(cmd == "esshelp")
            {
                pl.Message("Fougerite-Essentials " + Version + " by ice cold");
                pl.Message("/help - see all commands");
                pl.Message("/rules - see all the rules");
                pl.Message("/info - See info about this plugin");
                pl.Message("/friendhelp - See all information about the friends system");
                pl.Message("/sharehelp - See all help about the share system");
                if(EnableHome) { pl.Message("/home - See all help about the home system"); }
                if(EnableRemove) { pl.Message("/remove - Enables/disables remover tool"); }
                if(Enabletpr) { pl.Message("/tpr name - sends teleport request to that user"); pl.Message("/tpa - Accepts an teleport reqequest"); }
                if(EnableWarps) { pl.Message("/warphelp - See all the help for the warping system"); }
                if(pl.Admin || pl.Moderator)
                {
                    pl.Message("/prod - Shows the owner of the object you are looking at");
                    pl.Message("/country player - Shows from which country a player comes");
                    pl.Message("/download url filename - downloads that object and put it in the the Downloaded folder EXAMPLE: (/download http://myitem.com myitem.zip)");
                    pl.Message("/addnewspawn - adds a new spawns to the overwrite spawn list");
                }              
            }
            else if(cmd == "country")
            {
                if(pl.Admin || pl.Moderator)
                {
                    if(args.Length != 1) { pl.Message("Usage /country player"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if(target == null) { pl.Message("Couldn't find the target user"); return; }
                    string country = PlayerDatabase.GetSetting(target.SteamID, "Country");
                    pl.Message("[color #ffb90f]" + target.Name  + " is located from [color #c1ffc1]" + country);
                }
            }
            else if(cmd == "download")
            {
                if(pl.Admin)
                {
                    if(args.Length != 2) { pl.Message("Usage /download url filename - EXAMPLE: (/download http://myitem.com myitem.zip)"); return; }
                    using (WebClient web = new WebClient())
                    {
                        web.DownloadFileAsync(new Uri(args[0]), Util.GetRootFolder() + "\\Save\\Fougerite-Essentials\\Downloaded\\" + args[1]);
                        pl.Message("[color #00ced1]Downloading " + args[1] + " to downloaded folder");
                    }
                }
            }
            else if(cmd == "addnewspawn")
            {
                if(pl.Admin)
                {
                    if(EnableNewSpawns)
                    {
                        string[] c = SpawnsOverwrite.EnumSection("SpawnLocations");
                        string co = (Convert.ToInt32(c[c.Length - 1]) + 1).ToString();
                        SpawnsOverwrite.AddSetting("SpawnLocations", co, pl.Location.ToString());
                        SpawnsOverwrite.Save();
                    }                 
                }
            }
            else if(cmd == "warphelp")
            {
                pl.Message("Fougerite-Essentials WarpSystem by ice cold");
                pl.Message("/warp name - Warps you to that location");
                pl.Message("/warps - See all the current warps");
                if(pl.Admin)
                {
                    pl.Message("/warp_set Name");
                    pl.Message("/warp_remove Name");
                }
            }
            else if(cmd == "warp")
            {
                if(args.Length != 1) { pl.Message("Usage /warp name"); return; }
                if(Warps.ContainsSetting("Warps", args[0]))
                {
                    if (pl.Admin)
                    {
                        Vector3 loc = Util.GetUtil().ConvertStringToVector3(Warps.GetSetting("Warps", args[0]));
                        pl.TeleportTo(loc);
                        pl.Message("[color#00bfff]Warped to " + args[0]);
                    }
                    else
                    {
                        if(!warpcd.Contains(pl.UID))
                        {
                            var dict = new Dictionary<string, object>();
                            dict["pl"] = pl;
                            warpcd.Add(pl.UID);
                            Warpcooldown(WarpCooldown * 1000, dict).Start();
                            Warpdelaytimer(WarpDelay * 1000, dict).Start();
                            string message = WarpDelayMessage.Replace("{warpname}", args[0]);
                        }
                        else
                        {
                            pl.Message(WarpCooldownMessage);
                        }
                    }
                }             
            }
            else if(cmd == "warps")
            {
                pl.Message("WarpsList");
                string[] l = Warps.EnumSection("Warps");
                foreach(var num in l)
                {
                    pl.Message(num);
                }
            }
            else if(cmd == "warp_set")
            {
                if(pl.Admin)
                {
                    if(args.Length != 1) { pl.Message("Usage /warp_set Name"); return; }
                    if(Warps.ContainsSetting("Warps", args[0])) { pl.Message("There is already a warp with the name " + args[0]); return; }
                    Warps.AddSetting("Warps", args[0], pl.Location.ToString());
                    Warps.Save();
                    pl.Message("Warp saved");
                }
            }
            else if(cmd == "warp_remove")
            {
                if(pl.Admin)
                {
                    if(args.Length != 1) { pl.Message("Usage /warp_remove Name"); return; }
                    if(!Warps.ContainsSetting("Warps", args[0])) { pl.Message("There is no warp with the name " + args[0]); return; }
                    Warps.DeleteSetting("Warps", args[0]);
                    Warps.Save();
                    pl.Message("The warp " + args[0] + " has been succesfully removed");
                }
            }
            else if(cmd == "help")
            {
                if(EnableHelp)
                {
                    foreach (var h in HelpList.EnumSection("Help"))
                    {
                        string d = HelpList.GetSetting("Help", h);
                        pl.MessageFrom("Help", d);
                    }
                }
                
            }
            else if(cmd == "rules")
            {
                if(EnableRules)
                {
                    foreach (var r in RulesList.EnumSection("Rules"))
                    {
                        string d = RulesList.GetSetting("Help", r);
                        pl.MessageFrom("Help", d);
                    }
                }          
            }
            else if(cmd == "info")
            {
                pl.MessageFrom(Name, "[color #87cefa][Fougerite-Essentials " + Version + " plugin brought by ice cold");
                pl.MessageFrom(Name, "[color #20b2aa]Wanna support ice cold? https://www.patreon.com/uberrust");
                pl.MessageFrom(Name, "[color #8470ff]You can download this plugin at ");
            }
            else if(cmd == "friendhelp")
            {
                pl.Message("[Fougerite-Essentials] Friends system brought by ice cold");
                pl.Message("/addfriend Name - ads player to your friends list");
                pl.Message("/unfriend Name - Unfriend someone");
                pl.Message("/friends - See all your friends");
            }
            else if(cmd == "sharehelp")
            {
                pl.Message("[Fougerite-Essentials] Share system brought by ice cold");
                pl.Message("/share Name - Door/structure share the player");
                pl.Message("/unshare Name - unshare someone");
                pl.Message("/sharelist - See all the people you have shared");
            }
            else if(cmd == "addfriend")
            {
                if(EnableFriendsSystem)
                {
                    if (args.Length != 1) { pl.Message("Usage /addfriend Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if (target == null) { pl.Message("Couldn't find the target user"); return; }
                    if (friends.ContainsSetting(pl.SteamID, target.SteamID)) { string message = AlreadyFriendedMessage.Replace("{friend}", target.Name); pl.Message(message); return; }
                    string me = AddFriendMessage.Replace("{friend}", target.Name);
                    pl.Message(me);
                    friends.AddSetting(pl.SteamID, target.SteamID, target.Name);
                    friends.Save();
                }
             
            }
            else if(cmd == "unfriend")
            {
                if(EnableShareSystem)
                {
                    if (args.Length != 1) { pl.Message("Usage /unfriend Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if(target == null) { pl.Message("Couldn't find the target user"); return; }
                    if(!friends.ContainsSetting(pl.SteamID, target.SteamID)) { pl.Message(target.Name + " Isnt in your friends list"); return; }
                    friends.DeleteSetting(pl.SteamID, target.SteamID);
                    friends.Save();
                    string message = UnfriendMessage.Replace("{target}", target.Name);
                    pl.Message(message);
                    friends.DeleteSetting(pl.SteamID, target.SteamID);
                    friends.Save();
                }
               
            }
            else if(cmd == "friends")
            {
                if(EnableFriendsSystem)
                {
                    pl.Message("===FriendsList===");
                    foreach (var id in friends.EnumSection(pl.SteamID))
                    {
                        string m = friends.GetSetting(pl.SteamID, id);
                        pl.Message("_ " + m);
                    }
                }
            }
            else if(cmd == "share")
            {
                if(EnableShareSystem)
                {
                    if(args.Length != 1) { pl.Message("Usage /share Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if (target == null) { pl.Message("Couldn't find the target user");  return; }
                    if(share.ContainsSetting(pl.SteamID, target.SteamID)) { string message = AlreadySharedMessage.Replace("{player}", target.Name); pl.Message(message); return; }
                    share.AddSetting(pl.SteamID, target.SteamID, target.Name);
                    share.Save();
                    string me = SharedMessage.Replace("{player}", target.Name);
                    pl.Message(me);
                }
            }
            else if(cmd == "unshare")
            {
                if(EnableShareSystem)
                {
                    if(args.Length != 1) { pl.Message("Usage /unshare Name"); return; }
                    User target = Server.GetServer().FindPlayer(args[0]);
                    if(target == null) { pl.Message("Couldn't find the target user"); return; }
                    if(!share.ContainsSetting(pl.SteamID, target.SteamID)) { pl.Message("You are not sharing with " + target.Name); return; }
                    share.DeleteSetting(pl.SteamID, target.SteamID);
                    share.Save();
                    string message = UnSharedMessage.Replace("{player}", target.Name);
                    pl.Message(message);
                }
            }
            else if(cmd == "sharelist")
            {
                if(EnableShareSystem)
                {
                    pl.Message("===ShareList===");
                    foreach(var id in share.EnumSection(pl.SteamID))
                    {
                        string m = share.GetSetting(pl.SteamID, id);
                        pl.Message("- " + m);
                    }
                }
            }
            else if(cmd == "prod")
            {
                if(pl.Admin || pl.Moderator)
                {
                    cachedCharacter = pl.PlayerClient.rootControllable.idMain.GetComponent<Character>();
                    if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { pl.Message("He Hello thats the sky bro"); return; }

                    if(cachedhitInstance != null)
                    {
                        cachedCollider = cachedhitInstance.physicalColliderReferenceOnly;
                        if (cachedCollider == null) { pl.Message("Sorry but i cannot prod that"); return; }
                        cachedStructure = cachedCollider.GetComponent<StructureComponent>();

                        if (cachedStructure != null && cachedStructure._master != null)
                        {
                            cachedMaster = cachedStructure._master;
                            var name = PlayerDatabase.GetSetting(cachedMaster.ownerID.ToString(), "Name");
                            pl.Message(string.Format("{object} - {ID} - {name}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "Unknown" : name.ToString()));
                        }
                    }
                    else
                    {

                        cachedDeployable = cachedRaycast.collider.GetComponent<DeployableObject>();

                        if(cachedDeployable != null)
                        {
                            var name = PlayerDatabase.GetSetting(cachedMaster.ownerID.ToString(), "Name");
                            pl.Message(string.Format("{object} - {ID} - {name}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString()));
                        }
                    }
                    pl.Message("Failed to prod " + cachedRaycast.collider.gameObject.name);
                }
            }
            else if(cmd == "home")
            {
                if(EnableHome)
                {
                    if(args.Length != 1)
                    {
                        pl.Message("[Fougerite-Essentials] Home system brought by ice cold");
                        if(!SleepingHome)
                        {
                            pl.Message("/home Name - teleports you the home");
                            pl.Message("/sethome Name - Enabled sethome mode (hit a foundation or ceiling to save your home)");
                            pl.Message("/delhome Name - Deletes that home");
                            pl.Message("/homes - Shows the list of homes");
                        }
                        else
                        {
                            pl.Message("/homeon - Enables home mode (place a Sleepingbag or Bed to save that as your current home)");
                            pl.Message("/gohome - Teleports you to your sleepingBag or Bed");
                        }
                    }
                    else
                    {
                        if(!SleepingHome)
                        {
                            if(!homecd.Contains(pl.UID))
                            {
                                if (StructureHome.ContainsSetting(pl.SteamID, args[0]))
                                {
                                    var homeloc = StructureHome.GetSetting(pl.SteamID, args[0]);
                                    var dict = new Dictionary<string, object>();
                                    dict["pl"] = pl;
                                    dict["homeloc"] = homeloc;
                                    HomeTimer(HomeDelay * 1000, dict).Start();
                                    string message = HomeDelayMessage.Replace("{home}", args[0]).Replace("{delay}", HomeDelay.ToString());
                                    pl.Message(message);
                                    HomeCooldown(HomeCooldown * 1000, dict).Start();
                                    homecd.Add(pl.UID);
                                }
                                else
                                {
                                    string message = NoHomeMessage.Replace("{home}", args[0]);
                                    pl.Message(message);
                                }
                            }
                            else
                            {
                                string message = HomeCooldownMessage.Replace("{cooldown}", HomeCooldown.ToString());
                                pl.Message(message);
                            }
                        }
                    }
                }
            }
            else if(cmd == "sethome")
            {
                if(EnableHome)
                {
                    if(!homemode.Contains(pl.UID))
                    {
                        if (args.Length != 1) { pl.Message("Usage /sethome Name"); return; }
                        string[] l = StructureHome.EnumSection(pl.SteamID);
                        if ((Convert.ToBoolean(l.Length == MaxHomes)))
                        {
                            pl.Message(MaxHomesMessage);
                        }
                        else
                        {
                            homemode.Add(pl.UID);
                            pl.Message("Sethome mode activated hit a foundation/ceiling to set your home");
                            homenum.Add(pl.UID, args[0]);
                        }
                    }
                    else
                    {
                        pl.Message("Please do /homestop first");
                    }
                  
                }
            }
            else if(cmd == "")
        }