Skip to content

Commit

Permalink
Implement projectile scale
Browse files Browse the repository at this point in the history
  • Loading branch information
toberge committed Jul 3, 2024
1 parent c4a447f commit bcf61af
Show file tree
Hide file tree
Showing 11 changed files with 2,045 additions and 83 deletions.
11 changes: 8 additions & 3 deletions Assets/LazurController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void RpcFireProjectile(Vector3 output, Vector3 direction)
direction = direction,
maxDistance = MaxDistance,
initializationTime = Time.fixedTime,
size = stats.ProjectileSize
size = stats.ProjectileSize * stats.ProjectileScale
};
projectile.additionalProperties.Clear();

Expand All @@ -105,14 +105,16 @@ private void RpcFireProjectile(Vector3 output, Vector3 direction)
lastCollider = collider;
HitboxController hitbox = collider.GetComponent<HitboxController>();

projectile.position = rayCasts[0].point;
projectile.position += projectile.direction * rayCasts[0].distance;

OnRicochet?.Invoke(rayCasts[0], ref projectile);
if (hitbox != null)
OnHitboxCollision?.Invoke(hitbox, ref projectile);
OnColliderHit?.Invoke(rayCasts[0], ref projectile);

projectile.distanceTraveled += rayCasts[0].distance;
projectile.direction = Vector3.Reflect(projectile.direction, rayCasts[0].normal);

projectile.distanceTraveled += rayCasts[0].distance;
}
else
{
Expand All @@ -136,12 +138,15 @@ private void RpcFireProjectile(Vector3 output, Vector3 direction)

protected override void OnInitialize(GunStats gunstats)
{
Vfx.SetFloat("Size", gunstats.ProjectileScale);
animator.OnInitialize(gunstats);
}

protected override void OnReload(GunStats stats)
{
animator.OnReload(stats);
}

public override void InitializeProjectile(GunStats stats, uint shotID)
{
currentShotID = shotID;
Expand Down
30 changes: 16 additions & 14 deletions Assets/Prefabs/GunParts/EnlargerExtension.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ GameObject:
m_Component:
- component: {fileID: 8196151136836888530}
- component: {fileID: 7575752308601990708}
- component: {fileID: -1314935375335004500}
m_Layer: 0
m_Name: EnlargerExtension
m_TagString: Untagged
Expand Down Expand Up @@ -118,23 +117,26 @@ MonoBehaviour:
addition: 0.5
multiplier: 0
exponential: 1
- name: ProjectileScale
addition: 0
multiplier: 0
exponential: 3
- name: ProjectileDamage
addition: 0
multiplier: 1
exponential: 1
- name: ProjectileSpeed
addition: 0
multiplier: 0
exponential: 0.5
- name: FireRate
addition: 0
multiplier: 0
exponential: 0.7
outputs:
- {fileID: 932626616956480431}
midpoint: {fileID: 5729402012261899082}
model: {fileID: 993201347869452232}
--- !u!114 &-1314935375335004500
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8350213044137146345}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 586f8df323151294a9220b1f0d464466, type: 3}
m_Name:
m_EditorClassIdentifier:
multiplier: 10
--- !u!1001 &74844362063714969
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
13 changes: 0 additions & 13 deletions Assets/Prefabs/GunParts/LazurBarrel.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ GameObject:
m_Component:
- component: {fileID: 6030259934304341444}
- component: {fileID: 5695477544615188222}
- component: {fileID: 2680724073785080762}
- component: {fileID: 8865490531545464824}
- component: {fileID: 4273715955371138616}
- component: {fileID: 4536155953706137537}
Expand Down Expand Up @@ -583,18 +582,6 @@ MonoBehaviour:
attachmentPoints:
- {fileID: 2021858193588301184}
muzzleFlash: {fileID: 1933672864586849248}
--- !u!114 &2680724073785080762
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1569365569997936042}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c2bb47b3ca3e5854f9029b0888d83a3e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &8865490531545464824
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scenes/Menu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 785370674}
m_IndirectSpecularColor: {r: 0.062317036, g: 0.21927114, b: 0.4949812, a: 1}
m_IndirectSpecularColor: {r: 0.062406372, g: 0.21927595, b: 0.49484292, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ protected override void Awake()
positionActiveBuffer.Initialize(maxProjectiles);
vfx.SetGraphicsBuffer("Positions", positionActiveBuffer.Buffer);
vfx.SetInt("MaxParticleCount", maxProjectiles);
vfx.SetFloat("Size", visualSize);
vfx.SendEvent(VisualEffectAsset.PlayEventID);

if (!gunController || !gunController.Player)
return;
Expand All @@ -76,6 +74,8 @@ protected override void Awake()

protected override void OnInitialize(GunStats gunstats)
{
vfx.SetFloat("Size", visualSize * gunstats.ProjectileScale);
vfx.SendEvent(VisualEffectAsset.PlayEventID);
animator.OnInitialize(gunstats);
}

Expand Down Expand Up @@ -126,7 +126,7 @@ private void RpcFireProjectile(Vector3 output, Vector3 direction, Quaternion rot
loadedProjectile.position = output;
loadedProjectile.direction = direction;
loadedProjectile.rotation = rotation;
loadedProjectile.size = size;
loadedProjectile.size = size * stats.ProjectileScale;
loadedProjectile.additionalProperties["lastCollider"] = null;

projectiles[currentStateIndex] = loadedProjectile;
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Augment/BulletModifiers/ExplosionModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public void Detach(ProjectileController projectile)
private void Explode(RaycastHit other, ref ProjectileState state)
{
var instance = Instantiate(explosion, state.position, Quaternion.identity);
instance.Radius *= projectile.stats.ProjectileScale;
instance.Init();

var targets = instance.Explode(player);

// Trigger on hit, excluding this effect and using the scaled damage from the explosion
Expand Down
26 changes: 0 additions & 26 deletions Assets/Scripts/Augment/BulletModifiers/ProjectileEnlarger.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Scripts/Augment/BulletModifiers/ProjectileEnlarger.cs.meta

This file was deleted.

10 changes: 9 additions & 1 deletion Assets/Scripts/ExplosionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ public class ExplosionController : MonoBehaviour
[SerializeField] private AnimationCurve damageCurve;

[SerializeField] private float radius;
public float Radius => radius;
public float Radius
{
get => radius;
set
{
radius = value;
}
}

[SerializeField] private float knockbackForce = 2000;

Expand All @@ -35,6 +42,7 @@ private void Start()
public void Init()
{
visualEffect = GetComponent<VisualEffect>();
visualEffect.SetFloat("Size", radius / 6f);
visualEffect.enabled = false;
audioSource = GetComponent<AudioSource>();
}
Expand Down
Loading

0 comments on commit bcf61af

Please sign in to comment.