예제 #1
0
        /// <summary>
        /// This function returns the minimum and maximum relative coordinates of an element's bounding box.
        /// </summary>
        public static Tuple <Vector3, Vector3> GetBoundingBox(this PhysicalElement e)
        {
            Tuple <float, float, float, float, float, float> result = MtaClient.GetElementBoundingBox(e.MTAElement);
            Vector3 min = new Vector3(result.Item1, result.Item2, result.Item3);
            Vector3 max = new Vector3(result.Item4, result.Item5, result.Item6);

            return(new Tuple <Vector3, Vector3>(min, max));
        }
예제 #2
0
 /// <summary>
 /// Create a SightLine attached to a certain object
 /// </summary>
 public SightLine(PhysicalElement attachedTo, Vector3 relativeEndPos, Matrix4x4 offset, bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true, bool checkWorldObjects = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, bool includeWorldModelInformation = false, bool includeCarTyreHits = true, PhysicalElement ignoredElement = null) : base(attachedTo, relativeEndPos, offset)
 {
     CheckBuildings               = checkBuildings;
     CheckVehicles                = checkVehicles;
     CheckPeds                    = checkPeds;
     CheckWorldObjects            = checkWorldObjects;
     SeeThroughStuff              = seeThroughStuff;
     IgnoreSomeObjectsForCamera   = ignoreSomeObjectsForCamera;
     ShootThroughStuff            = shootThroughStuff;
     IncludeWorldModelInformation = includeWorldModelInformation;
     IncludeCarTyreHits           = includeCarTyreHits;
     IgnoredElement               = ignoredElement;
 }
예제 #3
0
 /// <summary>
 /// Creates a SightLine from a start and an end position
 /// </summary>
 public SightLine(Vector3 startPos, Vector3 endPos, bool checkBuildings = true, bool checkVehicles = true, bool checkPeds = true, bool checkWorldObjects = true, bool seeThroughStuff = false, bool ignoreSomeObjectsForCamera = false, bool shootThroughStuff = false, bool includeWorldModelInformation = false, bool includeCarTyreHits = true, PhysicalElement ignoredElement = null) : base(startPos, endPos)
 {
     CheckBuildings               = checkBuildings;
     CheckVehicles                = checkVehicles;
     CheckPeds                    = checkPeds;
     CheckWorldObjects            = checkWorldObjects;
     SeeThroughStuff              = seeThroughStuff;
     IgnoreSomeObjectsForCamera   = ignoreSomeObjectsForCamera;
     ShootThroughStuff            = shootThroughStuff;
     IncludeWorldModelInformation = includeWorldModelInformation;
     IncludeCarTyreHits           = includeCarTyreHits;
     IgnoredElement               = ignoredElement;
 }
예제 #4
0
 /// <summary>
 /// This function checks whether this element is currently streamed in (not virtualized) and are actual GTA objects in the world.
 /// </summary>
 public static bool IsStreamedIn(this PhysicalElement e)
 {
     return(MtaClient.IsElementStreamedIn(e.MTAElement));
 }
예제 #5
0
 /// <summary>
 /// Creates a blip attached to an element in the world
 /// </summary>
 public Blip(PhysicalElement physicalElement, BlipType icon, Color color, int size = 2, int ordering = 0, float visibleDistance = 16383.0f, Element visibleTo = null)
     : this(MtaServer.CreateBlipAttachedTo(physicalElement.MTAElement, (int)icon, size, color.R, color.G, color.B, color.A, ordering, visibleDistance, visibleTo?.MTAElement))
 {
 }
예제 #6
0
 /// <summary>
 /// Have the weapon target the center of any element (vehicle, ped, player, world object)
 /// </summary>
 public bool SetTarget(PhysicalElement physicalElement)
 {
     return(MtaClient.SetWeaponTarget(element, physicalElement.MTAElement, 255));
 }
예제 #7
0
 /// <summary>
 /// Set the ped to target a specific physical element
 /// </summary>
 public bool AimAt(PhysicalElement targetElement)
 {
     return(AimAt(targetElement.Position));
 }
예제 #8
0
 /// <summary>
 /// Attach this attachable to a toAttachable without any offset
 /// </summary>
 public void AttachTo(PhysicalElement toElement)
 {
     AttachTo(toElement, Matrix4x4.Identity);
 }
예제 #9
0
 /// <summary>
 /// Attach this attachable to a toAttachable with 2 vectors describing a position offset and a rotation offset
 /// </summary>
 public void AttachTo(PhysicalElement toElement, Vector3 positionOffset, Vector3 rotationOffset)
 {
     AttachTo(toElement, positionOffset, NumericHelper.EulerToQuaternion(rotationOffset));
 }
예제 #10
0
 /// <summary>
 /// Create a searchlight attached to an element
 /// </summary>
 public SearchLight(PhysicalElement attachTo, Vector3 relativeEnd, Matrix4x4 offset, float startRadius, float endRadius, bool renderSpot = true) : this(Vector3.Zero, relativeEnd, startRadius, endRadius, renderSpot)
 {
     AttachTo(attachTo, offset);
 }
예제 #11
0
 /// <summary>
 /// Create a new projectile with all the parameters
 /// </summary>
 public Projectile(PhysicalElement creator, ProjectileType projectile, Vector3 startPos, float force, PhysicalElement target, Vector3 rotation, Vector3 velocity, int model = -1)
     : this(MtaClient.CreateProjectile(creator.MTAElement, (int)projectile, startPos.X, startPos.Y, startPos.Z, force, target.MTAElement, rotation.X, rotation.Y, rotation.Z, velocity.X, velocity.Y, velocity.Z, -1))
 {
 }
예제 #12
0
 /// <summary>
 /// Sets the syncer of this element
 /// </summary>
 public static bool SetSyncer(this PhysicalElement source, Player target)
 {
     return(MtaServer.SetElementSyncer(source.MTAElement, target.MTAElement));
 }
예제 #13
0
 /// <summary>
 /// Gets the syncer of this element
 /// </summary>
 public static Player GetSyncer(this PhysicalElement source)
 {
     return((Player)ElementManager.Instance.GetElement(MtaServer.GetElementSyncer(source.MTAElement)));
 }
예제 #14
0
 /// <summary>
 /// Gets this element's zone name
 /// </summary>
 public static string GetZoneName(this PhysicalElement source, bool citiesOnly = false)
 {
     return(MtaServer.GetElementZoneName(source.MTAElement, citiesOnly));
 }
예제 #15
0
 internal OnContactEventArgs(MtaElement previousElement, MtaElement newElement)
 {
     PreviousElement = ElementManager.Instance.GetElement <PhysicalElement>(previousElement);
     NewElement      = ElementManager.Instance.GetElement <PhysicalElement>(newElement);
 }
예제 #16
0
 internal OnTargetEventArgs(MtaElement target)
 {
     Target = ElementManager.Instance.GetElement <PhysicalElement>(target);
 }
예제 #17
0
 /// <summary>
 /// Checks whether a certain element is inside a collision shape
 /// </summary>
 public bool IsElementWithin(PhysicalElement element)
 {
     return(MtaShared.IsElementWithinColShape(this.element, element.MTAElement));
 }
예제 #18
0
 /// <summary>
 /// Create a new projectile
 /// </summary>
 public Projectile(PhysicalElement creator, ProjectileType projectile, Vector3 startPos, float force, PhysicalElement target)
     : this(creator, projectile, startPos, force, target, Vector3.Zero)
 {
 }
예제 #19
0
 /// <summary>
 /// Attach this attachable to a toAttachable using a matrix to describe the positional and rotational offset
 /// </summary>
 public void AttachTo(PhysicalElement toElement, Matrix4x4 offsetMatrix)
 {
     toAttached = toElement;
     Offset     = offsetMatrix;
     Game.GameClient.OnUpdate += Update;
 }
예제 #20
0
 /// <summary>
 /// Create a new projectile
 /// </summary>
 public Projectile(PhysicalElement creator, ProjectileType projectile, Vector3 startPos, float force = 1.0f)
     : this(creator, projectile, startPos, force, null)
 {
 }
예제 #21
0
 /// <summary>
 /// Attach this attachable to a toAttachable with a vector describing the position offset and a quaternion describing the rotation offset
 /// </summary>
 public void AttachTo(PhysicalElement toElement, Vector3 positionOffset, Quaternion rotationOffset)
 {
     AttachTo(toElement, Matrix4x4.Transform(Matrix4x4.CreateTranslation(positionOffset), rotationOffset));
 }
예제 #22
0
 /// <summary>
 /// Attach this attachable to a toAttachable using a matrix to describe the positional and rotational offset
 /// </summary>
 public void AttachTo(PhysicalElement toElement, Matrix4x4 offsetMatrix)
 {
     toAttached = toElement;
     Offset     = offsetMatrix;
     OnAttach();
 }
예제 #23
0
 /// <summary>
 /// Make this ped face a specific physical element
 /// </summary>
 /// <param name="target">The element to face</param>
 public override void FaceElement(PhysicalElement target)
 {
     Rotation = NumericHelper.RotationBetweenPositions(target.Position, Position);
 }
예제 #24
0
 protected virtual void OnDetach()
 {
     toAttached = null;
 }
예제 #25
0
 /// <summary>
 /// Have the ped look at a specific physical element
 /// </summary>
 public bool LookAt(PhysicalElement lookAt, int time = 3000, int blend = 1000)
 {
     return(MtaClient.SetPedLookAt(element, 0, 0, 0, time, blend, lookAt.MTAElement));
 }
예제 #26
0
 /// <summary>
 /// Create a 3D line attached to a certain object
 /// </summary>
 public Dx3DLine(PhysicalElement attachedTo, Vector3 relativeEndPos, Matrix4x4 offset) : this(Vector3.Zero, relativeEndPos)
 {
     AttachTo(attachedTo, offset);
 }
예제 #27
0
 internal OnDamageEventArgs(MtaElement target)
 {
     Attacker = ElementManager.Instance.GetElement <PhysicalElement>(target);
 }
예제 #28
0
 /// <summary>
 /// Attach this attachable to a Physical Element with an offset
 /// </summary>
 public void AttachTo(PhysicalElement toElement, Vector3 offset)
 {
     MtaShared.AttachElements(element, toElement.MTAElement, offset.X, offset.Y, offset.Z, 0, 0, 0);
 }
예제 #29
0
 /// <summary>
 /// Creates a red standard blip attached to an element in the world
 /// </summary>
 public Blip(PhysicalElement physicalElement)
     : this(physicalElement, 0, Color.Red)
 {
 }
예제 #30
0
 /// <summary>
 /// Attach this attachable to a Physical Element without any offset
 /// </summary>
 public void AttachTo(PhysicalElement toElement)
 {
     AttachTo(toElement, Vector3.Zero);
 }