public static void UpdateFlickDesignation(Thing t)
        {
            bool           flag           = false;
            ThingWithComps thingWithComps = t as ThingWithComps;

            if (thingWithComps != null)
            {
                for (int i = 0; i < thingWithComps.AllComps.Count; i++)
                {
                    CompFlickable compFlickable = thingWithComps.AllComps[i] as CompFlickable;
                    if (compFlickable != null && compFlickable.WantsFlick())
                    {
                        flag = true;
                        break;
                    }
                }
            }
            Designation designation = t.Map.designationManager.DesignationOn(t, DesignationDefOf.Flick);

            if (flag && designation == null)
            {
                t.Map.designationManager.AddDesignation(new Designation(t, DesignationDefOf.Flick));
            }
            else if (!flag && designation != null)
            {
                designation.Delete();
            }
            TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.SwitchFlickingDesignation);
        }
Esempio n. 2
0
 public override void OnActivated()
 {
     base.OnActivated();
     Find.TutorialState.sandbagsRect = TutorUtility.FindUsableRect(7, 7, base.Map, 0f, false);
     this.sandbagCells = new List <IntVec3>();
     foreach (IntVec3 item in Find.TutorialState.sandbagsRect.EdgeCells)
     {
         if (item.x != Find.TutorialState.sandbagsRect.CenterCell.x && item.z != Find.TutorialState.sandbagsRect.CenterCell.z)
         {
             this.sandbagCells.Add(item);
         }
     }
     foreach (IntVec3 c in Find.TutorialState.sandbagsRect.ContractedBy(1))
     {
         if (!Find.TutorialState.sandbagsRect.ContractedBy(2).Contains(c))
         {
             List <Thing> thingList = c.GetThingList(base.Map);
             for (int i = thingList.Count - 1; i >= 0; i--)
             {
                 Thing thing = thingList[i];
                 if (thing.def.passability != Traversability.Standable && (thing.def.category == ThingCategory.Plant || thing.def.category == ThingCategory.Item))
                 {
                     thing.Destroy(DestroyMode.Vanish);
                 }
             }
         }
     }
 }
 public override void OnActivated()
 {
     base.OnActivated();
     Find.TutorialState.sandbagsRect = TutorUtility.FindUsableRect(7, 7, base.Map);
     sandbagCells = new List <IntVec3>();
     foreach (IntVec3 edgeCell in Find.TutorialState.sandbagsRect.EdgeCells)
     {
         if (edgeCell.x != Find.TutorialState.sandbagsRect.CenterCell.x && edgeCell.z != Find.TutorialState.sandbagsRect.CenterCell.z)
         {
             sandbagCells.Add(edgeCell);
         }
     }
     foreach (IntVec3 item in Find.TutorialState.sandbagsRect.ContractedBy(1))
     {
         if (!Find.TutorialState.sandbagsRect.ContractedBy(2).Contains(item))
         {
             List <Thing> thingList = item.GetThingList(base.Map);
             for (int num = thingList.Count - 1; num >= 0; num--)
             {
                 Thing thing = thingList[num];
                 if (thing.def.passability != 0 && (thing.def.category == ThingCategory.Plant || thing.def.category == ThingCategory.Item))
                 {
                     thing.Destroy();
                 }
             }
         }
     }
 }
 public override AcceptanceReport AllowAction(EventPack ep)
 {
     if (ep.Tag == "Designate-Sandbags")
     {
         return(TutorUtility.EventCellsAreWithin(ep, sandbagCells));
     }
     return(base.AllowAction(ep));
 }
 public override AcceptanceReport AllowAction(EventPack ep)
 {
     if (ep.Tag == "Designate-ZoneAdd_Growing")
     {
         return(TutorUtility.EventCellsMatchExactly(ep, this.cachedCells));
     }
     return(base.AllowAction(ep));
 }
 public override AcceptanceReport AllowAction(EventPack ep)
 {
     if (ep.Tag == "Designate-ZoneAddStockpile_Resources")
     {
         return(TutorUtility.EventCellsMatchExactly(ep, cachedCells));
     }
     return(base.AllowAction(ep));
 }
Esempio n. 7
0
 public override void LessonOnGUI()
 {
     if (!mineCells.NullOrEmpty())
     {
         TutorUtility.DrawLabelOnGUI(Gen.AveragePosition(mineCells), def.onMapInstruction);
     }
     base.LessonOnGUI();
 }
Esempio n. 8
0
 public override void LessonOnGUI()
 {
     if (!AllColonistsInCover())
     {
         TutorUtility.DrawCellRectOnGUI(Find.TutorialState.sandbagsRect, def.onMapInstruction);
     }
     base.LessonOnGUI();
 }
 public override AcceptanceReport AllowAction(EventPack ep)
 {
     if (ep.Tag == "Designate-Wall")
     {
         return(TutorUtility.EventCellsAreWithin(ep, this.cachedEdgeCells));
     }
     return(base.AllowAction(ep));
 }
Esempio n. 10
0
 public static void DrawCellRectOnGUI(CellRect cellRect, string label = null)
 {
     if (label != null)
     {
         Vector3 centerVector = cellRect.CenterVector3;
         TutorUtility.DrawLabelOnGUI(centerVector, label);
     }
 }
 public override void LessonOnGUI()
 {
     foreach (Thing weapon in Weapons)
     {
         TutorUtility.DrawLabelOnThingOnGUI(weapon, def.onMapInstruction);
     }
     base.LessonOnGUI();
 }
Esempio n. 12
0
 public override void LessonOnGUI()
 {
     foreach (Thing t in this.Weapons)
     {
         TutorUtility.DrawLabelOnThingOnGUI(t, this.def.onMapInstruction);
     }
     base.LessonOnGUI();
 }
Esempio n. 13
0
 public override void LessonOnGUI()
 {
     foreach (Thing item in this.NeedUnforbidItems())
     {
         TutorUtility.DrawLabelOnThingOnGUI(item, base.def.onMapInstruction);
     }
     base.LessonOnGUI();
 }
 public override AcceptanceReport AllowAction(EventPack ep)
 {
     if (ep.Tag == "Designate-Door")
     {
         return(TutorUtility.EventCellsAreWithin(ep, allowedPlaceCells));
     }
     return(base.AllowAction(ep));
 }
Esempio n. 15
0
 public override void LessonOnGUI()
 {
     if (!this.mineCells.NullOrEmpty <IntVec3>())
     {
         TutorUtility.DrawLabelOnGUI(Gen.AveragePosition(this.mineCells), this.def.onMapInstruction);
     }
     base.LessonOnGUI();
 }
 public override void LessonUpdate()
 {
     GenDraw.DrawFieldEdges(sandbagCells.Where((IntVec3 c) => !TutorUtility.BuildingOrBlueprintOrFrameCenterExists(c, base.Map, ThingDefOf.Sandbags)).ToList());
     GenDraw.DrawArrowPointingAt(Gen.AveragePosition(sandbagCells));
     if (ProgressPercent > 0.9999f)
     {
         Find.ActiveLesson.Deactivate();
     }
 }
Esempio n. 17
0
 public override void TryOpenComms(Pawn negotiator)
 {
     if (CanTradeNow)
     {
         Find.WindowStack.Add(new Dialog_Trade(negotiator, this));
         LessonAutoActivator.TeachOpportunity(ConceptDefOf.BuildOrbitalTradeBeacon, OpportunityType.Critical);
         PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(Goods.OfType <Pawn>(), "LetterRelatedPawnsTradeShip".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent);
         TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.TradeGoodsMustBeNearBeacon);
     }
 }
 public override void LessonUpdate()
 {
     cachedEdgeCells.Clear();
     cachedEdgeCells.AddRange(RoomRect.EdgeCells.Where((IntVec3 c) => !TutorUtility.BuildingOrBlueprintOrFrameCenterExists(c, base.Map, ThingDefOf.Wall)).ToList());
     GenDraw.DrawFieldEdges(cachedEdgeCells.Where((IntVec3 c) => c.GetEdifice(base.Map) == null).ToList());
     GenDraw.DrawArrowPointingAt(RoomRect.CenterVector3);
     if (ProgressPercent > 0.9999f)
     {
         Find.ActiveLesson.Deactivate();
     }
 }
 public override void LessonOnGUI()
 {
     foreach (Thing t in this.ThingsToSelect())
     {
         TutorUtility.DrawLabelOnThingOnGUI(t, this.def.onMapInstruction);
     }
     if (this.RelevantBill() == null)
     {
         UIHighlighter.HighlightTag("AddBill");
     }
     base.LessonOnGUI();
 }
		public override void LessonUpdate()
		{
			List<IntVec3> cells = (from c in this.sandbagCells
			where !TutorUtility.BuildingOrBlueprintOrFrameCenterExists(c, base.Map, ThingDefOf.Sandbags)
			select c).ToList();
			GenDraw.DrawFieldEdges(cells);
			GenDraw.DrawArrowPointingAt(Gen.AveragePosition(this.sandbagCells), false);
			if (this.ProgressPercent > 0.99989998340606689)
			{
				Find.ActiveLesson.Deactivate();
			}
		}
Esempio n. 21
0
        protected int NumPlaced()
        {
            int num = 0;

            foreach (IntVec3 item in this.BuildableRect)
            {
                if (TutorUtility.BuildingOrBlueprintOrFrameCenterExists(item, base.Map, base.def.thingDef))
                {
                    num++;
                }
            }
            return(num);
        }
        public override AcceptanceReport AllowAction(EventPack ep)
        {
            AcceptanceReport result;

            if (ep.Tag == "Designate-ZoneAddStockpile_Resources")
            {
                result = TutorUtility.EventCellsMatchExactly(ep, this.cachedCells);
            }
            else
            {
                result = base.AllowAction(ep);
            }
            return(result);
        }
        public override AcceptanceReport AllowAction(EventPack ep)
        {
            AcceptanceReport result;

            if (ep.Tag == "Designate-Door")
            {
                result = TutorUtility.EventCellsAreWithin(ep, this.allowedPlaceCells);
            }
            else
            {
                result = base.AllowAction(ep);
            }
            return(result);
        }
 public override void LessonUpdate()
 {
     this.cachedEdgeCells.Clear();
     this.cachedEdgeCells.AddRange((from c in this.RoomRect.EdgeCells
                                    where !TutorUtility.BuildingOrBlueprintOrFrameCenterExists(c, base.Map, ThingDefOf.Wall)
                                    select c).ToList());
     GenDraw.DrawFieldEdges((from c in this.cachedEdgeCells
                             where c.GetEdifice(base.Map) == null
                             select c).ToList());
     GenDraw.DrawArrowPointingAt(this.RoomRect.CenterVector3, false);
     if (this.ProgressPercent > 0.99989998340606689)
     {
         Find.ActiveLesson.Deactivate();
     }
 }
Esempio n. 25
0
 public override void TryOpenComms(Pawn negotiator)
 {
     if (this.CanTradeNow)
     {
         Find.WindowStack.Add(new Dialog_Trade(negotiator, this));
         LessonAutoActivator.TeachOpportunity(ConceptDefOf.BuildOrbitalTradeBeacon, OpportunityType.Critical);
         string empty  = string.Empty;
         string empty2 = string.Empty;
         PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(this.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradeShip".Translate(), false, true);
         if (!empty2.NullOrEmpty())
         {
             Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.PositiveEvent, (string)null);
         }
         TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.TradeGoodsMustBeNearBeacon);
     }
 }
Esempio n. 26
0
        public override void OnActivated()
        {
            base.OnActivated();
            CellRect cellRect = TutorUtility.FindUsableRect(10, 10, base.Map, 0f, noItems: true);
            GenStep_ScatterLumpsMineable genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineable();

            genStep_ScatterLumpsMineable.forcedDefToScatter = ThingDefOf.MineableSteel;
            genStep_ScatterLumpsMineable.ForceScatterAt(cellRect.CenterCell, base.Map);
            mineCells = new List <IntVec3>();
            foreach (IntVec3 item in cellRect)
            {
                Building edifice = item.GetEdifice(base.Map);
                if (edifice != null && edifice.def == ThingDefOf.MineableSteel)
                {
                    mineCells.Add(item);
                }
            }
        }
Esempio n. 27
0
        public override void OnActivated()
        {
            base.OnActivated();
            CellRect cellRect = TutorUtility.FindUsableRect(10, 10, base.Map, 0f, true);

            new GenStep_ScatterLumpsMineable
            {
                forcedDefToScatter = ThingDefOf.MineableSteel
            }.ForceScatterAt(cellRect.CenterCell, base.Map);
            this.mineCells = new List <IntVec3>();
            foreach (IntVec3 intVec in cellRect)
            {
                Building edifice = intVec.GetEdifice(base.Map);
                if (edifice != null && edifice.def == ThingDefOf.MineableSteel)
                {
                    this.mineCells.Add(intVec);
                }
            }
        }
Esempio n. 28
0
 public override void OnActivated()
 {
     base.OnActivated();
     if (def.giveOnActivateCount > 0)
     {
         Thing thing = ThingMaker.MakeThing(def.giveOnActivateDef);
         thing.stackCount = def.giveOnActivateCount;
         GenSpawn.Spawn(thing, TutorUtility.FindUsableRect(2, 2, Map).CenterCell, Map);
     }
     if (def.resetBuildDesignatorStuffs)
     {
         foreach (DesignationCategoryDef allDef in DefDatabase <DesignationCategoryDef> .AllDefs)
         {
             foreach (Designator resolvedAllowedDesignator in allDef.ResolvedAllowedDesignators)
             {
                 (resolvedAllowedDesignator as Designator_Build)?.ResetStuffToDefault();
             }
         }
     }
 }
		public override void OnActivated()
		{
			base.OnActivated();
			Find.TutorialState.sandbagsRect = TutorUtility.FindUsableRect(7, 7, base.Map, 0f, false);
			this.sandbagCells = new List<IntVec3>();
			foreach (IntVec3 edgeCell in Find.TutorialState.sandbagsRect.EdgeCells)
			{
				IntVec3 current = edgeCell;
				int x = current.x;
				IntVec3 centerCell = Find.TutorialState.sandbagsRect.CenterCell;
				if (x != centerCell.x)
				{
					int z = current.z;
					IntVec3 centerCell2 = Find.TutorialState.sandbagsRect.CenterCell;
					if (z != centerCell2.z)
					{
						this.sandbagCells.Add(current);
					}
				}
			}
			foreach (IntVec3 item in Find.TutorialState.sandbagsRect.ContractedBy(1))
			{
				if (!Find.TutorialState.sandbagsRect.ContractedBy(2).Contains(item))
				{
					List<Thing> thingList = item.GetThingList(base.Map);
					for (int num = thingList.Count - 1; num >= 0; num--)
					{
						Thing thing = thingList[num];
						if (thing.def.passability != 0 && (thing.def.category == ThingCategory.Plant || thing.def.category == ThingCategory.Item))
						{
							thing.Destroy(DestroyMode.Vanish);
						}
					}
				}
			}
		}
Esempio n. 30
0
 public override void OnActivated()
 {
     base.OnActivated();
     if (this.def.giveOnActivateCount > 0)
     {
         Thing thing = ThingMaker.MakeThing(this.def.giveOnActivateDef, null);
         thing.stackCount = this.def.giveOnActivateCount;
         GenSpawn.Spawn(thing, TutorUtility.FindUsableRect(2, 2, this.Map, 0f, false).CenterCell, this.Map, WipeMode.Vanish);
     }
     if (this.def.resetBuildDesignatorStuffs)
     {
         foreach (DesignationCategoryDef current in DefDatabase <DesignationCategoryDef> .AllDefs)
         {
             foreach (Designator current2 in current.ResolvedAllowedDesignators)
             {
                 Designator_Build designator_Build = current2 as Designator_Build;
                 if (designator_Build != null)
                 {
                     designator_Build.ResetStuffToDefault();
                 }
             }
         }
     }
 }