Finished Map Tab

This commit is contained in:
Reinier Vens 2020-12-18 13:48:03 +00:00
commit 615cc4e936
43 changed files with 8383 additions and 920 deletions

View file

@ -32,6 +32,7 @@ public class ActionGameManager : MonoBehaviour
private float _time;
private AetheriaInput _input;
private int _zoomLevelIndex;
public List<Ship> PlayerShips { get; } = new List<Ship>();
public DatabaseCache ItemData { get; private set; }
public ItemManager ItemManager { get; private set; }
@ -73,22 +74,27 @@ public class ActionGameManager : MonoBehaviour
SectorRenderer.MinimapDistance = Settings.MinimapZoomLevels[_zoomLevelIndex];
};
// _input.Global.MapToggle.performed += context =>
// {
// MapView.enabled = !MapView.enabled;
// GameplayUI.SetActive(!MapView.enabled);
// if (MapView.enabled)
// {
// MapView.BindInput(_input.UI);
// _input.Player.Disable();
// }
// else
// {
// _input.Player.Enable();
// SectorRenderer.ViewDistance = Settings.DefaultViewDistance;
// SectorRenderer.MinimapDistance = Settings.MinimapZoomLevels[_zoomLevelIndex];
// }
// };
_input.Global.MapToggle.performed += context =>
{
if (Menu.gameObject.activeSelf && Menu.CurrentTab == MenuTab.Map)
{
Menu.gameObject.SetActive(false);
return;
}
Menu.ShowTab(MenuTab.Map);
};
_input.Global.Inventory.performed += context =>
{
if (Menu.gameObject.activeSelf && Menu.CurrentTab == MenuTab.Inventory)
{
Menu.gameObject.SetActive(false);
return;
}
Menu.ShowTab(MenuTab.Inventory);
};
ConsoleController.AddCommand("editmode", _ => ToggleEditMode());
ConsoleController.AddCommand("savezone", args =>
@ -98,6 +104,20 @@ public class ActionGameManager : MonoBehaviour
SaveZone();
});
var stationType = ItemData.GetAll<HullData>().First(x=>x.HullType==HullType.Station);
var stationHull = ItemManager.CreateInstance(stationType, 0, 1) as EquippableItem;
var stationParent = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(2);
var parentOrbit = stationParent.Orbit.Data.ID;
var stationPos = Zone.GetOrbitPosition(parentOrbit) +
normalize(ItemManager.Random.NextFloat2() - float2(.5f, .5f)) * ItemManager.Random.NextFloat() * stationParent.GravityWellRadius.Value * .75f;
var stationOrbit = Zone.CreateOrbit(parentOrbit, stationPos);
var station = new OrbitalEntity(ItemManager, Zone, stationHull, stationOrbit.ID);
Zone.Entities.Add(station);
var hullType = ItemData.GetAll<HullData>().First(x=>x.HullType==HullType.Ship);
var shipHull = ItemManager.CreateInstance(hullType, 0, 1) as EquippableItem;
var ship = new Ship(ItemManager, Zone, shipHull);
// MapButton.onClick.AddListener(() =>
// {
// if (_currentMenuTabButton == MapPanel) return;
@ -106,9 +126,6 @@ public class ActionGameManager : MonoBehaviour
// _currentMenuTabButton = MapButton;
// });
//
// var hullType = ItemData.GetAll<HullData>().First(x=>x.HullType==HullType.Ship);
// var hull = ItemManager.CreateInstance(hullType, 0, 1) as EquippableItem;
// var entity = new Ship(ItemManager, Zone, hull);
//InventoryPanel.Display(ItemManager, entity);
}

View file

@ -799,6 +799,14 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
},
{
""name"": ""Inventory"",
""type"": ""Button"",
""id"": ""dafe13a7-da46-408e-853e-6954e37da5c8"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """"
}
],
""bindings"": [
@ -812,6 +820,17 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
""action"": ""Map Toggle"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""2eb827dd-4707-4648-b7e5-cf1fd8fa00da"",
""path"": ""<Keyboard>/#(I)"",
""interactions"": """",
""processors"": """",
""groups"": ""Keyboard&Mouse"",
""action"": ""Inventory"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
@ -901,6 +920,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
// Global
m_Global = asset.FindActionMap("Global", throwIfNotFound: true);
m_Global_MapToggle = m_Global.FindAction("Map Toggle", throwIfNotFound: true);
m_Global_Inventory = m_Global.FindAction("Inventory", throwIfNotFound: true);
}
public void Dispose()
@ -1121,11 +1141,13 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
private readonly InputActionMap m_Global;
private IGlobalActions m_GlobalActionsCallbackInterface;
private readonly InputAction m_Global_MapToggle;
private readonly InputAction m_Global_Inventory;
public struct GlobalActions
{
private @AetheriaInput m_Wrapper;
public GlobalActions(@AetheriaInput wrapper) { m_Wrapper = wrapper; }
public InputAction @MapToggle => m_Wrapper.m_Global_MapToggle;
public InputAction @Inventory => m_Wrapper.m_Global_Inventory;
public InputActionMap Get() { return m_Wrapper.m_Global; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
@ -1138,6 +1160,9 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
@MapToggle.started -= m_Wrapper.m_GlobalActionsCallbackInterface.OnMapToggle;
@MapToggle.performed -= m_Wrapper.m_GlobalActionsCallbackInterface.OnMapToggle;
@MapToggle.canceled -= m_Wrapper.m_GlobalActionsCallbackInterface.OnMapToggle;
@Inventory.started -= m_Wrapper.m_GlobalActionsCallbackInterface.OnInventory;
@Inventory.performed -= m_Wrapper.m_GlobalActionsCallbackInterface.OnInventory;
@Inventory.canceled -= m_Wrapper.m_GlobalActionsCallbackInterface.OnInventory;
}
m_Wrapper.m_GlobalActionsCallbackInterface = instance;
if (instance != null)
@ -1145,6 +1170,9 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
@MapToggle.started += instance.OnMapToggle;
@MapToggle.performed += instance.OnMapToggle;
@MapToggle.canceled += instance.OnMapToggle;
@Inventory.started += instance.OnInventory;
@Inventory.performed += instance.OnInventory;
@Inventory.canceled += instance.OnInventory;
}
}
}
@ -1218,5 +1246,6 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
public interface IGlobalActions
{
void OnMapToggle(InputAction.CallbackContext context);
void OnInventory(InputAction.CallbackContext context);
}
}

View file

@ -12,7 +12,7 @@ public class GameSettings : ScriptableObject
public float MinimapZoneGravityRange;
public float[] MinimapZoomLevels;
public int DefaultMinimapZoom;
public float IconSize;
public ExponentialCurve IconSize;
public int AsteroidMeshCount = 5;
public float MinimapAsteroidSize = 3;
public float PlanetRotationSpeed = 1;

View file

@ -84,8 +84,6 @@ public class SectorRenderer : MonoBehaviour
foreach(var camera in MinimapCameras)
camera.orthographicSize = value;
// MinimapGravityQuad.transform.localScale = value * 2 * Vector3.one;
foreach (var planet in _planets.Values)
planet.Icon.transform.localScale = Settings.IconSize / 256 * value * Vector3.one;
}
}
@ -214,13 +212,19 @@ public class SectorRenderer : MonoBehaviour
}
var planetInstance = _zone.PlanetInstances[planetData.ID];
planetInstance.BodyRadius.Subscribe(f => planet.Body.transform.localScale = f * Vector3.one);
planetInstance.BodyRadius.Subscribe(f =>
{
planet.Body.transform.localScale = f * Vector3.one;
});
planetInstance.GravityWellRadius.Subscribe(f => planet.GravityWell.transform.localScale = f * Vector3.one);
planetInstance.GravityWellDepth.Subscribe(f =>
{
if (f > _maxDepth) _maxDepth = f;
planet.GravityWell.material.SetFloat("_Depth", f);
planet.Icon.transform.position = new Vector3(0, -f, 0);
});
planetInstance.BodyData.Mass.Subscribe(f => planet.Icon.transform.localScale = Settings.IconSize.Evaluate(f) * Vector3.one);
_planets[planetData.ID] = planet;
if (!_rootFound)
@ -287,7 +291,8 @@ public class SectorRenderer : MonoBehaviour
{
var planetInstance = _zone.PlanetInstances[planet.Key];
var p = _zone.GetOrbitPosition(planetInstance.BodyData.Orbit);
planet.Value.transform.position = new Vector3(p.x, _zone.GetHeight(p) + planetInstance.BodyRadius.Value * 2, p.y);
planet.Value.transform.position = new Vector3(p.x, 0, p.y);
planet.Value.Body.transform.position = new Vector3(0, _zone.GetHeight(p) + planetInstance.BodyRadius.Value * 2, 0);
if(planet.Value is GasGiantObject gasGiantObject)
{
gasGiantObject.GravityWaves.material.SetFloat("_Phase", Time * Settings.PlanetSettings.WaveSpeed.Evaluate(planetInstance.BodyData.Mass.Value));

View file

@ -43,6 +43,8 @@ public interface INamedEntry
Union(26, typeof(GasGiantData)),
Union(27, typeof(SunData)),
Union(28, typeof(PlanetData)),
Union(29, typeof(CargoBayData)),
Union(30, typeof(DockingBayData)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
//[Union(21, typeof(ContractData))]
//[Union(22, typeof(Station))]

View file

@ -41,8 +41,7 @@ public abstract class Entity
public readonly Dictionary<object, float> VisibilitySources = new Dictionary<object, float>();
private List<IPopulationAssignment> PopulationAssignments = new List<IPopulationAssignment>();
private bool _active;
public EquippedItem[,] GearOccupancy;
public EquippedItem[,] ThermalOccupancy;

View file

@ -142,6 +142,8 @@ public class Shape
Union(1, typeof(CompoundCommodityData)),
Union(2, typeof(GearData)),
Union(3, typeof(HullData)),
Union(4, typeof(CargoBayData)),
Union(5, typeof(DockingBayData)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<ItemData>))]
public abstract class ItemData : DatabaseEntry, INamedEntry
{
@ -265,6 +267,14 @@ public class CargoBayData : EquippableItemData
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Tool;
}
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class DockingBayData : CargoBayData
{
[InspectableField, JsonProperty("maxSize"), Key(13)]
public int2 MaxSize;
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Tool;
}
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class HullData : EquippableItemData
{
@ -277,6 +287,9 @@ public class HullData : EquippableItemData
[InspectableField, JsonProperty("hullType"), Key(15)]
public HullType HullType;
[InspectableField, JsonProperty("gridOffset"), Key(16)]
public float GridOffset;
[IgnoreMember]
public Shape InteriorCells
{

View file

@ -70,6 +70,9 @@ public class InventoryPanel : MonoBehaviour
spriteIndex += 1 << i;
}
if (item != null)
spriteIndex += 1 << 8;
if (spriteIndex == 0)
{
var empty = new GameObject("Empty Node", typeof(RectTransform));
@ -111,6 +114,9 @@ public class InventoryPanel : MonoBehaviour
if (ItemMatch(_offsets[i]))
spriteIndex += 1 << i;
if (item != null)
spriteIndex += 1 << 8;
if (spriteIndex == 0)
{
var empty = new GameObject("Empty Node", typeof(RectTransform));

View file

@ -107,6 +107,6 @@ public static class UnityExtensions
public static Color ToColor(this float3 v) => new Color(v.x,v.y,v.z);
public static Vector3 Flatland(this Vector2 v) => new Vector3(v.x,0,v.y);
public static Vector3 Flatland(this Vector2 v, float y = 0) => new Vector3(v.x,y,v.y);
public static Vector2 Flatland(this Vector3 v) => new Vector2(v.x,v.z);
}