Ammo Consumption Hotfix
Weapons weren't firing for some reason
This commit is contained in:
parent
47189c8a7e
commit
64a8589b7f
6 changed files with 43 additions and 43 deletions
|
|
@ -86,7 +86,7 @@ Material:
|
|||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Scale: 4.910362
|
||||
- _Scale: 1.33001
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ PrefabInstance:
|
|||
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 60.98
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
|
||||
type: 3}
|
||||
|
|
@ -1302,8 +1302,8 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 741153267}
|
||||
m_LocalRotation: {x: 0.015506903, y: 0.9502416, z: -0.30741313, w: 0.047933225}
|
||||
m_LocalPosition: {x: -117.51999, y: -77.08743, z: 149.09026}
|
||||
m_LocalRotation: {x: 0.0155069195, y: 0.9502416, z: -0.30741316, w: 0.047933277}
|
||||
m_LocalPosition: {x: -117.52002, y: -77.087425, z: 149.09026}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 412917866}
|
||||
|
|
@ -1773,8 +1773,8 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 965376321}
|
||||
m_LocalRotation: {x: 0.015506903, y: 0.9502416, z: -0.30741313, w: 0.047933225}
|
||||
m_LocalPosition: {x: -117.51999, y: -77.08743, z: 149.09026}
|
||||
m_LocalRotation: {x: 0.0155069195, y: 0.9502416, z: -0.30741316, w: 0.047933277}
|
||||
m_LocalPosition: {x: -117.52002, y: -77.087425, z: 149.09026}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
|
@ -2722,7 +2722,7 @@ PrefabInstance:
|
|||
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 55.675
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
|
||||
type: 3}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
|
||||
public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
if (target == null) return;
|
||||
if(weapon.Data is LauncherData launcher)
|
||||
{
|
||||
if (target == null) return;
|
||||
var p = ProjectilePrototype.Instantiate<GuidedProjectile>();
|
||||
p.Source = source.transform;
|
||||
p.SourceEntity = source.Entity;
|
||||
|
|
@ -38,7 +38,6 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
var p = ProjectilePrototype.Instantiate<GuidedProjectile>();
|
||||
p.Source = source.transform;
|
||||
p.SourceEntity = source.Entity;
|
||||
p.Target = target.transform;
|
||||
p.Frequency = guidance.DodgeFrequency;
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
|
|
|
|||
|
|
@ -74,13 +74,14 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
public InstantWeapon(ItemManager context, InstantWeaponData data, Entity entity, EquippedItem item) : base(context,data,entity,item)
|
||||
{
|
||||
_data = data;
|
||||
_ammo = data.MagazineSize;
|
||||
}
|
||||
|
||||
protected void Trigger()
|
||||
{
|
||||
// If 1 ammo is consumed per burst, perform ammo consumption here
|
||||
// If 1 ammo is consumed per burst, perform ammo and energy consumption here
|
||||
// UseAmmo returns false when triggering reload; cancel firing if that is the case
|
||||
if(_data.SingleAmmoBurst && !UseAmmo()) return;
|
||||
if(_data.SingleAmmoBurst && (!Entity.TryConsumeEnergy(Energy) || !UseAmmo())) return;
|
||||
|
||||
_burstRemaining = (int) BurstCount;
|
||||
_burstInterval = BurstTime / _burstRemaining;
|
||||
|
|
@ -105,33 +106,34 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
{
|
||||
if (_data.MagazineSize <= 1) return true;
|
||||
|
||||
if (_ammo > 0) _ammo--;
|
||||
else
|
||||
if (_ammo > 0)
|
||||
{
|
||||
var hasAmmo = true;
|
||||
if (_data.AmmoType != Guid.Empty)
|
||||
{
|
||||
var cargo = Entity.FindItemInCargo(_data.AmmoType);
|
||||
if (cargo != null)
|
||||
{
|
||||
var item = cargo.ItemsOfType[_data.AmmoType][0];
|
||||
if (item is SimpleCommodity simpleCommodity)
|
||||
cargo.Remove(simpleCommodity, 1);
|
||||
}
|
||||
else hasAmmo = false;
|
||||
}
|
||||
if(hasAmmo)
|
||||
{
|
||||
OnReloadBegin?.Invoke();
|
||||
_cooldown = 1;
|
||||
_coolingDown = true;
|
||||
_firing = false;
|
||||
}
|
||||
_burstRemaining = 0;
|
||||
return false;
|
||||
_ammo--;
|
||||
return true;
|
||||
}
|
||||
|
||||
var hasAmmo = true;
|
||||
if (_data.AmmoType != Guid.Empty)
|
||||
{
|
||||
var cargo = Entity.FindItemInCargo(_data.AmmoType);
|
||||
if (cargo != null)
|
||||
{
|
||||
var item = cargo.ItemsOfType[_data.AmmoType][0];
|
||||
if (item is SimpleCommodity simpleCommodity)
|
||||
cargo.Remove(simpleCommodity, 1);
|
||||
}
|
||||
else hasAmmo = false;
|
||||
}
|
||||
if(hasAmmo)
|
||||
{
|
||||
OnReloadBegin?.Invoke();
|
||||
_cooldown = 1;
|
||||
_coolingDown = true;
|
||||
_firing = false;
|
||||
}
|
||||
_burstRemaining = 0;
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Execute(float delta)
|
||||
|
|
@ -139,11 +141,11 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
base.Execute(delta);
|
||||
if (_coolingDown)
|
||||
{
|
||||
_cooldown -= delta / (_data.AmmoType != Guid.Empty && _ammo == 0 ? _data.ReloadTime : Cooldown);
|
||||
_cooldown -= delta / (_data.MagazineSize > 0 && _ammo == 0 ? _data.ReloadTime : Cooldown);
|
||||
if (_cooldown < 0)
|
||||
{
|
||||
_coolingDown = false;
|
||||
if (_data.AmmoType != Guid.Empty && _ammo == 0)
|
||||
if (_data.MagazineSize > 0 && _ammo == 0)
|
||||
{
|
||||
_ammo = _data.MagazineSize;
|
||||
OnReloadComplete?.Invoke();
|
||||
|
|
@ -156,14 +158,13 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
_burstTimer += delta;
|
||||
while (_burstRemaining > 0 && _burstTimer > 0)
|
||||
{
|
||||
if (!Entity.TryConsumeEnergy(Energy))
|
||||
// If multiple ammo is consumed per burst, perform ammo and energy consumption here
|
||||
// UseAmmo returns false when triggering reload; cancel firing if that is the case
|
||||
if (!_data.SingleAmmoBurst && (!Entity.TryConsumeEnergy(Energy) || !UseAmmo()))
|
||||
{
|
||||
_burstRemaining = 0;
|
||||
return false;
|
||||
}
|
||||
// If 1 ammo is consumed per shot in the burst, perform ammo consumption here
|
||||
// UseAmmo returns false when triggering reload; cancel firing if that is the case
|
||||
if (!_data.SingleAmmoBurst && !UseAmmo()) return false;
|
||||
|
||||
_burstRemaining--;
|
||||
_burstTimer -= _burstInterval;
|
||||
|
|
|
|||
BIN
GameData/AetherDB.msgpack
(Stored with Git LFS)
BIN
GameData/AetherDB.msgpack
(Stored with Git LFS)
Binary file not shown.
BIN
GameData/PlayerSettings.msgpack
(Stored with Git LFS)
BIN
GameData/PlayerSettings.msgpack
(Stored with Git LFS)
Binary file not shown.
Loading…
Reference in a new issue