예제 #1
0
 public void Init()
 {
     if (ioEnt != null && !entityRef.IsValid(true))
     {
         entityRef.Set(ioEnt);
     }
     if (entityRef.IsValid(true))
     {
         ioEnt = entityRef.Get(true).GetComponent <IOEntity>();
     }
 }
예제 #2
0
 public virtual void SetupInitialDoorConnection()
 {
     if (targetDoor == null && !entityRef.IsValid(true))
     {
         SetTargetDoor(FindDoor(PairWithLockedDoors()));
     }
     if (targetDoor != null && !entityRef.IsValid(true))
     {
         entityRef.Set(targetDoor);
     }
     if (entityRef.IsValid(true) && targetDoor == null)
     {
         SetTargetDoor(entityRef.Get(true).GetComponent <Door>());
     }
 }
예제 #3
0
    public virtual void BecomeDud()
    {
        Vector3    position  = base.transform.position;
        Quaternion rotation  = base.transform.rotation;
        bool       flag      = false;
        EntityRef  entityRef = parentEntity;

        while (entityRef.IsValid(base.isServer) && !flag)
        {
            BaseEntity baseEntity = entityRef.Get(base.isServer);
            if (baseEntity.syncPosition)
            {
                flag = true;
            }
            entityRef = baseEntity.parentEntity;
        }
        if (flag)
        {
            SetParent(null);
        }
        base.transform.SetPositionAndRotation(position, rotation);
        SetFlag(Flags.On, false);
        SetCollisionEnabled(true);
        if (flag)
        {
            SetMotionEnabled(true);
        }
        Effect.server.Run("assets/bundled/prefabs/fx/impacts/blunt/concrete/concrete1.prefab", this, 0u, Vector3.zero, Vector3.zero);
        SendNetworkUpdate();
        CancelInvoke(base.KillMessage);
        Invoke(base.KillMessage, 1200f);
    }
예제 #4
0
 public BaseMountable GetSaddle()
 {
     if (!saddleRef.IsValid(base.isServer))
     {
         return(null);
     }
     return(saddleRef.Get(base.isServer).GetComponent <BaseMountable>());
 }
예제 #5
0
 public void CheckInvalidBoat()
 {
     if (!fuelSystem.fuelStorageInstance.IsValid(base.isServer) || !storageUnitInstance.IsValid(base.isServer))
     {
         Debug.Log("Destroying invalid boat ");
         Invoke(ActualDeath, 1f);
     }
 }
예제 #6
0
 public override void PlayerServerInput(InputState inputState, BasePlayer player)
 {
     base.PlayerServerInput(inputState, player);
     if (currentlyControllingEnt.IsValid(true) && Interface.CallHook("OnBookmarkInput", this, player, inputState) == null)
     {
         currentlyControllingEnt.Get(true).GetComponent <IRemoteControllable>().UserInput(inputState, player);
     }
 }
예제 #7
0
 public void Server_TryOpenMarket(RPCMessage msg)
 {
     if (!CanPlayerInteract(msg.player))
     {
         return;
     }
     if (!_marketplace.IsValid(true))
     {
         Debug.LogError("Marketplace is not set", this);
         return;
     }
     using (EntityIdList entityIdList = Facepunch.Pool.Get <EntityIdList>())
     {
         entityIdList.entityIds = Facepunch.Pool.GetList <uint>();
         GetDeliveryEligibleVendingMachines(entityIdList.entityIds);
         ClientRPCPlayer(null, msg.player, "Client_OpenMarket", entityIdList);
     }
 }
예제 #8
0
    public void AssignPoints()
    {
        BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true);

        if (activeGameMode == null || !activeGameMode.IsMatchActive())
        {
            return;
        }
        if (activeGameMode.IsTeamGame())
        {
            if (captureTeam != -1 && captureFraction == 1f)
            {
                activeGameMode.ModifyTeamScore(captureTeam, scorePerSecond);
            }
        }
        else if (capturedPlayer.IsValid(true))
        {
            activeGameMode.ModifyPlayerGameScore(capturedPlayer.Get(true).GetComponent <BasePlayer>(), "score", scorePerSecond);
        }
    }
예제 #9
0
 public bool IsOccupied(bool isServer = true)
 {
     return(horse.IsValid(isServer));
 }
예제 #10
0
    public void UpdateCaptureAmount()
    {
        if (base.isClient)
        {
            return;
        }
        float        num            = captureFraction;
        BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true);

        if (activeGameMode == null)
        {
            return;
        }
        if (captureTrigger.entityContents == null)
        {
            SetFlag(Flags.Busy, false, false, false);
        }
        else
        {
            if (!activeGameMode.IsMatchActive())
            {
                return;
            }
            if (activeGameMode.IsTeamGame())
            {
                int[] array = new int[activeGameMode.GetNumTeams()];
                foreach (BaseEntity entityContent in captureTrigger.entityContents)
                {
                    if (!(entityContent == null) && !entityContent.isClient)
                    {
                        BasePlayer component = entityContent.GetComponent <BasePlayer>();
                        if (!(component == null) && component.IsAlive() && !component.IsNpc && component.gamemodeteam != -1)
                        {
                            array[component.gamemodeteam]++;
                        }
                    }
                }
                int num2 = 0;
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] > 0)
                    {
                        num2++;
                    }
                }
                if (num2 < 2)
                {
                    int num3 = -1;
                    int num4 = 0;
                    for (int j = 0; j < array.Length; j++)
                    {
                        if (array[j] > num4)
                        {
                            num4 = array[j];
                            num3 = j;
                        }
                    }
                    if (captureTeam == -1 && captureFraction == 0f)
                    {
                        capturingTeam = num3;
                    }
                    if (captureFraction > 0f && num3 != captureTeam && num3 != capturingTeam)
                    {
                        captureFraction = Mathf.Clamp01(captureFraction - Time.deltaTime / timeToCapture);
                        if (captureFraction == 0f)
                        {
                            captureTeam = -1;
                        }
                    }
                    else if (captureTeam == -1 && captureFraction < 1f && capturingTeam == num3)
                    {
                        DoProgressEffect();
                        captureFraction = Mathf.Clamp01(captureFraction + Time.deltaTime / timeToCapture);
                        if (captureFraction == 1f)
                        {
                            DoCaptureEffect();
                            captureTeam = num3;
                        }
                    }
                }
                SetFlag(Flags.Busy, num2 > 1);
            }
            else
            {
                if (!capturingPlayer.IsValid(true) && !capturedPlayer.IsValid(true))
                {
                    captureFraction = 0f;
                }
                if (captureTrigger.entityContents.Count == 0)
                {
                    capturingPlayer.Set(null);
                }
                if (captureTrigger.entityContents.Count == 1)
                {
                    foreach (BaseEntity entityContent2 in captureTrigger.entityContents)
                    {
                        BasePlayer component2 = entityContent2.GetComponent <BasePlayer>();
                        if (component2 == null)
                        {
                            continue;
                        }
                        if (!capturedPlayer.IsValid(true) && captureFraction == 0f)
                        {
                            capturingPlayer.Set(component2);
                        }
                        if (captureFraction > 0f && component2 != capturedPlayer.Get(true) && component2 != capturingPlayer.Get(true))
                        {
                            captureFraction = Mathf.Clamp01(captureFraction - Time.deltaTime / timeToCapture);
                            if (captureFraction == 0f)
                            {
                                capturedPlayer.Set(null);
                            }
                        }
                        else if (!capturedPlayer.Get(true) && captureFraction < 1f && capturingPlayer.Get(true) == component2)
                        {
                            DoProgressEffect();
                            captureFraction = Mathf.Clamp01(captureFraction + Time.deltaTime / timeToCapture);
                            if (captureFraction == 1f)
                            {
                                DoCaptureEffect();
                                capturedPlayer.Set(component2);
                            }
                        }
                        break;
                    }
                }
                SetFlag(Flags.Busy, captureTrigger.entityContents.Count > 1);
            }
            if (num != captureFraction)
            {
                SendNetworkUpdate();
            }
        }
    }