-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from kbatbouta/development-cctv-turret
Development cctv turret
- Loading branch information
Showing
47 changed files
with
1,099 additions
and
144 deletions.
There are no files selected for viewing
Binary file not shown.
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Defs> | ||
<DesignationCategoryDef> | ||
<defName>Intelligences</defName> | ||
<label>Intelligences</label> | ||
<description>Automated Camera and Intels building can be found here.</description> | ||
<order>454</order> | ||
<specialDesignatorClasses> | ||
<li>Designator_Cancel</li> | ||
<li>Designator_Deconstruct</li> | ||
</specialDesignatorClasses> | ||
</DesignationCategoryDef> | ||
</Defs> |
Large diffs are not rendered by default.
Oops, something went wrong.
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,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Defs> | ||
|
||
<ResearchProjectDef> | ||
<defName>TribalCCTV</defName> | ||
<label>Animal Warning System</label> | ||
<description>A Trained parrot in the nest.</description> | ||
<baseCost>450</baseCost> | ||
<techLevel>Medieval</techLevel> | ||
<researchViewX>0</researchViewX> | ||
<researchViewY>1</researchViewY> | ||
<tab>cai5000</tab> | ||
</ResearchProjectDef> | ||
|
||
<ResearchProjectDef> | ||
<defName>IndustrialCCTV</defName> | ||
<label>Automated Camera System</label> | ||
<description>An automated camera keep sight of an area.</description> | ||
<baseCost>600</baseCost> | ||
<techLevel>Industrial</techLevel> | ||
<prerequisites> | ||
<li>TribalCCTV</li> | ||
</prerequisites> | ||
<researchViewX>1</researchViewX> | ||
<researchViewY>1</researchViewY> | ||
<tab>cai5000</tab> | ||
</ResearchProjectDef> | ||
|
||
<ResearchProjectDef> | ||
<defName>SpacerCCTV</defName> | ||
<label>Advanced Light Sensor</label> | ||
<description>New version of automated camera for</description> | ||
<baseCost>1850</baseCost> | ||
<requiredResearchBuilding>HiTechResearchBench</requiredResearchBuilding> | ||
<requiredResearchFacilities> | ||
<li>MultiAnalyzer</li> | ||
</requiredResearchFacilities> | ||
<techLevel>Spacer</techLevel> | ||
<prerequisites> | ||
<li>MicroelectronicsBasics</li> | ||
<li>IndustrialCCTV</li> | ||
</prerequisites> | ||
<researchViewX>2</researchViewX> | ||
<researchViewY>1</researchViewY> | ||
<tab>cai5000</tab> | ||
</ResearchProjectDef> | ||
|
||
</Defs> |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Defs> | ||
<ResearchTabDef> | ||
<defName>cai5000</defName> | ||
<label>CombatAI5000</label> | ||
</ResearchTabDef> | ||
</Defs> |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
using CombatAI.Comps; | ||
namespace CombatAI | ||
{ | ||
public abstract class CCTVTopAnimator | ||
{ | ||
public ThingComp_CCTVTop comp; | ||
|
||
public CCTVTopAnimator(ThingComp_CCTVTop comp) | ||
{ | ||
this.comp = comp; | ||
} | ||
|
||
public abstract float CurRotation | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
public abstract void Tick(); | ||
} | ||
} |
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,49 @@ | ||
using System; | ||
using CombatAI.Comps; | ||
using Verse; | ||
namespace CombatAI | ||
{ | ||
public class CCTVTopAnimator_Periodic : CCTVTopAnimator | ||
{ | ||
private bool idleTurnClockwise; | ||
private int ticksUntilIdleTurn; | ||
|
||
public CCTVTopAnimator_Periodic(ThingComp_CCTVTop comp) : base(comp) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Current turret top rotation. | ||
/// </summary> | ||
public override float CurRotation | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
public override void Tick() | ||
{ | ||
if (ticksUntilIdleTurn > 0) | ||
{ | ||
ticksUntilIdleTurn--; | ||
if (ticksUntilIdleTurn <= 0) | ||
{ | ||
idleTurnClockwise = !idleTurnClockwise; | ||
} | ||
return; | ||
} | ||
if (idleTurnClockwise) | ||
{ | ||
CurRotation += 0.26f; | ||
} | ||
else | ||
{ | ||
CurRotation -= 0.26f; | ||
} | ||
if (Math.Abs(CurRotation) > 60) | ||
{ | ||
ticksUntilIdleTurn = Rand.RangeInclusive(30, 100); | ||
} | ||
} | ||
} | ||
} |
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,57 @@ | ||
using System.Collections.Generic; | ||
using CombatAI.R; | ||
using UnityEngine; | ||
using Verse; | ||
namespace CombatAI | ||
{ | ||
public class PlaceWorker_WallCCTV : PlaceWorker | ||
{ | ||
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null) | ||
{ | ||
Map map = Find.CurrentMap; | ||
if (rot == Rot4.North || rot == Rot4.South) | ||
{ | ||
GenDraw.DrawFieldEdges(new List<IntVec3> | ||
{ | ||
center | ||
}, !center.Impassable(map) ? Color.white : Color.red); | ||
IntVec3 wall = center + IntVec3.North.RotatedBy(rot); | ||
GenDraw.DrawFieldEdges(new List<IntVec3> | ||
{ | ||
wall | ||
}, wall.Impassable(map) ? Color.blue : Color.red); | ||
} | ||
else | ||
{ | ||
GenDraw.DrawFieldEdges(new List<IntVec3> | ||
{ | ||
center | ||
}, !center.Impassable(map) ? Color.white : Color.red); | ||
IntVec3 wall = center + IntVec3.South.RotatedBy(rot); | ||
GenDraw.DrawFieldEdges(new List<IntVec3> | ||
{ | ||
wall | ||
}, wall.Impassable(map) ? Color.blue : Color.red); | ||
} | ||
} | ||
|
||
public override AcceptanceReport AllowsPlacing(BuildableDef def, IntVec3 center, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) | ||
{ | ||
if (rot == Rot4.North || rot == Rot4.South) | ||
{ | ||
if (center.Impassable(map) || !(center + IntVec3.North.RotatedBy(rot)).Impassable(map)) | ||
{ | ||
return Keyed.CombatAI_PlaceWorker_WallMounted; | ||
} | ||
} | ||
else | ||
{ | ||
if (center.Impassable(map) || !(center + IntVec3.South.RotatedBy(rot)).Impassable(map)) | ||
{ | ||
return Keyed.CombatAI_PlaceWorker_WallMounted; | ||
} | ||
} | ||
return true; | ||
} | ||
} | ||
} |
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,110 @@ | ||
using System.Collections.Generic; | ||
using CombatAI.Comps; | ||
using Verse; | ||
namespace CombatAI | ||
{ | ||
public class WallCCTVTracker : MapComponent | ||
{ | ||
private static readonly List<Thing> _destroyList = new List<Thing>(); | ||
private readonly FlagArray grid; | ||
private readonly CellIndices indices; | ||
|
||
public WallCCTVTracker(Map map) : base(map) | ||
{ | ||
indices = map.cellIndices; | ||
grid = new FlagArray(indices.NumGridCells); | ||
} | ||
|
||
public void Register(Thing thing) | ||
{ | ||
if (thing == null || !thing.Spawned) | ||
{ | ||
return; | ||
} | ||
ThingComp_CCTVTop top = thing.GetComp_Fast<ThingComp_CCTVTop>(); | ||
if (top != null && top.Props.wallMounted) | ||
{ | ||
Rot4 rot = thing.Rotation; | ||
IntVec3 center = thing.Position; | ||
IntVec3 wall; | ||
if (rot == Rot4.North || rot == Rot4.South) | ||
{ | ||
wall = center + IntVec3.North.RotatedBy(rot); | ||
} | ||
else | ||
{ | ||
wall = center + IntVec3.South.RotatedBy(rot); | ||
} | ||
if (wall.InBounds(map)) | ||
{ | ||
grid.Set(indices.CellToIndex(wall), true); | ||
} | ||
} | ||
} | ||
|
||
public void Register(ThingComp_CCTVTop top) | ||
{ | ||
if (top != null && top.Props.wallMounted && top.parent.Spawned) | ||
{ | ||
Rot4 rot = top.parent.Rotation; | ||
IntVec3 center = top.parent.Position; | ||
IntVec3 wall; | ||
if (rot == Rot4.North || rot == Rot4.South) | ||
{ | ||
wall = center + IntVec3.North.RotatedBy(rot); | ||
} | ||
else | ||
{ | ||
wall = center + IntVec3.South.RotatedBy(rot); | ||
} | ||
if (wall.InBounds(map)) | ||
{ | ||
grid.Set(indices.CellToIndex(wall), true); | ||
} | ||
} | ||
} | ||
|
||
public void Notify_CellChanged(IntVec3 cell) | ||
{ | ||
if (cell.InBounds(map) && grid.Get(indices.CellToIndex(cell)) && !cell.Impassable(map)) | ||
{ | ||
grid.Set(indices.CellToIndex(cell), false); | ||
for (int i = 0; i < 8; i++) | ||
{ | ||
IntVec3 loc = cell + GenAdj.AdjacentCells[i]; | ||
_destroyList.Clear(); | ||
if (loc.InBounds(map)) | ||
{ | ||
foreach (Thing thing in loc.GetThingList(map)) | ||
{ | ||
ThingComp_CCTVTop top = thing.GetComp_Fast<ThingComp_CCTVTop>(); | ||
if (top != null && top.Props.wallMounted) | ||
{ | ||
Rot4 rot = thing.Rotation; | ||
IntVec3 center = thing.Position; | ||
IntVec3 wall; | ||
if (rot == Rot4.North || rot == Rot4.South) | ||
{ | ||
wall = center + IntVec3.North.RotatedBy(rot); | ||
} | ||
else | ||
{ | ||
wall = center + IntVec3.South.RotatedBy(rot); | ||
} | ||
if (wall.InBounds(map) && wall == cell) | ||
{ | ||
_destroyList.Add(thing); | ||
} | ||
} | ||
} | ||
} | ||
for (int j = 0; j < _destroyList.Count; j++) | ||
{ | ||
_destroyList[j].Destroy(DestroyMode.Deconstruct); | ||
} | ||
} | ||
_destroyList.Clear(); | ||
} | ||
} | ||
} | ||
} |
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,32 @@ | ||
using System; | ||
using UnityEngine; | ||
using Verse; | ||
namespace CombatAI.Comps | ||
{ | ||
public class CompProperties_CCTVTop : CompProperties_Sighter | ||
{ | ||
public Type animator; | ||
[Unsaved(allowLoading: false)] | ||
public float baseWidth; | ||
public float fieldOfView; | ||
public GraphicData graphicData; | ||
[Unsaved(allowLoading: false)] | ||
public Material turretTopMat; | ||
public bool wallMounted; | ||
|
||
public CompProperties_CCTVTop() | ||
{ | ||
compClass = typeof(ThingComp_CCTVTop); | ||
} | ||
|
||
public override void ResolveReferences(ThingDef parentDef) | ||
{ | ||
base.ResolveReferences(parentDef); | ||
baseWidth = Mathf.Sin(0.5f * fieldOfView * Mathf.PI / 180f) * radius * 2; | ||
LongEventHandler.ExecuteWhenFinished(delegate | ||
{ | ||
turretTopMat = MaterialPool.MatFrom(graphicData.texPath); | ||
}); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.