Example #1
0
 public void Init()
 {
     if (ioEnt != null && !entityRef.IsValid(true))
     {
         entityRef.Set(ioEnt);
     }
     if (entityRef.IsValid(true))
     {
         ioEnt = entityRef.Get(true).GetComponent <IOEntity>();
     }
 }
Example #2
0
    public virtual void SetTargetDoor(Door newTargetDoor)
    {
        Door door = targetDoor;

        targetDoor = newTargetDoor;
        SetFlag(Flags.On, targetDoor != null);
        entityRef.Set(newTargetDoor);
        if (door != targetDoor && targetDoor != null)
        {
            DoAction();
        }
    }
Example #3
0
 public void Setup(Marketplace marketplace, MarketTerminal terminal, VendingMachine vendingMachine)
 {
     sourceMarketplace.Set(marketplace);
     sourceTerminal.Set(terminal);
     targetVendingMachine.Set(vendingMachine);
     _state = State.Takeoff;
     _sinceLastStateChange = 0f;
     _pickUpTicks          = 0;
 }
Example #4
0
 public void SetWorldEntity(BaseEntity ent)
 {
     if (!BaseEntityEx.IsValid(ent))
     {
         worldEnt.Set(null);
         MarkDirty();
     }
     else if (worldEnt.uid != ent.net.ID)
     {
         worldEnt.Set(ent);
         MarkDirty();
         OnMovedToWorld();
         if (contents != null)
         {
             contents.OnMovedToWorld();
         }
     }
 }
Example #5
0
    public void SpawnChildEntity()
    {
        MicrophoneStandIOEntity microphoneStandIOEntity = GameManager.server.CreateEntity(IOSubEntity.resourcePath, IOSubEntitySpawnPos.localPosition, IOSubEntitySpawnPos.localRotation) as MicrophoneStandIOEntity;

        microphoneStandIOEntity.enableSaving = enableSaving;
        microphoneStandIOEntity.SetParent(this);
        microphoneStandIOEntity.Spawn();
        ioEntity.Set(microphoneStandIOEntity);
        SendNetworkUpdate();
    }
Example #6
0
 public void SpawnSubEntities()
 {
     if (!Rust.Application.isLoadingSave)
     {
         BaseEntity baseEntity = GameManager.server.CreateEntity(storageUnitPrefab.resourcePath, storageUnitPoint.localPosition, storageUnitPoint.localRotation);
         baseEntity.Spawn();
         baseEntity.SetParent(this);
         storageUnitInstance.Set(baseEntity);
         fuelSystem.SpawnFuelStorage(fuelStoragePrefab, fuelStoragePoint);
     }
 }
Example #7
0
 public void SpawnFuelStorage(GameObjectRef fuelStoragePrefab, Transform fuelStoragePoint)
 {
     if (fuelStoragePrefab != null && !(fuelStoragePoint == null) && !Rust.Application.isLoadingSave)
     {
         Vector3    pos        = owner.transform.InverseTransformPoint(fuelStoragePoint.position);
         Quaternion rot        = Quaternion.Inverse(owner.transform.rotation) * fuelStoragePoint.rotation;
         BaseEntity baseEntity = GameManager.server.CreateEntity(fuelStoragePrefab.resourcePath, pos, rot);
         baseEntity.SetParent(owner);
         baseEntity.Spawn();
         fuelStorageInstance.Set(baseEntity);
     }
 }
Example #8
0
 public override void OnFlagsChanged(Flags old, Flags next)
 {
     base.OnFlagsChanged(old, next);
     if (!base.isServer || old.HasFlag(Flags.Reserved8) == next.HasFlag(Flags.Reserved8))
     {
         return;
     }
     if (next.HasFlag(Flags.Reserved8))
     {
         IAudioConnectionSource connectionSource = GetConnectionSource(this, BoomBox.BacktrackLength);
         if (connectionSource != null)
         {
             ClientRPC(null, "Client_PlayAudioFrom", connectionSource.ToEntity().net.ID);
             connectedTo.Set(connectionSource.ToEntity());
         }
     }
     else if (connectedTo.IsSet)
     {
         ClientRPC(null, "Client_StopPlayingAudio");
         connectedTo.Set(null);
     }
 }
Example #9
0
 public override void OnFlagsChanged(Flags old, Flags next)
 {
     base.OnFlagsChanged(old, next);
     if (base.isServer && old.HasFlag(Flags.Reserved8) != next.HasFlag(Flags.Reserved8) && next.HasFlag(Flags.Reserved8))
     {
         IOEntity audioSource = GetAudioSource(this, BoomBox.BacktrackLength);
         if (audioSource != null)
         {
             ClientRPC(null, "Client_PlayAudioFrom", audioSource.net.ID);
         }
         connectedTo.Set(audioSource);
     }
 }
Example #10
0
            void FixedUpdate()
            {
                base.DoMovement();
                var launcherDist = (launcher.transform.position - transform.position).magnitude;

                if (!target.IsSet())
                {
                    Vis.Entities <BaseCombatEntity>(transform.position, 20, entList, 8192 | (1 << 11) | (1 << 17), QueryTriggerInteraction.Ignore);
                    float      best       = -1.0f;
                    BaseEntity bestTarget = null;

                    foreach (var ent in entList)
                    {
                        if (ignoreSet.Contains(ent))
                        {
                            continue;
                        }

                        var dir = ent.transform.position - transform.position;
                        var dot = Vector3.Dot(_currentVelocity, dir);

                        if (dot > best)
                        {
                            best       = dot;
                            bestTarget = ent;
                        }

                        //Print($"ent.name: {ent.name}");
                    }

                    if (bestTarget && launcherDist > 5.0f)
                    {
                        target.Set(bestTarget);
                    }
                }
                else
                {
                    var hit = new RaycastHit();
                    hit.normal = Vector3.zero;
                    SendMessage("ProjectileImpact", hit);
                    Perforate();
                }
            }
Example #11
0
    public void DeleteBookmark(RPCMessage msg)
    {
        BasePlayer player = msg.player;

        if (!IsPlayerAdmin(player) || isStatic)
        {
            return;
        }
        string text = msg.read.String();

        if (IsValidIdentifier(text) && controlBookmarks.ContainsKey(text) && Interface.CallHook("OnBookmarkDelete", this, player, text) == null)
        {
            uint num = controlBookmarks[text];
            controlBookmarks.Remove(text);
            SendControlBookmarks(player);
            if (num == currentlyControllingEnt.uid)
            {
                currentlyControllingEnt.Set(null);
                SendNetworkUpdate();
            }
        }
    }
Example #12
0
    public override void SpawnSubEntities()
    {
        base.SpawnSubEntities();
        if (Rust.Application.isLoadingSave)
        {
            return;
        }
        BaseEntity       baseEntity       = GameManager.server.CreateEntity(potPrefab.resourcePath, Vector3.zero, Quaternion.identity);
        StorageContainer storageContainer = baseEntity as StorageContainer;

        if (storageContainer != null)
        {
            storageContainer.SetParent(this);
            storageContainer.Spawn();
            PotInstance.Set(baseEntity);
        }
        else
        {
            Debug.LogError(GetType().Name + ": Spawned prefab is not a StorageContainer as expected.");
        }
        PlayerStorageInfo[] array = playerStoragePoints;
        foreach (PlayerStorageInfo playerStorageInfo in array)
        {
            baseEntity = GameManager.server.CreateEntity(playerStoragePrefab.resourcePath, playerStorageInfo.storagePos.localPosition, playerStorageInfo.storagePos.localRotation);
            CardTablePlayerStorage cardTablePlayerStorage = baseEntity as CardTablePlayerStorage;
            if (cardTablePlayerStorage != null)
            {
                cardTablePlayerStorage.SetCardTable(this);
                cardTablePlayerStorage.SetParent(this);
                cardTablePlayerStorage.Spawn();
                playerStorageInfo.storageInstance.Set(baseEntity);
            }
            else
            {
                Debug.LogError(GetType().Name + ": Spawned prefab is not a CardTablePlayerStorage as expected.");
            }
        }
    }
Example #13
0
 public void SetOccupiedBy(RidableHorse newHorse)
 {
     horse.Set(newHorse);
 }
    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();
            }
        }
    }
 public void SetCardTable(CardTable cardTable)
 {
     cardTableRef.Set(cardTable);
 }