Exemplo n.º 1
0
        public override void OnKilled()
        {
            if (LifeState == LifeState.Dead)
            {
                return;
            }

            LifeState = LifeState.Dead;

            Log.Info("Pawn got killed");

            var ragdoll = CreateRagdoll(LastDamage.Force, GetHitboxBone(LastDamage.HitboxIndex));

            ClearCollisionLayers();
            EnableDrawing = false;

            Ragdoll   = ragdoll;
            DeathTime = 0;

            // NOTE: This pawn/entity will keep existing until the round manager decides otherwise.
            var roundMgr = RoundManager.Get();

            if (roundMgr != null)
            {
                roundMgr?.OnPawnKilled(this);
            }

            base.OnKilled();
        }
Exemplo n.º 2
0
        public override void PostCameraSetup(Camera camera)
        {
            base.PostCameraSetup(camera);

            if (lastCameraRot == Rotation.Identity)
            {
                lastCameraRot = Camera.Rot;
            }

            var angleDiff        = Rotation.Difference(lastCameraRot, Camera.Rot);
            var angleDiffDegrees = angleDiff.Angle();
            var allowance        = 20.0f;

            if (angleDiffDegrees > allowance)
            {
                lastCameraRot = Rotation.Lerp(lastCameraRot, Camera.Rot, 1.0f - (allowance / angleDiffDegrees));
            }

            if (camera is FirstPersonCamera)
            {
                AddCameraEffects(camera);
            }

            if (timeSinceUpdatedFramerate > 1)
            {
                timeSinceUpdatedFramerate = 0;
                UpdateFps((int)(1.0f / Time.Delta));
            }
        }
Exemplo n.º 3
0
 public void Update()
 {
     if (!App.update)
     {
         return;
     }
     using (TimeWarning.New("CompanionServer.MessageQueue"))
     {
         lock (_messageQueue)
         {
             _stopwatch.Restart();
             while (_messageQueue.Count > 0 && _stopwatch.Elapsed.TotalMilliseconds < 5.0)
             {
                 Message message = _messageQueue.Dequeue();
                 Dispatch(message);
             }
         }
     }
     if ((float)_lastCleanup >= 3f)
     {
         _lastCleanup = 0f;
         _ipTokenBuckets.Cleanup();
         _ipBans.Cleanup();
         _playerTokenBuckets.Cleanup();
         _pairingTokenBuckets.Cleanup();
     }
 }
Exemplo n.º 4
0
Arquivo: Gun.cs Projeto: cr4yz/sandbox
    public override void OnPlayerControlTick(Player owner)
    {
        base.OnPlayerControlTick(owner);

        //DebugTrace( owner );
        return;

        if (!NavMesh.IsLoaded)
        {
            return;
        }

        timeSinceLast = 0;

        var forward = owner.EyeRot.Forward * 2000;


        var tr = Trace.Ray(owner.EyePos, owner.EyePos + forward)
                 .Ignore(owner)
                 .Run();

        var closestPoint = NavMesh.GetClosestPoint(tr.EndPos);

        DebugOverlay.Line(tr.EndPos, closestPoint, 0.1f);

        DebugOverlay.Axis(closestPoint, Rotation.LookAt(tr.Normal), 2.0f, Time.Delta * 2);
        DebugOverlay.Text(closestPoint, $"CLOSEST Walkable POINT", Time.Delta * 2);

        NavMesh.BuildPath(Owner.WorldPos, closestPoint);
    }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
0
        private void TickPlayback()
        {
            if (_frames.Count == 0 ||
                _pause <= 3)
            {
                return;
            }

            if (_playbackIndex >= _frames.Count)
            {
                _playbackIndex = 0;
                _pause         = 0;
                return;
            }

            CurrentFrame = _frames[_playbackIndex];
            _playbackIndex++;
        }
Exemplo n.º 7
0
        public void SetText(string newText)
        {
            if (TextLabel.Text == newText)
            {
                return;
            }

            if (TextActive < 3.0)
            {
                TextLabel.SetClass("active", false);
                DelayedActivate = true;
            }
            else
            {
                TextLabel.SetClass("active", true);
            }

            TextActive     = 0;
            TextLabel.Text = newText;
        }
Exemplo n.º 8
0
 private void Update()
 {
     if (!((float)timeSinceUpdated < 0.25f))
     {
         timeSinceUpdated = 0f;
         sb.Clear();
         sb.AppendLine(BenchmarkTitle);
         sb.AppendLine(BenchmarkSubtitle);
         sb.AppendLine();
         sb.Append(Performance.current.frameRate).Append(" FPS");
         sb.Append(" / ").Append(Performance.current.frameTime.ToString("0.0")).Append("ms");
         sb.AppendLine().Append(Performance.current.memoryAllocations).Append(" MB");
         sb.Append(" / ").Append(Performance.current.memoryCollections).Append(" GC");
         sb.AppendLine().Append(Performance.current.memoryUsageSystem).Append(" RAM");
         sb.AppendLine().Append(Performance.current.loadBalancerTasks).Append(" TASKS");
         sb.Append(" / ").Append(Rust.Workshop.WorkshopSkin.QueuedCount).Append(" SKINS");
         sb.Append(" / ").Append(Performance.current.invokeHandlerTasks).Append(" INVOKES");
         sb.AppendLine();
         sb.AppendLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString());
         PerformanceText.text = sb.ToString();
     }
 }
Exemplo n.º 9
0
 public void GetDeliveryEligibleVendingMachines(List <uint> vendingMachineIds)
 {
     if ((float)_deliveryEligibleLastCalculated < 5f)
     {
         if (vendingMachineIds == null)
         {
             return;
         }
         foreach (uint item in _deliveryEligible)
         {
             vendingMachineIds.Add(item);
         }
         return;
     }
     _deliveryEligibleLastCalculated = 0f;
     _deliveryEligible.Clear();
     foreach (MapMarker serverMapMarker in MapMarker.serverMapMarkers)
     {
         VendingMachineMapMarker vendingMachineMapMarker;
         if ((object)(vendingMachineMapMarker = serverMapMarker as VendingMachineMapMarker) != null && !(vendingMachineMapMarker.server_vendingMachine == null))
         {
             VendingMachine server_vendingMachine = vendingMachineMapMarker.server_vendingMachine;
             if (!(server_vendingMachine == null) && (_003CGetDeliveryEligibleVendingMachines_003Eg__IsEligible_007C24_0(server_vendingMachine, config.vendingMachineOffset, 1) || _003CGetDeliveryEligibleVendingMachines_003Eg__IsEligible_007C24_0(server_vendingMachine, config.vendingMachineOffset + Vector3.forward * config.maxDistanceFromVendingMachine, 2)))
             {
                 _deliveryEligible.Add(server_vendingMachine.net.ID);
             }
         }
     }
     if (vendingMachineIds == null)
     {
         return;
     }
     foreach (uint item2 in _deliveryEligible)
     {
         vendingMachineIds.Add(item2);
     }
 }
Exemplo n.º 10
0
    public override void PostCameraSetup(Camera camera)
    {
        base.PostCameraSetup(camera);

        if (lastCameraRot == Rotation.Identity)
        {
            lastCameraRot = Camera.Rot;
        }

        var angleDiff        = Rotation.Difference(lastCameraRot, Camera.Rot);
        var angleDiffDegrees = angleDiff.Angle();
        var allowance        = 20.0f;

        if (angleDiffDegrees > allowance)
        {
            // We could have a function that clamps a rotation to within x degrees of another rotation?
            lastCameraRot = Rotation.Lerp(lastCameraRot, Camera.Rot, 1.0f - (allowance / angleDiffDegrees));
        }
        else
        {
            //lastCameraRot = Rotation.Lerp( lastCameraRot, Camera.Rot, Time.Delta * 0.2f * angleDiffDegrees );
        }

        // uncomment for lazy cam
        //camera.Rot = lastCameraRot;

        if (camera is FirstPersonCamera)
        {
            AddCameraEffects(camera);
        }

        if (timeSinceUpdatedFramerate > 1)
        {
            timeSinceUpdatedFramerate = 0;
            //UpdateFps( (int) (1.0f / Time.Delta) );
        }
    }