Example #1
0
        public PropData GetProp(PropSlot slot)
        {
            CheckExistence();

            var prop = Rage.Player.Player_GetProp(NativePointer, (uint)slot);

            return(StructConverter.PointerToStruct <PropData>(prop));
        }
Example #2
0
 public void SetProp(PropSlot slot, byte drawable, byte texture)
 {
     SetProp(slot, new PropData(drawable, texture));
 }
Example #3
0
        public void SetProp(PropSlot slot, PropData data)
        {
            CheckExistence();

            Rage.Player.Player_SetProp(NativePointer, (uint)slot, data);
        }
    protected override void Update()
    {
        var acceleration = Vector3.zero;

        if (CurrentTask == null && PropSlot == null)
        {
            acceleration = UpdateMovement();
            if (IsInputInState(eInput.Interact, eButtonState.Pressed))
            {
                float minDistance = float.MaxValue;
                Prop  closestProp = null;
                foreach (var prop in Prop.PropsList)
                {
                    var distance = DistanceUtility.Get2d(prop.transform, transform);
                    if (CanHoldProp(prop, distance:distance) &&
                        prop.CanMoveProp() &&
                        distance < minDistance)
                    {
                        closestProp = prop;
                        minDistance = distance;
                    }
                }

                if (closestProp != null)
                {
                    closestProp.PickUpProp(this);
                }


                if (PropSlot == null)
                {
                    foreach (var task in Interactable.Interactables)
                    {
                        var distance = (transform.position - task.transform.position).magnitude;
                        if (distance <= minDistance && task.CanInteract(transform.position))
                        {
                            CurrentTask = task;
                            minDistance = distance;
                            CurrentTask.StartInteraction(this);
                        }
                    }
                }
            }
        }
        else if (PropSlot != null)
        {
            acceleration = UpdateMovement();
            if (IsInputInState(eInput.Interact, eButtonState.Pressed))
            {
                PropSlot.DropProp();
            }
        }
        else if (CurrentTask != null)
        {
            Debug.DrawLine(transform.position, CurrentTask.transform.position, Color.green);

            var distance = (transform.position - CurrentTask.transform.position).magnitude;
            if (!CurrentTask.CanInteract(transform.position) ||
                IsInputInState(eInput.Interact, eButtonState.Pressed))
            {
                CurrentTask.EndInteraction();
                CurrentTask = null;
            }

            if (CurrentTask != null)
            {
                acceleration -= Velocity;
                Velocity      = Vector3.zero;
            }
        }
        UpdateVisuals(acceleration, Velocity);
        TryHideObjectsHiddingPlayer();
        base.Update();
    }
Example #5
0
 public Task SetPropAsync(PropSlot slot, byte drawable, byte texture)
 {
     return(SetPropAsync(slot, new PropData(drawable, texture)));
 }
Example #6
0
 public Task SetPropAsync(PropSlot slot, PropData data)
 {
     return(_plugin.Schedule(() => SetProp(slot, data)));
 }
Example #7
0
 public Task <PropData> GetPropAsync(PropSlot slot)
 {
     return(_plugin.Schedule(() => GetProp(slot)));
 }