Aetheria/Assets/Scripts/ServerShared/Behaviors/ProjectileWeapon.cs
Reinier Vens f643f6cc8a New Inventory System + Overhaul
Removed universal GameContext references
Refactored GameContext: It's now only responsible for item management. As such it's now called ItemManager
GlobalData is gone, relevant settings are distributed amongst specialized settings classes
Entities are no longer database entries, references to them are now direct - Zone is reponsible for storing them in ZonePacks
Controller subtypes are now generic classes, class argument is task type
Inventory is now a 2D grid instead of a list
Entity temperature is now a 2D grid instead of a number
Item sizes are now arbitrary shapes instead of a number
Hardpoints are now arbitrary shapes instead
Equipped items have their own temperatures
Map view now displays sunlight colors
Integrated Allegorithmic Substance Plugin
Imported Djinni ship and assigned Substance materials
Removed Node Editor framework (might come back later but needs work to integrate with behavior system)
2020-12-10 23:20:38 +00:00

63 lines
No EOL
2.4 KiB
C#

using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class ProjectileWeaponData : WeaponData
{
[InspectablePrefab, JsonProperty("bullet"), Key(6)]
public string BulletPrefab;
[InspectableField, JsonProperty("spread"), Key(7)]
public PerformanceStat Spread = new PerformanceStat();
[InspectableField, JsonProperty("bulletInherit"), Key(8)]
public float Inherit;
[InspectableField, JsonProperty("bulletVelocity"), Key(9)]
public PerformanceStat Velocity = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
{
return new ProjectileWeapon(context, this, entity, item);
}
}
public class ProjectileWeapon : IBehavior
{
private ProjectileWeaponData _data;
private Entity Entity { get; }
private EquippedItem Item { get; }
private ItemManager Context { get; }
public BehaviorData Data => _data;
public ProjectileWeapon(ItemManager context, ProjectileWeaponData c, Entity entity, EquippedItem item)
{
Context = context;
_data = c;
Entity = entity;
Item = item;
}
// private void Fire()
// {
// Hardpoint.Temperature += _projectileWeapon.Heat.Evaluate(Hardpoint) / Hardpoint.HeatCapacity;
// var inst = GameObject.Instantiate(_projectileWeapon.BulletPrefab).transform;
// Physics.IgnoreCollision(Hardpoint.Ship.Ship.GetComponent<Collider>(), inst.GetComponent<Collider>());
// var bullet = inst.GetComponent<Bullet>();
// bullet.Target = Hardpoint.Ship.Ship.Target;
// bullet.Source = Hardpoint.Ship.Ship.Hitpoints;
// bullet.Lifetime = _projectileWeapon.Range.Evaluate(Hardpoint) / _projectileWeapon.Velocity.Evaluate(Hardpoint);
// bullet.Damage = _projectileWeapon.Damage.Evaluate(Hardpoint);
// inst.position = Hardpoint.Proxy.position;
// inst.rotation = Hardpoint.Proxy.rotation;
// inst.GetComponent<Rigidbody>().velocity = _projectileWeapon.Velocity.Evaluate(Hardpoint) * Vector3.RotateTowards(-inst.forward, Hardpoint.Ship.Ship.Direction, _projectileWeapon.Deflection * Mathf.Deg2Rad, 1);
// Hardpoint.Ship.Ship.AudioSource.PlayOneShot(_projectileWeapon.Sounds.RandomElement());
// Debug.Log($"Firing bullet {b}");
// }
public bool Update(float delta)
{
return true;
}
}