public static void ChangedSetting(TupleStruct <Players.Player, JSONNode, string> data)
        {
            switch (data.item3)
            {
            case "world_settings":
                var ps = PlayerState.GetPlayerState(data.item1);

                if (ps != null && data.item2.GetAsOrDefault(_Monsters, Convert.ToInt32(ps.MonstersEnabled)) != Convert.ToInt32(ps.MonstersEnabled))
                {
                    if (!Configuration.GetorDefault("MonstersCanBeDisabled", true))
                    {
                        PandaChat.Send(data.item1, "The server administrator had disabled the changing of Monsters.", ChatColor.red);
                    }
                    else
                    {
                        ps.MonstersEnabled = data.item2.GetAsOrDefault(_Monsters, Convert.ToInt32(ps.MonstersEnabled)) != 0;
                    }

                    PandaChat.Send(data.item1, "Settlers! Mod Monsters are now " + (ps.MonstersEnabled ? "on" : "off"), ChatColor.green);

                    if (!ps.MonstersEnabled)
                    {
                        MonsterTracker.KillAllZombies(data.item1);
                    }
                }

                break;
            }
        }
示例#2
0
        private IObjectRef GetCachedOrCreateResource(IResourceSource resourceSource, Type interfaceType, bool addRef = true)
        {
            object     obj2;
            IObjectRef ref3;

            Validate.IsNotNull <IResourceSource>(resourceSource, "resourceSource");
            if (resourceSource.IsResource)
            {
                return(GetRef((IObjectRef)resourceSource, interfaceType, addRef));
            }
            TupleStruct <ResourceID, long> resourceKey = TupleStruct.Create <ResourceID, long>(resourceSource.ResourceID, resourceSource.Version);

Label_0036:
            obj2 = this.sync;
            lock (obj2)
            {
                IObjectRef objectRef = this.TryGetCachedResourceImpl(resourceKey, interfaceType, addRef);
                if (objectRef != null)
                {
                    return(GetRef(objectRef, interfaceType, addRef));
                }
                objectRef = resourceSource.CreateResource(this);
                if (this.genCaches[0].TryAdd <TupleStruct <ResourceID, long>, IObjectRef>(resourceKey, objectRef))
                {
                    ref3 = GetRef(objectRef, interfaceType, addRef);
                }
                else
                {
                    objectRef.Dispose();
                    goto Label_0036;
                }
            }
            return(ref3);
        }
 public static void OnNPCJobChanged(TupleStruct <NPCBase, IJob, IJob> data)
 {
     if (!data.item1.NPCType.IsLaborer)
     {
         data.item1.GetTempValues().Remove(LEAVETIME_JOB);
     }
 }
示例#4
0
        private IObjectRef TryGetCachedResourceImpl(TupleStruct <ResourceID, long> resourceKey, Type interfaceType, bool addRef)
        {
            object sync = this.sync;

            lock (sync)
            {
                IObjectRef ref2;
                if (this.genCaches[0].TryGetValue(resourceKey, out ref2))
                {
                    return(GetRef(ref2, interfaceType, addRef));
                }
                for (int i = 1; i < this.genCaches.Length; i++)
                {
                    IObjectRef ref4;
                    if (this.genCaches[i].TryRemove <TupleStruct <ResourceID, long>, IObjectRef>(resourceKey, out ref4))
                    {
                        if (this.genCaches[0].TryAdd <TupleStruct <ResourceID, long>, IObjectRef>(resourceKey, ref4))
                        {
                            return(GetRef(ref4, interfaceType, addRef));
                        }
                        ref4.Dispose();
                    }
                }
                return(null);
            }
        }
示例#5
0
        private PlacedBitmap GetOrCreateFontPreview(string gdiFontName, float fontSize, PaintDotNet.UI.Media.Brush textBrush)
        {
            PlacedBitmap bitmap;
            TupleStruct <string, float, PaintDotNet.UI.Media.Brush> key = TupleStruct.Create <string, float, PaintDotNet.UI.Media.Brush>(gdiFontName, fontSize, textBrush);
            Dictionary <TupleStruct <string, float, PaintDotNet.UI.Media.Brush>, PlacedBitmap> fontPreviewRenderCache = this.fontPreviewRenderCache;

            lock (fontPreviewRenderCache)
            {
                this.fontPreviewRenderCache.TryGetValue(key, out bitmap);
            }
            if (bitmap == null)
            {
                bitmap = this.CreateFontPreview(gdiFontName, fontSize, textBrush);
                Dictionary <TupleStruct <string, float, PaintDotNet.UI.Media.Brush>, PlacedBitmap> dictionary2 = this.fontPreviewRenderCache;
                lock (dictionary2)
                {
                    if (this.fontPreviewRenderCache.ContainsKey(key))
                    {
                        bitmap.Dispose();
                        return(this.fontPreviewRenderCache[key]);
                    }
                    this.fontPreviewRenderCache.Add(key, bitmap);
                }
            }
            return(bitmap);
        }
示例#6
0
        public override PropertyCollection OnCreateSavePropertyCollection()
        {
            List <Property> properties = new List <Property> {
                StaticListChoiceProperty.CreateForEnum <DdsFileFormat>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_DXT1, false)
            };

            object[] valueChoices = new object[] { DdsCompressorType.RangeFit, DdsCompressorType.ClusterFit, DdsCompressorType.IterativeFit };
            properties.Add(new StaticListChoiceProperty(PropertyNames.CompressorType, valueChoices, 1));
            object[] objArray2 = new object[] { DdsErrorMetric.Uniform, DdsErrorMetric.Perceptual };
            properties.Add(new StaticListChoiceProperty(PropertyNames.ErrorMetric, objArray2, 1));
            properties.Add(new BooleanProperty(PropertyNames.WeightColorByAlpha, false, true));
            properties.Add(new BooleanProperty(PropertyNames.GenerateMipMaps, false));
            object[] objArray3 = new object[] { ResamplingAlgorithm.Fant, ResamplingAlgorithm.SuperSampling, ResamplingAlgorithm.Bilinear, ResamplingAlgorithm.Bicubic, ResamplingAlgorithm.NearestNeighbor };
            properties.Add(new StaticListChoiceProperty(PropertyNames.MipMapResamplingAlgorithm, objArray3, 0));
            List <PropertyCollectionRule> rules = new List <PropertyCollectionRule>();

            object[] valuesForReadOnly = new object[] { DdsFileFormat.DDS_FORMAT_A8B8G8R8, DdsFileFormat.DDS_FORMAT_A8R8G8B8, DdsFileFormat.DDS_FORMAT_A4R4G4B4, DdsFileFormat.DDS_FORMAT_A1R5G5B5, DdsFileFormat.DDS_FORMAT_R5G6B5, DdsFileFormat.DDS_FORMAT_R8G8B8, DdsFileFormat.DDS_FORMAT_X8B8G8R8, DdsFileFormat.DDS_FORMAT_X8R8G8B8 };
            rules.Add(new ReadOnlyBoundToValueRule <object, StaticListChoiceProperty>(PropertyNames.ErrorMetric, PropertyNames.FileFormat, valuesForReadOnly, false));
            object[] objArray5 = new object[] { DdsFileFormat.DDS_FORMAT_A8B8G8R8, DdsFileFormat.DDS_FORMAT_A8R8G8B8, DdsFileFormat.DDS_FORMAT_A4R4G4B4, DdsFileFormat.DDS_FORMAT_A1R5G5B5, DdsFileFormat.DDS_FORMAT_R5G6B5, DdsFileFormat.DDS_FORMAT_R8G8B8, DdsFileFormat.DDS_FORMAT_X8B8G8R8, DdsFileFormat.DDS_FORMAT_X8R8G8B8 };
            rules.Add(new ReadOnlyBoundToValueRule <object, StaticListChoiceProperty>(PropertyNames.CompressorType, PropertyNames.FileFormat, objArray5, false));
            TupleStruct <object, object>[] sourcePropertyNameValuePairs = new TupleStruct <object, object>[] { Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_A8B8G8R8), Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_A8R8G8B8), Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_A4R4G4B4), Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_A1R5G5B5), Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_R5G6B5), Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_R8G8B8), Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_X8B8G8R8), Tuple.Create <object, object>(PropertyNames.FileFormat, DdsFileFormat.DDS_FORMAT_X8R8G8B8), Tuple.Create <object, object>(PropertyNames.CompressorType, DdsCompressorType.RangeFit) };
            rules.Add(new ReadOnlyBoundToNameValuesRule(PropertyNames.WeightColorByAlpha, false, sourcePropertyNameValuePairs));
            rules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.MipMapResamplingAlgorithm, PropertyNames.GenerateMipMaps, true));
            return(new PropertyCollection(properties, rules));
        }
示例#7
0
        public static void ChangedSetting(TupleStruct <Players.Player, JSONNode, string> data)
        {
            switch (data.item3)
            {
            case "world_settings":
                var ps             = PlayerState.GetPlayerState(data.item1);
                var maxToggleTimes = Configuration.GetorDefault("MaxSettlersToggle", 4);

                if (ps != null && data.item2.GetAsOrDefault(_Setters, Convert.ToInt32(ps.SettlersEnabled)) != Convert.ToInt32(ps.SettlersEnabled))
                {
                    if (!Configuration.GetorDefault("SettlersEnabled", true))
                    {
                        PandaChat.Send(data.item1, "The server administrator had disabled the changing of Settlers.", ChatColor.red);
                    }
                    else if (!HasToggeledMaxTimes(maxToggleTimes, ps, data.item1))
                    {
                        TurnSettlersOn(data.item1, ps, maxToggleTimes, data.item2.GetAsOrDefault(_Setters, Convert.ToInt32(ps.SettlersEnabled)) != 0);
                    }

                    PandaChat.Send(data.item1, "Settlers! Mod Settlers are now " + (ps.SettlersEnabled ? "on" : "off"), ChatColor.green);
                }

                break;
            }
        }
示例#8
0
 protected void RemoveEventHandler(Delegate clientHandler, Action <T, Delegate> removeProxyHandlerFn)
 {
     Validate.IsNotNull <Action <T, Delegate> >(removeProxyHandlerFn, "removeProxyHandlerFn");
     if (clientHandler != null)
     {
         Delegate delegate2 = null;
         lock (events)
         {
             if (this.clientHandlerToRemoveProxyHandlerFnMap == null)
             {
                 return;
             }
             for (int i = this.clientHandlerToRemoveProxyHandlerFnMap.Count - 1; i >= 0; i--)
             {
                 TupleStruct <Delegate, Delegate, Action <T, Delegate> > struct2 = this.clientHandlerToRemoveProxyHandlerFnMap[i];
                 if ((struct2.Item1 == clientHandler) && (struct2.Item3 == removeProxyHandlerFn))
                 {
                     this.clientHandlerToRemoveProxyHandlerFnMap.RemoveAt(i);
                     delegate2 = struct2.Item2;
                     break;
                 }
             }
         }
         if (delegate2 != null)
         {
             removeProxyHandlerFn(base.innerRefT, delegate2);
         }
     }
 }
示例#9
0
        public static TupleStruct <T1, T2> AddTuple <T1, T2>(this ICollection <TupleStruct <T1, T2> > collection, T1 item1, T2 item2)
        {
            TupleStruct <T1, T2> item = TupleStruct.Create <T1, T2>(item1, item2);

            collection.Add(item);
            return(item);
        }
示例#10
0
        private IObjectRef TryGetCachedResource(IResourceSource resourceSource, Type interfaceType, bool addRef = true)
        {
            Validate.IsNotNull <IResourceSource>(resourceSource, "resourceSource");
            if (resourceSource.IsResource)
            {
                return(null);
            }
            TupleStruct <ResourceID, long> resourceKey = TupleStruct.Create <ResourceID, long>(resourceSource.ResourceID, resourceSource.Version);

            return(this.TryGetCachedResourceImpl(resourceKey, interfaceType, addRef));
        }
示例#11
0
        private PlacedBitmap TryGetFontPreview(string gdiFontName, float fontSize, PaintDotNet.UI.Media.Brush textBrush)
        {
            PlacedBitmap bitmap;
            TupleStruct <string, float, PaintDotNet.UI.Media.Brush> key = TupleStruct.Create <string, float, PaintDotNet.UI.Media.Brush>(gdiFontName, fontSize, textBrush);
            Dictionary <TupleStruct <string, float, PaintDotNet.UI.Media.Brush>, PlacedBitmap> fontPreviewRenderCache = this.fontPreviewRenderCache;

            lock (fontPreviewRenderCache)
            {
                bool flag2 = this.fontPreviewRenderCache.TryGetValue(key, out bitmap);
            }
            return(bitmap);
        }
示例#12
0
        internal static Task <Unit> CreateFrameworkTasksWrapper(this TaskManager taskManager, IReadOnlyList <TupleStruct <Task, double> > fxTasksAndProgressWeights)
        {
            Validate.IsNotNull <IReadOnlyList <TupleStruct <Task, double> > >(fxTasksAndProgressWeights, "fxTasksAndProgressWeights");
            object             sync                = new object();
            int                count               = fxTasksAndProgressWeights.Count;
            int                completedCount      = 0;
            double             num                 = ((IEnumerable <double>)(from tapw in fxTasksAndProgressWeights select tapw.Item2)).Sum();
            double             totalProgressWeight = (num <= 0.0) ? 1.0 : num;
            VirtualTask <Unit> virtualTask         = taskManager.CreateVirtualTask(TaskState.Running);
            Action <int, Task> continueWithAction  = delegate(int index, Task task) {
                object obj1 = sync;
                lock (obj1)
                {
                    TupleStruct <Task, double> struct2 = fxTasksAndProgressWeights[index];
                    double increment = struct2.Item2 / totalProgressWeight;
                    virtualTask.IncrementProgressBy(increment);
                    completedCount += 1;
                    if (completedCount == count)
                    {
                        List <Exception> innerExceptions = null;
                        for (int k = 0; k < count; k++)
                        {
                            struct2 = fxTasksAndProgressWeights[k];
                            AggregateException exception = struct2.Item1.Exception;
                            if (exception != null)
                            {
                                innerExceptions = innerExceptions ?? new List <Exception>();
                                innerExceptions.AddRange(exception.InnerExceptions);
                            }
                        }
                        if (innerExceptions == null)
                        {
                            virtualTask.TaskResult = Result.Unit;
                        }
                        else
                        {
                            virtualTask.TaskResult = Result.NewError((innerExceptions.Count == 1) ? innerExceptions[0] : new AggregateException(innerExceptions), false);
                        }
                        virtualTask.SetState(TaskState.Finished);
                    }
                }
            };

            for (int j = 0; j < count; j++)
            {
                int index = j;
                TupleStruct <Task, double> struct2 = fxTasksAndProgressWeights[j];
                struct2.Item1.ContinueWith(delegate(Task t) {
                    continueWithAction(index, t);
                });
            }
            return(virtualTask);
        }
示例#13
0
 protected void AddEventHandler(Delegate clientHandler, Delegate proxyHandler, Action <T, Delegate> removeProxyHandlerFn)
 {
     Validate.Begin().IsNotNull <Delegate>(proxyHandler, "proxyHandler").IsNotNull <Action <T, Delegate> >(removeProxyHandlerFn, "removeProxyHandlerFn").Check();
     if (clientHandler != null)
     {
         lock (events)
         {
             if (this.clientHandlerToRemoveProxyHandlerFnMap == null)
             {
                 this.clientHandlerToRemoveProxyHandlerFnMap = new List <TupleStruct <Delegate, Delegate, Action <T, Delegate> > >(1);
             }
             this.clientHandlerToRemoveProxyHandlerFnMap.Add(TupleStruct.Create <Delegate, Delegate, Action <T, Delegate> >(clientHandler, proxyHandler, removeProxyHandlerFn));
         }
     }
 }
示例#14
0
        protected void Initialize()
        {
            this.OnInitializing();
            this.stamp = BrushToolChangesBase <TDerived, TTool> .stampCache.Get(TupleStruct.Create <double, double, double, bool>((double)this.PenWidth, (double)this.Hardness, 1.0, this.Antialiasing));

            double num            = this.PenWidth * 0.15;
            double stampSpacingPx = Math.Max(1.0, num);
            BrushStrokeLengthMetric lengthMetric = this.Antialiasing ? BrushStrokeLengthMetric.Euclidean : BrushStrokeLengthMetric.Anamorphic;

            this.renderData = new BrushStrokeRenderData(this.stamp.Size, stampSpacingPx, 7, lengthMetric);
            this.renderData.AddInputPoints(this.InputPoints);
            this.renderData.EnsureStrokeSamplesUpdated();
            this.renderDataCurrencyToken = this.renderData.CreateCurrencyToken();
            this.renderCache             = new BrushStrokeRenderCache(this.renderData, this.stamp, 7);
            this.OnInitialized();
        }
示例#15
0
        private void OnLanguageChanged(object sender, ValueChangedEventArgs <CultureInfo> e)
        {
            List <TupleStruct <string, string> > list = new List <TupleStruct <string, string> >();
            object sync = this.Sync;

            lock (sync)
            {
                string b = this.TryGetUserFilesPath();
                if ((this.currentUserFilesPath != null) && (b != null))
                {
                    if (!string.Equals(this.currentUserFilesPath, b, StringComparison.InvariantCultureIgnoreCase))
                    {
                        list.Add(TupleStruct.Create <string, string>(this.currentUserFilesPath, b));
                        this.currentUserFilesPath = b;
                    }
                    foreach (string str2 in this.resNameToSubDirNameMap.Keys.ToArrayEx <string>())
                    {
                        string a    = this.resNameToSubDirNameMap[str2];
                        string str4 = PdnResources.GetString(str2);
                        if (!string.Equals(a, str4, StringComparison.InvariantCultureIgnoreCase))
                        {
                            string str5 = Path.Combine(b, a);
                            string str6 = Path.Combine(b, str4);
                            this.resNameToSubDirNameMap[str2] = str4;
                            list.Add(TupleStruct.Create <string, string>(str5, str6));
                        }
                    }
                }
            }
            foreach (TupleStruct <string, string> struct2 in list)
            {
                string path = struct2.Item1;
                string str8 = struct2.Item2;
                try
                {
                    if (Directory.Exists(path) && !Directory.Exists(str8))
                    {
                        Directory.Move(path, str8);
                    }
                }
                catch (Exception exception)
                {
                    ExceptionDialog.ShowErrorDialog(null, exception);
                }
            }
        }
示例#16
0
        public static void OnNPCJobChanged(TupleStruct <NPCBase, IJob, IJob> data)
        {
            if (data != null && data.item1 != null && !data.item1.NPCType.IsLaborer)
            {
                data.item1.CustomData.SetAs(LEAVETIME_JOB, 0);
            }

            if (data.item3 is GuardJobInstance guardJob)
            {
                var settings = (GuardJobSettings)guardJob.Settings;
                guardJob.Settings = new GuardJobSettings()
                {
                    BlockTypes              = settings.BlockTypes,
                    CooldownMissingItem     = settings.CooldownMissingItem,
                    CooldownSearchingTarget = settings.CooldownSearchingTarget,
                    CooldownShot            = settings.CooldownShot,
                    Damage            = settings.Damage,
                    NPCType           = settings.NPCType,
                    NPCTypeKey        = settings.NPCTypeKey,
                    OnHitAudio        = settings.OnHitAudio,
                    OnShootAudio      = settings.OnShootAudio,
                    OnShootResultItem = settings.OnShootResultItem,
                    Range             = settings.Range,
                    RecruitmentItem   = settings.RecruitmentItem,
                    ShootItem         = settings.ShootItem,
                    SleepType         = settings.SleepType
                };
            }
            else if (data.item3 is CraftingJobInstance craftingJob)
            {
                var settings = (CraftingJobSettings)craftingJob.Settings;
                craftingJob.Settings = new CraftingJobSettings()
                {
                    BlockTypes       = settings.BlockTypes,
                    CraftingCooldown = settings.CraftingCooldown,
                    MaxCraftsPerHaul = settings.MaxCraftsPerHaul,
                    NPCType          = settings.NPCType,
                    NPCTypeKey       = settings.NPCTypeKey,
                    OnCraftedAudio   = settings.OnCraftedAudio,
                    RecruitmentItem  = settings.RecruitmentItem
                };
            }

            data.item1.ApplyJobResearch();
        }
            public bool MoveNext()
            {
                while (_index < _dictionary._count)
                {
                    if (_dictionary._entries[_index].HashCode >= 0)
                    {
                        var entry = _dictionary._entries[_index];
                        _current = new TupleStruct <int, int, TValue>(entry.Offset, entry.Size, entry.Value);
                        _index++;
                        return(true);
                    }

                    _index++;
                }

                _index   = _dictionary._count + 1;
                _current = new TupleStruct <int, int, TValue>();

                return(false);
            }
示例#18
0
        public static void ChangedSetting(TupleStruct <Players.Player, JSONNode, string> data)
        {
            switch (data.item3)
            {
            case "world_settings":
                var ps = PlayerState.GetPlayerState(data.item1);

                if (ps != null && data.item2.GetAsOrDefault(_Difficulty, ps.Difficulty.Rank) != ps.Difficulty.Rank)
                {
                    var difficulty = GameDifficulty.GameDifficulties.FirstOrDefault(kvp => kvp.Value.Rank == data.item2.GetAsOrDefault(_Difficulty, ps.Difficulty.Rank)).Key;

                    if (difficulty != null)
                    {
                        ChangeDifficulty(data.item1, ps, difficulty);
                    }
                }

                break;
            }
        }
示例#19
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         List <TupleStruct <Delegate, Delegate, Action <T, Delegate> > > clientHandlerToRemoveProxyHandlerFnMap;
         lock (events)
         {
             clientHandlerToRemoveProxyHandlerFnMap      = this.clientHandlerToRemoveProxyHandlerFnMap;
             this.clientHandlerToRemoveProxyHandlerFnMap = null;
         }
         if (clientHandlerToRemoveProxyHandlerFnMap != null)
         {
             for (int i = clientHandlerToRemoveProxyHandlerFnMap.Count - 1; i >= 0; i--)
             {
                 TupleStruct <Delegate, Delegate, Action <T, Delegate> > struct2 = clientHandlerToRemoveProxyHandlerFnMap[i];
                 struct2.Item3(base.innerRefT, struct2.Item2);
             }
         }
     }
     base.Dispose(disposing);
 }
示例#20
0
        public static void Run()
        {
            (int min, int max) = GetRange(new int[] { 1, 3, 5, 7, 9 });

            Console.WriteLine($"{min}, {max}");

            var range = GetRange(new int[] { 1, 3, 5, 7, 9 });

            Console.WriteLine($"{range.min},{range.max}");

            Debugger.Break();

            // How Tuples were Before

            (int min2, int max2) = GetRangeOld(new int[] { 1, 3, 5, 7, 9 });

            var range2 = GetRangeOld(new int[] { 1, 3, 5, 7, 9 });

            Console.WriteLine($"{range2.Item1},{range2.Item2}");

            var fakeStruct = new TupleStruct();

            Debugger.Break();
        }
 void IEnumerator.Reset()
 {
     _index   = 0;
     _current = new TupleStruct <int, int, TValue>();
 }
 internal Enumerator(DictionaryBlob <TValue> dictionary)
 {
     _dictionary = dictionary;
     _index      = 0;
     _current    = new TupleStruct <int, int, TValue>();
 }
示例#23
0
 private static CircleBrushStamp GetCachedStamp(double diameter, double hardness, double opacity, bool isAntialiased) =>
 BrushToolChangesBase <TDerived, TTool> .stampCache.Get(TupleStruct.Create <double, double, double, bool>(diameter, hardness, opacity, isAntialiased));
        public void CalculateColoniesThatRequireMonsters()
        {
            int bannerCount = BannerTracker.GetCount();

            coloniesRequiringZombies.Clear();

            for (int i = 0; i < bannerCount; i++)
            {
                Banner banner;

                if (!BannerTracker.TryGetAtIndex(i, out banner) || !banner.KeyLocation.IsValid)
                {
                    continue;
                }

                Colony colony = Colony.Get(banner.Owner);

                if (colony.FollowerCount == 0)
                {
                    colony.OnZombieSpawn(true);
                    continue;
                }

                var ps = PlayerState.GetPlayerState(banner.Owner);
                IDifficultySetting difficultyColony = colony.Owner.DifficultySetting;

                if (!MonsterManager.BossActive)
                {
                    if (!ps.MonstersEnabled || !difficultyColony.ShouldSpawnZombies(colony))
                    {
                        colony.OnZombieSpawn(true);
                        continue;
                    }
                }

                double nextZombieSpawnTime = NextZombieSpawnTimes.GetValueOrDefault(colony, 0.0);

                if (nextZombieSpawnTime > Pipliz.Time.SecondsSinceStartDoubleThisFrame)
                {
                    continue;
                }

                if (colony.InSiegeMode)
                {
                    if (Pipliz.Time.SecondsSinceStartDoubleThisFrame - colony.LastSiegeModeSpawn < siegeModeCooldown)
                    {
                        continue;
                    }
                    else
                    {
                        colony.LastSiegeModeSpawn = Pipliz.Time.SecondsSinceStartDoubleThisFrame;
                    }
                }

                // lagging behind, or no cooldown set: teleport to current time
                if (Pipliz.Time.SecondsSinceStartDoubleThisFrame - nextZombieSpawnTime > MONSTERS_DELAY_THRESHOLD_SECONDS)
                {
                    NextZombieSpawnTimes[colony] = Pipliz.Time.SecondsSinceStartDoubleThisFrame;
                }

                coloniesRequiringZombies.Add(TupleStruct.Create(colony, banner));
            }
        }
示例#25
0
 internal double <CreateFrameworkTasksWrapper> b__0_0(TupleStruct <Task, double> tapw) =>
 public override PropertyCollectionRule Clone() =>
 new ReadOnlyBoundToNameValuesRule(this.targetPropertyName, this.inverse, this.sourcePropertyNameValuePairs.Select <TupleStruct <string, object>, TupleStruct <object, object> >(t => TupleStruct.Create <object, object>(t.Item1, t.Item2)).ToArrayEx <TupleStruct <object, object> >());
 public ReadOnlyBoundToNameValuesRule(object targetPropertyName, bool inverse, params TupleStruct <object, object>[] sourcePropertyNameValuePairs)
 {
     this.targetPropertyName           = targetPropertyName.ToString();
     this.inverse                      = inverse;
     this.sourcePropertyNameValuePairs = sourcePropertyNameValuePairs.Select <TupleStruct <object, object>, TupleStruct <string, object> >(p => TupleStruct.Create <string, object>(p.Item1.ToString(), p.Item2)).ToArrayEx <TupleStruct <string, object> >();
 }
示例#28
0
        internal Expression CompilationUnit(TupleStruct<Int32,bool> info,List<Expression> funcList, Expression body, LabelTarget label)
        {
            BlockExpression e = funcList.Count == 0 ? Expression.Block(body) : Expression.Block(Expression.Block(funcList), body);

            return MethodDef(info, e, label, null);
        }
示例#29
0
        /// <summary>
        ///     定义一个匿名函数
        /// </summary>
        /// <param name="info">
        ///     TupleStruct<Int32,bool>
        ///       @First 函数参数个数
        ///       @Second 是否是不定参数
        /// </param>
        /// <param name="body">函数体</param>
        /// <param name="label">结束标记</param>
        /// <param name="upValues">闭包变量集合</param>
        /// <returns></returns>
        internal Expression MethodDef(TupleStruct<Int32,bool> info, BlockExpression body, LabelTarget label, List<KeyValuePair<string, Int32>> upValues)
        {
            //函数体
            Expression funcBody = Expression.Block(body, Expression.Call(typeof(Instructor).GetMethod("SetReturnVoid")),Expression.Label(label));

            Action func = Expression.Lambda<Action>(funcBody).Compile();   //编译方法体

            Expression o = ScriptObject.CreateFunction(func, info.First, info.Second).GetConstantExpression();

            if (upValues == null || upValues.Count == 0) return o;

            List<Expression> steps = new List<Expression>();

            Expression e = Expression.Call(typeof(Instructor).GetMethod("SetUpvaluesLength"), o, upValues.Count.GetConstantExpression());

            steps.Add(e);

            for (int i = 0; i < upValues.Count; i++)
            {
                KeyValuePair<string, Int32> upvalue = upValues[i];

                e = Expression.Call(typeof(Instructor).GetMethod("SetUpvalue"), o, i.GetConstantExpression(), upvalue.Value.GetConstantExpression());

                steps.Add(e);
            }

            steps.Add(o);

            return Expression.Block(steps);
        }
示例#30
0
 internal CircleBrushStamp <.cctor> b__34_0(TupleStruct <double, double, double, bool> tup) =>
示例#31
0
        public static NetworkMenu BuildMenu(Players.Player player, Dictionary <string, JobCounts> jobCounts, bool fired, string firedName, int firedCount)
        {
            NetworkMenu menu = new NetworkMenu();

            menu.LocalStorage.SetAs("header", _localizationHelper.LocalizeOrDefault("ColonyManagement", player));
            menu.Width  = 1000;
            menu.Height = 600;

            if (fired)
            {
                var count = firedCount.ToString();

                if (firedCount == int.MaxValue)
                {
                    count = "all";
                }

                menu.Items.Add(new ButtonCallback(GameLoader.NAMESPACE + ".KillFired", new LabelData($"{_localizationHelper.LocalizeOrDefault("Kill", player)} {count} {_localizationHelper.LocalizeOrDefault("Fired", player)} {firedName}", UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)));
            }
            else
            {
                menu.Items.Add(new ButtonCallback(GameLoader.NAMESPACE + ".PlayerDetails", new LabelData(_localizationHelper.GetLocalizationKey("PlayerDetails"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)));
            }

            menu.Items.Add(new Line());

            if (!fired)
            {
                ColonyState ps = ColonyState.GetColonyState(player.ActiveColony);

                if (Configuration.GetorDefault("ColonistsRecruitment", true))
                {
                    player.ActiveColony.HappinessData.RecruitmentCostCalculator.GetCost(player.ActiveColony.HappinessData.CachedHappiness, player.ActiveColony, out float num);
                    var cost = Configuration.GetorDefault("CompoundingFoodRecruitmentCost", 2) * ps.ColonistsBought;

                    if (cost < 1)
                    {
                        cost = 1;
                    }

                    menu.Items.Add(new HorizontalSplit(new Label(new LabelData(_localizationHelper.GetLocalizationKey("RecruitmentCost"), UnityEngine.Color.black)),
                                                       new Label(new LabelData((cost + num).ToString(), UnityEngine.Color.black))));
                }

                if (ps.CallToArmsEnabled)
                {
                    menu.Items.Add(new ButtonCallback(GameLoader.NAMESPACE + ".CallToArms", new LabelData(_localizationHelper.GetLocalizationKey("DeactivateCallToArms"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)));
                }
                else
                {
                    menu.Items.Add(new ButtonCallback(GameLoader.NAMESPACE + ".CallToArms", new LabelData(_localizationHelper.GetLocalizationKey("ActivateCallToArms"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)));
                }
            }


            List <TupleStruct <IItem, int> > header = new List <TupleStruct <IItem, int> >();

            header.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Job"), UnityEngine.Color.black)), 140));

            if (!fired)
            {
                header.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 140));
            }

            header.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Working"), UnityEngine.Color.black)), 140));
            header.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("NotWorking"), UnityEngine.Color.black)), 140));
            header.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 140));
            header.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 140));

            menu.Items.Add(new HorizontalRow(header));
            int jobCount = 0;

            foreach (var jobKvp in jobCounts)
            {
                if (fired && jobKvp.Value.AvailableCount == 0)
                {
                    continue;
                }

                jobCount++;
                List <TupleStruct <IItem, int> > items = new List <TupleStruct <IItem, int> >();

                items.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData(_localizationHelper.LocalizeOrDefault(jobKvp.Key.Replace(" ", ""), player), UnityEngine.Color.black)), 140));

                if (!fired)
                {
                    items.Add(TupleStruct.Create <IItem, int>(new ButtonCallback(jobKvp.Key + ".JobDetailsButton", new LabelData(_localizationHelper.GetLocalizationKey("Details"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 140));
                }

                items.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData(jobKvp.Value.TakenCount.ToString(), UnityEngine.Color.black)), 140));
                items.Add(TupleStruct.Create <IItem, int>(new Label(new LabelData(jobKvp.Value.AvailableCount.ToString(), UnityEngine.Color.black)), 140));

                if (fired)
                {
                    items.Add(TupleStruct.Create <IItem, int>(new ButtonCallback(jobKvp.Key + ".MoveFired", new LabelData(_localizationHelper.GetLocalizationKey("MoveFired"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft)), 140));
                }
                else
                {
                    items.Add(TupleStruct.Create <IItem, int>(new DropDown(new LabelData(_localizationHelper.GetLocalizationKey("Amount"), UnityEngine.Color.black), jobKvp.Key + ".Recruit", _recruitCount), 140));
                    items.Add(TupleStruct.Create <IItem, int>(new ButtonCallback(jobKvp.Key + ".RecruitButton", new LabelData(_localizationHelper.GetLocalizationKey("Recruit"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 140));
                    items.Add(TupleStruct.Create <IItem, int>(new ButtonCallback(jobKvp.Key + ".FireButton", new LabelData(_localizationHelper.GetLocalizationKey("Fire"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 140));
                }

                menu.LocalStorage.SetAs(jobKvp.Key + ".Recruit", 0);

                menu.Items.Add(new HorizontalRow(items));
            }

            if (jobCount == 0)
            {
                menu.Items.Add(new Label(new LabelData(_localizationHelper.LocalizeOrDefault("NoJobs", player), UnityEngine.Color.black)));
            }

            //if (!fired && Configuration.GetorDefault("AllowPlayerToResetThemself", true))
            //{
            //    menu.Items.Add(new Line(UnityEngine.Color.black));
            //    menu.Items.Add(new ButtonCallback(GameLoader.NAMESPACE + ".ResetPlayer." + player.ID, new LabelData(_localizationHelper.GetLocalizationKey("ResetPlayer"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)));
            //}

            return(menu);
        }
示例#32
0
 public override void Post(SendOrPostCallback d, object state)
 {
     this.queue.Enqueue(TupleStruct.Create <SendOrPostCallback, object>(d, state));
     this.EnsureProcessQueueIsPosted();
 }