public override IEnumerable <Gizmo> CompGetGizmosExtra() { if (this.Pawn.Drafted) { if (Cannons.Count > 0) { if (Cannons.Any(x => x.cannonDef.weaponType == WeaponType.Rotatable)) { int i = 0; foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Turret)) { Command_TargeterCooldownAction turretCannons = new Command_TargeterCooldownAction(); turretCannons.cannon = cannon; turretCannons.comp = this; turretCannons.defaultLabel = "TestFire".Translate(cannon.cannonDef.label) + i; turretCannons.icon = cannon.GizmoIcon; if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription)) { turretCannons.defaultDesc = cannon.cannonDef.gizmoDescription; } turretCannons.targetingParams = new TargetingParameters { //Buildings, Things, Animals, Humans, and Mechs default to targetable canTargetLocations = true }; i++; yield return(turretCannons); } } if (Cannons.Any(x => x.cannonDef.weaponType == WeaponType.Static)) { if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Port)) { foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Port)) { Command_CooldownAction portSideCannons = new Command_CooldownAction(); portSideCannons.cannon = cannon; portSideCannons.comp = this; portSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label); if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription)) { portSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription; } portSideCannons.icon = cannon.GizmoIcon; if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription)) { portSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription; } portSideCannons.action = delegate() { SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0); List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList(); if (RimShipMod.mod.settings.shuffledCannonFire) { cannonOrder.Shuffle(); } foreach (int i in cannonOrder) { tmpCannonItem.First.Push(i); } this.broadsideFire.Add(tmpCannonItem); }; foreach (ShipHandler handler in this.CompShip.handlers) { if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate) { portSideCannons.Disable("NotEnoughCannonCrew".Translate(this.Pawn.LabelShort, handler.role.label)); } } yield return(portSideCannons); } } if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Starboard)) { foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Starboard)) { Command_CooldownAction starboardSideCannons = new Command_CooldownAction(); starboardSideCannons.cannon = cannon; starboardSideCannons.comp = this; starboardSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label); if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription)) { starboardSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription; } starboardSideCannons.icon = cannon.GizmoIcon; starboardSideCannons.action = delegate() { SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0); List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList(); if (RimShipMod.mod.settings.shuffledCannonFire) { cannonOrder.Shuffle(); } foreach (int i in cannonOrder) { tmpCannonItem.First.Push(i); } this.broadsideFire.Add(tmpCannonItem); }; foreach (ShipHandler handler in this.CompShip.handlers) { if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate) { starboardSideCannons.Disable("NotEnoughCannonCrew".Translate(Pawn.LabelShort, handler.role.label)); } } yield return(starboardSideCannons); } } if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Bow)) { foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Bow)) { Command_CooldownAction bowSideCannons = new Command_CooldownAction(); bowSideCannons.cannon = cannon; bowSideCannons.comp = this; bowSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label); if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription)) { bowSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription; } bowSideCannons.icon = cannon.GizmoIcon; bowSideCannons.action = delegate() { SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0); List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList(); if (RimShipMod.mod.settings.shuffledCannonFire) { cannonOrder.Shuffle(); } foreach (int i in cannonOrder) { tmpCannonItem.First.Push(i); } this.broadsideFire.Add(tmpCannonItem); }; foreach (ShipHandler handler in this.CompShip.handlers) { if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate) { bowSideCannons.Disable("NotEnoughCannonCrew".Translate(Pawn.LabelShort, handler.role.label)); } } yield return(bowSideCannons); } } if (Cannons.Any(x => x.cannonDef.weaponLocation == WeaponLocation.Stern)) { foreach (CannonHandler cannon in Cannons.Where(x => x.cannonDef.weaponLocation == WeaponLocation.Starboard)) { Command_CooldownAction sternSideCannons = new Command_CooldownAction(); sternSideCannons.cannon = cannon; sternSideCannons.comp = this; sternSideCannons.defaultLabel = "CannonLabel".Translate(cannon.cannonDef.label); if (!string.IsNullOrEmpty(cannon.cannonDef.gizmoDescription)) { sternSideCannons.defaultDesc = cannon.cannonDef.gizmoDescription; } sternSideCannons.icon = cannon.GizmoIcon; sternSideCannons.action = delegate() { SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0); List <int> cannonOrder = Enumerable.Range(0, cannon.cannonDef.numberCannons).ToList(); if (RimShipMod.mod.settings.shuffledCannonFire) { cannonOrder.Shuffle(); } foreach (int i in cannonOrder) { tmpCannonItem.First.Push(i); } this.broadsideFire.Add(tmpCannonItem); }; foreach (ShipHandler handler in this.CompShip.handlers) { if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate) { sternSideCannons.Disable("NotEnoughCannonCrew".Translate(Pawn.LabelShort, handler.role.label)); } } yield return(sternSideCannons); } } Command_SetRange range = new Command_SetRange(); range.defaultLabel = "SetRange".Translate(); range.icon = TexCommand.Attack; range.activeCannons = Cannons.FindAll(x => x.cannonDef.weaponType == WeaponType.Static); range.cannonComp = this; yield return(range); } } } }
/*public override void PostDraw() * { * foreach(CannonHandler cannon in this.Cannons) * { * if(cannon.CannonTexture != null) * { * Graphic graphic = GhostUtility.GhostGraphicFor(cannon.CannonTexture, ) * } * } * }*/ public override IEnumerable <Gizmo> CompGetGizmosExtra() { if (this.Pawn.Drafted) { if (this.cannons != null && this.cannons.Count > 0) { if (this.cannons.Any(x => x.weaponType == WeaponType.Broadside)) { if (this.cannons.Any(x => x.weaponLocation == WeaponLocation.Port)) { foreach (CannonHandler cannon in this.cannons.Where(x => x.weaponLocation == WeaponLocation.Port)) { Command_CooldownAction portSideCannons = new Command_CooldownAction(); portSideCannons.cannon = cannon; portSideCannons.comp = this; portSideCannons.defaultLabel = "CannonLabel".Translate(cannon.label); portSideCannons.icon = TexCommandShips.BroadsideCannon_Port; portSideCannons.action = delegate() { SPTuples.SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuples.SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0); List <int> cannonOrder = Enumerable.Range(0, cannon.numberCannons).ToList(); if (RimShipMod.mod.settings.shuffledCannonFire) { cannonOrder.Shuffle(); } foreach (int i in cannonOrder) { tmpCannonItem.First.Push(i); } this.broadsideFire.Add(tmpCannonItem); }; portSideCannons.hotKey = KeyBindingDefOf.Misc4; foreach (ShipHandler handler in this.CompShip.handlers) { if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate) { portSideCannons.Disable("NotEnoughCannonCrew".Translate(this.Pawn.LabelShort, handler.role.label)); } } yield return(portSideCannons); } } if (this.cannons.Any(x => x.weaponLocation == WeaponLocation.Starboard)) { foreach (CannonHandler cannon in this.cannons.Where(x => x.weaponLocation == WeaponLocation.Starboard)) { Command_CooldownAction starboardSideCannons = new Command_CooldownAction(); starboardSideCannons.cannon = cannon; starboardSideCannons.comp = this; starboardSideCannons.defaultLabel = "CannonLabel".Translate(cannon.label); starboardSideCannons.icon = TexCommandShips.BroadsideCannon_Starboard; starboardSideCannons.action = delegate() { SPTuples.SPTuple <Stack <int>, CannonHandler, int> tmpCannonItem = new SPTuples.SPTuple <Stack <int>, CannonHandler, int>(new Stack <int>(), cannon, 0); List <int> cannonOrder = Enumerable.Range(0, cannon.numberCannons).ToList(); if (RimShipMod.mod.settings.shuffledCannonFire) { cannonOrder.Shuffle(); } foreach (int i in cannonOrder) { tmpCannonItem.First.Push(i); } this.broadsideFire.Add(tmpCannonItem); }; starboardSideCannons.hotKey = KeyBindingDefOf.Misc5; foreach (ShipHandler handler in this.CompShip.handlers) { if (!RimShipMod.mod.settings.debugDraftAnyShip && handler.role.handlingType == HandlingTypeFlags.Cannons && handler.handlers.Count < handler.role.slotsToOperate) { starboardSideCannons.Disable("NotEnoughCannonCrew".Translate(this.Pawn.LabelShort, handler.role.label)); } } yield return(starboardSideCannons); } } Command_SetRange range = new Command_SetRange(); range.defaultLabel = "SetRange".Translate(); range.icon = TexCommand.Attack; range.activeCannons = this.cannons.FindAll(x => x.weaponType == WeaponType.Broadside); range.cannonComp = this; yield return(range); } } } }