Interface IMyGunObject<T>
This can be hand held weapon (including welders and drills) as well as weapons on ship (including ship drills).
Namespace: VRage.Game.ModAPI
Assembly: VRage.Game.dll
Syntax
public interface IMyGunObject<out T>
where T : MyDeviceBase
Type Parameters
Name | Description |
---|---|
T |
Properties
BackkickForcePerSecond
Gets force in Newtons.
Declaration
float BackkickForcePerSecond { get; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
Not related to modders. Modders should return zero
DefinitionId
Gets block definition id
Declaration
MyDefinitionId DefinitionId { get; }
Property Value
Type | Description |
---|---|
MyDefinitionId |
EnabledInWorldRules
Gets if enabled by world rules (WeaponsEnabled)
Declaration
bool EnabledInWorldRules { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
GunBase
Gets class that extends from MyDeviceBase. It could be MyToolBase, MyGunBase or even custom logic. Keep in mind, that some functions works differently for tools, gun or custom logic.
Declaration
T GunBase { get; }
Property Value
Type | Description |
---|---|
T |
IsShooting
Should return true when the weapon is shooting projectiles and other classes should react accordingly (i.e.apply backkick force etc.)
Declaration
bool IsShooting { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSkinnable
Gets if character weapon/tool is skinnable
Declaration
bool IsSkinnable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsTargetLockingCapable
Gets if device can lock targets. (Warfare 2 feature)
Declaration
bool IsTargetLockingCapable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaximumShotLength
Zero means that the gun should not update shoot direction at all
Declaration
float MaximumShotLength { get; }
Property Value
Type | Description |
---|---|
System.Single | Minimal time interval in milliseconds between two direction updates |
NeedsShootDirectionWhileAiming
Whether this gun needs the shoot direction at all times. Guns that do not will have their direction
Declaration
bool NeedsShootDirectionWhileAiming { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ShakeAmount
Gets shake amount of grid, when
Declaration
float ShakeAmount { get; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
Not related to modders. Modders should return zero
ShootDirectionUpdateTime
Zero means that the gun should not update shoot direction at all
Declaration
int ShootDirectionUpdateTime { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Minimal time interval in milliseconds between two direction updates |
Methods
BeginFailReaction(MyShootActionEnum, MyGunStatusEnum)
Perform a fail reaction to begin shoot that is shown on all clients (e.g. fail sound, etc.)
Declaration
void BeginFailReaction(MyShootActionEnum action, MyGunStatusEnum status)
Parameters
Type | Name | Description |
---|---|---|
MyShootActionEnum | action | The shooting action, whose begin shoot failed |
MyGunStatusEnum | status | Why the begin shoot failed |
BeginFailReactionLocal(MyShootActionEnum, MyGunStatusEnum)
Perform a fail reaction to begin shoot that is shown only on client that controls character or ship, that has this device
Declaration
void BeginFailReactionLocal(MyShootActionEnum action, MyGunStatusEnum status)
Parameters
Type | Name | Description |
---|---|---|
MyShootActionEnum | action | The shooting action, whose begin shoot failed |
MyGunStatusEnum | status | Why the begin shoot failed |
BeginShoot(MyShootActionEnum)
Called when device start shooting
Declaration
void BeginShoot(MyShootActionEnum action)
Parameters
Type | Name | Description |
---|---|---|
MyShootActionEnum | action | Type if shooting |
CanShoot(MyShootActionEnum, Int64, out MyGunStatusEnum)
Should return true if and only if the gun would be able to shoot using the given shoot action. This method should not do any side-effects such as play sounds or create particle FX.
Declaration
bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status)
Parameters
Type | Name | Description |
---|---|---|
MyShootActionEnum | action | The shooting action to test |
System.Int64 | shooter | Id of shooting player |
MyGunStatusEnum | status | Detailed status of the gun, telling why the gun couldn't perform the given shoot action |
Returns
Type | Description |
---|---|
System.Boolean |
DirectionToTarget(Vector3D)
Gets direction vector (normalized) between device and provided target vector. Used for character devices
Declaration
Vector3 DirectionToTarget(Vector3D target)
Parameters
Type | Name | Description |
---|---|---|
Vector3D | target | Target vector in world coordinates |
Returns
Type | Description |
---|---|
Vector3 | Normalized direction between device position and provided vector |
DrawHud(IMyCameraController, Int64)
When device is selected, this method is called in Draw thread. Example: welder shows info about what block it welds.
Declaration
void DrawHud(IMyCameraController camera, long playerId)
Parameters
Type | Name | Description |
---|---|---|
IMyCameraController | camera | Current camera |
System.Int64 | playerId | Player that controls device |
DrawHud(IMyCameraController, Int64, Boolean)
When device is selected, this method is called in Draw thread.
Declaration
void DrawHud(IMyCameraController camera, long playerId, bool fullUpdate)
Parameters
Type | Name | Description |
---|---|---|
IMyCameraController | camera | Current camera |
System.Int64 | playerId | Player that controls device |
System.Boolean | fullUpdate | True when should update internal cache |
EndShoot(MyShootActionEnum)
Called when device stop shooting
Declaration
void EndShoot(MyShootActionEnum action)
Parameters
Type | Name | Description |
---|---|---|
MyShootActionEnum | action | Type if shooting |
GetAmmunitionAmount()
Gets current ammunition left before reloading
Declaration
int GetAmmunitionAmount()
Returns
Type | Description |
---|---|
System.Int32 | Ammunition amount |
GetMagazineAmount()
Gets magazines amount
Declaration
int GetMagazineAmount()
Returns
Type | Description |
---|---|
System.Int32 | Magazines amount |
GetMuzzlePosition()
Gets muzzle world position
Declaration
Vector3D GetMuzzlePosition()
Returns
Type | Description |
---|---|
Vector3D | Position of muzzle in world coordinates |
GetShootDirection()
Direction where gun is shooting
Declaration
Vector3 GetShootDirection()
Returns
Type | Description |
---|---|
Vector3 |
GetTotalAmmunitionAmount()
Gets total ammunition count: GetAmmunitionAmount() + GetMagazineAmount() * Magazine.Capacity
Declaration
int GetTotalAmmunitionAmount()
Returns
Type | Description |
---|---|
System.Int32 | Total ammunition amount |
IsToolbarUsable()
Returns true if can be used with LMB/RMB like drills
Declaration
bool IsToolbarUsable()
Returns
Type | Description |
---|---|
System.Boolean | True if can be used with LMB/RMB like drills |
OnControlAcquired(IMyCharacter)
Called when control over device acquired
Declaration
void OnControlAcquired(IMyCharacter owner)
Parameters
Type | Name | Description |
---|---|---|
IMyCharacter | owner | Controlling character |
OnControlReleased()
Called when control over device lost
Declaration
void OnControlReleased()
Shoot(MyShootActionEnum, Vector3, Nullable<Vector3D>, String)
Perform the shoot action according to the action parameter. This method should only be called when CanShoot returns true for the given action!
Declaration
void Shoot(MyShootActionEnum action, Vector3 direction, Nullable<Vector3D> overrideWeaponPos, string gunAction = null)
Parameters
Type | Name | Description |
---|---|---|
MyShootActionEnum | action | The shooting action to perform |
Vector3 | direction | The prefered direction of shooting |
System.Nullable<Vector3D> | overrideWeaponPos | Changes weapon position, world space. |
System.String | gunAction | Always null |
ShootFailReactionLocal(MyShootActionEnum, MyGunStatusEnum)
Perform a fail reaction to during shooting that is shown only on client that controls character or ship, that has this device
Declaration
void ShootFailReactionLocal(MyShootActionEnum action, MyGunStatusEnum status)
Parameters
Type | Name | Description |
---|---|---|
MyShootActionEnum | action | The shooting action, whose shooting failed |
MyGunStatusEnum | status | Why the shooting failed |
SupressShootAnimation()
When too close to object and hands shouldn't be extended
Declaration
bool SupressShootAnimation()
Returns
Type | Description |
---|---|
System.Boolean | True if too close |
UpdateSoundEmitter()
If device has sound emmiter(s), it(they) should be updated
Declaration
void UpdateSoundEmitter()