Murder Satellites

Created TurretController, which performs basic combat for fixed orbital installations
Projectiles self-destruct at maximum range
Created turret prefab
Outfitted turret in game manager
Entity position is now 3D
Entities responsible for updating their own position and orientation
Barrel positions and orientations available from entity code
Inventory code will display modal dialog for invalid item moves instead of breaking
Yaw articulation working (full 360 rotation still borked)
This commit is contained in:
Reinier Vens 2021-01-06 14:56:39 +00:00
commit ef816cc7e0
60 changed files with 2536 additions and 244 deletions

View file

@ -223,6 +223,7 @@
<e p="Attribution.txt" t="Include" />
</e>
</e>
<e p="Rotate.cs" t="Include" />
<e p="SchematicDisplay.cs" t="Include" />
<e p="SchematicListElement.cs" t="Include" />
<e p="SchematicTriggerGroupElement.cs" t="Include" />
@ -1444,7 +1445,6 @@
<e p="Agents" t="Include">
<e p="AgentBehavior.cs" t="Include" />
<e p="AgentTask.cs" t="Include" />
<e p="Aim.cs" t="Include" />
<e p="HaulingTask.cs" t="Include" />
<e p="Locomotion.cs" t="Include" />
<e p="Mining.cs" t="Include" />
@ -1488,6 +1488,7 @@
<e p="TowingController.cs" t="Include" />
<e p="Trigger.cs" t="Include" />
<e p="Turning.cs" t="Include" />
<e p="TurretController.cs" t="Include" />
<e p="VelocityConversion.cs" t="Include" />
<e p="VelocityLimit.cs" t="Include" />
<e p="Visibility.cs" t="Include" />

View file

@ -37,7 +37,6 @@
<Path>Logs</Path>
<Path>Recordings</Path>
<Path>Server</Path>
<Path>Temp</Path>
<Path>UserSettings</Path>
<Path>obj</Path>
</explicitExcludes>

View file

@ -196,11 +196,13 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Geometry\Curves\LineSegment.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\ConeSpanner\LeftVertexEvent.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\Obstacle.cs" />
<Compile Include="Assets\EntityPrefab.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\DebugHelpers\Persistence\DoubleStreamElement.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Geometry\OverlapRemoval\OverlapRemovalNode.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\Station.cs" />
<Compile Include="Assets\Scripts\GameSettings.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\ValidateArg.cs" />
<Compile Include="Assets\ProjectileManager.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\DebugHelpers\Persistence\CurveStreamElement.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\Nudging\PointByDelegateComparer.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Layout\Arrowhead.cs" />
@ -330,6 +332,7 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Geometry\ConvexHull\HullPointComparer.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\Layered\Ordering\OrderingMeasure.cs" />
<Compile Include="Assets\com.unity.uiextensions\Runtime\Scripts\Primitives\UILineRenderer.cs" />
<Compile Include="Assets\HullCollider.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\CdtThreader.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\LargeGraphLayout\IZoomLevelCalculator.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\BundleBase.cs" />
@ -342,6 +345,7 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Visibility\VisibilityVertex.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Layout\ProximityOverlapRemoval\MST\MstOnDelaunayTriangulation.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\GraphAlgorithms\CycleRemoval\CycleRemoval.cs" />
<Compile Include="Assets\SchematicTriggerGroupElement.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Geometry\Curves\IFunction.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\Layered\RefinerBetweenTwoLayers.cs" />
<Compile Include="Assets\Scripts\Sector Display\SnapToGrid.cs" />
@ -399,6 +403,7 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\ProjectionSolver\ISolverShell.cs" />
<Compile Include="Assets\Scripts\NIH\NaughtyAttributes\Scripts\Core\DrawerAttributes\DropdownAttribute.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Visibility\SegmentBase.cs" />
<Compile Include="Assets\GuidedProjectile.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\LargeGraphLayout\LgLayoutSettings.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\Nudging\CombinatorialNudger.cs" />
<Compile Include="Assets\Scripts\TechTreeMsagl.cs" />
@ -448,6 +453,7 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Geometry\RectanglePacking\RectanglePacking.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Layout\Arrowheads.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Miscellaneous\Phylo\PhyloTreeLayoutCalclulation.cs" />
<Compile Include="Assets\ThrusterHardpoint.cs" />
<Compile Include="Assets\Scripts\NIH\NaughtyAttributes\Scripts\Core\ValidatorAttributes\ValidatorAttribute.cs" />
<Compile Include="Assets\InventoryMenu.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Layout\IdealEdgeLengthSettings.cs" />
@ -460,13 +466,17 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\DebugHelpers\Persistence\GeometryGraphWriter.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\ProjectionSolver\UniformSolverVar.cs" />
<Compile Include="Assets\Shaders\Compute\Stardust.cs" />
<Compile Include="Assets\WeaponHardpoint.cs" />
<Compile Include="Assets\Scripts\NIH\MIConvexHull\Cell2.cs" />
<Compile Include="Assets\Scripts\NIH\MIConvexHull\ConvexHull\ObjectManager.cs" />
<Compile Include="Assets\Scripts\NIH\NaughtyAttributes\Scripts\Core\DrawerAttributes\ButtonAttribute.cs" />
<Compile Include="Assets\Scripts\Sector Display\WaveScroll.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\ProjectionSolver\Block.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\Layered\SugiyamaLayoutSettings.cs" />
<Compile Include="Assets\Rotate.cs" />
<Compile Include="Assets\Projectile.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\ProjectionSolver\SolverShell.cs" />
<Compile Include="Assets\ArticulationPoint.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\BundleInfo.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\TimeMeasurer.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\DataStructures\CollectionUtilities.cs" />
@ -529,6 +539,7 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\Layered\RecoveryLayeredLayoutEngine.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\ClusterBoundaryPort.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\Nudging\AxisEdgeHighPointEvent.cs" />
<Compile Include="Assets\GuidedProjectileManager.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\ConeSpanner\PortLocationEvent.cs" />
<Compile Include="Assets\Scripts\NIH\MIConvexHull\ConvexHull\ConvexHullAlgorithm.Initialize.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\Incremental\Relayout.cs" />
@ -695,16 +706,6 @@
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\BasicReflectionEvent.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\Layered\IntEdge.cs" />
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\PointPairOrder.cs" />
<Compile Include="Assets\SchematicTriggerGroupElement.cs" />
<Compile Include="Assets\ArticulationPoint.cs" />
<Compile Include="Assets\WeaponHardpoint.cs" />
<Compile Include="Assets\ThrusterHardpoint.cs" />
<Compile Include="Assets\EntityPrefab.cs" />
<Compile Include="Assets\HullCollider.cs" />
<Compile Include="Assets\GuidedProjectile.cs" />
<Compile Include="Assets\GuidedProjectileManager.cs" />
<Compile Include="Assets\ProjectileManager.cs" />
<Compile Include="Assets\Projectile.cs" />
<None Include="Assets\com.unity.uiextensions\Runtime\Resources\Shaders\UIAdditive.shader" />
<None Include="Assets\TextMesh Pro\Resources\Shaders\TMPro.cginc" />
<None Include="Assets\TextMesh Pro\Resources\Shaders\TMP_SDF-Mobile Overlay.shader" />

View file

@ -14,14 +14,32 @@ public class ArticulationPoint : MonoBehaviour
public float PitchMin;
public float PitchMax;
public float Speed;
private float _yaw;
private float _pitch;
void Update()
{
if (Target)
{
var targetLocal = transform.parent.InverseTransformPoint(Target.position);
var yaw = Vector2.SignedAngle(new Vector2(0, 1), new Vector2(targetLocal.x, targetLocal.z));
var pitch = Vector2.SignedAngle(new Vector2(1, 0), new Vector2(targetLocal.z, targetLocal.y));
transform.localRotation = Quaternion.Euler(clamp(-pitch, -PitchMin, -PitchMax), clamp(yaw, YawMin, YawMax), 0);
var targetYaw = clamp(-yaw, YawMin, YawMax);
var targetPitch = clamp(-pitch, PitchMin, PitchMax);
if (abs(targetYaw - _yaw) < Speed * Time.deltaTime)
_yaw = targetYaw;
else _yaw = _yaw + sign(targetYaw - _yaw) * Speed * Time.deltaTime;
if (abs(targetPitch - _pitch) < Speed * Time.deltaTime)
_pitch = targetPitch;
else _pitch = _pitch + sign(targetPitch - _pitch) * Speed * Time.deltaTime;
transform.localRotation = Quaternion.Euler(_pitch, _yaw, 0);
}
}
}

View file

@ -18,6 +18,7 @@ public class InventoryMenu : MonoBehaviour
public PropertiesPanel PropertiesPanel;
public ActionGameManager GameManager;
public RectTransform DragParent;
public ConfirmationDialog Dialog;
private int _currentPanel = -1;
@ -126,12 +127,23 @@ public class InventoryMenu : MonoBehaviour
if (data is InventoryCargoEventData cargoEvent)
{
cargoEvent.CargoBay.Remove(_dragItem);
_dragTargetPanel.DropItem(_dragItem, _dragTargetPosition);
}
else if (data is InventoryEntityEventData entityEvent)
{
entityEvent.Entity.Unequip(_originalEquippedItem);
if (entityEvent.Entity.Unequip(_originalEquippedItem) != null)
{
_dragTargetPanel.DropItem(_dragItem, _dragTargetPosition);
}
else
{
Dialog.Clear();
Dialog.Title.text = "Unable to move item!";
Dialog.AddProperty("Verify that cargo bays are empty before un-equipping them.");
Dialog.Show();
}
}
_dragTargetPanel.DropItem(_dragItem, _dragTargetPosition);
_dragTargetPanel.FakeOccupancy = null;
}
else

View file

@ -0,0 +1,87 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Radiators 1
m_Shader: {fileID: 4800000, guid: d69ef48273708ef4680762f5cdcfc860, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: -812895718602229137, guid: b7e648471e9dfc44490bd41973711541,
type: 3}
m_Scale: {x: 8, y: 8}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: -6057190860509678031, guid: 2b42584452fe0cc4fa4e8a115230b156,
type: 3}
m_Scale: {x: 8, y: 8}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: -894214952450941493, guid: 2b42584452fe0cc4fa4e8a115230b156,
type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpPower: 2
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _Emission: 15
- _EmissionFresnel: 4
- _EmissionRoughnessFresnelPower: 0.5
- _GlossMapScale: 1
- _Glossiness: 1
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReverseRim: 0
- _Rotation: 0
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 1, g: 0.40135294, b: 0, a: 1}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f396635dc77c59c44ac85ae278a2e909
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,381 @@
fileFormatVersion: 2
guid: 504c7bfe0d50ff64a88b8eac2ceb46f8
ScriptedImporter:
internalIDToNameTable:
- first:
1: 100000
second: metal_car_paint/metal_car_paint
- first:
4: 400000
second: metal_car_paint/metal_car_paint/Transform
- first:
21: 2100000
second: mat.Car paint
- first:
23: 2300000
second: metal_car_paint/metal_car_paint/MeshRenderer
- first:
28: 2800000
second: Car paint_baseColor
- first:
28: 2800002
second: Car paint_normal
- first:
28: 2800004
second: Car paint_metallic
- first:
28: 2800006
second: Car paint_ambientOcclusion
- first:
28: 2800008
second: Car paint_height
- first:
33: 3300000
second: metal_car_paint/metal_car_paint/MeshFilter
- first:
114: 11400000
second: sbsar
- first:
114: 11400002
second: graph0
- first:
135: 13500000
second: metal_car_paint/metal_car_paint/SphereCollider
- first:
1001: 100100000
second: metal_car_paint
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 232528478, guid: 43a8bbf65be290d44ba52b94476242b9, type: 3}
version: 29
projectContext: 0
mGraphInstanceData:
- graphLabel: Car paint
prototypeName: Car paint
graphDescIndex: 0
generateAllOutputs: 0
generateMipMaps: 1
preset: " <sbspreset pkgurl=\"pkg://metal_car_paint\" label=\"\" >\n <presetinput
identifier=\"$outputsize\" uid=\"2092133592\" type=\"8\" value=\"11,11\" />\n
<presetinput identifier=\"normal_intensity\" uid=\"2045651458\" type=\"0\"
value=\"0.25\" />\n <presetinput identifier=\"age\" uid=\"2038752334\" type=\"0\"
value=\"1\" />\n <presetinput identifier=\"flakes\" uid=\"20245147\" type=\"4\"
value=\"1\" />\n <presetinput identifier=\"flakes_scale\" uid=\"20192266\"
type=\"0\" value=\"1\" />\n <presetinput identifier=\"paint_scratches\" uid=\"22509202\"
type=\"0\" value=\"1\" />\n <presetinput identifier=\"paint_peeling\" uid=\"103560714\"
type=\"0\" value=\"0.246\" />\n <presetinput identifier=\"metal_roughness\"
uid=\"22504787\" type=\"0\" value=\"0.39\" />\n <presetinput identifier=\"paint_color\"
uid=\"105341618\" type=\"2\" value=\"1,0.15685,0\" />\n <presetinput identifier=\"paint_roughness\"
uid=\"22504606\" type=\"0\" value=\"0\" />\n <presetinput identifier=\"paint_metallic\"
uid=\"22503567\" type=\"0\" value=\"1\" />\n </sbspreset>\n"
shaderName: Standard
materialProperties:
shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
shaderKeywords: _MAINTEX _METALLICGLOSSMAP _NORMALMAP _OCCLUSIONMAP _PARALLAXMAP
lightmapFlags: 4
enableInstancingVariants: 0
doubleSidedGI: 0
customRenderQueue: -1
texEnvs:
- name: _BumpMap
texture: {fileID: 3068890721646206586, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
type: 3}
scale: {x: 1, y: 1}
offset: {x: 0, y: 0}
- name: _DetailAlbedoMap
texture: {instanceID: 0}
scale: {x: 1, y: 1}
offset: {x: 0, y: 0}
- name: _DetailMask
texture: {instanceID: 0}
scale: {x: 1, y: 1}
offset: {x: 0, y: 0}
- name: _DetailNormalMap
texture: {instanceID: 0}
scale: {x: 1, y: 1}
offset: {x: 0, y: 0}
- name: _EmissionMap
texture: {instanceID: 0}
scale: {x: 2, y: 2}
offset: {x: 0, y: 0}
- name: _MainTex
texture: {fileID: 5917659159057834157, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
type: 3}
scale: {x: 2, y: 2}
offset: {x: 0, y: 0}
- name: _MetallicGlossMap
texture: {fileID: -3552914696322007609, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
type: 3}
scale: {x: 1, y: 1}
offset: {x: 0, y: 0}
- name: _OcclusionMap
texture: {fileID: -1242281561028671816, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
type: 3}
scale: {x: 1, y: 1}
offset: {x: 0, y: 0}
- name: _ParallaxMap
texture: {fileID: -1652887728991447519, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
type: 3}
scale: {x: 1, y: 1}
offset: {x: 0, y: 0}
floats:
- name: _BumpScale
float: 1
- name: _Cutoff
float: 0.5
- name: _DetailNormalMapScale
float: 1
- name: _DstBlend
float: 0
- name: _GlossMapScale
float: 1
- name: _Glossiness
float: 0.5
- name: _GlossyReflections
float: 1
- name: _Metallic
float: 0
- name: _Mode
float: 0
- name: _OcclusionStrength
float: 1
- name: _Parallax
float: 0.005
- name: _SmoothnessTextureChannel
float: 0
- name: _SpecularHighlights
float: 1
- name: _SrcBlend
float: 1
- name: _UVSec
float: 0
- name: _ZWrite
float: 1
colors:
- name: _Color
color: {r: 1, g: 1, b: 1, a: 1}
- name: _EmissionColor
color: {r: 0, g: 0, b: 0, a: 1}
outputDescList:
- outputName: diffuse
identifier: diffuse
usageName: diffuse
channelStr: diffuse
label: Diffuse
usage: 0
bImage: 1
bNumerical: 0
bLinear: 0
- outputName: baseColor
identifier: basecolor
usageName: baseColor
channelStr: baseColor
label: Base Color
usage: 1
bImage: 1
bNumerical: 0
bLinear: 0
- outputName: normal
identifier: normal
usageName: normal
channelStr: normal
label: Normal
usage: 7
bImage: 1
bNumerical: 0
bLinear: 1
- outputName: specular
identifier: specular
usageName: specular
channelStr: specular
label: Specular
usage: 11
bImage: 1
bNumerical: 0
bLinear: 0
- outputName: glossiness
identifier: glossiness
usageName: glossiness
channelStr: glossiness
label: Glossiness
usage: 14
bImage: 1
bNumerical: 0
bLinear: 1
- outputName: roughness
identifier: roughness
usageName: roughness
channelStr: roughness
label: Roughness
usage: 15
bImage: 1
bNumerical: 0
bLinear: 1
- outputName: metallic
identifier: metallic
usageName: metallic
channelStr: metallic
label: Metallic
usage: 34
bImage: 1
bNumerical: 0
bLinear: 1
- outputName: ambientOcclusion
identifier: ambient_occlusion
usageName: ambientOcclusion
channelStr: ambientOcclusion
label: Ambient Occlusion
usage: 5
bImage: 1
bNumerical: 0
bLinear: 1
- outputName: height
identifier: height
usageName: height
channelStr: height
label: Height
usage: 9
bImage: 1
bNumerical: 0
bLinear: 1
texturePackingList:
- targetName: diffuse
components:
- sourceName: diffuse
from: 0
to: 3
- targetName: baseColor
components:
- sourceName: baseColor
from: 0
to: 3
- targetName: normal
components:
- sourceName: normal
from: 0
to: 3
- targetName: specular
components:
- sourceName: specular
from: 0
to: 3
- targetName: glossiness
components:
- sourceName: glossiness
from: 0
to: 3
- targetName: roughness
components:
- sourceName: roughness
from: 0
to: 3
- targetName: metallic
components:
- sourceName: smoothness
from: 0
to: 3
- targetName: ambientOcclusion
components:
- sourceName: ambientOcclusion
from: 0
to: 3
- targetName: height
components:
- sourceName: height
from: 0
to: 3
textureParameters:
- textureName: Car paint_glossiness
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_diffuse
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_baseColor
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_normal
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_specular
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_roughness
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_metallic
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_ambientOcclusion
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint_height
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - diffuse
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - baseColor
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - normal
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - specular
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - glossiness
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - roughness
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - metallic
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - ambientOcclusion
wrapMode: 0
filterMode: 1
aniso: 1
- textureName: Car paint - height
wrapMode: 0
filterMode: 1
aniso: 1
colorSpaceList: []
inputTextureMap: []
targetSettingList:
- label: Default
bOverride: 0
bLockRatio: 1
textureWidth: 2048
textureHeight: 2048
textureFormatMode: 0
normalCompressed: 0
bGenerateOnLoad: 1
material: {fileID: 3720744386649352057, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8,
type: 3}
generatedTextures:
- {fileID: 5917659159057834157, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8, type: 3}
- {fileID: 3068890721646206586, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8, type: 3}
- {fileID: -3552914696322007609, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8, type: 3}
- {fileID: -1242281561028671816, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8, type: 3}
- {fileID: -1652887728991447519, guid: 504c7bfe0d50ff64a88b8eac2ceb46f8, type: 3}

BIN
Assets/Materials/Substance/Metal/metal_car_paint white.sbsar (Stored with Git LFS) Normal file

Binary file not shown.

View file

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

View file

@ -0,0 +1,101 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Turret
m_Shader: {fileID: 4800000, guid: f69be63d97f3ffe499bc8ad9f5a104c6, type: 3}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- ALWAYS
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: f1647736355d8a14aa3444e46a012714, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BlendOp: 0
- _BumpScale: 1
- _CameraFadingEnabled: 0
- _CameraFarFadeDistance: 2
- _CameraNearFadeDistance: 1
- _ColorMode: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DistortionBlend: 0.5
- _DistortionEnabled: 0
- _DistortionStrength: 1
- _DistortionStrengthScaled: 0
- _DstBlend: 10
- _EmissionEnabled: 0
- _FlipbookMode: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1
- _LightingEnabled: 0
- _Metallic: 0
- _Mode: 3
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 0
- _SoftParticlesFarFadeDistance: 1
- _SoftParticlesNearFadeDistance: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 397fd6d1d65c2c84bbd629fd9d4bc19a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Models/Turret.blend (Stored with Git LFS)

Binary file not shown.

View file

@ -69,7 +69,7 @@ ModelImporter:
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
normalImportMode: 1
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0

Binary file not shown.

BIN
Assets/Models/Turret.fbx (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,113 @@
fileFormatVersion: 2
guid: 33ad68f41d4b2fe4c9801f449debd3b6
ModelImporter:
serializedVersion: 20101
internalIDToNameTable:
- first:
74: -5395469358196396232
second: LD12_Scanner|LD12_Scanner2Action
- first:
74: -339793421420189680
second: LD12_Scanner|LD12_ScannerAction
- first:
74: -1060864838660959178
second: LD12_Scanner2|LD12_Scanner2Action
- first:
74: 2014324191034718849
second: LD12_Scanner2|LD12_ScannerAction
externalObjects: {}
materials:
materialImportMode: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 0
preserveHierarchy: 0
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 1
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 2
humanoidOversampling: 1
avatarSetup: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -11,13 +11,16 @@ public class Projectile : MonoBehaviour
public float Gravity;
private bool _alive;
public Zone Zone { get; set; }
public Vector3 StartPosition { get; set; }
public Vector3 Velocity { get; set; }
public float Damage { get; set; }
public DamageType DamageType { get; set; }
public Entity SourceEntity { get; set; }
public float Range { get; set; }
// Start is called before the first frame update
void Start()
{
@ -34,20 +37,25 @@ public class Projectile : MonoBehaviour
{
if (SourceEntity == null) return;
var position = transform.position;
Velocity += Vector3.up * (sign(Zone.GetHeight(float2(position.x,position.z)) - position.y) * Gravity * Time.deltaTime);
var ray = new Ray(position, Velocity);
if (Physics.Raycast(ray, out var hit, Velocity.magnitude, LayerMask.NameToLayer("Combat")))
{
var hull = hit.collider.GetComponent<HullCollider>();
if (hull)
{
hull.SendHit(Damage, DamageType, SourceEntity, hit);
}
StartCoroutine(Kill());
}
if(_alive)
{
var position = transform.position;
Velocity += Vector3.up * (sign(Zone.GetHeight(float2(position.x,position.z)) - position.y) * Gravity * Time.deltaTime);
var ray = new Ray(position, Velocity);
if (Physics.Raycast(ray, out var hit, Velocity.magnitude, LayerMask.NameToLayer("Combat")))
{
var hull = hit.collider.GetComponent<HullCollider>();
if (hull)
{
hull.SendHit(Damage, DamageType, SourceEntity, hit);
}
StartCoroutine(Kill());
}
transform.position += Velocity;
if((transform.position - StartPosition).magnitude > Range)
StartCoroutine(Kill());
}
}
IEnumerator Kill()

View file

@ -12,7 +12,8 @@ public class ProjectileManager : MonoBehaviour
p.SourceEntity = source.Entity;
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
var barrel = source.GetBarrel(hp);
p.transform.position = barrel.position;
p.Range = source.Entity.ItemManager.Evaluate(data.Range, item.EquippableItem, source.Entity);
p.StartPosition = p.transform.position = barrel.position;
p.Velocity = barrel.forward * source.Entity.ItemManager.Evaluate(data.Velocity, item.EquippableItem, source.Entity);
p.Damage = source.Entity.ItemManager.Evaluate(data.Damage, item.EquippableItem, source.Entity);
p.DamageType = data.DamageType;

View file

@ -7196,5 +7196,6 @@ MonoBehaviour:
Target: {fileID: 0}
YawMin: 0
YawMax: 0
PitchMin: 15
PitchMax: -45
PitchMin: -45
PitchMax: 15
Speed: 15

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8ffa1560728d1e848b6553d85057a511
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -86,7 +86,7 @@ TrailRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Time: 2
m_Time: 0.1
m_Parameters:
serializedVersion: 3
widthMultiplier: 1

View file

@ -49,6 +49,7 @@ Infinity By ProSymbols
Box by Rajive
storage by Gajah Mada Studio
Tank by Creative Stall
Satellite by Amelia
Other

BIN
Assets/Resources/Sprites/Icons/Stroked/Satellite.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,118 @@
fileFormatVersion: 2
guid: f1647736355d8a14aa3444e46a012714
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

15
Assets/Rotate.cs Normal file
View file

@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate : MonoBehaviour
{
public Vector3 Axis;
public float Speed;
void Update()
{
transform.localRotation *= Quaternion.AngleAxis(Speed * Time.deltaTime, Axis);
}
}

View file

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4daff8784b3444a4ab5466da3368cd7a
guid: cd72410ad11370d478bf52dc4afddc0c
MonoImporter:
externalObjects: {}
serializedVersion: 2

View file

@ -4586,10 +4586,10 @@ RectTransform:
m_Father: {fileID: 947321578}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 129.725, y: 0}
m_SizeDelta: {x: 36.930023, y: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &608624600
MonoBehaviour:
@ -4629,7 +4629,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &620555923
RectTransform:
m_ObjectHideFlags: 0
@ -4650,7 +4650,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -35.87}
m_SizeDelta: {x: 285.7, y: 90.91}
m_SizeDelta: {x: 285.7, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &620555924
MonoBehaviour:
@ -4690,9 +4690,10 @@ MonoBehaviour:
type: 3}
IncrementField: {fileID: 5486709585343280439, guid: 9c14c92a1a08b0a4fb4f6aa6f8504082,
type: 3}
Content: {fileID: 0}
Content: {fileID: 620555923}
SelectedChild: {fileID: 0}
CancelClickCatcher: {fileID: 1420548305}
ButtonGroup: {fileID: 947321577}
Cancel: {fileID: 1176624628}
Confirm: {fileID: 843760693}
--- !u!114 &620555925
@ -5691,10 +5692,10 @@ RectTransform:
m_Father: {fileID: 620555923}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 142.85, y: -21.455}
m_SizeDelta: {x: 269.7, y: 26.91}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &738229278
MonoBehaviour:
@ -7798,10 +7799,10 @@ RectTransform:
m_Father: {fileID: 620555923}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 142.85, y: -66.91}
m_SizeDelta: {x: 269.7, y: 32}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &947321579
MonoBehaviour:
@ -10975,27 +10976,27 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 55.629997
value: 55.675
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_SizeDelta.x
value: 47.259995
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11100,17 +11101,17 @@ PrefabInstance:
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 55.629997
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_SizeDelta.x
value: 111.259995
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11125,7 +11126,7 @@ PrefabInstance:
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11135,7 +11136,7 @@ PrefabInstance:
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11150,22 +11151,22 @@ PrefabInstance:
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_SizeDelta.x
value: 111.259995
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11175,7 +11176,7 @@ PrefabInstance:
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 55.629997
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4710256612221957410, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11532,27 +11533,27 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 60.754997
value: 60.98
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_SizeDelta.x
value: 57.509995
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11652,17 +11653,17 @@ PrefabInstance:
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 208.945
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_SizeDelta.x
value: 121.509995
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11677,7 +11678,7 @@ PrefabInstance:
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11687,7 +11688,7 @@ PrefabInstance:
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2297648055057363568, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11702,22 +11703,22 @@ PrefabInstance:
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -16
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_SizeDelta.x
value: 121.509995
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -11727,7 +11728,7 @@ PrefabInstance:
- target: {fileID: 3873577224371502733, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 60.754997
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4710256612221957410, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -13721,6 +13722,7 @@ MonoBehaviour:
PropertiesPanel: {fileID: 7399108074413661592}
GameManager: {fileID: 1009503729}
DragParent: {fileID: 245842385}
Dialog: {fileID: 620555924}
--- !u!1 &2011788088
GameObject:
m_ObjectHideFlags: 0
@ -15804,7 +15806,8 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 45f0e5e2648ab8a40ba0d8e384188776, type: 3}
m_Sprite: {fileID: -134468233401069099, guid: ef4a863cd35ba454cb1d7e37e6388abe,
type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
@ -15813,7 +15816,7 @@ MonoBehaviour:
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
m_PixelsPerUnitMultiplier: 1.5
--- !u!222 &1605725322975872061
CanvasRenderer:
m_ObjectHideFlags: 0

Binary file not shown.

View file

@ -110,7 +110,7 @@ public class ActionGameManager : MonoBehaviour
_input.Player.Disable();
GameplayUI.SetActive(false);
Menu.ShowTab(MenuTab.Map);
MenuMap.Position = _currentShip.Position;
MenuMap.Position = _currentShip.Position.xz;
};
_input.Global.Inventory.performed += context =>
@ -354,10 +354,10 @@ public class ActionGameManager : MonoBehaviour
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(3);
var parentOrbit = stationParent.Orbit.Data.ID;
var parentPos = Zone.GetOrbitPosition(parentOrbit);
var stationPos = parentPos + ItemManager.Random.NextFloat2Direction() * stationParent.GravityWellRadius.Value * .1f;
var stationOrbit = Zone.CreateOrbit(parentOrbit, stationPos);
var stationParentOrbit = stationParent.Orbit.Data.ID;
var stationParentPos = Zone.GetOrbitPosition(stationParentOrbit);
var stationPos = stationParentPos + ItemManager.Random.NextFloat2Direction() * stationParent.GravityWellRadius.Value * .1f;
var stationOrbit = Zone.CreateOrbit(stationParentOrbit, stationPos);
var station = new OrbitalEntity(ItemManager, Zone, stationHull, stationOrbit.ID);
Zone.Entities.Add(station);
var dockingBayData = ItemData.GetAll<DockingBayData>().First();
@ -365,6 +365,34 @@ public class ActionGameManager : MonoBehaviour
station.TryEquip(dockingBay);
station.Active = true;
var reactorData = ItemData.GetAll<GearData>().First(x => x.HardpointType == HardpointType.Reactor && x.Shape.Height == 2);
var autocannonData = ItemData.GetAll<GearData>().First(x => x.Name == "Autocannon");
var ammoData = ItemData.GetAll<SimpleCommodityData>().First(x => x.Name == "AC2 Ammo");
var turretType = ItemData.GetAll<HullData>().First(x=>x.HullType==HullType.Turret);
var turretHull = ItemManager.CreateInstance(turretType, 0, 1) as EquippableItem;
var turretParent = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(5);
var turretParentOrbit = turretParent.Orbit.Data.ID;
var turretParentPos = Zone.GetOrbitPosition(turretParentOrbit);
var turretPos = turretParentPos + ItemManager.Random.NextFloat2Direction() * turretParent.GravityWellRadius.Value * .05f;
var turretOrbit = Zone.CreateOrbit(turretParentOrbit, turretPos);
var turret = new OrbitalEntity(ItemManager, Zone, turretHull, turretOrbit.ID);
turret.TryEquip(ItemManager.CreateInstance(reactorData, .5f, 1) as EquippableItem);
var controlModuleData = ItemData.GetAll<GearData>().First(x => x.Name == "Murder Module");
turret.TryEquip(ItemManager.CreateInstance(controlModuleData, .5f, 1) as EquippableItem);
turret.TryEquip(ItemManager.CreateInstance(autocannonData, .5f, 1) as EquippableItem);
turret.TryEquip(ItemManager.CreateInstance(autocannonData, .5f, 1) as EquippableItem);
var cargo1Data = ItemData.GetAll<CargoBayData>().First(x => x.Name == "Cargo Bay 1x1");
var cargo1 = ItemManager.CreateInstance(cargo1Data, .5f, 1);
turret.TryEquip(cargo1 as EquippableItem);
turret.CargoBays.First().TryStore(ItemManager.CreateInstance(ammoData, 400));
turret.Active = true;
Zone.Entities.Add(turret);
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);
@ -378,21 +406,18 @@ public class ActionGameManager : MonoBehaviour
//dockingCargo.TryStore(ItemManager.CreateInstance(thrusterData, .5f, 1));
}
var reactorData = ItemData.GetAll<GearData>().First(x => x.HardpointType == HardpointType.Reactor && x.Shape.Height == 2);
ship.TryEquip(ItemManager.CreateInstance(reactorData, .5f, 1) as EquippableItem);
var cockpitData = ItemData.GetAll<GearData>().First(x => x.Behaviors.Any(b=>b is CockpitData));
ship.TryEquip(ItemManager.CreateInstance(cockpitData, .5f, 1) as EquippableItem);
var autocannonData = ItemData.GetAll<GearData>().First(x => x.Name == "Autocannon");
ship.TryEquip(ItemManager.CreateInstance(autocannonData, .5f, 1) as EquippableItem);
ship.TryEquip(ItemManager.CreateInstance(autocannonData, .5f, 1) as EquippableItem);
var cargoData = ItemData.GetAll<CargoBayData>().First(x => x.Name == "Cargo Bay 4x4");
ship.TryEquip(ItemManager.CreateInstance(cargoData, .5f, 1) as EquippableItem);
var ammoData = ItemData.GetAll<SimpleCommodityData>().First(x => x.Name == "AC2 Ammo");
ship.CargoBays.First().TryStore(ItemManager.CreateInstance(ammoData, 100));
ship.CargoBays.First().TryStore(ItemManager.CreateInstance(ammoData, 200));
//dockingCargo.TryStore(ItemManager.CreateInstance(reactorData, .5f, 1));
Dock();
@ -413,7 +438,7 @@ public class ActionGameManager : MonoBehaviour
if (_currentShip.Parent != null) return;
foreach (var entity in Zone.Entities.ToArray())
{
if (lengthsq(entity.Position - _currentShip.Position) <
if (lengthsq(entity.Position.xz - _currentShip.Position.xz) <
Settings.GameplaySettings.DockingDistance * Settings.GameplaySettings.DockingDistance)
{
var bay = entity.TryDock(_currentShip);

View file

@ -22,6 +22,11 @@ namespace UniRx.Triggers
return onBeginDrag ?? (onBeginDrag = new Subject<PointerEventData>());
}
private void OnDisable()
{
onBeginDrag = null;
}
protected override void RaiseOnCompletedOnDestroy()
{
if (onBeginDrag != null)

View file

@ -22,6 +22,11 @@ namespace UniRx.Triggers
return onDrag ?? (onDrag = new Subject<PointerEventData>());
}
private void OnDisable()
{
onDrag = null;
}
protected override void RaiseOnCompletedOnDestroy()
{
if (onDrag != null)

View file

@ -22,6 +22,11 @@ namespace UniRx.Triggers
return onEndDrag ?? (onEndDrag = new Subject<PointerEventData>());
}
private void OnDisable()
{
onEndDrag = null;
}
protected override void RaiseOnCompletedOnDestroy()
{
if (onEndDrag != null)

View file

@ -22,6 +22,11 @@ namespace UniRx.Triggers
return onPointerClick ?? (onPointerClick = new Subject<PointerEventData>());
}
private void OnDisable()
{
onPointerClick = null;
}
protected override void RaiseOnCompletedOnDestroy()
{
if (onPointerClick != null)

View file

@ -22,6 +22,11 @@ namespace UniRx.Triggers
return onPointerEnter ?? (onPointerEnter = new Subject<PointerEventData>());
}
private void OnDisable()
{
onPointerEnter = null;
}
protected override void RaiseOnCompletedOnDestroy()
{
if (onPointerEnter != null)

View file

@ -22,6 +22,11 @@ namespace UniRx.Triggers
return onPointerExit ?? (onPointerExit = new Subject<PointerEventData>());
}
private void OnDisable()
{
onPointerExit = null;
}
protected override void RaiseOnCompletedOnDestroy()
{
if (onPointerExit != null)

View file

@ -426,34 +426,25 @@ public class SectorRenderer : MonoBehaviour
foreach (var entity in EntityInstances)
{
var hullData = ItemManager.GetData(entity.Key.Hull) as HullData;
if(entity.Key is Ship ship)
if(entity.Value is ShipInstance shipInstance)
{
var shipInstance = entity.Value as ShipInstance;
var normal = _zone.GetNormal(ship.Position);
var f = new float2(normal.x, normal.z);
var fl = lengthsq(f);
if (fl > .001)
{
var fa = 1 / (1 - fl) - 1;
entity.Key.Velocity += normalize(f) * Settings.PlanetSettings.GravityStrength * fa;
}
//Debug.Log($"Normal: {normal}");
var shipRight = ship.Direction.Rotate(ItemRotation.Clockwise);
var forward = Vector3.Cross(new Vector3(shipRight.x, 0, shipRight.y), normal);
entity.Value.Transform.rotation = Quaternion.LookRotation(forward, normal);
for (int i = 0; i < shipInstance.Thrusters.Length; i++)
{
var emissionModule = shipInstance.ThrusterParticles[i].emission;
emissionModule.rateOverTimeMultiplier = shipInstance.ThrusterBaseEmission[i] * shipInstance.Thrusters[i].Axis;
}
entity.Value.Transform.rotation = ((Ship) entity.Key).Rotation;
}
foreach (var x in entity.Value.Barrels)
{
entity.Key.HardpointTransforms[x.Key] = (x.Value[0].position, x.Value[0].forward);
}
entity.Value.LookAtPoint.position = entity.Value.Transform.position + (Vector3) entity.Key.LookDirection * (entity.Key.Target != null
? (EntityInstances[entity.Key.Target].Transform.position - entity.Value.Transform.position).magnitude : 100);
var h = _zone.GetHeight(entity.Key.Position);
entity.Value.Transform.position = new Vector3(entity.Key.Position.x, h + hullData.GridOffset, entity.Key.Position.y);
entity.Value.Transform.position = entity.Key.Position;
}
var fogPos = FogCameraParent.position;

View file

@ -1,34 +0,0 @@
/* 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 System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.Mathematics;
using static Unity.Mathematics.math;
public class Aim : AgentBehavior
{
public float2 Objective;
private Thruster _thrust;
private Turning _turning;
private VelocityLimit _velocityLimit;
public Aim(ItemManager context, Entity entity, ControllerData controllerData) : base(context, entity, controllerData)
{
_velocityLimit = Entity.GetBehaviors<VelocityLimit>().FirstOrDefault();
_thrust = Entity.GetBehavior<Thruster>();
_turning = Entity.GetBehavior<Turning>();
}
public override void Update(float delta)
{
if (_thrust != null && _turning != null)
{
float2 diff = Objective - Entity.Position;
_turning.Axis = TurningInput(diff);
_thrust.Axis = 0;
}
}
}

View file

@ -14,45 +14,45 @@ public class Locomotion : AgentBehavior
public float2 Objective;
private const float TangentSensitivity = 2;
private Thruster _thrust;
private Turning _turning;
private VelocityLimit _velocityLimit;
private Thruster[] _thrusters;
private float _thrust;
public Locomotion(ItemManager context, Entity entity, ControllerData controllerData) : base(context, entity, controllerData)
{
_velocityLimit = Entity.GetBehaviors<VelocityLimit>().FirstOrDefault();
_thrust = Entity.GetBehavior<Thruster>();
_turning = Entity.GetBehavior<Turning>();
_velocityLimit = Entity.GetBehavior<VelocityLimit>();
_thrusters = entity.GetBehaviors<Thruster>()
.Where(t => t.Item.EquippableItem.Rotation == ItemRotation.Reversed)
.ToArray();
_thrust = _thrusters.Sum(t => t.Thrust);
}
public override void Update(float delta)
{
if (_thrust != null && _turning != null)
{
float2 diff = Objective - Entity.Position;
// We want to go top speed in the direction of our target
var topSpeed = _velocityLimit?.Limit ?? 1000;
float2 desiredVelocity = normalize(diff) * topSpeed;
var accelerationTime = length(desiredVelocity - Entity.Velocity) / (_thrust.Thrust / Entity.Mass);
var accelerationDistance = accelerationTime * length((desiredVelocity + Entity.Velocity) / 2);
var diff = Objective - Entity.Position.xz;
// We want to go top speed in the direction of our target
var topSpeed = _velocityLimit?.Limit ?? 1000;
float2 desiredVelocity = normalize(diff) * topSpeed;
var accelerationTime = length(desiredVelocity - Entity.Velocity) / (_thrust / Entity.Mass);
var accelerationDistance = accelerationTime * length((desiredVelocity + Entity.Velocity) / 2);
// We do not have enough space to get to full speed, use approximate maneuvering
if (accelerationDistance > length(diff))
{
float2 tangential = Entity.Velocity - dot(normalize(diff), normalize(Entity.Velocity)) * Entity.Velocity;
float2 adjustedDirection = normalize(diff) - tangential * TangentSensitivity;
_turning.Axis = TurningInput(adjustedDirection);
_thrust.Axis = 1;
}
// We have plenty of space, use exact maneuvering
else
{
var deltaV = desiredVelocity - Entity.Velocity;
_turning.Axis = TurningInput(deltaV);
_thrust.Axis = ThrustInput(deltaV);
}
}
// We do not have enough space to get to full speed, use approximate maneuvering
// if (accelerationDistance > length(diff))
// {
// float2 tangential = Entity.Velocity - dot(normalize(diff), normalize(Entity.Velocity)) * Entity.Velocity;
// float2 adjustedDirection = normalize(diff) - tangential * TangentSensitivity;
//
// _turning.Axis = TurningInput(adjustedDirection);
// _thrust.Axis = 1;
// }
// // We have plenty of space, use exact maneuvering
// else
// {
// var deltaV = desiredVelocity - Entity.Velocity;
// _turning.Axis = TurningInput(deltaV);
// _thrust.Axis = ThrustInput(deltaV);
// }
}
}

View file

@ -117,6 +117,7 @@ public abstract class PersistentBehaviorData
Union(31, typeof(CapacitorData)),
Union(32, typeof(CockpitData)),
Union(33, typeof(HeatsinkData)),
Union(34, typeof(TurretControllerData)),
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
public abstract class BehaviorData
{

View file

@ -44,7 +44,6 @@ public abstract class ControllerBase<T> : IBehavior, IController<T>, IInitializa
protected Locomotion Locomotion;
protected VelocityMatch VelocityMatch;
protected Aim Aim;
protected Func<float2> TargetPosition;
protected Func<float2> TargetVelocity;
protected bool MatchVelocity;
@ -80,7 +79,6 @@ public abstract class ControllerBase<T> : IBehavior, IController<T>, IInitializa
{
Locomotion = new Locomotion(ItemManager, Entity, _controllerData);
VelocityMatch = new VelocityMatch(ItemManager, Entity, _controllerData);
Aim = new Aim(ItemManager, Entity, _controllerData);
}
public void Initialize()
@ -128,7 +126,7 @@ public abstract class ControllerBase<T> : IBehavior, IController<T>, IInitializa
Entity.RemoveParent();
var targetPosition = TargetPosition();
var distance = length(targetPosition - Entity.Position);
var distance = length(targetPosition - Entity.Position.xz);
if (MatchVelocity)
{
var targetVelocity = TargetVelocity();
@ -203,7 +201,7 @@ public abstract class ControllerBase<T> : IBehavior, IController<T>, IInitializa
public void MoveTo(Entity entity, bool matchVelocity = true, Action onFinish = null)
{
TargetPosition = () => entity.Position;
TargetPosition = () => entity.Position.xz;
TargetVelocity = () => entity.Velocity;
MatchVelocity = matchVelocity;
_movementPhase = MovementPhase.Locomotion;

View file

@ -116,7 +116,7 @@ public class MiningController : ControllerBase<Mining>, IBehavior, IPersistentBe
private void NextAsteroid()
{
_asteroid = Zone.NearestAsteroid(Task.Asteroids, Entity.Position);
_asteroid = Zone.NearestAsteroid(Task.Asteroids, Entity.Position.xz);
Entity.SetMessage("Selecting new asteroid.");
}

View file

@ -58,7 +58,7 @@ public class MiningTool : IBehavior
var asteroidTransform = Entity.Zone.GetAsteroidTransform(AsteroidBelt, Asteroid);
if (AsteroidBelt != Guid.Empty &&
Entity.Zone.AsteroidExists(AsteroidBelt, Asteroid) &&
length(Entity.Position - asteroidTransform.xy) - asteroidTransform.w < Range)
length(Entity.Position.xz - asteroidTransform.xz) - asteroidTransform.w < Range)
{
Entity.Zone.MineAsteroid(
Entity,

View file

@ -50,7 +50,7 @@ public class PatrolController : IBehavior, IInitializableBehavior
_locomotion.Objective = Entity.Zone.GetOrbitPosition(_targetOrbit);
_locomotion.Update(delta);
if(length(Entity.Position - _locomotion.Objective) < _data.TargetDistance)
if(length(Entity.Position.xz - _locomotion.Objective) < _data.TargetDistance)
RandomTarget();
return true;

View file

@ -74,7 +74,7 @@ public class ResourceScanner : IBehavior, IAlwaysUpdatedBehavior
{
if(Asteroid > -1 &&
Asteroid < beltData.Asteroids.Length &&
length(Entity.Position - Entity.Zone.GetAsteroidTransform(ScanTarget, Asteroid).xy) < Range)
length(Entity.Position.xz - Entity.Zone.GetAsteroidTransform(ScanTarget, Asteroid).xy) < Range)
{
_scanTime += delta;
if (_scanTime > ScanDuration)
@ -88,7 +88,7 @@ public class ResourceScanner : IBehavior, IAlwaysUpdatedBehavior
}
else
{
if(length(Entity.Position - Entity.Zone.GetOrbitPosition(planetData.Orbit)) < Range)
if(length(Entity.Position.xz - Entity.Zone.GetOrbitPosition(planetData.Orbit)) < Range)
{
_scanTime += delta;
if (_scanTime > ScanDuration)

View file

@ -109,8 +109,8 @@ public class SurveyController : ControllerBase<Survey>, IBehavior, IPersistentBe
private void NextPlanet()
{
var planets = Task.Planets.Select(id => Zone.Planets[id]);
var nearestPlanet = planets.MinBy(p => lengthsq(Entity.Position - GetPosition(p)));
_asteroid = nearestPlanet is AsteroidBeltData ? Zone.NearestAsteroid(nearestPlanet.ID, Entity.Position) : -1;
var nearestPlanet = planets.MinBy(p => lengthsq(Entity.Position.xz - GetPosition(p)));
_asteroid = nearestPlanet is AsteroidBeltData ? Zone.NearestAsteroid(nearestPlanet.ID, Entity.Position.xz) : -1;
_targetPlanet = nearestPlanet.ID;
}
@ -118,7 +118,7 @@ public class SurveyController : ControllerBase<Survey>, IBehavior, IPersistentBe
{
if (planet is AsteroidBeltData)
{
if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position);
if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position.xz);
return Zone.GetAsteroidTransform(planet.ID, asteroid).xy;
}
return Zone.GetOrbitPosition(planet.Orbit);
@ -128,7 +128,7 @@ public class SurveyController : ControllerBase<Survey>, IBehavior, IPersistentBe
{
if (planet is AsteroidBeltData)
{
if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position);
if(asteroid == -1) asteroid = Zone.NearestAsteroid(planet.ID, Entity.Position.xz);
return Zone.GetAsteroidVelocity(planet.ID, asteroid);
}
return Zone.GetOrbitVelocity(planet.Orbit);

View file

@ -65,7 +65,7 @@ public class TowingController : ControllerBase<StationTowing>, IBehavior, IPersi
MoveTo(() =>
{
var orbitParent = Zone.GetOrbitPosition(Task.OrbitParent);
var parentToUs = Entity.Position - orbitParent;
var parentToUs = Entity.Position.xz - orbitParent;
return orbitParent + normalize(parentToUs) * Task.OrbitDistance;
}, () => Zone.GetOrbitVelocity(Task.OrbitParent), OnDelivery);
}
@ -76,7 +76,7 @@ public class TowingController : ControllerBase<StationTowing>, IBehavior, IPersi
Entity.SetMessage("Target delivered. Returning Home.");
var orbit = Zone.CreateOrbit(Task.OrbitParent, Entity.Position);
var orbit = Zone.CreateOrbit(Task.OrbitParent, Entity.Position.xz);
Task.Station.OrbitData = orbit.ID;
FinishTask();

View file

@ -20,9 +20,9 @@ public class Trigger : IBehavior
{
private TriggerData _data;
private Entity Entity { get; }
private EquippedItem Item { get; }
private ItemManager Context { get; }
public Entity Entity { get; }
public EquippedItem Item { get; }
public ItemManager Context { get; }
public BehaviorData Data => _data;

View file

@ -0,0 +1,93 @@
/* 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 System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class TurretControllerData : BehaviorData
{
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
{
return new TurretController(context, this, entity, item);
}
}
public class TurretController : IBehavior
{
private TurretControllerData _data;
private Dictionary<Trigger, WeaponData> _triggers = new Dictionary<Trigger, WeaponData>();
public Entity EquippedEntity { get; }
public EquippedItem Item { get; }
public ItemManager Context { get; }
public BehaviorData Data => _data;
public TurretController(ItemManager context, TurretControllerData data, Entity equippedEntity, EquippedItem item)
{
Context = context;
_data = data;
EquippedEntity = equippedEntity;
Item = item;
var weapons = equippedEntity.Equipment.Where(e => e.Behaviors.Any(b => b.Data is WeaponData));
foreach (var weapon in weapons)
{
CheckWeapon(item);
}
equippedEntity.Equipment.ObserveAdd().Subscribe(add => CheckWeapon(add.Value));
equippedEntity.Equipment.ObserveRemove().Subscribe(remove =>
{
foreach (var bg in remove.Value.BehaviorGroups)
if (_triggers.ContainsKey(bg.Trigger))
_triggers.Remove(bg.Trigger);
});
}
private void CheckWeapon(EquippedItem item)
{
foreach (var bg in item.BehaviorGroups)
{
if (bg.Trigger != null)
{
foreach (var b in bg.Behaviors)
{
if(b.Data is WeaponData weaponData)
_triggers.Add(bg.Trigger, weaponData);
}
}
}
}
public bool Update(float delta)
{
if (EquippedEntity.Target != null)
{
var diff = EquippedEntity.Target.Position - EquippedEntity.Position;
EquippedEntity.LookDirection = normalize(diff);
var dist = length(diff);
foreach (var x in _triggers)
{
if (Context.Evaluate(x.Value.Range, x.Key.Item.EquippableItem, EquippedEntity) > dist &&
dot(EquippedEntity.HardpointTransforms[EquippedEntity.Hardpoints[x.Key.Item.Position.x, x.Key.Item.Position.y]].direction,
EquippedEntity.LookDirection) > .9f)
{
x.Key.Pull();
}
}
}
else
{
EquippedEntity.Target = EquippedEntity.Zone.Entities.FirstOrDefault(e => e is Ship);
}
return true;
}
}

View file

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

View file

@ -23,7 +23,7 @@ public abstract class Entity
public Zone Zone;
public EquippableItem Hull;
public float2 Position;
public float3 Position;
public float2 Direction = float2(0,1);
public float2 Velocity;
@ -49,6 +49,7 @@ public abstract class Entity
public readonly Dictionary<string, float> Messages = new Dictionary<string, float>();
public readonly Dictionary<object, float> VisibilitySources = new Dictionary<object, float>();
public readonly Dictionary<HardpointData, (float3 position, float3 direction)> HardpointTransforms = new Dictionary<HardpointData, (float3 position, float3 direction)>();
public readonly List<EquippedItem>[] TriggerGroups;
@ -337,9 +338,9 @@ public abstract class Entity
if (!ItemFits(itemData, hullData, item, hullCoord)) return false;
EquippedItem equippedItem;
if (itemData.HardpointType == HardpointType.Tool || itemData.HardpointType == HardpointType.Thermal)
{
EquippedItem equippedItem;
if(itemData is CargoBayData)
{
if (itemData is DockingBayData)
@ -358,34 +359,25 @@ public abstract class Entity
equippedItem = new EquippedItem(ItemManager, item, hullCoord, this);
Equipment.Add(equippedItem);
}
foreach (var i in itemData.Shape.Coordinates)
{
var occupiedCoord = hullCoord + itemData.Shape.Rotate(i, item.Rotation);
(itemData.HardpointType == HardpointType.Thermal ? ThermalOccupancy : GearOccupancy)[occupiedCoord.x, occupiedCoord.y] = equippedItem;
}
Mass += itemData.Mass;
_orderedEquipment = Equipment.OrderBy(x => x.SortPosition).ToArray();
return true;
}
else
{
var equippedItem = new EquippedItem(ItemManager, item, hullCoord, this);
equippedItem = new EquippedItem(ItemManager, item, hullCoord, this);
Equipment.Add(equippedItem);
foreach (var i in itemData.Shape.Coordinates)
{
var occupiedCoord = hullCoord + itemData.Shape.Rotate(i, item.Rotation);
ThermalMass[occupiedCoord.x, occupiedCoord.y] += ItemManager.GetThermalMass(item) / itemData.Shape.Coordinates.Length;
Conductivity[occupiedCoord.x, occupiedCoord.y] *= itemData.Conductivity;
(itemData.HardpointType == HardpointType.Thermal ? ThermalOccupancy : GearOccupancy)[occupiedCoord.x, occupiedCoord.y] = equippedItem;
}
Mass += itemData.Mass;
_orderedEquipment = Equipment.OrderBy(x => x.SortPosition).ToArray();
return true;
}
foreach (var i in itemData.Shape.Coordinates)
{
var occupiedCoord = hullCoord + itemData.Shape.Rotate(i, item.Rotation);
// TODO: Track thermal mass of cargo bay contents as reactive property
ThermalMass[occupiedCoord.x, occupiedCoord.y] += ItemManager.GetThermalMass(item) / itemData.Shape.Coordinates.Length;
Conductivity[occupiedCoord.x, occupiedCoord.y] *= itemData.Conductivity;
(itemData.HardpointType == HardpointType.Thermal ? ThermalOccupancy : GearOccupancy)[occupiedCoord.x, occupiedCoord.y] = equippedItem;
}
Mass += itemData.Mass;
_orderedEquipment = Equipment.OrderBy(x => x.SortPosition).ToArray();
return true;
}
public EquippedDockingBay TryDock(Ship ship)
@ -553,6 +545,7 @@ public abstract class Entity
Position = Parent.Position;
Velocity = Parent.Velocity;
}
else Position.y = Zone.GetHeight(Position.xz) + hullData.GridOffset;
}
public void SetMessage(string message)

View file

@ -22,7 +22,7 @@ public class OrbitalEntity : Entity
{
if (OrbitData != Guid.Empty)
{
Position = Zone.GetOrbitPosition(OrbitData);
Position.xz = Zone.GetOrbitPosition(OrbitData);
Velocity = Zone.GetOrbitVelocity(OrbitData);
}

View file

@ -11,6 +11,7 @@ using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using quaternion = Unity.Mathematics.quaternion;
[MessagePackObject]
public class Ship : Entity
@ -31,6 +32,8 @@ public class Ship : Entity
private Thruster[] _leftThrusters;
private Thruster[] _clockwiseThrusters;
private Thruster[] _counterClockwiseThrusters;
public quaternion Rotation { get; private set; }
protected override void OnActivate()
{
@ -49,7 +52,7 @@ public class Ship : Entity
public override void Update(float delta)
{
Position += Velocity * delta;
Position.xz += Velocity * delta;
if (_active)
{
foreach (var thruster in _allThrusters) thruster.Axis = 0;
@ -65,6 +68,18 @@ public class Ship : Entity
foreach (var thruster in _clockwiseThrusters) thruster.Axis += deltaRot;
foreach (var thruster in _counterClockwiseThrusters) thruster.Axis += -deltaRot;
}
var normal = Zone.GetNormal(Position.xz);
var f = new float2(normal.x, normal.z);
var fl = lengthsq(f);
if (fl > .001)
{
var fa = 1 / (1 - fl) - 1;
Velocity += normalize(f) * Zone.Settings.GravityStrength * fa;
}
var shipRight = Direction.Rotate(ItemRotation.Clockwise);
var forward = cross(float3(shipRight.x, 0, shipRight.y), normal);
Rotation = quaternion.LookRotation(forward, normal);
base.Update(delta);
}
}

View file

@ -25,7 +25,7 @@ public class Zone
private HashSet<Guid> _updatedOrbits = new HashSet<Guid>();
private PlanetSettings _settings;
public PlanetSettings Settings;
private float _time;
private Random _random;
@ -34,12 +34,12 @@ public class Zone
public Zone(PlanetSettings settings, ZonePack pack)
{
Data = pack.Data;
_settings = settings;
Settings = settings;
_random = new Random(Convert.ToUInt32(abs(Data.ID.GetHashCode())));
foreach (var orbit in pack.Orbits)
{
Orbits.Add(orbit.ID, new Orbit(_settings, orbit));
Orbits.Add(orbit.ID, new Orbit(Settings, orbit));
}
foreach (var planet in pack.Planets)
@ -77,7 +77,7 @@ public class Zone
public void AddOrbit(OrbitData orbit)
{
Orbits.Add(orbit.ID, new Orbit(_settings, orbit));
Orbits.Add(orbit.ID, new Orbit(Settings, orbit));
}
public void Update(float time, float deltaTime)
@ -194,14 +194,14 @@ public class Zone
if(belt.RespawnTimers.ContainsKey(i)) size = 0;
else if (belt.Damage.ContainsKey(i))
{
var asteroidHitpoints = _settings.AsteroidHitpoints.Evaluate(beltData.Asteroids[i].Size);
var asteroidHitpoints = Settings.AsteroidHitpoints.Evaluate(beltData.Asteroids[i].Size);
var damage = (asteroidHitpoints - belt.Damage[i]) / asteroidHitpoints;
size = _settings.AsteroidSize.Evaluate(damage * beltData.Asteroids[i].Size);
size = Settings.AsteroidSize.Evaluate(damage * beltData.Asteroids[i].Size);
}
else size = _settings.AsteroidSize.Evaluate(beltData.Asteroids[i].Size);
else size = Settings.AsteroidSize.Evaluate(beltData.Asteroids[i].Size);
belt.Transforms[i] = float4(
OrbitData.Evaluate((float) frac(_time / _settings.OrbitPeriod.Evaluate(beltData.Asteroids[i].Distance) +
OrbitData.Evaluate((float) frac(_time / Settings.OrbitPeriod.Evaluate(beltData.Asteroids[i].Distance) +
beltData.Asteroids[i].Phase)) * beltData.Asteroids[i].Distance + orbitPosition,
(float) (_time * beltData.Asteroids[i].RotationSpeed % (PI * 2)), size);
}
@ -212,7 +212,7 @@ public class Zone
var parentPosition = GetOrbitPosition(parent);
var delta = position - parentPosition;
var distance = length(delta);
var period = _settings.OrbitPeriod.Evaluate(distance);
var period = Settings.OrbitPeriod.Evaluate(distance);
var phase = atan2(delta.y, delta.x) / (PI * 2);
var currentPhase = frac(_time / period);
var storedPhase = (float) frac(phase - currentPhase);
@ -224,7 +224,7 @@ public class Zone
Parent = parent,
Phase = storedPhase
};
Orbits.Add(orbit.ID, new Orbit(_settings, orbit));
Orbits.Add(orbit.ID, new Orbit(Settings, orbit));
return orbit;
}
@ -235,7 +235,7 @@ public class Zone
var asteroidTransform = belt.Transforms[asteroid];
var size = beltData.Asteroids[asteroid].Size;
var asteroidHitpoints = _settings.AsteroidHitpoints.Evaluate(size);
var asteroidHitpoints = Settings.AsteroidHitpoints.Evaluate(size);
if (!belt.Damage.ContainsKey(asteroid))
belt.Damage[asteroid] = 0;
@ -247,7 +247,7 @@ public class Zone
if (belt.Damage[asteroid] > asteroidHitpoints)
{
belt.RespawnTimers[asteroid] = _settings.AsteroidRespawnTime.Evaluate(size);
belt.RespawnTimers[asteroid] = Settings.AsteroidRespawnTime.Evaluate(size);
belt.Damage.Remove(asteroid);
belt.MiningAccumulator.Remove((miner, asteroid));
return;
@ -255,7 +255,7 @@ public class Zone
var resourceCount = beltData.Resources.Sum(x => x.Value);
var resource = beltData.Resources.MaxBy(x => pow(x.Value, 1f / penetration) * _random.NextFloat());
if (efficiency * _random.NextFloat() * belt.MiningAccumulator[(miner, asteroid)] * resourceCount / _settings.MiningDifficulty > 1)
if (efficiency * _random.NextFloat() * belt.MiningAccumulator[(miner, asteroid)] * resourceCount / Settings.MiningDifficulty > 1)
{
belt.MiningAccumulator.Remove((miner, asteroid));
// var newSimpleCommodity = new SimpleCommodity
@ -269,7 +269,7 @@ public class Zone
}
public float GetHeight(float2 position)
{
float result = -PowerPulse(length(position)/(Data.Radius*2), _settings.ZoneDepthExponent) * _settings.ZoneDepth;
float result = -PowerPulse(length(position)/(Data.Radius*2), Settings.ZoneDepthExponent) * Settings.ZoneDepth;
foreach (var body in PlanetInstances.Values)
{
var p = (position - body.Orbit.Position); //GetOrbitPosition(body.BodyData.Orbit)
@ -287,7 +287,7 @@ public class Zone
if(distSqr < waveRadius*waveRadius)
{
var depth = gas.GravityWavesDepth.Value;
var frequency = _settings.WaveFrequency.Evaluate(body.BodyData.Mass.Value);
var frequency = Settings.WaveFrequency.Evaluate(body.BodyData.Mass.Value);
var speed = gas.GravityWavesSpeed.Value;
result -= RadialWaves(sqrt(distSqr) / waveRadius, 8, 1.25f, frequency, _time * speed) * depth;
}
@ -301,7 +301,7 @@ public class Zone
{
var normal = GetNormal(position);
var f = new float2(normal.x, normal.z);
return f * _settings.GravityStrength * lengthsq(f);// * Mathf.Abs(GetHeight(position));
return f * Settings.GravityStrength * lengthsq(f);// * Mathf.Abs(GetHeight(position));
}
public static float PowerPulse(float x, float exponent)

View file

@ -12,6 +12,7 @@ using UnityEngine.UI;
public class ConfirmationDialog : PropertiesPanel
{
public ClickCatcher CancelClickCatcher;
public GameObject ButtonGroup;
public Button Cancel;
public Button Confirm;
@ -42,6 +43,7 @@ public class ConfirmationDialog : PropertiesPanel
go.SetActive(true);
go.transform.SetSiblingIndex(Title.transform.GetSiblingIndex() + 1);
};
gameObject.SetActive(false);
}
private void End()
@ -52,10 +54,16 @@ public class ConfirmationDialog : PropertiesPanel
public void Show(Action onConfirm = null, Action onCancel = null)
{
gameObject.SetActive(true);
_onConfirm = onConfirm;
Confirm.gameObject.SetActive(onConfirm!=null);
_onCancel = onCancel;
Cancel.gameObject.SetActive(onCancel!=null);
ButtonGroup.SetActive(onConfirm!=null && onCancel!=null);
transform.position = Mouse.current.position.ReadValue();
CancelClickCatcher.gameObject.SetActive(true);
}

View file

@ -388,16 +388,19 @@ public class InventoryPanel : MonoBehaviour
}
}
public void DropItem(ItemInstance item, int2 position)
public bool DropItem(ItemInstance item, int2 position)
{
if (_displayedEntity != null && item is EquippableItem equippableItem)
{
_displayedEntity.TryEquip(equippableItem, position);
return _displayedEntity.TryEquip(equippableItem, position);
}
else
if(_displayedCargo != null)
{
_displayedCargo?.TryStore(item, position);
return _displayedCargo.TryStore(item, position);
}
return false;
}
public UniRx.IObservable<InventoryEventData> OnClickAsObservable() => _onClick ?? (_onClick = new Subject<InventoryEventData>());

View file

@ -201,6 +201,7 @@
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Net\Cursor.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Ast\August.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Ast\Maxval.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Heatsink.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\LiteNetLib\BaseChannel.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\LiteNetLib\ReliableChannel.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Proto\QueryType.cs" />
@ -300,7 +301,6 @@
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Cooldown.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\LinqFaster\First.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Ast\Group.cs" />
<Compile Include="Assets\Scripts\ServerShared\Agents\Aim.cs" />
<Compile Include="Assets\Scripts\ServerShared\PlayerData.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Net\Clustering\HostEntry.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver.Linq\WhereClauseParsers\SubQueryVisitor\AllSubQueryVisitor.cs" />
@ -326,6 +326,7 @@
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Model\EmergencyRepair.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\EnergyDraw.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\LinqFaster\WhereSelect.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\ConstantWeapon.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Ast\Max.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Ast\Sample.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Radiator.cs" />
@ -383,6 +384,7 @@
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Ast\Min.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\LiteNetLib\NetUtils.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver.Linq\WhereClauseParsers\SubQueryVisitor\ISubQueryVisitor.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\TurretController.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\LinqFaster\Skip.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\ReqlUserError.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\RethinkDb.Driver\Generated\Ast\IndexDrop.cs" />
@ -512,8 +514,6 @@
<Compile Include="Assets\Scripts\ServerShared\Agents\Mining.cs" />
<Compile Include="Assets\Scripts\ServerShared\ZoneData.cs" />
<Compile Include="Assets\Scripts\ServerShared\NIH\LinqFaster\Max.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\Heatsink.cs" />
<Compile Include="Assets\Scripts\ServerShared\Behaviors\ConstantWeapon.cs" />
<None Include="Assets\Scripts\ServerShared\NIH\LinqFaster\readme.txt" />
<None Include="Assets\Scripts\ServerShared\Economy.Shared.Unity.asmdef" />
<Reference Include="Unity.Mathematics">