예제 #1
0
 public void Register(Building_DJStand stand)
 {
     if (!stand.DestroyedOrNull() && !allStands.Contains(stand))
     {
         allStands.Add(stand);
     }
 }
예제 #2
0
 public void UnRegister(Building_DJStand stand)
 {
     if (stand != null && allStands.Contains(stand))
     {
         allStands.Remove(stand);
     }
 }
예제 #3
0
        protected override LordJob CreateLordJob(IntVec3 spot, Pawn organizer)
        {
            if (tempStand == null)
            {
                Core.Error("Failed to find DJ table!");
                return(null);
            }

            var job = new LordJob_Joinable_Disco(spot, organizer, this.def, tempStand);

            tempStand = null;
            return(job);
        }
예제 #4
0
        public SequenceHandler CreateAndInitHandler(Building_DJStand stand)
        {
            if (handlerType == null)
            {
                return(null);
            }

            var instance = Activator.CreateInstance(handlerType, this, stand) as SequenceHandler;

            if (instance == null)
            {
                return(null);
            }

            instance.Init();
            return(instance);
        }
예제 #5
0
        public DiscoProgram MakeProgram(Building_DJStand stand, Dictionary <string, string> overrides = null)
        {
            if (programClass == null)
            {
                return(null);
            }

            var instance = Activator.CreateInstance(programClass, this) as DiscoProgram;

            if (instance == null)
            {
                return(null);
            }

            instance.DJStand = stand;
            this.overrides   = (overrides?.Count ?? 0) > 0 ? overrides : null;
            instance.Init();
            this.overrides = null;
            return(instance);
        }
예제 #6
0
        protected override bool TryFindGatherSpot(Pawn organizer, out IntVec3 spot)
        {
            //return RCellFinder.TryFindGatheringSpot_NewTemp(organizer, this.def, false, out spot);
            var tracker = organizer.Map?.GetComponent <DiscoTracker>();

            spot = default;
            if (tracker == null)
            {
                Core.Warn($"Organizer {organizer.LabelShortCap}'s map is null or does not have a DiscoTracker comp");
                return(false);
            }

            var stands = tracker.GetAllValidDJStands();

            if (stands.EnumerableNullOrEmpty())
            {
                return(false);
            }

            tempStand = stands.RandomElementByWeight(dj => dj.FloorBounds.Area);
            spot      = tempStand.GetGatherSpot();
            return(true);
        }
예제 #7
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            var reachPlatform = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell);

            reachPlatform.finishActions ??= new List <System.Action>();
            reachPlatform.finishActions.Add(() =>
            {
                LookTargets t = new LookTargets(reachPlatform.actor);
                Messages.Message("DSC.DJArrived".Translate(), t, MessageTypeDefOf.PositiveEvent);

                var lordJob = pawn.Map?.lordManager?.LordOf(pawn)?.LordJob;
                if (lordJob is LordJob_Joinable_Disco dl)
                {
                    stand = dl.DJStand;
                    stand.PickSequenceIfNull = true;
                }
            });
            yield return(reachPlatform);

            Toil toil = new Toil();

            toil.defaultCompleteMode = ToilCompleteMode.Never;
            toil.initAction          = delegate()
            {
                Map.pawnDestinationReservationManager.Reserve(this.pawn, this.job, this.pawn.Position);
                pawn.pather.StopDead();
                pawn.rotationTracker.FaceCell(TargetB.Cell);
            };
            toil.finishActions ??= new List <System.Action>();
            toil.finishActions.Add(() =>
            {
                Core.Log("Finished standing at DJ platform. Shutting down platform.");
                stand.PickSequenceIfNull = false;
            });
            yield return(toil);
        }
 public LordJob_Joinable_Disco(IntVec3 spot, Pawn organizer, GatheringDef gatheringDef, Building_DJStand stand) : base(spot, organizer, gatheringDef)
 {
     this.durationTicks = Rand.RangeInclusive(10000, 15000);
     this.DJStand       = stand;
 }
예제 #9
0
 public SequenceHandler(SequenceDef def, Building_DJStand stand)
 {
     Def   = def;
     Stand = stand;
 }