コード例 #1
0
    protected override bool Check(Vector3 position, Quaternion rotation, int mask = -1)
    {
        bool flag;

        position = position + (rotation * this.bounds.center);
        OBB oBB = new OBB(position, this.bounds.size, rotation);
        List <BaseEntity> list = Pool.GetList <BaseEntity>();

        Vis.Entities <BaseEntity>(position, oBB.extents.magnitude, list, this.layers & mask, QueryTriggerInteraction.Collide);
        List <BaseEntity> .Enumerator enumerator = list.GetEnumerator();
        try
        {
            while (enumerator.MoveNext())
            {
                BaseEntity     current           = enumerator.Current;
                DeployVolume[] deployVolumeArray = PrefabAttribute.server.FindAll <DeployVolume>(current.prefabID);
                if (!DeployVolume.Check(current.transform.position, current.transform.rotation, deployVolumeArray, oBB, 1 << (this.layer & 31)))
                {
                    continue;
                }
                Pool.FreeList <BaseEntity>(ref list);
                flag = true;
                return(flag);
            }
            Pool.FreeList <BaseEntity>(ref list);
            return(false);
        }
        finally
        {
            ((IDisposable)enumerator).Dispose();
        }
        return(flag);
    }
コード例 #2
0
 public bool CheckPlacement(Deployable deployable, Ray ray, float fDistance)
 {
     using (TimeWarning.New("Deploy.CheckPlacement", 0.1f))
     {
         RaycastHit raycastHit;
         if (!Physics.Raycast(ray, ref raycastHit, fDistance, 1235288065))
         {
             return(false);
         }
         DeployVolume[] all              = PrefabAttribute.server.FindAll <DeployVolume>(deployable.prefabID);
         Vector3        point            = ((RaycastHit) ref raycastHit).get_point();
         Quaternion     deployedRotation = this.GetDeployedRotation(((RaycastHit) ref raycastHit).get_normal(), ((Ray) ref ray).get_direction());
         Quaternion     rotation         = deployedRotation;
         DeployVolume[] volumes          = all;
         if (DeployVolume.Check(point, rotation, volumes, -1))
         {
             return(false);
         }
         if (!this.IsPlacementAngleAcceptable(((RaycastHit) ref raycastHit).get_point(), deployedRotation))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
    public bool CheckPlacement(Deployable deployable, Ray ray, float fDistance)
    {
        RaycastHit raycastHit;
        bool       flag;

        using (TimeWarning timeWarning = TimeWarning.New("Deploy.CheckPlacement", 0.1f))
        {
            if (UnityEngine.Physics.Raycast(ray, out raycastHit, fDistance, 1235288065))
            {
                DeployVolume[] deployVolumeArray = PrefabAttribute.server.FindAll <DeployVolume>(deployable.prefabID);
                Vector3        vector3           = raycastHit.point;
                Quaternion     deployedRotation  = this.GetDeployedRotation(raycastHit.normal, ray.direction);
                if (DeployVolume.Check(vector3, deployedRotation, deployVolumeArray, -1))
                {
                    flag = false;
                }
                else if (this.IsPlacementAngleAcceptable(raycastHit.point, deployedRotation))
                {
                    return(true);
                }
                else
                {
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }
        }
        return(flag);
    }
コード例 #4
0
 private object CanChangeGrade(BasePlayer player, BuildingBlock block, BuildingGrade.Enum iGrade)
 {
     if (DeployVolume.Check(block.transform.position, block.transform.rotation, PrefabAttribute.server.FindAll <DeployVolume>(block.prefabID), ~(1 << block.gameObject.layer)))
     {
         return(false);
     }
     return(null);
 }
コード例 #5
0
 private static bool UpgradeBlocked(BuildingBlock block)
 {
     if (!block.blockDefinition.checkVolumeOnUpgrade)
     {
         return(false);
     }
     return(DeployVolume.Check(block.transform.position, block.transform.rotation, PrefabAttribute.server.FindAll <DeployVolume>(block.prefabID), ~(1 << block.gameObject.layer)));
 }
コード例 #6
0
 private bool IsRotationBlocked()
 {
     if (!this.blockDefinition.checkVolumeOnRotate)
     {
         return(false);
     }
     return(DeployVolume.Check(((Component)this).get_transform().get_position(), ((Component)this).get_transform().get_rotation(), PrefabAttribute.server.FindAll <DeployVolume>(this.prefabID), ~(1 << ((Component)this).get_gameObject().get_layer())));
 }
コード例 #7
0
 private bool IsUpgradeBlocked()
 {
     if (!this.blockDefinition.checkVolumeOnUpgrade)
     {
         return(false);
     }
     DeployVolume[] deployVolumeArray = PrefabAttribute.server.FindAll <DeployVolume>(this.prefabID);
     return(DeployVolume.Check(base.transform.position, base.transform.rotation, deployVolumeArray, ~(1 << (base.gameObject.layer & 31))));
 }
コード例 #8
0
ファイル: BuildingBlock.cs プロジェクト: Ailtop/RustDocuments
 private bool IsRotationBlocked()
 {
     if (!blockDefinition.checkVolumeOnRotate)
     {
         return(false);
     }
     DeployVolume[] volumes = PrefabAttribute.server.FindAll <DeployVolume>(prefabID);
     return(DeployVolume.Check(base.transform.position, base.transform.rotation, volumes, ~(1 << base.gameObject.layer)));
 }
コード例 #9
0
    protected override bool Check(Vector3 position, Quaternion rotation, int mask = -1)
    {
        position += rotation * bounds.center;
        OBB test = new OBB(position, bounds.size, rotation);
        List <BaseEntity> obj = Pool.GetList <BaseEntity>();

        Vis.Entities(position, test.extents.magnitude, obj, (int)layers & mask);
        foreach (BaseEntity item in obj)
        {
            DeployVolume[] volumes = PrefabAttribute.server.FindAll <DeployVolume>(item.prefabID);
            if (DeployVolume.Check(item.transform.position, item.transform.rotation, volumes, test, 1 << layer))
            {
                Pool.FreeList(ref obj);
                return(true);
            }
        }
        Pool.FreeList(ref obj);
        return(false);
    }
コード例 #10
0
    protected override bool Check(Vector3 position, Quaternion rotation, int mask = -1)
    {
        position = Vector3.op_Addition(position, Quaternion.op_Multiply(rotation, ((Bounds) ref this.bounds).get_center()));
        OBB test;

        ((OBB) ref test).\u002Ector(position, ((Bounds) ref this.bounds).get_size(), rotation);
        List <BaseEntity> list = (List <BaseEntity>)Pool.GetList <BaseEntity>();

        Vis.Entities <BaseEntity>(position, ((Vector3) ref test.extents).get_magnitude(), list, LayerMask.op_Implicit(this.layers) & mask, (QueryTriggerInteraction)2);
        foreach (BaseEntity baseEntity in list)
        {
            DeployVolume[] all = PrefabAttribute.server.FindAll <DeployVolume>(baseEntity.prefabID);
            if (DeployVolume.Check(((Component)baseEntity).get_transform().get_position(), ((Component)baseEntity).get_transform().get_rotation(), all, test, 1 << this.layer))
            {
                // ISSUE: cast to a reference type
                Pool.FreeList <BaseEntity>((List <M0>&) ref list);
                return(true);
            }
        }
        // ISSUE: cast to a reference type
        Pool.FreeList <BaseEntity>((List <M0>&) ref list);
        return(false);
    }
コード例 #11
0
ファイル: Deployer.cs プロジェクト: Ailtop/RustDocuments
 public bool CheckPlacement(Deployable deployable, Ray ray, float fDistance)
 {
     using (TimeWarning.New("Deploy.CheckPlacement"))
     {
         RaycastHit hitInfo;
         if (!UnityEngine.Physics.Raycast(ray, out hitInfo, fDistance, 1235288065))
         {
             return(false);
         }
         DeployVolume[] volumes          = PrefabAttribute.server.FindAll <DeployVolume>(deployable.prefabID);
         Vector3        point            = hitInfo.point;
         Quaternion     deployedRotation = GetDeployedRotation(hitInfo.normal, ray.direction);
         if (DeployVolume.Check(point, deployedRotation, volumes))
         {
             return(false);
         }
         if (!IsPlacementAngleAcceptable(hitInfo.point, deployedRotation))
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #12
0
    public bool UpdatePlacement(
        Transform transform,
        Construction common,
        ref Construction.Target target)
    {
        if (!target.valid)
        {
            return(false);
        }
        if (!common.canBypassBuildingPermission && !target.player.CanBuild())
        {
            Construction.lastPlacementError = "Player doesn't have permission";
            return(false);
        }
        List <Socket_Base> list = (List <Socket_Base>)Pool.GetList <Socket_Base>();

        common.FindMaleSockets(target, list);
        foreach (Socket_Base socketBase in list)
        {
            Construction.Placement placement = (Construction.Placement)null;
            if (!Object.op_Inequality((Object)target.entity, (Object)null) || !((PrefabAttribute)target.socket != (PrefabAttribute)null) || !target.entity.IsOccupied(target.socket))
            {
                if (placement == null)
                {
                    placement = socketBase.DoPlacement(target);
                }
                if (placement != null)
                {
                    if (!socketBase.CheckSocketMods(placement))
                    {
                        transform.set_position(placement.position);
                        transform.set_rotation(placement.rotation);
                    }
                    else if (!this.TestPlacingThroughRock(ref placement, target))
                    {
                        transform.set_position(placement.position);
                        transform.set_rotation(placement.rotation);
                        Construction.lastPlacementError = "Placing through rock";
                    }
                    else if (!Construction.TestPlacingThroughWall(ref placement, transform, common, target))
                    {
                        transform.set_position(placement.position);
                        transform.set_rotation(placement.rotation);
                        Construction.lastPlacementError = "Placing through wall";
                    }
                    else if ((double)Vector3.Distance(placement.position, target.player.eyes.position) > (double)common.maxplaceDistance + 1.0)
                    {
                        transform.set_position(placement.position);
                        transform.set_rotation(placement.rotation);
                        Construction.lastPlacementError = "Too far away";
                    }
                    else
                    {
                        DeployVolume[] all = PrefabAttribute.server.FindAll <DeployVolume>(this.prefabID);
                        if (DeployVolume.Check(placement.position, placement.rotation, all, -1))
                        {
                            transform.set_position(placement.position);
                            transform.set_rotation(placement.rotation);
                            Construction.lastPlacementError = "Not enough space";
                        }
                        else if (BuildingProximity.Check(target.player, this, placement.position, placement.rotation))
                        {
                            transform.set_position(placement.position);
                            transform.set_rotation(placement.rotation);
                        }
                        else if (common.isBuildingPrivilege && !target.player.CanPlaceBuildingPrivilege(placement.position, placement.rotation, common.bounds))
                        {
                            transform.set_position(placement.position);
                            transform.set_rotation(placement.rotation);
                            Construction.lastPlacementError = "Cannot stack building privileges";
                        }
                        else
                        {
                            bool flag = target.player.IsBuildingBlocked(placement.position, placement.rotation, common.bounds);
                            if (!common.canBypassBuildingPermission && flag)
                            {
                                transform.set_position(placement.position);
                                transform.set_rotation(placement.rotation);
                                Construction.lastPlacementError = "Building privilege";
                            }
                            else
                            {
                                target.inBuildingPrivilege = flag;
                                transform.set_position(placement.position);
                                transform.set_rotation(placement.rotation);
                                // ISSUE: cast to a reference type
                                Pool.FreeList <Socket_Base>((List <M0>&) ref list);
                                return(true);
                            }
                        }
                    }
                }
            }
        }
        // ISSUE: cast to a reference type
        Pool.FreeList <Socket_Base>((List <M0>&) ref list);
        return(false);
    }
コード例 #13
0
ファイル: Construction.cs プロジェクト: Ailtop/RustDocuments
    public bool UpdatePlacement(Transform transform, Construction common, ref Target target)
    {
        if (!target.valid)
        {
            return(false);
        }
        if (!common.canBypassBuildingPermission && !target.player.CanBuild())
        {
            lastPlacementError = "You don't have permission to build here";
            return(false);
        }
        List <Socket_Base> obj = Pool.GetList <Socket_Base>();

        common.FindMaleSockets(target, obj);
        foreach (Socket_Base item in obj)
        {
            Placement placement = null;
            if (target.entity != null && target.socket != null && target.entity.IsOccupied(target.socket))
            {
                continue;
            }
            if (placement == null)
            {
                placement = item.DoPlacement(target);
            }
            if (placement == null)
            {
                continue;
            }
            if (!item.CheckSocketMods(placement))
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                continue;
            }
            if (!TestPlacingThroughRock(ref placement, target))
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "Placing through rock";
                continue;
            }
            if (!TestPlacingThroughWall(ref placement, transform, common, target))
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "Placing through wall";
                continue;
            }
            if (!TestPlacingCloseToRoad(ref placement, target))
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "Placing too close to road";
                continue;
            }
            if (Vector3.Distance(placement.position, target.player.eyes.position) > common.maxplaceDistance + 1f)
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "Too far away";
                continue;
            }
            DeployVolume[] volumes = PrefabAttribute.server.FindAll <DeployVolume>(prefabID);
            if (DeployVolume.Check(placement.position, placement.rotation, volumes))
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "Not enough space";
                continue;
            }
            if (BuildingProximity.Check(target.player, this, placement.position, placement.rotation))
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "Too close to another building";
                continue;
            }
            if (common.isBuildingPrivilege && !target.player.CanPlaceBuildingPrivilege(placement.position, placement.rotation, common.bounds))
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "Cannot stack building privileges";
                continue;
            }
            bool flag = target.player.IsBuildingBlocked(placement.position, placement.rotation, common.bounds);
            if (!common.canBypassBuildingPermission && flag)
            {
                transform.position = placement.position;
                transform.rotation = placement.rotation;
                lastPlacementError = "You don't have permission to build here";
                continue;
            }
            target.inBuildingPrivilege = flag;
            transform.SetPositionAndRotation(placement.position, placement.rotation);
            Pool.FreeList(ref obj);
            return(true);
        }
        Pool.FreeList(ref obj);
        return(false);
    }
コード例 #14
0
    public bool UpdatePlacement(Transform transform, Construction common, ref Construction.Target target)
    {
        bool flag;

        if (!target.valid)
        {
            return(false);
        }
        if (!common.canBypassBuildingPermission && !target.player.CanBuild())
        {
            Construction.lastPlacementError = "Player doesn't have permission";
            return(false);
        }
        List <Socket_Base> list = Pool.GetList <Socket_Base>();

        common.FindMaleSockets(target, list);
        List <Socket_Base> .Enumerator enumerator = list.GetEnumerator();
        try
        {
            while (enumerator.MoveNext())
            {
                Socket_Base            current   = enumerator.Current;
                Construction.Placement placement = null;
                if (target.entity != null && target.socket != null && target.entity.IsOccupied(target.socket))
                {
                    continue;
                }
                if (placement == null)
                {
                    placement = current.DoPlacement(target);
                }
                if (placement == null)
                {
                    continue;
                }
                if (!current.CheckSocketMods(placement))
                {
                    transform.position = placement.position;
                    transform.rotation = placement.rotation;
                }
                else if (!this.TestPlacingThroughRock(ref placement, target))
                {
                    transform.position = placement.position;
                    transform.rotation = placement.rotation;
                    Construction.lastPlacementError = "Placing through rock";
                }
                else if (!Construction.TestPlacingThroughWall(ref placement, transform, common, target))
                {
                    transform.position = placement.position;
                    transform.rotation = placement.rotation;
                    Construction.lastPlacementError = "Placing through wall";
                }
                else if (Vector3.Distance(placement.position, target.player.eyes.position) <= common.maxplaceDistance + 1f)
                {
                    DeployVolume[] deployVolumeArray = PrefabAttribute.server.FindAll <DeployVolume>(this.prefabID);
                    if (DeployVolume.Check(placement.position, placement.rotation, deployVolumeArray, -1))
                    {
                        transform.position = placement.position;
                        transform.rotation = placement.rotation;
                        Construction.lastPlacementError = "Not enough space";
                    }
                    else if (BuildingProximity.Check(target.player, this, placement.position, placement.rotation))
                    {
                        transform.position = placement.position;
                        transform.rotation = placement.rotation;
                    }
                    else if (!common.isBuildingPrivilege || target.player.CanPlaceBuildingPrivilege(placement.position, placement.rotation, common.bounds))
                    {
                        bool flag1 = target.player.IsBuildingBlocked(placement.position, placement.rotation, common.bounds);
                        if (common.canBypassBuildingPermission || !flag1)
                        {
                            target.inBuildingPrivilege = flag1;
                            transform.position         = placement.position;
                            transform.rotation         = placement.rotation;
                            Pool.FreeList <Socket_Base>(ref list);
                            flag = true;
                            return(flag);
                        }
                        else
                        {
                            transform.position = placement.position;
                            transform.rotation = placement.rotation;
                            Construction.lastPlacementError = "Building privilege";
                        }
                    }
                    else
                    {
                        transform.position = placement.position;
                        transform.rotation = placement.rotation;
                        Construction.lastPlacementError = "Cannot stack building privileges";
                    }
                }
                else
                {
                    transform.position = placement.position;
                    transform.rotation = placement.rotation;
                    Construction.lastPlacementError = "Too far away";
                }
            }
            Pool.FreeList <Socket_Base>(ref list);
            return(false);
        }
        finally
        {
            ((IDisposable)enumerator).Dispose();
        }
        return(flag);
    }