First Flight
Added MPL license headers SectorRenderer renders entities in sector, manages particle systems for ship thrusters Thrusters apply torque based on orientation and position relative to ship center of mass GameManager controls the player ship's thrusters Player can dock with station if they are near
This commit is contained in:
parent
e3f3bd5de5
commit
c4be204cd0
172 changed files with 6753 additions and 779 deletions
|
|
@ -1,3 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
|
|
@ -14,6 +18,9 @@ public class ThrusterData : BehaviorData
|
|||
|
||||
[InspectableField, JsonProperty("heat"), Key(3)]
|
||||
public PerformanceStat Heat = new PerformanceStat();
|
||||
|
||||
[InspectablePrefab, JsonProperty("Particles"), Key(4)]
|
||||
public string ParticlesPrefab;
|
||||
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
{
|
||||
|
|
@ -28,6 +35,7 @@ public class Thruster : IAnalogBehavior
|
|||
public ItemManager Context { get; }
|
||||
|
||||
public float Thrust { get; private set; }
|
||||
public float Torque { get; }
|
||||
|
||||
public float Axis
|
||||
{
|
||||
|
|
@ -47,12 +55,19 @@ public class Thruster : IAnalogBehavior
|
|||
_data = data;
|
||||
Entity = entity;
|
||||
Item = item;
|
||||
var hullData = context.GetData(entity.Hull) as HullData;
|
||||
var hullCenter = hullData.Shape.CenterOfMass;
|
||||
var itemData = context.GetData(item.EquippableItem);
|
||||
var itemCenter = hullData.Shape.Inset(itemData.Shape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
||||
var toCenter = hullCenter - itemCenter;
|
||||
Torque = -dot(toCenter, float2(1, 0).Rotate(item.EquippableItem.Rotation));
|
||||
}
|
||||
|
||||
public bool Update(float delta)
|
||||
{
|
||||
Thrust = Context.Evaluate(_data.Thrust, Item.EquippableItem, Entity);
|
||||
Entity.Velocity += Entity.Direction * _input * Thrust / Entity.Mass * delta;
|
||||
Entity.Velocity -= Entity.Direction.Rotate(Item.EquippableItem.Rotation) * _input * Thrust / Entity.Mass * delta;
|
||||
Entity.Direction = mul(Entity.Direction, Unity.Mathematics.float2x2.Rotate(_input * Torque * Thrust / Entity.Mass / 100 * delta));
|
||||
Item.Temperature += (_input * Context.Evaluate(_data.Heat, Item.EquippableItem, Entity) * delta) / Context.GetThermalMass(Item.EquippableItem);
|
||||
Entity.VisibilitySources[this] = _input * Context.Evaluate(_data.Visibility, Item.EquippableItem, Entity);
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue