Station Compass Icons

This commit is contained in:
Reinier Vens 2021-05-12 13:49:04 +01:00
commit 710d17ff4c
21 changed files with 72 additions and 8877 deletions

View file

@ -86,7 +86,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Scale: 2.2925873
- _Scale: 1.6706811
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1

View file

@ -4383,6 +4383,7 @@ GameObject:
m_Component:
- component: {fileID: 336445423}
- component: {fileID: 336445422}
- component: {fileID: 336445424}
m_Layer: 5
m_Name: IconPivot
m_TagString: Untagged
@ -4422,6 +4423,19 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &336445424
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 336445421}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 75b24e04994ddc14a83fc147dfc74181, type: 3}
m_Name:
m_EditorClassIdentifier:
Icon: {fileID: 230026525}
--- !u!1001 &342600466
PrefabInstance:
m_ObjectHideFlags: 0
@ -16135,6 +16149,8 @@ MonoBehaviour:
type: 3}
Sun: {fileID: 2259714927540639794, guid: 046dde0f4600bce41ad33c476f99b309, type: 3}
CompassIconPrototype: {fileID: 336445422}
OrbitalIcon: {fileID: 21300000, guid: 97bce58bfe43bfa40870ca062cfb7ec1, type: 3}
WormholeIcon: {fileID: 21300000, guid: 6d0b27330fdcc8347b1e09a2d17a0673, type: 3}
PlanetoidIcon: {fileID: 2800000, guid: 823d8a1c4e071994087624c39f62b319, type: 3}
PlanetIcon: {fileID: 2800000, guid: 0d2acbd593b7fd349b0b26b4844733ef, type: 3}
--- !u!114 &1009503735
@ -23707,7 +23723,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}
@ -24919,7 +24935,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}

View file

@ -59,6 +59,7 @@ public class EntityInstance : MonoBehaviour
_constantWeaponManagers.Clear();
}
public CompassIcon CompassIcon { get; set; }
public Dictionary<HardpointData, Transform[]> Barrels { get; private set; }
public Dictionary<HardpointData, int> BarrelIndices { get; private set; }
public Dictionary<Radiator, MeshRenderer> RadiatorMeshes { get; private set; }

View file

@ -0,0 +1,9 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CompassIcon : MonoBehaviour
{
public Image Icon;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 75b24e04994ddc14a83fc147dfc74181
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -59,8 +59,8 @@ public class ZoneRenderer : MonoBehaviour
public Prototype CompassIconPrototype;
[Header("Icons")]
public Texture2D PlanetoidIcon;
public Texture2D PlanetIcon;
public Sprite OrbitalIcon;
public Sprite WormholeIcon;
[HideInInspector] public Dictionary<Entity, EntityInstance> EntityInstances = new Dictionary<Entity, EntityInstance>();
[HideInInspector] public Dictionary<Guid, PlanetObject> Planets = new Dictionary<Guid, PlanetObject>();
@ -83,7 +83,7 @@ public class ZoneRenderer : MonoBehaviour
private List<IDisposable> _zoneSubscriptions = new List<IDisposable>();
private PlanetObject[] _suns;
public Dictionary<Wormhole, (GameObject gravity, Transform icon)> WormholeInstances = new Dictionary<Wormhole, (GameObject, Transform)>();
public Dictionary<Wormhole, (GameObject gravity, CompassIcon icon)> WormholeInstances = new Dictionary<Wormhole, (GameObject, CompassIcon)>();
private List<ItemPickup> _loot = new List<ItemPickup>();
public Zone Zone { get; private set; }
@ -215,7 +215,8 @@ public class ZoneRenderer : MonoBehaviour
{
var instance = Instantiate(WormholePrefab);
instance.position = new Vector3(wormhole.Position.x, 0, wormhole.Position.y);
var icon = CompassIconPrototype.Instantiate<Transform>();
var icon = CompassIconPrototype.Instantiate<CompassIcon>();
icon.Icon.sprite = WormholeIcon;
WormholeInstances.Add(wormhole, (instance.gameObject, icon));
}
@ -284,9 +285,15 @@ public class ZoneRenderer : MonoBehaviour
ItemManager.Log($"Failed to instantiate {hullData.Name} entity with invalid prefab: no EntityInstance component!");
return;
}
if (entity.HullData.HullType == HullType.Station)
{
instance.CompassIcon = CompassIconPrototype.Instantiate<CompassIcon>();
instance.CompassIcon.Icon.sprite = OrbitalIcon;
}
}
instance.SetEntity(this, entity);
EntityInstances.Add(entity, instance);
}
@ -481,12 +488,26 @@ public class ZoneRenderer : MonoBehaviour
else planet.Value.Body.transform.rotation *= Quaternion.AngleAxis(Settings.PlanetRotationSpeed, Vector3.up);
}
foreach (var entityInstance in EntityInstances.Values)
{
if(entityInstance.CompassIcon)
{
var difference = entityInstance.Entity.Position.xz - PerspectiveEntity.Position.xz;
var distance = length(difference);
entityInstance.CompassIcon.gameObject.SetActive(
PerspectiveEntity.EntityInfoGathered[entityInstance.Entity] > Settings.GameplaySettings.TargetDetectionInfoThreshold &&
distance > _minimapDistance);
entityInstance.CompassIcon.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90);
}
}
foreach (var wormhole in WormholeInstances.Values)
{
var difference = wormhole.gravity.transform.position.Flatland() - (Vector2)PerspectiveEntity.Position.xz;
var distance = difference.magnitude;
wormhole.icon.gameObject.SetActive(distance > _minimapDistance);
wormhole.icon.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90);
wormhole.icon.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90);
}
var fogPos = FogCameraParent.position;

Binary file not shown.