/// <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)); }
/// <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; }
/// <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; }
/// <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)); }
/// <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)) { }
/// <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)); }
/// <summary> /// Set the ped to target a specific physical element /// </summary> public bool AimAt(PhysicalElement targetElement) { return(AimAt(targetElement.Position)); }
/// <summary> /// Attach this attachable to a toAttachable without any offset /// </summary> public void AttachTo(PhysicalElement toElement) { AttachTo(toElement, Matrix4x4.Identity); }
/// <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)); }
/// <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); }
/// <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)) { }
/// <summary> /// Sets the syncer of this element /// </summary> public static bool SetSyncer(this PhysicalElement source, Player target) { return(MtaServer.SetElementSyncer(source.MTAElement, target.MTAElement)); }
/// <summary> /// Gets the syncer of this element /// </summary> public static Player GetSyncer(this PhysicalElement source) { return((Player)ElementManager.Instance.GetElement(MtaServer.GetElementSyncer(source.MTAElement))); }
/// <summary> /// Gets this element's zone name /// </summary> public static string GetZoneName(this PhysicalElement source, bool citiesOnly = false) { return(MtaServer.GetElementZoneName(source.MTAElement, citiesOnly)); }
internal OnContactEventArgs(MtaElement previousElement, MtaElement newElement) { PreviousElement = ElementManager.Instance.GetElement <PhysicalElement>(previousElement); NewElement = ElementManager.Instance.GetElement <PhysicalElement>(newElement); }
internal OnTargetEventArgs(MtaElement target) { Target = ElementManager.Instance.GetElement <PhysicalElement>(target); }
/// <summary> /// Checks whether a certain element is inside a collision shape /// </summary> public bool IsElementWithin(PhysicalElement element) { return(MtaShared.IsElementWithinColShape(this.element, element.MTAElement)); }
/// <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) { }
/// <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; }
/// <summary> /// Create a new projectile /// </summary> public Projectile(PhysicalElement creator, ProjectileType projectile, Vector3 startPos, float force = 1.0f) : this(creator, projectile, startPos, force, null) { }
/// <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)); }
/// <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(); }
/// <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); }
protected virtual void OnDetach() { toAttached = null; }
/// <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)); }
/// <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); }
internal OnDamageEventArgs(MtaElement target) { Attacker = ElementManager.Instance.GetElement <PhysicalElement>(target); }
/// <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); }
/// <summary> /// Creates a red standard blip attached to an element in the world /// </summary> public Blip(PhysicalElement physicalElement) : this(physicalElement, 0, Color.Red) { }
/// <summary> /// Attach this attachable to a Physical Element without any offset /// </summary> public void AttachTo(PhysicalElement toElement) { AttachTo(toElement, Vector3.Zero); }