This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
187 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Amatsugu.Phos.Tiles; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Unity.Entities; | ||
using Unity.Mathematics; | ||
using Unity.Transforms; | ||
|
||
namespace Amatsugu.Phos.ECS | ||
{ | ||
public class TurretSystem : ComponentSystem | ||
{ | ||
protected override void OnUpdate() | ||
{ | ||
Entities.ForEach((Entity e, ref Turret t, ref Translation pos, ref AttackSpeed speed, ref AttackRange range) => | ||
{ | ||
var r = EntityManager.GetComponentData<Rotation>(t.Head).Value; | ||
r = math.mul(math.normalizesafe(r), quaternion.AxisAngle(math.up(), 10 * Time.DeltaTime)); | ||
EntityManager.SetComponentData(t.Head, new Rotation | ||
{ | ||
Value = r | ||
}); | ||
|
||
var fwd = math.rotate(r, new float3(0, 0, 1)); | ||
|
||
|
||
|
||
}); | ||
} | ||
} | ||
|
||
public struct Turret : IComponentData | ||
{ | ||
internal Entity Head; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Scripts/Game Logic/Systems/Combat/TurretSystem.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
Assets/Scripts/Map/Tiles/MappedTiles/Buildings/TurretTile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using Amatsugu.Phos.ECS; | ||
using Amatsugu.Phos.TileEntities; | ||
using Amatsugu.Phos.UnitComponents; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Unity.Entities; | ||
using Unity.Rendering; | ||
|
||
using UnityEngine; | ||
|
||
namespace Amatsugu.Phos.Tiles | ||
{ | ||
public class TurretTile : BuildingTile | ||
{ | ||
public TurretTileEntity turretTile; | ||
|
||
private Entity _turretHead; | ||
|
||
public TurretTile(HexCoords coords, float height, Map map, TurretTileEntity tInfo) : base(coords, height, map, tInfo) | ||
{ | ||
turretTile = tInfo; | ||
} | ||
|
||
public override void RenderBuilding() | ||
{ | ||
base.RenderBuilding(); | ||
var e = GetBuildingEntity(); | ||
_turretHead = turretTile.turretHead.Instantiate(SurfacePoint); | ||
Map.EM.AddComponentData(e, new Turret | ||
{ | ||
Head = _turretHead | ||
}); | ||
} | ||
|
||
|
||
protected override void PrepareEntity() | ||
{ | ||
base.PrepareEntity(); | ||
var e = GetBuildingEntity(); | ||
Map.EM.AddComponentData(e, new AttackRange | ||
{ | ||
Value = turretTile.attackRange, | ||
ValueSq = turretTile.attackRange * turretTile.attackRange | ||
}); | ||
Map.EM.AddComponentData(e, new AttackSpeed | ||
{ | ||
Value = turretTile.fireRate | ||
}); | ||
} | ||
|
||
public override void OnHide() | ||
{ | ||
base.OnHide(); | ||
Map.EM.AddComponent<FrozenRenderSceneTag>(_turretHead); | ||
} | ||
|
||
public override void OnShow() | ||
{ | ||
base.OnShow(); | ||
Map.EM.RemoveComponent<FrozenRenderSceneTag>(_turretHead); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Scripts/Map/Tiles/MappedTiles/Buildings/TurretTile.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
Assets/Scripts/Map/Tiles/TileInfo/Buildings/TurretTileEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Amatsugu.Phos.Tiles; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Unity.Entities; | ||
|
||
using UnityEngine; | ||
|
||
namespace Amatsugu.Phos.TileEntities | ||
{ | ||
[CreateAssetMenu(menuName = "Map Asset/Tile/Building/Turret")] | ||
public class TurretTileEntity : BuildingTileEntity | ||
{ | ||
[Header("Turret")] | ||
public float fireRate; | ||
public float damage; | ||
public float attackRange; | ||
public ProjectileMeshEntity projectileMesh; | ||
public MeshEntityRotatable turretHead; | ||
|
||
public override Tile CreateTile(Map map, HexCoords pos, float height) | ||
{ | ||
return new TurretTile(pos, height, map, this); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Scripts/Map/Tiles/TileInfo/Buildings/TurretTileEntity.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.