Ejemplo n.º 1
0
    public BaseEntity CreateConstruction(Target target, bool bNeedsValidPlacement = false)
    {
        GameObject gameObject = GameManager.server.CreatePrefab(fullName, Vector3.zero, Quaternion.identity, false);
        bool       flag       = UpdatePlacement(gameObject.transform, this, ref target);
        BaseEntity baseEntity = GameObjectEx.ToBaseEntity(gameObject);

        if (bNeedsValidPlacement && !flag)
        {
            if (BaseEntityEx.IsValid(baseEntity))
            {
                baseEntity.Kill();
            }
            else
            {
                GameManager.Destroy(gameObject);
            }
            return(null);
        }
        DecayEntity decayEntity = baseEntity as DecayEntity;

        if ((bool)decayEntity)
        {
            decayEntity.AttachToBuilding(target.entity as DecayEntity);
        }
        return(baseEntity);
    }
Ejemplo n.º 2
0
    public void ProcessCollision(Collision collision)
    {
        if (base.isClient || collision == null || collision.gameObject == null || collision.gameObject == null)
        {
            return;
        }
        ContactPoint contact    = collision.GetContact(0);
        BaseEntity   baseEntity = null;

        if (contact.otherCollider.attachedRigidbody == rigidBody)
        {
            baseEntity = GameObjectEx.ToBaseEntity(contact.otherCollider);
        }
        else if (contact.thisCollider.attachedRigidbody == rigidBody)
        {
            baseEntity = GameObjectEx.ToBaseEntity(contact.thisCollider);
        }
        if (baseEntity != null)
        {
            float forceMagnitude = collision.impulse.magnitude / UnityEngine.Time.fixedDeltaTime;
            if (QueueCollisionDamage(baseEntity, forceMagnitude) > 0f)
            {
                ShowCollisionFX(collision);
            }
        }
    }
Ejemplo n.º 3
0
    public void DoRadialDamage()
    {
        List <Collider> obj      = Pool.GetList <Collider>();
        Vector3         position = base.transform.position + new Vector3(0f, radius * 0.75f, 0f);

        Vis.Colliders(position, radius, obj, AttackLayers);
        HitInfo hitInfo = new HitInfo();

        hitInfo.DoHitEffects = true;
        hitInfo.DidHit       = true;
        hitInfo.HitBone      = 0u;
        hitInfo.Initiator    = ((creatorEntity == null) ? GameObjectEx.ToBaseEntity(base.gameObject) : creatorEntity);
        hitInfo.PointStart   = base.transform.position;
        foreach (Collider item in obj)
        {
            if (item.isTrigger && (item.gameObject.layer == 29 || item.gameObject.layer == 18))
            {
                continue;
            }
            BaseCombatEntity baseCombatEntity = GameObjectEx.ToBaseEntity(item.gameObject) as BaseCombatEntity;
            if (!(baseCombatEntity == null) && baseCombatEntity.isServer && baseCombatEntity.IsAlive() && (!ignoreNPC || !baseCombatEntity.IsNpc) && baseCombatEntity.IsVisible(position))
            {
                if (baseCombatEntity is BasePlayer)
                {
                    Effect.server.Run("assets/bundled/prefabs/fx/impacts/additive/fire.prefab", baseCombatEntity, 0u, new Vector3(0f, 1f, 0f), Vector3.up);
                }
                hitInfo.PointEnd         = baseCombatEntity.transform.position;
                hitInfo.HitPositionWorld = baseCombatEntity.transform.position;
                hitInfo.damageTypes.Set(DamageType.Heat, damagePerSecond * tickRate);
                Interface.CallHook("OnFireBallDamage", this, baseCombatEntity, hitInfo);
                baseCombatEntity.OnAttacked(hitInfo);
            }
        }
        Pool.FreeList(ref obj);
    }
Ejemplo n.º 4
0
    internal override GameObject InterestedInObject(GameObject obj)
    {
        obj = base.InterestedInObject(obj);
        if (obj == null)
        {
            return(null);
        }
        BaseEntity baseEntity = GameObjectEx.ToBaseEntity(obj);

        if (baseEntity == null)
        {
            return(null);
        }
        if (baseEntity.isClient)
        {
            return(null);
        }
        if (!baseEntity.syncPosition)
        {
            return(null);
        }
        if (!baseEntity.GetComponent <MagnetLiftable>())
        {
            return(null);
        }
        return(baseEntity.gameObject);
    }
Ejemplo n.º 5
0
 protected void UpdateBaseEntity()
 {
     if ((bool)this && (bool)base.gameObject)
     {
         _baseEntity = GameObjectEx.ToBaseEntity(base.gameObject) as T;
     }
 }
Ejemplo n.º 6
0
 public void Clear()
 {
     if (IsSpawned)
     {
         BaseEntity baseEntity = GameObjectEx.ToBaseEntity(spawnInstance.gameObject);
         if (baseEntity != null)
         {
             baseEntity.Kill();
         }
     }
 }
Ejemplo n.º 7
0
    private bool OnGround()
    {
        BaseEntity component = GetComponent <BaseEntity>();

        if ((bool)component)
        {
            Construction construction = PrefabAttribute.server.Find <Construction>(component.prefabID);
            if ((bool)construction)
            {
                Socket_Base[] allSockets = construction.allSockets;
                for (int i = 0; i < allSockets.Length; i++)
                {
                    SocketMod[] socketMods = allSockets[i].socketMods;
                    for (int j = 0; j < socketMods.Length; j++)
                    {
                        SocketMod_AreaCheck socketMod_AreaCheck = socketMods[j] as SocketMod_AreaCheck;
                        if ((bool)socketMod_AreaCheck && socketMod_AreaCheck.wantsInside && !socketMod_AreaCheck.DoCheck(component.transform.position, component.transform.rotation))
                        {
                            if (ConVar.Physics.groundwatchdebug)
                            {
                                Debug.Log("GroundWatch failed: " + socketMod_AreaCheck.hierachyName);
                            }
                            return(false);
                        }
                    }
                }
            }
        }
        List <Collider> obj = Facepunch.Pool.GetList <Collider>();

        Vis.Colliders(base.transform.TransformPoint(groundPosition), radius, obj, layers);
        foreach (Collider item in obj)
        {
            BaseEntity baseEntity = GameObjectEx.ToBaseEntity(item.gameObject);
            if (!baseEntity || (!(baseEntity == component) && !baseEntity.IsDestroyed && !baseEntity.isClient))
            {
                DecayEntity decayEntity  = component as DecayEntity;
                DecayEntity decayEntity2 = baseEntity as DecayEntity;
                if (!decayEntity || decayEntity.buildingID == 0 || !decayEntity2 || decayEntity2.buildingID == 0 || decayEntity.buildingID == decayEntity2.buildingID)
                {
                    Facepunch.Pool.FreeList(ref obj);
                    return(true);
                }
            }
        }
        if (ConVar.Physics.groundwatchdebug)
        {
            Debug.Log("GroundWatch failed: Legacy radius check");
        }
        Facepunch.Pool.FreeList(ref obj);
        return(false);
    }
Ejemplo n.º 8
0
            public static RendererInstance From(Renderer renderer)
            {
                RendererInstance result = default(RendererInstance);

                result.IsVisible      = renderer.isVisible;
                result.CastShadows    = renderer.shadowCastingMode != ShadowCastingMode.Off;
                result.RecieveShadows = renderer.receiveShadows;
                result.Enabled        = renderer.enabled && renderer.gameObject.activeInHierarchy;
                result.Size           = renderer.bounds.size.magnitude;
                result.Distance       = Vector3.Distance(renderer.bounds.center, Camera.main.transform.position);
                result.MaterialCount  = renderer.sharedMaterials.Length;
                result.RenderType     = renderer.GetType().Name;
                BaseEntity baseEntity = GameObjectEx.ToBaseEntity(renderer.gameObject);

                if ((bool)baseEntity)
                {
                    result.EntityName = baseEntity.PrefabName;
                    if (baseEntity.net != null)
                    {
                        result.EntityId = baseEntity.net.ID;
                    }
                }
                else
                {
                    result.ObjectName = TransformEx.GetRecursiveName(renderer.transform);
                }
                if (renderer is MeshRenderer)
                {
                    result.BoneCount = 0;
                    MeshFilter component = renderer.GetComponent <MeshFilter>();
                    if ((bool)component)
                    {
                        result.ReadMesh(component.sharedMesh);
                    }
                }
                if (renderer is SkinnedMeshRenderer)
                {
                    SkinnedMeshRenderer skinnedMeshRenderer = renderer as SkinnedMeshRenderer;
                    result.ReadMesh(skinnedMeshRenderer.sharedMesh);
                    result.UpdateWhenOffscreen = skinnedMeshRenderer.updateWhenOffscreen;
                }
                if (renderer is ParticleSystemRenderer)
                {
                    ParticleSystem component2 = renderer.GetComponent <ParticleSystem>();
                    if ((bool)component2)
                    {
                        result.MeshName      = component2.name;
                        result.ParticleCount = component2.particleCount;
                    }
                }
                return(result);
            }
Ejemplo n.º 9
0
 public override void ObjectEntered(GameObject obj)
 {
     if (!base.isClient)
     {
         if (!Armed())
         {
             CancelInvoke(Arm);
             blocked = true;
         }
         else if (Interface.CallHook("OnTrapTrigger", this, obj) == null)
         {
             BasePlayer ply = GameObjectEx.ToBaseEntity(obj) as BasePlayer;
             Trigger(ply);
         }
     }
 }
Ejemplo n.º 10
0
 private static bool CheckFlags(List <Collider> list, DeployVolume volume)
 {
     for (int i = 0; i < list.Count; i++)
     {
         GameObject gameObject = list[i].gameObject;
         if (gameObject.CompareTag("DeployVolumeIgnore"))
         {
             continue;
         }
         ColliderInfo component = gameObject.GetComponent <ColliderInfo>();
         if (!(component == null) && volume.ignore != 0 && component.HasFlag(volume.ignore))
         {
             continue;
         }
         if (volume.entityList.Length == 0)
         {
             return(true);
         }
         BaseEntity baseEntity = GameObjectEx.ToBaseEntity(list[i]);
         bool       flag       = false;
         if (baseEntity != null)
         {
             BaseEntity[] array = volume.entityList;
             foreach (BaseEntity baseEntity2 in array)
             {
                 if (baseEntity.prefabID == baseEntity2.prefabID)
                 {
                     flag = true;
                     break;
                 }
             }
         }
         if (volume.entityMode == EntityMode.IncludeList)
         {
             if (flag)
             {
                 return(true);
             }
         }
         else if (volume.entityMode == EntityMode.ExcludeList && !flag)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
    private void OnGroundMissing()
    {
        BaseEntity baseEntity = GameObjectEx.ToBaseEntity(base.gameObject);

        if (baseEntity != null && Interface.CallHook("OnEntityGroundMissing", baseEntity) == null)
        {
            BaseCombatEntity baseCombatEntity = baseEntity as BaseCombatEntity;
            if (baseCombatEntity != null)
            {
                baseCombatEntity.Die();
            }
            else
            {
                baseEntity.Kill(BaseNetworkable.DestroyMode.Gib);
            }
        }
    }
Ejemplo n.º 12
0
 public void DelayedFire()
 {
     if ((bool)hurtTarget)
     {
         BaseEntity baseEntity = GameObjectEx.ToBaseEntity(hurtTarget);
         if (baseEntity != null)
         {
             HitInfo hitInfo = new HitInfo(this, baseEntity, DamageType.Bite, 50f, base.transform.position);
             hitInfo.damageTypes.Add(DamageType.Stab, 30f);
             baseEntity.OnAttacked(hitInfo);
         }
         hurtTarget = null;
     }
     RadialResetCorpses(1800f);
     Fire();
     Hurt(25f);
 }
Ejemplo n.º 13
0
    public override GameObject InterestedInObject(GameObject obj)
    {
        obj = base.InterestedInObject(obj);
        if (obj == null)
        {
            return(null);
        }
        BaseEntity baseEntity = GameObjectEx.ToBaseEntity(obj);

        if (baseEntity == null)
        {
            return(null);
        }
        if (baseEntity.isClient)
        {
            return(null);
        }
        return(baseEntity.gameObject);
    }
Ejemplo n.º 14
0
 public virtual void UpdatePillars()
 {
     BoxCollider[] array = pillars;
     foreach (BoxCollider boxCollider in array)
     {
         boxCollider.gameObject.SetActive(true);
         Collider[] array2 = Physics.OverlapBox(boxCollider.transform.TransformPoint(boxCollider.center), boxCollider.size * 0.5f, boxCollider.transform.rotation, 2097152);
         foreach (Collider collider in array2)
         {
             if (collider.CompareTag("Usable Auxiliary"))
             {
                 BaseEntity baseEntity = GameObjectEx.ToBaseEntity(collider.gameObject);
                 if (!(baseEntity == null) && !EqualNetID(baseEntity) && collider != boxCollider)
                 {
                     boxCollider.gameObject.SetActive(false);
                 }
             }
         }
     }
 }
Ejemplo n.º 15
0
    public void WakeNearbyRigidbodies()
    {
        List <Collider> obj = Facepunch.Pool.GetList <Collider>();

        Vis.Colliders(base.transform.position, 7f, obj, 34816);
        foreach (Collider item in obj)
        {
            Rigidbody attachedRigidbody = item.attachedRigidbody;
            if (attachedRigidbody != null && attachedRigidbody.IsSleeping())
            {
                attachedRigidbody.WakeUp();
            }
            BaseEntity        baseEntity = GameObjectEx.ToBaseEntity(item);
            BaseRidableAnimal baseRidableAnimal;
            if (baseEntity != null && (object)(baseRidableAnimal = baseEntity as BaseRidableAnimal) != null && baseRidableAnimal.isServer)
            {
                baseRidableAnimal.UpdateDropToGroundForDuration(2f);
            }
        }
        Facepunch.Pool.FreeList(ref obj);
    }
Ejemplo n.º 16
0
        public static void del(Arg args)
        {
            if (!args.HasArgs())
            {
                return;
            }
            IEnumerable <Transform> enumerable = from x in GetCurrent()
                                                 where x.name.ToLower() == args.FullString.ToLower()
                                                 select x;

            if (enumerable.Count() == 0)
            {
                enumerable = from x in GetCurrent()
                             where x.name.StartsWith(args.FullString, StringComparison.CurrentCultureIgnoreCase)
                             select x;
            }
            if (enumerable.Count() == 0)
            {
                args.ReplyWith("Couldn't find  " + args.FullString);
                return;
            }
            foreach (Transform item in enumerable)
            {
                BaseEntity baseEntity = GameObjectEx.ToBaseEntity(item.gameObject);
                if (BaseEntityEx.IsValid(baseEntity))
                {
                    if (baseEntity.isServer)
                    {
                        baseEntity.Kill();
                    }
                }
                else
                {
                    GameManager.Destroy(item.gameObject);
                }
            }
            args.ReplyWith("Deleted " + enumerable.Count() + " objects");
        }
Ejemplo n.º 17
0
    internal override GameObject InterestedInObject(GameObject obj)
    {
        obj = base.InterestedInObject(obj);
        if (obj == null)
        {
            return(null);
        }
        BaseEntity baseEntity = GameObjectEx.ToBaseEntity(obj);

        if (baseEntity == null)
        {
            return(null);
        }
        if (baseEntity.isClient)
        {
            return(null);
        }
        if (!includeNPCs && baseEntity.IsNpc)
        {
            return(null);
        }
        return(baseEntity.gameObject);
    }
Ejemplo n.º 18
0
 public void SetResting(bool isResting)
 {
     if (isResting != IsResting() && isResting && TimeAlive() > 1f && CanMerge())
     {
         List <Collider> obj = Pool.GetList <Collider>();
         Vis.Colliders(base.transform.position, 0.5f, obj, 512);
         foreach (Collider item in obj)
         {
             BaseEntity baseEntity = GameObjectEx.ToBaseEntity(item.gameObject);
             if ((bool)baseEntity)
             {
                 FireBall fireBall = baseEntity.ToServer <FireBall>();
                 if ((bool)fireBall && fireBall.CanMerge() && fireBall != this)
                 {
                     fireBall.Invoke(Extinguish, 1f);
                     fireBall.canMerge = false;
                     AddLife(fireBall.TimeLeft() * 0.25f);
                 }
             }
         }
         Pool.FreeList(ref obj);
     }
     SetFlag(Flags.OnFire, isResting);
 }
 public void Awake()
 {
     ezSoftBones = GetComponents <EZSoftBone>();
     player      = GameObjectEx.ToBaseEntity(base.gameObject) as BasePlayer;
 }
Ejemplo n.º 20
0
 public static bool TestFlying(BasePlayer ply, Vector3 oldPos, Vector3 newPos, bool verifyGrounded)
 {
     ply.isInAir    = false;
     ply.isOnPlayer = false;
     if (verifyGrounded)
     {
         float   flyhack_extrusion = ConVar.AntiHack.flyhack_extrusion;
         Vector3 vector            = (oldPos + newPos) * 0.5f;
         if (!ply.OnLadder() && !WaterLevel.Test(vector - new Vector3(0f, flyhack_extrusion, 0f), true, ply) && (EnvironmentManager.Get(vector) & EnvironmentType.Elevator) == 0)
         {
             float   flyhack_margin = ConVar.AntiHack.flyhack_margin;
             float   radius         = ply.GetRadius();
             float   height         = ply.GetHeight(false);
             Vector3 vector2        = vector + new Vector3(0f, radius - flyhack_extrusion, 0f);
             Vector3 vector3        = vector + new Vector3(0f, height - radius, 0f);
             float   radius2        = radius - flyhack_margin;
             ply.isInAir = !UnityEngine.Physics.CheckCapsule(vector2, vector3, radius2, 1503731969, QueryTriggerInteraction.Ignore);
             if (ply.isInAir)
             {
                 int num = UnityEngine.Physics.OverlapCapsuleNonAlloc(vector2, vector3, radius2, buffer, 131072, QueryTriggerInteraction.Ignore);
                 for (int i = 0; i < num; i++)
                 {
                     BasePlayer basePlayer = GameObjectEx.ToBaseEntity(buffer[i].gameObject) as BasePlayer;
                     if (!(basePlayer == null) && !(basePlayer == ply) && !basePlayer.isInAir && !basePlayer.isOnPlayer && !basePlayer.TriggeredAntiHack() && !basePlayer.IsSleeping())
                     {
                         ply.isOnPlayer = true;
                         ply.isInAir    = false;
                         break;
                     }
                 }
                 for (int j = 0; j < buffer.Length; j++)
                 {
                     buffer[j] = null;
                 }
             }
         }
     }
     else
     {
         ply.isInAir = !ply.OnLadder() && !ply.IsSwimming() && !ply.IsOnGround();
     }
     if (ply.isInAir)
     {
         bool    flag = false;
         Vector3 v    = newPos - oldPos;
         float   num2 = Mathf.Abs(v.y);
         float   num3 = v.Magnitude2D();
         if (v.y >= 0f)
         {
             ply.flyhackDistanceVertical += v.y;
             flag = true;
         }
         if (num2 < num3)
         {
             ply.flyhackDistanceHorizontal += num3;
             flag = true;
         }
         if (flag)
         {
             float num4 = Mathf.Max((ply.flyhackPauseTime > 0f) ? ConVar.AntiHack.flyhack_forgiveness_vertical_inertia : ConVar.AntiHack.flyhack_forgiveness_vertical, 0f);
             float num5 = ply.GetJumpHeight() + num4;
             if (ply.flyhackDistanceVertical > num5)
             {
                 return(true);
             }
             float num6 = Mathf.Max((ply.flyhackPauseTime > 0f) ? ConVar.AntiHack.flyhack_forgiveness_horizontal_inertia : ConVar.AntiHack.flyhack_forgiveness_horizontal, 0f);
             float num7 = 5f + num6;
             if (ply.flyhackDistanceHorizontal > num7)
             {
                 return(true);
             }
         }
     }
     else
     {
         ply.flyhackDistanceVertical   = 0f;
         ply.flyhackDistanceHorizontal = 0f;
     }
     return(false);
 }
Ejemplo n.º 21
0
        private void OnEntityBuilt(Planner planner, GameObject go)
        {
            var player = planner?.GetOwnerPlayer();

            if (player == null || permission.UserHasPermission(player.UserIDString, permBypass))
            {
                return;
            }

            var entity        = GameObjectEx.ToBaseEntity(go);
            var buildingBlock = entity?.GetComponent <BuildingBlock>();

            if (buildingBlock == null)
            {
                return;
            }

            if (buildingBlock.WaterFactor() >= config.MaxWaterDepth)
            {
                if (config.RefundResources)
                {
                    RefundResources(player, buildingBlock);
                }
                buildingBlock.Kill(BaseNetworkable.DestroyMode.Gib);
                Player.Reply(player, Lang("MaxWaterDepth", player.UserIDString, config.MaxWaterDepth));
                return;
            }

            var buildingId = buildingBlock.buildingID;

            if (buildingIds.ContainsKey(buildingId))
            {
                var connectingStructure = buildingIds[buildingBlock.buildingID];
                if (buildingBlock.name == foundation || buildingBlock.name == triFoundation)
                {
                    var foundationCount    = GetCountOf(connectingStructure, foundation);
                    var triFoundationCount = GetCountOf(connectingStructure, triFoundation);

                    if (buildingBlock.name == foundation && foundationCount >= config.MaxFoundations)
                    {
                        if (config.RefundResources)
                        {
                            RefundResources(player, buildingBlock);
                        }
                        buildingBlock.Kill(BaseNetworkable.DestroyMode.Gib);
                        Player.Reply(player, Lang("MaxFoundations", player.UserIDString, config.MaxFoundations));
                    }
                    else if (buildingBlock.name == triFoundation && triFoundationCount >= config.MaxTriFoundations)
                    {
                        if (config.RefundResources)
                        {
                            RefundResources(player, buildingBlock);
                        }
                        buildingBlock.Kill(BaseNetworkable.DestroyMode.Gib);
                        Player.Reply(player, Lang("MaxTriFoundations", player.UserIDString, config.MaxTriFoundations));
                    }
                    else
                    {
                        var structure = new List <BuildingBlock>(connectingStructure);
                        structure.Add(buildingBlock);
                        buildingIds[buildingId] = structure;
                    }
                }
                else
                {
                    if (!allowedBuildingBlocks.Contains(buildingBlock.name))
                    {
                        BuildingBlock firstFoundation = null;
                        foreach (var block in connectingStructure.Where(b => !string.IsNullOrEmpty(b.name) && b.name.Contains(triFoundation) || b.name.Contains(foundation)))
                        {
                            firstFoundation = block;
                        }

                        if (firstFoundation != null)
                        {
                            var height = (float)Math.Round(buildingBlock.transform.position.y - firstFoundation.transform.position.y, 0, MidpointRounding.AwayFromZero);
                            if (config.MaxBuildHeight <= height)
                            {
                                if (config.RefundResources)
                                {
                                    RefundResources(player, buildingBlock);
                                }
                                buildingBlock.Kill(BaseNetworkable.DestroyMode.Gib);
                                Player.Reply(player, Lang("MaxBuildHeight", player.UserIDString, (config.MaxBuildHeight / 3)));
                            }
                        }
                    }
                }
            }
            else
            {
                var structure = new List <BuildingBlock>();
                structure.Add(buildingBlock);
                buildingIds[buildingId] = structure;
            }
        }
Ejemplo n.º 22
0
 public void UpdateTargetVisibility()
 {
     if (HasTarget())
     {
         Vector3    position   = _target.transform.position;
         BasePlayer basePlayer = _target as BasePlayer;
         if ((bool)basePlayer)
         {
             position = basePlayer.eyes.position;
         }
         bool       flag       = false;
         float      num        = Vector3.Distance(position, muzzleTransform.position);
         Vector3    normalized = (position - muzzleTransform.position).normalized;
         RaycastHit hitInfo;
         if (num < maxTargetRange && InFiringArc(_target) && GamePhysics.Trace(new Ray(muzzleTransform.position + normalized * 6f, normalized), 0f, out hitInfo, num * 1.1f, 1218652417) && GameObjectEx.ToBaseEntity(hitInfo.collider.gameObject) == _target)
         {
             flag = true;
         }
         if (flag)
         {
             lastSeenTargetTime = UnityEngine.Time.realtimeSinceStartup;
         }
         targetVisible = flag;
     }
 }