コード例 #1
0
    private bool ValidatePrefab()
    {
        GameObject obj2;

        if (string.IsNullOrEmpty(this._sleepingAvatarPrefab))
        {
            return(false);
        }
        NetCull.PrefabSearch search = NetCull.LoadPrefab(this._sleepingAvatarPrefab, out obj2);
        if (((int)search) != 1)
        {
            Debug.LogError(string.Format("sleeping avatar prefab named \"{0}\" resulted in {1} which was not {2}(required)", this.prefab, search, NetCull.PrefabSearch.NGC));
            return(false);
        }
        IDMain component = obj2.GetComponent <IDMain>();

        if (!(component is SleepingAvatar))
        {
            Debug.LogError(string.Format("Theres no Sleeping avatar on prefab \"{0}\"", this.prefab), obj2);
            return(false);
        }
        this._hasInventory = component.GetLocal <Inventory>();
        TakeDamage local = component.GetLocal <TakeDamage>();

        this._hasTakeDamage  = (bool)local;
        this._takeDamageType = !this._hasTakeDamage ? null : local.GetType();
        return(true);
    }
コード例 #2
0
    // Token: 0x06002C3D RID: 11325 RVA: 0x000A5AE4 File Offset: 0x000A3CE4
    private bool ValidatePrefab()
    {
        if (string.IsNullOrEmpty(this._sleepingAvatarPrefab))
        {
            return(false);
        }
        GameObject gameObject;

        global::NetCull.PrefabSearch prefabSearch = global::NetCull.LoadPrefab(this._sleepingAvatarPrefab, out gameObject);
        if ((int)prefabSearch != 1)
        {
            Debug.LogError(string.Format("sleeping avatar prefab named \"{0}\" resulted in {1} which was not {2}(required)", this.prefab, prefabSearch, global::NetCull.PrefabSearch.NGC));
            return(false);
        }
        IDMain component = gameObject.GetComponent <IDMain>();

        if (!(component is global::SleepingAvatar))
        {
            Debug.LogError(string.Format("Theres no Sleeping avatar on prefab \"{0}\"", this.prefab), gameObject);
            return(false);
        }
        this._hasInventory = component.GetLocal <global::Inventory>();
        global::TakeDamage local = component.GetLocal <global::TakeDamage>();

        this._hasTakeDamage  = local;
        this._takeDamageType = ((!this._hasTakeDamage) ? null : local.GetType());
        return(true);
    }
コード例 #3
0
 // Token: 0x06000B8A RID: 2954 RVA: 0x0002D494 File Offset: 0x0002B694
 private static global::LifeStatus HurtShared(IDBase attacker, IDBase victim, global::TakeDamage.Quantity damageQuantity, out global::DamageEvent damage, object extraData = null)
 {
     if (victim)
     {
         IDMain idMain = victim.idMain;
         if (idMain)
         {
             global::TakeDamage takeDamage;
             if (idMain is global::Character)
             {
                 takeDamage = ((global::Character)idMain).takeDamage;
             }
             else
             {
                 takeDamage = idMain.GetLocal <global::TakeDamage>();
             }
             if (takeDamage && !takeDamage.takenodamage)
             {
                 takeDamage.MarkDamageTime();
                 damage.victim.id   = victim;
                 damage.attacker.id = attacker;
                 damage.amount      = damageQuantity.value;
                 damage.sender      = takeDamage;
                 damage.status      = ((!takeDamage.dead) ? global::LifeStatus.IsAlive : global::LifeStatus.IsDead);
                 damage.damageTypes = (global::DamageTypeFlags)0;
                 damage.extraData   = extraData;
                 if ((int)damageQuantity.Unit == -1)
                 {
                     takeDamage.ApplyDamageTypeList(ref damage, damageQuantity.list);
                 }
                 takeDamage.Hurt(ref damage);
                 return(damage.status);
             }
         }
     }
     damage.victim.id   = null;
     damage.attacker.id = null;
     damage.amount      = 0f;
     damage.sender      = null;
     damage.damageTypes = (global::DamageTypeFlags)0;
     damage.status      = global::LifeStatus.Failed;
     damage.extraData   = extraData;
     return(global::LifeStatus.Failed);
 }
コード例 #4
0
ファイル: TakeDamage.cs プロジェクト: salvadj1/RustSource
 private static LifeStatus HurtShared(IDBase attacker, IDBase victim, Quantity damageQuantity, out DamageEvent damage, object extraData = null)
 {
     if (victim != null)
     {
         IDMain idMain = victim.idMain;
         if (idMain != null)
         {
             TakeDamage takeDamage;
             if (idMain is Character)
             {
                 takeDamage = ((Character)idMain).takeDamage;
             }
             else
             {
                 takeDamage = idMain.GetLocal <TakeDamage>();
             }
             if ((takeDamage != null) && !takeDamage.takenodamage)
             {
                 takeDamage.MarkDamageTime();
                 damage.victim.id   = victim;
                 damage.attacker.id = attacker;
                 damage.amount      = damageQuantity.value;
                 damage.sender      = takeDamage;
                 damage.status      = !takeDamage.dead ? LifeStatus.IsAlive : LifeStatus.IsDead;
                 damage.damageTypes = 0;
                 damage.extraData   = extraData;
                 if (((int)damageQuantity.Unit) == -1)
                 {
                     takeDamage.ApplyDamageTypeList(ref damage, damageQuantity.list);
                 }
                 takeDamage.Hurt(ref damage);
                 return(damage.status);
             }
         }
     }
     damage.victim.id   = null;
     damage.attacker.id = null;
     damage.amount      = 0f;
     damage.sender      = null;
     damage.damageTypes = 0;
     damage.status      = LifeStatus.Failed;
     damage.extraData   = extraData;
     return(LifeStatus.Failed);
 }
コード例 #5
0
    public void GrabCarrier()
    {
        RaycastHit        raycastHit;
        bool              flag;
        MeshBatchInstance meshBatchInstance;
        Ray ray = new Ray(base.transform.position + (Vector3.up * 0.01f), Vector3.down);

        if (Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray, out raycastHit, 5f, out flag, out meshBatchInstance))
        {
            IDMain dMain = (!flag ? IDBase.GetMain(raycastHit.collider) : meshBatchInstance.idMain);
            if (dMain)
            {
                TransCarrier local = dMain.GetLocal <TransCarrier>();
                if (local)
                {
                    local.AddObject(this);
                }
            }
        }
    }
コード例 #6
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 (Facepunch.MeshBatch.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);
                }
            }
        }
    }
コード例 #7
0
    // Token: 0x06003C1A RID: 15386 RVA: 0x000D6C94 File Offset: 0x000D4E94
    public void GrabCarrier()
    {
        Ray ray;

        ray..ctor(base.transform.position + Vector3.up * 0.01f, Vector3.down);
        RaycastHit        raycastHit;
        bool              flag;
        MeshBatchInstance meshBatchInstance;

        if (Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray, ref raycastHit, 5f, ref flag, ref meshBatchInstance))
        {
            IDMain idmain = (!flag) ? IDBase.GetMain(raycastHit.collider) : meshBatchInstance.idMain;
            if (idmain)
            {
                global::TransCarrier local = idmain.GetLocal <global::TransCarrier>();
                if (local)
                {
                    local.AddObject(this);
                }
            }
        }
    }
コード例 #8
0
    private static LifeStatus HurtShared(IDBase attacker, IDBase victim, TakeDamage.Quantity damageQuantity, out DamageEvent damage, object extraData = null)
    {
        damage = new DamageEvent();
        TakeDamage takeDamage;

        if (victim)
        {
            IDMain dMain = victim.idMain;
            if (dMain)
            {
                takeDamage = (!(dMain is Character) ? dMain.GetLocal <TakeDamage>() : ((Character)dMain).takeDamage);
                if (takeDamage && !takeDamage.takenodamage)
                {
                    takeDamage.MarkDamageTime();
                    damage.victim.id   = victim;
                    damage.attacker.id = attacker;
                    damage.amount      = damageQuantity.@value;
                    damage.sender      = takeDamage;
                    damage.status      = (!takeDamage.dead ? LifeStatus.IsAlive : LifeStatus.IsDead);
                    damage.damageTypes = (DamageTypeFlags)0;
                    damage.extraData   = extraData;
                    if ((int)damageQuantity.Unit == -1)
                    {
                        takeDamage.ApplyDamageTypeList(ref damage, damageQuantity.list);
                    }
                    takeDamage.Hurt(ref damage);
                    return(damage.status);
                }
            }
        }
        damage.victim.id   = null;
        damage.attacker.id = null;
        damage.amount      = 0f;
        damage.sender      = null;
        damage.damageTypes = (DamageTypeFlags)0;
        damage.status      = LifeStatus.Failed;
        damage.extraData   = extraData;
        return(LifeStatus.Failed);
    }
コード例 #9
0
    // Token: 0x060033CD RID: 13261 RVA: 0x000C2024 File Offset: 0x000C0224
    public void CheckPlacementResults(Ray ray, out Vector3 pos, out Quaternion rot, out global::TransCarrier carrier, out global::DeployableItemDataBlock.DeployPlaceResults results)
    {
        float num   = this.placeRange;
        bool  flag  = false;
        bool  flag2 = false;
        bool  flag3 = false;
        global::DeployableObject deployableObject = null;
        bool              flag4 = false;
        bool              flag5 = false;
        bool              flag6 = this.minCastRadius >= float.Epsilon;
        RaycastHit        raycastHit;
        bool              flag8;
        MeshBatchInstance meshBatchInstance;
        bool              flag7 = (!flag6) ? Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray, ref raycastHit, num, -472317957, ref flag8, ref meshBatchInstance) : Facepunch.MeshBatch.MeshBatchPhysics.SphereCast(ray, this.minCastRadius, ref raycastHit, num, -472317957, ref flag8, ref meshBatchInstance);
        Vector3           point = ray.GetPoint(num);

        if (!flag7)
        {
            Vector3 vector = point;
            vector.y += 0.5f;
            flag4     = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(vector, Vector3.down, ref raycastHit, 5f, -472317957, ref flag8, ref meshBatchInstance);
        }
        Vector3 vector2;
        Vector3 vector3;

        if (flag7 || flag4)
        {
            IDMain idmain = (!flag8) ? IDBase.GetMain(raycastHit.collider) : meshBatchInstance.idMain;
            flag3   = (idmain is global::StructureComponent || idmain is global::StructureMaster);
            vector2 = raycastHit.point;
            vector3 = raycastHit.normal;
            flag    = (!flag3 && (deployableObject = (idmain as global::DeployableObject)));
            if (this.carrierSphereCastMode != global::DeployableItemDataBlock.CarrierSphereCastMode.Allowed && flag7 && flag6 && !global::DeployableItemDataBlock.NonVariantSphereCast(ray, vector2))
            {
                float num2;
                Ray   ray2;
                if (this.carrierSphereCastMode == global::DeployableItemDataBlock.CarrierSphereCastMode.AdjustedRay)
                {
                    Vector3 origin  = ray.origin;
                    Vector3 point2  = raycastHit.point;
                    Vector3 vector4 = point2 - origin;
                    num2 = vector4.magnitude + this.minCastRadius * 2f;
                    ray2..ctor(origin, vector4);
                    Debug.DrawLine(ray.origin, ray.GetPoint(num2), Color.cyan);
                }
                else
                {
                    num2 = num + this.minCastRadius;
                    ray2 = ray;
                }
                RaycastHit        raycastHit2;
                bool              flag10;
                MeshBatchInstance meshBatchInstance2;
                bool              flag9;
                if (!(flag9 = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray2, ref raycastHit2, num2, -472317957, ref flag10, ref meshBatchInstance2)))
                {
                    Vector3 vector5 = vector2;
                    vector5.y += 0.5f;
                    flag9      = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(vector5, Vector3.down, ref raycastHit2, 5f, -472317957, ref flag10, ref meshBatchInstance2);
                }
                if (flag9)
                {
                    IDMain idmain2 = (!flag10) ? IDBase.GetMain(raycastHit2.collider) : meshBatchInstance2.idMain;
                    carrier = ((!idmain2) ? raycastHit2.collider.GetComponent <global::TransCarrier>() : idmain2.GetLocal <global::TransCarrier>());
                }
                else
                {
                    carrier = null;
                }
            }
            else
            {
                carrier = ((!idmain) ? raycastHit.collider.gameObject : idmain.gameObject).GetComponent <global::TransCarrier>();
            }
            flag2 = (raycastHit.collider is TerrainCollider || raycastHit.collider.gameObject.layer == 10);
            flag5 = true;
        }
        else
        {
            vector2 = point;
            vector3 = Vector3.up;
            carrier = null;
        }
        bool flag11 = false;
        global::Hardpoint hardpoint = null;

        if (this.hardpointType != global::Hardpoint.hardpoint_type.None)
        {
            hardpoint = global::Hardpoint.GetHardpointFromRay(ray, this.hardpointType);
            if (hardpoint)
            {
                flag11  = true;
                vector2 = hardpoint.transform.position;
                vector3 = hardpoint.transform.up;
                carrier = hardpoint.GetMaster().GetTransCarrier();
                flag5   = true;
            }
        }
        bool flag12 = false;

        if (this.spacingRadius > 0f)
        {
            Collider[] array = Physics.OverlapSphere(vector2, this.spacingRadius);
            foreach (Collider collider in array)
            {
                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(vector2, gameObject.transform.position) < this.spacingRadius)
                {
                    flag12 = true;
                    break;
                }
            }
        }
        bool flag13 = false;

        if (flag && !this.forcePlaceable && deployableObject.cantPlaceOn)
        {
            flag13 = true;
        }
        pos = vector2;
        if (this.orientationMode == global::DeployableOrientationMode.Default)
        {
            if (this.uprightOnly)
            {
                this.orientationMode = global::DeployableOrientationMode.Upright;
            }
            else
            {
                this.orientationMode = global::DeployableOrientationMode.NormalUp;
            }
        }
        Quaternion quaternion;

        switch (this.orientationMode)
        {
        case global::DeployableOrientationMode.NormalUp:
            quaternion = global::TransformHelpers.LookRotationForcedUp(ray.direction, vector3);
            break;

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

        case global::DeployableOrientationMode.NormalForward:
        {
            Vector3 forward = Vector3.Cross(ray.direction, Vector3.up);
            quaternion = global::TransformHelpers.LookRotationForcedUp(forward, vector3);
            break;
        }

        case global::DeployableOrientationMode.HardpointPosRot:
            if (flag11)
            {
                quaternion = hardpoint.transform.rotation;
            }
            else
            {
                quaternion = global::TransformHelpers.LookRotationForcedUp(ray.direction, Vector3.up);
            }
            break;

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

        if (this.checkPlacementZones)
        {
            flag14 = global::NoPlacementZone.ValidPos(pos);
        }
        float num3 = Vector3.Angle(vector3, 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 && num3 >= 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 : global::TransformHelpers.LookRotationForcedUp(rot, Vector3.up), this.ObjectToPlace.transform.localScale));
    }
コード例 #10
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);
    }
コード例 #11
0
    public void CheckPlacementResults(Ray ray, out Vector3 pos, out Quaternion rot, out TransCarrier carrier, out DeployableItemDataBlock.DeployPlaceResults results)
    {
        results = new DeployableItemDataBlock.DeployPlaceResults();
        RaycastHit        raycastHit;
        Vector3           vector3;
        Vector3           vector31;
        bool              flag;
        MeshBatchInstance meshBatchInstance;
        Ray               ray1;
        float             single;
        RaycastHit        raycastHit1;
        bool              flag1;
        MeshBatchInstance meshBatchInstance1;
        Quaternion        quaternion;
        bool              flag2;
        float             single1          = this.placeRange;
        IDMain            dMain            = null;
        bool              flag3            = false;
        bool              flag4            = false;
        bool              flag5            = false;
        DeployableObject  deployableObject = null;
        bool              flag6            = false;
        bool              flag7            = false;
        bool              flag8            = this.minCastRadius >= 1.401298E-45f;
        bool              flag9            = (!flag8 ? Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray, out raycastHit, single1, -472317957, out flag, out meshBatchInstance) : Facepunch.MeshBatch.MeshBatchPhysics.SphereCast(ray, this.minCastRadius, out raycastHit, single1, -472317957, out flag, out meshBatchInstance));
        Vector3           point            = ray.GetPoint(single1);

        if (!flag9)
        {
            Vector3 vector32 = point;
            vector32.y = vector32.y + 0.5f;
            flag6      = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(vector32, Vector3.down, out raycastHit, 5f, -472317957, out flag, out meshBatchInstance);
        }
        if (flag9 || flag6)
        {
            dMain    = (!flag ? IDBase.GetMain(raycastHit.collider) : meshBatchInstance.idMain);
            flag5    = (dMain is StructureComponent ? true : dMain is StructureMaster);
            vector3  = raycastHit.point;
            vector31 = raycastHit.normal;
            if (flag5)
            {
                flag2 = false;
            }
            else
            {
                DeployableObject deployableObject1 = dMain as DeployableObject;
                deployableObject = deployableObject1;
                flag2            = deployableObject1;
            }
            flag3 = flag2;
            if (this.carrierSphereCastMode == DeployableItemDataBlock.CarrierSphereCastMode.Allowed || !flag9 || !flag8 || DeployableItemDataBlock.NonVariantSphereCast(ray, vector3))
            {
                carrier = ((!dMain ? raycastHit.collider.gameObject : dMain.gameObject)).GetComponent <TransCarrier>();
            }
            else
            {
                if (this.carrierSphereCastMode != DeployableItemDataBlock.CarrierSphereCastMode.AdjustedRay)
                {
                    single = single1 + this.minCastRadius;
                    ray1   = ray;
                }
                else
                {
                    Vector3 vector33 = ray.origin;
                    Vector3 vector34 = raycastHit.point - vector33;
                    single = vector34.magnitude + this.minCastRadius * 2f;
                    ray1   = new Ray(vector33, vector34);
                    Debug.DrawLine(ray.origin, ray.GetPoint(single), Color.cyan);
                }
                bool flag10 = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(ray1, out raycastHit1, single, -472317957, out flag1, out meshBatchInstance1);
                bool flag11 = flag10;
                if (!flag10)
                {
                    Vector3 vector35 = vector3;
                    vector35.y = vector35.y + 0.5f;
                    flag11     = Facepunch.MeshBatch.MeshBatchPhysics.Raycast(vector35, Vector3.down, out raycastHit1, 5f, -472317957, out flag1, out meshBatchInstance1);
                }
                if (!flag11)
                {
                    carrier = null;
                }
                else
                {
                    IDMain dMain1 = (!flag1 ? IDBase.GetMain(raycastHit1.collider) : meshBatchInstance1.idMain);
                    carrier = (!dMain1 ? raycastHit1.collider.GetComponent <TransCarrier>() : dMain1.GetLocal <TransCarrier>());
                }
            }
            flag4 = (raycastHit.collider is TerrainCollider ? true : raycastHit.collider.gameObject.layer == 10);
            flag7 = true;
        }
        else
        {
            vector3  = point;
            vector31 = Vector3.up;
            carrier  = null;
        }
        bool      flag12           = false;
        Hardpoint hardpointFromRay = null;

        if (this.hardpointType != Hardpoint.hardpoint_type.None)
        {
            hardpointFromRay = Hardpoint.GetHardpointFromRay(ray, this.hardpointType);
            if (hardpointFromRay)
            {
                flag12   = true;
                vector3  = hardpointFromRay.transform.position;
                vector31 = hardpointFromRay.transform.up;
                carrier  = hardpointFromRay.GetMaster().GetTransCarrier();
                flag7    = true;
            }
        }
        bool flag13 = false;

        if (this.spacingRadius > 0f)
        {
            Collider[] colliderArray = Physics.OverlapSphere(vector3, this.spacingRadius);
            int        num           = 0;
            while (num < (int)colliderArray.Length)
            {
                Collider   collider   = colliderArray[num];
                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(vector3, gameObject.transform.position) >= this.spacingRadius)
                {
                    num++;
                }
                else
                {
                    flag13 = true;
                    break;
                }
            }
        }
        bool flag14 = false;

        if (flag3 && !this.forcePlaceable && deployableObject.cantPlaceOn)
        {
            flag14 = true;
        }
        pos = vector3;
        if (this.orientationMode == DeployableOrientationMode.Default)
        {
            if (!this.uprightOnly)
            {
                this.orientationMode = DeployableOrientationMode.NormalUp;
            }
            else
            {
                this.orientationMode = DeployableOrientationMode.Upright;
            }
        }
        switch (this.orientationMode)
        {
        case DeployableOrientationMode.NormalUp:
        {
            quaternion = TransformHelpers.LookRotationForcedUp(ray.direction, vector31);
            break;
        }

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

        case DeployableOrientationMode.NormalForward:
        {
            Vector3 vector36 = Vector3.Cross(ray.direction, Vector3.up);
            quaternion = TransformHelpers.LookRotationForcedUp(vector36, vector31);
            break;
        }

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

        default:
        {
            throw new NotImplementedException();
        }
        }
        rot = quaternion * this.ObjectToPlace.transform.localRotation;
        bool flag15 = false;

        if (this.checkPlacementZones)
        {
            flag15 = NoPlacementZone.ValidPos(pos);
        }
        float single2 = Vector3.Angle(vector31, Vector3.up);

        results.falseFromDeployable      = (this.CanStackOnDeployables || !flag3 ? flag14 : true);
        results.falseFromTerrian         = (!this.TerrainOnly ? false : !flag4);
        results.falseFromClose           = (this.spacingRadius <= 0f ? false : flag13);
        results.falseFromHardpoint       = (!this.requireHardpoint ? false : !flag12);
        results.falseFromAngle           = (this.requireHardpoint ? false : single2 >= this.ObjectToPlace.maxSlope);
        results.falseFromPlacementZone   = (!this.checkPlacementZones ? false : !flag15);
        results.falseFromHittingNothing  = !flag7;
        results.falseFromStructure       = (!this.StructureOnly ? false : !flag5);
        results.falseFromFitRequirements = (this.fitRequirements == null ? false : !this.fitRequirements.Test(pos, (!this.fitTestForcedUp ? rot : TransformHelpers.LookRotationForcedUp(rot, Vector3.up)), this.ObjectToPlace.transform.localScale));
    }