Exemple #1
0
        private static void PreFillTab(ITab __instance, ref object[] __state)
        {
            if (MP.IsInMultiplayer)
            {
                __state = new object[2];

                var soul = pawnSoulITabSoulToShowGetter.Invoke(__instance, Array.Empty <object>());

                if (soul != null)
                {
                    MP.WatchBegin();
                    var prayerTracker = compSoulPrayerTrackerField(soul);
                    prayerTrackerAllowPrayingSync.Watch(prayerTracker);
                    prayerTrackerShowPrayerSync.Watch(prayerTracker);
                    __state[0] = true;


                    var favourTracker = compSoulFavourTrackerField(soul);
                    var favoursList   = soulFavourTrackerFavoursField(favourTracker);

                    var favorValues = new float[favoursList.Count];
                    for (var i = 0; i < favoursList.Count; i++)
                    {
                        favorValues[i] = favourProgressFavourValueField(favoursList[i]);
                    }

                    __state[1] = favorValues;
                }
                else
                {
                    __state[0] = false;
                }
            }
        }
Exemple #2
0
        public IResult Call(IServiceProvider services, RouteCallMatch match, HttpListenerContext context)
        {
            object route = _constructor.Construct(services);

            _contextSetDelegate?.Invoke(route, context);
            return((IResult)_delegate(route, match.Parameters));
        }
 private static void SyncedTryStartSermon(Building altar, int index)
 {
     if (altarTryStartSermonMethod != null)
     {
         altarTryStartSermonMethod.Invoke(altar, new object[] { GetSermon(altar, index) });
     }
 }
 private static void SyncedInterceptedEndSermon(Building altar)
 {
     if (altar != null)
     {
         altarEndSermonMethod.Invoke(altar, Array.Empty <object>());
     }
 }
        static bool Prefix(ref WeaponHitInfo hitInfo, int groupIdx, int weaponIdx, Weapon weapon, float toHitChance,
                           float prevDodgedDamage, AttackDirector.AttackSequence __instance)
        {
            if (!weapon.weaponDef.ComponentTags.Contains(CLUSTER_TAG))
            {
                return(true);
            }
            Logger.Debug("had the cluster tag");
            var newNumberOfShots      = weapon.ProjectilesPerShot * hitInfo.numberOfShots;
            var originalNumberOfShots = hitInfo.numberOfShots;

            hitInfo.numberOfShots  = newNumberOfShots;
            hitInfo.toHitRolls     = new float[newNumberOfShots];
            hitInfo.locationRolls  = new float[newNumberOfShots];
            hitInfo.dodgeRolls     = new float[newNumberOfShots];
            hitInfo.dodgeSuccesses = new bool[newNumberOfShots];
            hitInfo.hitLocations   = new int[newNumberOfShots];
            hitInfo.hitPositions   = new Vector3[newNumberOfShots];
            hitInfo.hitVariance    = new int[newNumberOfShots];
            hitInfo.hitQualities   = new AttackImpactQuality[newNumberOfShots];
            AttackSequenceGetClusteredHits.Invoke(
                __instance,
                new object[] { hitInfo, groupIdx, weaponIdx, weapon, toHitChance, prevDodgedDamage }
                );

            PrintHitLocations(hitInfo);
            hitInfo.numberOfShots = originalNumberOfShots;
            return(false);
        }
        private static void SyncExtendedPawnData(SyncWorker sync, ref object data)
        {
            if (sync.isWriting)
            {
                var id = int.MaxValue;

                foreach (DictionaryEntry dictionaryEntry in pawnStorageDictionary(extendedDataStorageInstance))
                {
                    if (dictionaryEntry.Value == data)
                    {
                        id = (int)dictionaryEntry.Key;
                        break;
                    }
                }

                sync.Write(id);
            }
            else
            {
                var id = sync.Read <int>();

                if (id != int.MaxValue && thingsById.TryGetValue(id, out var thing) && thing is Pawn)
                {
                    data = getExtendedDataForPawnMethod.Invoke(extendedDataStorageInstance, new object[] { thing });
                }
            }
        }
Exemple #7
0
        public void Init(HttpApplication context)
        {
            PropertyInfoHandle  fileChangesMonitorGet = FastValueGetSet.GetPropertyInfoHandle("FileChangesMonitor", typeof(HttpRuntime));
            object              o       = fileChangesMonitorGet.GetValue(null);
            GetFieldValueHandle f       = FastFieldGetSet.FindGetValueHandle(o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase));
            object              monitor = f(o);
            FastInvokeHandler   m       = FastValueGetSet.GetCustomerMethodInfo(monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic));

            m.Invoke(monitor, new object[] { });
        }
 // Used for syncing WonderWorker
 // Pretty easy, as WonderWorker has a field storing the def that uses it, and the def stores the worker
 private static void SyncWonderWorker(SyncWorker sync, ref object obj)
 {
     if (sync.isWriting)
     {
         sync.Write(wonderWorkerDefField(obj).shortHash);
     }
     else
     {
         obj = wonderDefWorkerIntField(getDefByShortHash.Invoke(null, sync.Read <ushort>()));
     }
 }
Exemple #9
0
        public string Proceed(string content)
        {
            var handlerTarget  = ObjectFactory.CreateInstance(HandlerTargetType);
            var parameterTuple = (ICustomTuple)RpcSerializer.Deserialize(content, HandlerParameterTupleType);
            var parameterArray = parameterTuple.ToObjectArray();
            var result         = _fastInvokeHandler.Invoke(handlerTarget, parameterArray);

            if (result == null)
            {
                return(string.Empty);
            }
            return(RpcSerializer.Serialize(result));
        }
Exemple #10
0
        public byte[] Proceed(byte[] contentBytes)
        {
            var handlerTarget  = ObjectFactory.CreateInstance(HandlerTargetType);
            var parameterTuple = (ICustomTuple)BinarySerializer.Deserialize(contentBytes, HandlerParameterTupleType);
            var parameterArray = parameterTuple.ToObjectArray();
            var result         = _fastInvokeHandler.Invoke(handlerTarget, parameterArray);

            if (result == null)
            {
                return(FrameFormat.EmptyBytes);
            }
            return(BinarySerializer.Serialize(result));
        }
Exemple #11
0
        public static object Invoke(string classFullName, string methodName, object[] paramters)
        {
            string            key     = classFullName + methodName;
            FastInvokeHandler handler = null;
            bool existKey             = true;

            lock (_keyFastInvokeHandlerLock){
                if (_keyFastInvokeHandler.ContainsKey(key))
                {
                    handler = _keyFastInvokeHandler[key];
                }
                else
                {
                    existKey = false;
                }
            }
            if (existKey == false)
            {
                Type type         = null;
                bool existTheType = false;
                lock (_classFullNameTypeDicLock){
                    existTheType = _classFullNameTypeDic.ContainsKey(classFullName);
                    if (existTheType)
                    {
                        type = _classFullNameTypeDic[classFullName];
                    }
                }
                if (existTheType == false)
                {
                    type = ControllerAssmeblyUtil.CreateType(classFullName);
                    lock (_classFullNameTypeDicLock){
                        _classFullNameTypeDic[classFullName] = type;
                    }
                }
                var methodInfo = type.GetMethod(methodName);
                if (methodInfo == null)
                {
                    return(null);
                }
                handler = GetMethodInvoker(methodInfo);
                lock (_keyFastInvokeHandlerLock){
                    _keyFastInvokeHandler[key] = handler;
                }
            }
            var obj = ControllerAssmeblyUtil.CreateInstance(classFullName);

            return(handler.Invoke(obj, paramters));
        }
Exemple #12
0
 void SmartStockpileDesignatorWorker(SyncWorker sync, ref Designator_ZoneAddStockpile obj)
 {
     if (sync.isWriting)
     {
         sync.Write(new List <ThingDef>((IEnumerable <ThingDef>)allowedThingsGetter.Invoke(obj)));
         sync.Write(specialThingFilterDefLabel(obj));
         sync.Write(priorityLabel(obj));
         sync.Write(contentsLabel(obj));
     }
     else
     {
         var allowedThings         = sync.Read <List <ThingDef> >();
         var specialThingFilterDef = sync.Read <SpecialThingFilterDef>();
         var priority = sync.Read <StoragePriority>();
         var label    = sync.Read <string>();
         obj = (Designator_ZoneAddStockpile)Activator.CreateInstance(designatorType, allowedThings, specialThingFilterDef, priority, label);
     }
 }
Exemple #13
0
        static bool Prefix(ref int ___hitIndex, BallisticEffect __instance)
        {
            var damage = __instance.weapon.DamagePerShotAdjusted(__instance.weapon.parent.occupiedDesignMask);

            BallisticEffect_OnImpact.Invoke(__instance, new object[] { damage });
            if (___hitIndex >= __instance.hitInfo.toHitRolls.Length - 1)
            {
                WeaponEffect_OnComplete(__instance);
                return(false);
            }

            ___hitIndex++;
            if (ShouldFire(__instance, ___hitIndex))
            {
                __instance.Fire(__instance.hitInfo, ___hitIndex, 0);
            }
            return(false);
        }
Exemple #14
0
        /// <summary>
        /// 通过字符串的方式来执行方法
        /// </summary>
        /// <param name="obj">方法所在对象</param>
        /// <param name="name">方法名称</param>
        /// <param name="values">方法对应的参数值</param>
        /// <returns></returns>
        protected object RunMethod(object obj, string name, params object[] values)
        {
            Type       type   = obj.GetType();
            MethodInfo method = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public);

            if (method == null)
            {
                return(null);
            }
            try
            {
                FastInvokeHandler handler = DynamicCalls.GetMethodInvoker(method);
                return(handler.Invoke(obj, values));
            }
            catch
            {
                return(null);
            }
        }
Exemple #15
0
        private static void SyncedTryLearnPower(ThingComp comp, int disciplineIndex, int abilityIndex)
        {
            IList abilityList;

            // Minor discipline
            if (disciplineIndex >= 0)
            {
                var defsList = compPsykerMinorDisciplinesField(comp);
                abilityList = psykerDisciplineDefAbilitiesField(defsList[disciplineIndex]);
            }
            // Main discipline
            else
            {
                var disciplineDef = compPsykerMainDisciplineField(comp);
                abilityList = psykerDisciplineDefAbilitiesField(disciplineDef);
            }

            compPsykerTryLearnAbilityMethod.Invoke(comp, abilityList[abilityIndex]);
        }
Exemple #16
0
        public static object Invoke(object instance, string methodName, object[] paramters)
        {
            var               type          = instance.GetType();
            string            classFullName = instance.GetType().ToString();
            string            key           = classFullName + methodName;
            FastInvokeHandler handler       = null;
            bool              existKey      = true;

            lock (_keyFastInvokeHandlerLock){
                if (_keyFastInvokeHandler.ContainsKey(key))
                {
                    handler = _keyFastInvokeHandler[key];
                }
                else
                {
                    existKey = false;
                }
            }
            if (existKey == false)
            {
                var methodInfo = type.GetMethod(methodName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
                if (methodInfo == null)
                {
                    return(null);
                }
                handler = GetMethodInvoker(methodInfo);
                lock (_keyFastInvokeHandlerLock){
                    _keyFastInvokeHandler[key] = handler;
                }
            }
            try {
                return(handler.Invoke(instance, paramters));
            } catch (Exception ex) {
                StringBuilder msg = new StringBuilder();
                msg.AppendLine("调用方法:" + classFullName + "-->" + methodName);
                msg.AppendLine("异常信息:" + ex.Message);
                msg.AppendLine("StackTrace:" + ex.StackTrace);
                string info = msg.ToString();
                Moon.Orm.Util.LogUtil.Error(info);
                throw new Exception(info);
            }
        }
Exemple #17
0
        /// <summary>
        /// 运行编译函数并返回结果
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public string Invoke(EntityInfo entityInfo, UIConfigItem classConfig,
                             List <UIModelItem> selectPropertys, UIModelItem classInfo)
        {
            Buffalo.GeneratorInfo.EntityInfo entity = entityInfo.ToGeneratorEntity(classInfo);
            List <Property> lst = new List <Property>(selectPropertys.Count);

            foreach (UIModelItem item in selectPropertys)
            {
                lst.Add(item.ToGeneratItem());
            }
            try
            {
                string ret = _methodInfo.Invoke(_codeClass, new object[] { entity, lst }) as string;
                return(ret);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #18
0
 public static GUIStyle GetTextStyle(Rect size, TextAnchor alignment, Font font, string message)
 {
     return((GUIStyle)_getTextStyle?.Invoke(null, new object[] { size, alignment, font, message }));
 }
Exemple #19
0
 public static bool IsHost()
 {
     return((bool)_isHost.Invoke(null, null));
 }
Exemple #20
0
 public object Invoke(params object[] args) => invoker.Invoke(classType, args);
Exemple #21
0
        /// <summary>
        /// 运行该函数
        /// </summary>
        /// <param name="methodName">函数名</param>
        /// <param name="args">参数</param>
        /// <returns></returns>
        public object Invoke(string methodName, params object[] args)
        {
            FastInvokeHandler fhandle = FastValueGetSet.GetCustomerMethodInfo(_classHandle.ClassType, methodName, GetParamTypes(args));

            return(fhandle.Invoke(_instance, args));
        }
Exemple #22
0
 public object Invoke(params object[] args)
 {
     return(invoker.Invoke(classType, args));
 }
 public object Invoke(object target, params object[] args)
 {
     return(_handler.Invoke(target, args));
 }
Exemple #24
0
 /// <summary>
 /// Invokes the compiled method.
 /// </summary>
 /// <param name="parameters">
 /// The parameters to pass to the method.
 /// </param>
 /// <returns>
 /// The return value of the method.
 /// </returns>
 public object Invoke(params object[] parameters)
 {
     //return method.Invoke(typeResults.Instantiate(), parameters);
     return(FastInvoke.Invoke(Instance, parameters));
 }
        private static void SyncedConnectToSkyMind(Thing pawn, bool broadcastEvent)
        {
            var comp = gcAttpCompField();

            gameComponentConnectUserMethod.Invoke(comp, pawn, broadcastEvent);
        }
Exemple #26
0
 public object Invoke(TargetObjectType TargetObject, params object[] Paramters)
 {
     return(methodHandler.Invoke(TargetObject, Paramters));
 }
Exemple #27
0
 public static void ChefEventMessage(ChefEventMessage.ChefEventType type, GameObject chef, GameObject @object)
 {
     _chefEventMessage.Invoke(null, new object[] { type, chef, @object });
 }
Exemple #28
0
 public T Invoke <T>(params object[] parameters) => (T)_handler.Invoke(_type, parameters);
Exemple #29
0
        public override void Execute(Data.Data data, Dictionary <string, object> parameters)
        {
            SessionHandler.EnqueueAction(() =>
            {
                var player = Utils.GetPlayer();
                if (player != null)
                {
                    var id = new MyDefinitionId((MyObjectBuilderType)typeof(MyObjectBuilder_RadioAntenna), "SmallBlockRadioAntenna");
                    var up = player.Character.PositionComp.GetOrientation().Up;
                    up.Normalize();
                    var definitionBase = (MyRadioAntennaDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(id);
                    var pos            = player.GetPosition() + up * 50;
                    var world          = MatrixD.CreateWorld(pos, Vector3.Forward, Vector3.Up);
                    var color          = Color.Red.ColorToHSV();
                    var pirateFaction  = MySession.Static.Factions.TryGetFactionByTag("SPRT");
                    MyCubeBuilder.SpawnDynamicGrid(definitionBase, player.Character, world, color,
                                                   MyStringHash.NullOrEmpty,
                                                   0L, MyCubeBuilder.SpawnFlags.Default | MyCubeBuilder.SpawnFlags.SpawnAsMaster,
                                                   pirateFaction.FounderId, entity =>
                    {
                        var grid           = (MyCubeGrid)entity;
                        var pirateAntennas = MySession.Static.GetComponent <MyPirateAntennas>();
                        if (pirateAntennas != null)
                        {
                            var drones = Utils.IsInSpace(pos) ? Configuration.Plugin.Get(c => c.SpaceDrones): Configuration.Plugin.Get(c => c.PlanetDrones);
                            var drone  = (string.IsNullOrEmpty(Drone) ? drones[_random.Next(drones.Length)]: Drone) ?? "Vulture Drone";

                            MyDefinitionManager.Static.TryGetDefinition(
                                new MyDefinitionId(
                                    (MyObjectBuilderType)typeof(MyObjectBuilder_SpawnGroupDefinition),
                                    drone), out MySpawnGroupDefinition spawnGroup);
                            if (spawnGroup != null)
                            {
                                Vector3D?nullable = new Vector3D?();
                                for (int index = 0; index < 10; ++index)
                                {
                                    world    = entity.WorldMatrix;
                                    nullable = MyEntities.FindFreePlace(
                                        world.Translation + MyUtils.GetRandomVector3Normalized() * 1500,
                                        spawnGroup.SpawnRadius);
                                    if (nullable.HasValue)
                                    {
                                        break;
                                    }
                                }

                                foreach (var antenna in grid.GetFatBlocks <MyRadioAntenna>())
                                {
                                    _spawnDrone.Invoke(pirateAntennas,
                                                       new object[]
                                    {
                                        antenna, pirateFaction.FounderId, nullable.Value, spawnGroup,
                                        new Vector3?(), new Vector3?()
                                    });
                                }

                                var spawns = spawnGroup.Prefabs.Select(prefab => prefab.SubtypeId.ToSplitCase())
                                             .GroupBy(s => s).Select(grouping =>
                                                                     (grouping.Count() > 1 ? grouping.Count() + "x " : "") + grouping.Key)
                                             .Join();
                                var msg = "Spawned " + spawns;
                                Utils.SendChat(msg);
                                ActionNotification.SendActionMessage(msg, Color.Red, "ArcHudGPSNotification1");
                            }
                        }
                        grid.CubeBlocks.ToList().ForEach(block => grid.RemoveBlock(block));
                    });
                }
            });
        }
 private static void SyncedGetGizmos27(ThingComp comp, int id) => skyCloudCoreGetGizmos27.Invoke(comp, GetPawnFromComp(comp, id));