Ejemplo n.º 1
0
        //-------------------------UI --------------------


        public void DoListing(Rect rect, ref Vector2 scrollPosition, ref float viewHeight, bool showOnlyActiveThings, IntVec3 dropLocation = new IntVec3(), Map dropMap = null)
        {
            //Bill result = null;
            //GUI.BeginGroup(rect);
            //Text.Font = GameFont.Small;
            //if (BuildingsUnderConstruction.Count < 15)
            //{
            //    Rect rect2 = new Rect(0f, 0f, 150f, 29f);
            //    if (Widgets.ButtonText(rect2, "AddBuilding".Translate(), true, false, true))
            //    {
            //        Log.Message("Click");
            //        Find.WindowStack.Add(new FloatMenu(recipeOptionsMaker()));
            //    }
            //    UIHighlighter.HighlightOpportunity(rect2, "AddBuilding");
            //}
            //Text.Anchor = TextAnchor.UpperLeft;
            //GUI.color = Color.white;

            List <ThingForDeployment> _DisplayedThingsForDeployment = this.ThingForDeployment.Where(t => t.ShouldBeShown(showOnlyActiveThings)).ToList();


            Rect outRect  = new Rect(rect.xMin, rect.yMin, rect.width, rect.height);
            Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, viewHeight);

            Widgets.BeginScrollView(outRect, ref scrollPosition, viewRect, true);
            float num = 0f;

            for (int i = 0; i < _DisplayedThingsForDeployment.Count; i++)
            {
                ThingForDeployment _ThingForDeployment = _DisplayedThingsForDeployment[i];
                Rect rect3 = _ThingForDeployment.DoInterface(0f, num, viewRect.width, i, dropLocation, dropMap);
                //if (!bill.DeletedOrDereferenced && Mouse.IsOver(rect3))
                //{
                //    result = bill;
                //}
                num += rect3.height + 6f;
                Widgets.DrawLineHorizontal(viewRect.x, num, viewRect.width);
            }
            if (Event.current.type == EventType.Layout)
            {
                viewHeight = num + 60f;
            }
            Widgets.EndScrollView();
            //GUI.EndGroup();
        } //DoListing
Ejemplo n.º 2
0
        } //GetTickInterval

        public override void TickOnInterval()
        {
            //Gets the Currently under construction Thing
            ThingForDeployment _CurrentlyUnderConstruction = this.ThingForDeployment.FirstOrFallback(t => t.ConstructionInProgress, null);

            if (_CurrentlyUnderConstruction != null)
            {
                //Continue currently under construction
                _CurrentlyUnderConstruction.WorkRemaining--;

                //Check if Finished
                if (_CurrentlyUnderConstruction.WorkRemaining <= 0)
                {
                    //Finish one Unit
                    _CurrentlyUnderConstruction.ConstructionInProgress = false;
                    _CurrentlyUnderConstruction.UnitsAvalable++;
                    _CurrentlyUnderConstruction.WorkRemaining = _CurrentlyUnderConstruction.TotalNeededWork;
                    _CurrentlyUnderConstruction.AfterCompletion();
                }
            }
            else
            {
                if (this.ThingForDeployment.Any(b => b.UnitsRequestedAditional >= 1))
                {
                    ThingForDeployment _ThingToStart = this.ThingForDeployment.Where(b => b.UnitsRequestedAditional >= 1).RandomElement();

                    if (_ThingToStart != null &&
                        GameComponent_Prometheus.Instance.Comp_Quest.ResourceGetReserveStatus(GameComponent_Prometheus_Quest.EnumResourceType.Power) >= _ThingToStart.TotalNeededPower &&
                        GameComponent_Prometheus.Instance.Comp_Quest.ResourceGetReserveStatus(GameComponent_Prometheus_Quest.EnumResourceType.ResourceUnits) >= _ThingToStart.TotalNeededResources)
                    {
                        _ThingToStart.ConstructionInProgress = true;
                        _ThingToStart.UnitsRequestedAditional--;
                        _ThingToStart.WorkRemaining = _ThingToStart.TotalNeededWork;

                        GameComponent_Prometheus.Instance.Comp_Quest.ResourceAddToReserves(GameComponent_Prometheus_Quest.EnumResourceType.ResourceUnits, -_ThingToStart.TotalNeededResources);
                        GameComponent_Prometheus.Instance.Comp_Quest.ResourceAddToReserves(GameComponent_Prometheus_Quest.EnumResourceType.Power, -_ThingToStart.TotalNeededPower);
                    }
                }
            }
        } //TickOnInterval
Ejemplo n.º 3
0
        } //DoListing

        public void AddNewBuildingsUnderConstruction()
        {
            DefDatabase <ThingDef> .AllDefs.ToList().ForEach(x =>
            {
                Fabrication.CompProperties_Fabricated _FabricationCompPropeties = x.GetCompProperties <Fabrication.CompProperties_Fabricated>();
                if (_FabricationCompPropeties != null &&
                    (x.researchPrerequisites == null || x.researchPrerequisites.All(r => r.IsFinished || string.Equals(r.defName, "Research_ED_Prometheus_Quest_Unlock"))))
                {
                    if (!this.ThingForDeployment.Any(b => string.Equals(b.defName, x.defName)))
                    {
                        ThingForDeployment _NewThing   = new ThingForDeployment(x.defName, x.label);
                        _NewThing.WorkRemaining        = _FabricationCompPropeties.RequiredWork;
                        _NewThing.TotalNeededWork      = _FabricationCompPropeties.RequiredWork;
                        _NewThing.PreventConstruction  = _FabricationCompPropeties.PreventConstruction;
                        _NewThing.TotalNeededPower     = _FabricationCompPropeties.RequiredPower;
                        _NewThing.TotalNeededResources = _FabricationCompPropeties.RequiredMaterials;

                        this.ThingForDeployment.Add(_NewThing);
                    }
                }
            });

            this.ThingForDeployment.OrderBy(x => x.label);
        }