Skip to content

Commit

Permalink
More Work on turrets
Browse files Browse the repository at this point in the history
Various bug fixes
Improvements to Phos core ai
  • Loading branch information
Amatsugu committed Jun 30, 2020
1 parent 6594ed6 commit 2039cb2
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 90 deletions.
8 changes: 8 additions & 0 deletions Assets/Build.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ MonoBehaviour:
offshorePlatformMesh: {fileID: 0}
icon: {fileID: 0}
faction: 1
maxHealth: 100
maxHealth: 1000
healthBar: {fileID: 11400000, guid: 64264ba37fb009140b7237d68e6e4e60, type: 2}
healthBarOffset:
x: 0
Expand Down
84 changes: 57 additions & 27 deletions Assets/Scenes/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ RectTransform:
m_Children:
- {fileID: 2033154686}
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand Down Expand Up @@ -1914,7 +1914,7 @@ Transform:
m_LocalScale: {x: 20, y: 50, z: 20}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &170076733
GameObject:
Expand Down Expand Up @@ -2497,7 +2497,7 @@ Transform:
m_Children:
- {fileID: 574622351}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &196126402
MonoBehaviour:
Expand Down Expand Up @@ -5994,7 +5994,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
--- !u!114 &534669907
MonoBehaviour:
Expand Down Expand Up @@ -6369,7 +6369,7 @@ RectTransform:
- {fileID: 491449966}
- {fileID: 1802015228}
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand Down Expand Up @@ -6772,6 +6772,49 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 557116066}
m_CullTransparentMesh: 0
--- !u!1 &574144031
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 574144033}
- component: {fileID: 574144032}
m_Layer: 0
m_Name: Steam
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &574144032
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 574144031}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ef4bffeda13d7a748973ff9204401c07, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &574144033
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 574144031}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &574622350
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -6988,7 +7031,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &612722465
GameObject:
Expand Down Expand Up @@ -8170,7 +8213,7 @@ RectTransform:
- {fileID: 1551769501}
- {fileID: 1723077716}
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand Down Expand Up @@ -10040,7 +10083,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1040115290
GameObject:
Expand Down Expand Up @@ -10931,7 +10974,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1189289495
GameObject:
Expand Down Expand Up @@ -12424,7 +12467,6 @@ GameObject:
- component: {fileID: 1369379225}
- component: {fileID: 1369379227}
- component: {fileID: 1369379226}
- component: {fileID: 1369379228}
m_Layer: 8
m_Name: _GLOBAL
m_TagString: Untagged
Expand Down Expand Up @@ -12501,25 +12543,13 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
statusUI: {fileID: 53534244}
baseNameUI: {fileID: 0}
mainCamera: {fileID: 0}
cameraController: {fileID: 0}
baseNameUI: {fileID: 636739581}
mainCamera: {fileID: 534669904}
cameraController: {fileID: 534669909}
tileDatabase: {fileID: 11400000, guid: f973b4e22fe4f24429859b2a7732f9b3, type: 2}
unitDatabase: {fileID: 11400000, guid: 257b8032a7f89164fa7302037505cacf, type: 2}
buildingDatabase: {fileID: 11400000, guid: 0916d0c03da4488419a09b66e76cac63, type: 2}
rarityColors: {fileID: 11400000, guid: ae4d7de8b5bf37241b9237424a88b932, type: 2}
--- !u!114 &1369379228
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1369379222}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ef4bffeda13d7a748973ff9204401c07, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1381702101
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -12866,7 +12896,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -443.00003}
m_AnchoredPosition: {x: 0, y: -443}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1427279150
Expand Down Expand Up @@ -17538,7 +17568,7 @@ RectTransform:
m_Children:
- {fileID: 1740703293}
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand Down
51 changes: 47 additions & 4 deletions Assets/Scenes/MainMenu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 19.842604, g: 75.43801, b: 151.95778, a: 1}
m_IndirectSpecularColor: {r: 19.842604, g: 75.43801, b: 151.91823, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -668,6 +668,49 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &379879225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 379879227}
- component: {fileID: 379879226}
m_Layer: 0
m_Name: Steam
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &379879226
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 379879225}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ef4bffeda13d7a748973ff9204401c07, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &379879227
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 379879225}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &458254135
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -699,7 +742,7 @@ Transform:
- {fileID: 583560981}
- {fileID: 1805130590}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &458254137
MonoBehaviour:
Expand Down Expand Up @@ -1248,7 +1291,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
Expand Down Expand Up @@ -1807,7 +1850,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
--- !u!1 &1805130585
GameObject:
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Effects/LineFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public static void UpdateStaticLine(EntityCommandBuffer.Concurrent cmb, int inde
cmb.SetComponent(index, e, new Rotation { Value = r });
}

public static (float3 translation, float3 scale, Quaternion rotation) PrepareLine(float3 a, float3 b, float thiccness)
public static (float3 translation, float3 scale, quaternion rotation) PrepareLine(float3 a, float3 b, float thiccness)
{
var dir = b - a;
return (a, new float3(thiccness, thiccness, Vector3.Magnitude(dir)), Quaternion.LookRotation(dir, Vector3.up));
return (a, new float3(thiccness, thiccness, math.length(dir)), quaternion.LookRotationSafe(dir, math.up()));
}
}
}
16 changes: 12 additions & 4 deletions Assets/Scripts/Game Logic/Systems/Combat/PhosCoreSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ protected override void OnUpdate()

private void SimulateAI()
{
Entities.WithNone<Disabled>().ForEach((Entity e, ref PhosCore core, ref PhosCoreData data, ref Translation t, ref FactionId faction) =>
Entities.WithNone<BuildingOffTag>().ForEach((Entity e, ref PhosCore core, ref PhosCoreData data, ref Translation t, ref FactionId faction) =>
{
var baseAngle = (((float)Time.ElapsedTime % core.spinRate) / core.spinRate) * (math.PI * 2); //Angle of the ring
var baseAngle = (((float)Time.ElapsedTime % core.spinRate) / core.spinRate) * (math.PI * 2); //Rotation of the ring
PostUpdateCommands.SetComponent(data.ring, new Rotation { Value = quaternion.AxisAngle(Vector3.up, baseAngle + (math.PI * 2) / 12f) });
if (core.nextVolleyTime <= Time.ElapsedTime)
{
Expand Down Expand Up @@ -121,6 +121,8 @@ private void FireBurst(float3 startPos, float baseAngle, float3 target, PhosCore

private void FirePorjectile(float3 startPos, float angle, float3 target, PhosCore core, double targetTime, FactionId team)
{
if (target.Equals(0))
return;
var dir = math.rotate(quaternion.RotateY(angle), Vector3.forward);
var pos = startPos + (dir * 2.9f) + new float3(0, 4, 0);
dir.y = .4f;
Expand Down Expand Up @@ -148,24 +150,29 @@ private struct PhosProjectileJob : IJobChunk //IJobForEachWithEntity<PhosProject
[ReadOnly] public ArchetypeChunkComponentType<PhosProjectile> projectileType;
public ArchetypeChunkComponentType<PhysicsVelocity> velocityType;
[ReadOnly] public ArchetypeChunkComponentType<Translation> translationType;
[ReadOnly] public ArchetypeChunkEntityType entityType;
public EntityCommandBuffer.Concurrent CMB;

public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var vel = chunk.GetNativeArray(velocityType);
var proj = chunk.GetNativeArray(projectileType);
var trans = chunk.GetNativeArray(translationType);
var entities = chunk.GetNativeArray(entityType);
for (int i = 0; i < chunk.Count; i++)
{
if (curTime < proj[i].targetTime)
continue;
var v = vel[i];
v.Linear = math.normalize(proj[i].target - trans[i].Value) * proj[i].flightSpeed;
vel[i] = v;
CMB.RemoveComponent<PhosProjectile>(chunkIndex, entities[i]);
}
}
}

private EntityQuery entityQuery;
private EndSimulationEntityCommandBufferSystem endSimulation;

protected override void OnCreate()
{
Expand All @@ -185,6 +192,7 @@ protected override void OnCreate()
}
};
entityQuery = GetEntityQuery(desc);
endSimulation = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
}

protected override JobHandle OnUpdate(JobHandle inputDeps)
Expand All @@ -195,10 +203,10 @@ protected override JobHandle OnUpdate(JobHandle inputDeps)
projectileType = GetArchetypeChunkComponentType<PhosProjectile>(true),
velocityType = GetArchetypeChunkComponentType<PhysicsVelocity>(false),
translationType = GetArchetypeChunkComponentType<Translation>(true),
CMB = endSimulation.CreateCommandBuffer().ToConcurrent(),
entityType = GetArchetypeChunkEntityType()
};
////inputDeps = job.Schedule(this, inputDeps);
inputDeps = job.ScheduleParallel(entityQuery, inputDeps);
inputDeps.Complete();
return inputDeps;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public struct ProjectileCollisionJob : ICollisionEventsJob

public void Execute(CollisionEvent collisionEvent)
{
if (damage.HasComponent(collisionEvent.Entities.EntityA))
DealDamage(collisionEvent.Entities.EntityA, collisionEvent.Entities.EntityB);
else if (damage.HasComponent(collisionEvent.Entities.EntityB))
DealDamage(collisionEvent.Entities.EntityB, collisionEvent.Entities.EntityA);
if (damage.HasComponent(collisionEvent.EntityA))
DealDamage(collisionEvent.EntityA, collisionEvent.EntityB);
else if (damage.HasComponent(collisionEvent.EntityB))
DealDamage(collisionEvent.EntityB, collisionEvent.EntityA);
}

private void DealDamage(Entity src, Entity tgt)
Expand Down

0 comments on commit 2039cb2

Please sign in to comment.