コード例 #1
0
        public void Link_LinksCorrectly()
        {
            //Arrange
            var entity   = new Entity("valid");
            var entities = new Entities()
            {
                entity
            };
            var entityGroup = new EntityGroup("group");

            entityGroup.AddEntity(new Entity("invalid"), "0");
            entityGroup.AddEntity(entity, "1");
            var entityGroups = new EntityGroups()
            {
                entityGroup
            };
            var linker = new EntityGroupsLinker(entityGroups);

            //Act
            entityGroups = linker.Link(entities);

            //Assert
            Assert.AreEqual(1, entityGroups.Single().EntitySubscriptions.Where(s => s.Entity.Name == "valid").Count());
            Assert.AreEqual(0, entityGroups.Single().EntitySubscriptions.Where(s => s.Entity.Name == "invalid").Count());
        }
コード例 #2
0
    /**
     * Spawns a number of entities around a given position.
     */

    public static void SpawnEntitiesAroundPosition(string _entityGroupName, Vector3 _pos, int _minRange, int _maxRange, int count, Entity target = null)
    {
        Vector3 spawnPoint;
        int     lastEntityId = 0;

        for (int i = 0; i < count; i += 1)
        {
            if (!GameManager.Instance.World.GetRandomSpawnPositionMinMaxToPosition(_pos, _minRange, _maxRange, 1, false, out spawnPoint))
            {
                continue;
            }

            int nextEntityId = EntityGroups.GetRandomFromGroup(_entityGroupName, ref lastEntityId);
            if (nextEntityId == 0)
            {
                continue;
            }

            Entity entity = EntityFactory.CreateEntity(nextEntityId, spawnPoint);

            if (entity == null)
            {
                continue;
            }

            entity.SetSpawnerSource(EnumSpawnerSource.Dynamic);
            GameManager.Instance.World.SpawnEntityInWorld(entity);
        }
    }
コード例 #3
0
 public void Initialize(IEntityManager entityManager, MessageManager messageManager, EntityGroups groups, bool active)
 {
     this.entityManager  = entityManager;
     this.messageManager = messageManager;
     this.groups         = groups;
     this.active         = active;
 }
コード例 #4
0
        internal bool IsItemBlacklisted(Item item, out bool isGroup)
        {
            if (this.Filters.ItemBlacklist.Contains(new ItemDefinition(item.type)))
            {
                isGroup = false;
                return(true);
            }

            lock (this.MyLock) {
                IReadOnlySet <string> grpsPerItem;

                if (EntityGroups.TryGetGroupsPerItem(item.type, out grpsPerItem))
                {
                    foreach (string grpName in grpsPerItem)
                    {
                        if (this.Filters.ItemGroupBlacklist.Contains(grpName))
                        {
                            isGroup = true;
                            return(true);
                        }
                    }
                }
            }

            isGroup = false;
            return(false);
        }
コード例 #5
0
        private bool IsNpcLootBlacklisted(NPC npc, out bool isGroup)
        {
            if (this.Filters.NpcLootBlacklist.Contains(new NPCDefinition(npc.type)))
            {
                isGroup = false;
                return(true);
            }

            lock (this.MyLock) {
                IReadOnlySet <string> grpsPerNPC;

                if (EntityGroups.TryGetGroupsPerNPC(npc.type, out grpsPerNPC))
                {
                    foreach (string grpName in grpsPerNPC)
                    {
                        if (this.Filters.NpcLootGroupBlacklist.Contains(grpName))
                        {
                            isGroup = true;
                            return(true);
                        }
                    }
                }
            }

            isGroup = false;
            return(false);
        }
コード例 #6
0
        public static void Postfix(EntityAlive __instance)
        {
            String strSpawnGroup = "";
            EntityClass entityClass = EntityClass.list[__instance.entityClass];
            if (entityClass.Properties.Values.ContainsKey("SpawnOnDeath"))
            {
                // Spawn location
                Vector3i blockPos = default(Vector3i);
                blockPos.x = (int)__instance.position.x;
                blockPos.y = (int)__instance.position.y;
                blockPos.z = (int)__instance.position.z;


                // <property name="SpawnOnDeath" value="EnemyAnimalsForest" />
                strSpawnGroup = entityClass.Properties.Values["SpawnOnDeath"];

                int classID = 0;
                // try to spawn from a group
                Entity entity = EntityFactory.CreateEntity(EntityGroups.GetRandomFromGroup(strSpawnGroup, ref classID), __instance.position);
                if (entity != null)
                {
                    __instance.world.SetBlockRPC(blockPos, BlockValue.Air);
                    GameManager.Instance.World.SpawnEntityInWorld(entity);
                    return;
                }

                // If no group, then assume its an entity
                int entityID = EntityClass.FromString(strSpawnGroup);
                entity = EntityFactory.CreateEntity(entityID, __instance.position);
                if(entity != null)
                {
                    GameManager.Instance.World.SpawnEntityInWorld(entity);
                }
            }
        }
コード例 #7
0
ファイル: RewardGiveNPCSDX.cs プロジェクト: 7D2DMods/NPCs
    public void SpawnFromGroup(string strEntityGroup, EntityPlayer player)
    {
        int EntityID = 0;

        // If the group is set, then use it.
        if (string.IsNullOrEmpty(strEntityGroup))
        {
            return;
        }

        EntityID = EntityGroups.GetRandomFromGroup(strEntityGroup);
        if (EntityID == -1)
        {
            return; // failed
        }
        Entity NewEntity = EntityFactory.CreateEntity(EntityID, player.position, player.rotation);

        if (NewEntity)
        {
            NewEntity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
            GameManager.Instance.World.SpawnEntityInWorld(NewEntity);
            if (NewEntity is EntityAliveSDX)
            {
                LocalPlayerUI uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
                uiforPlayer.windowManager.Open("JoinInformation", true, false, true);
                //(NewEntity as EntityAliveSDX).SetOwner(player as EntityPlayerLocal);
            }
        }
        else
        {
            Debug.Log(" Could not Spawn NPC for: " + player.EntityName + " : " + player.entityId);
        }
    }
コード例 #8
0
ファイル: FileAdapter.cs プロジェクト: mind0n/hive
 public void Process(EntityGroups cache)
 {
     foreach (KeyValuePair<string, EntityGroup> i in cache)
     {
         SaveEntities(i.Value);
     }
 }
コード例 #9
0
    public void CheckForSpawn(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue)
    {
        if (string.IsNullOrEmpty(SpawnGroup))
        {
            Debug.Log("Spawner does not have a SpawnGroup property set: " + this.GetBlockName());
            return;
        }

        if (_blockValue.meta2 == 0)
        {
            int    ClassID   = 0;
            int    EntityID  = EntityGroups.GetRandomFromGroup(this.SpawnGroup, ref ClassID);
            Entity NewEntity = EntityFactory.CreateEntity(EntityID, _blockPos.ToVector3() + Vector3.up) as Entity;
            if (NewEntity)
            {
                NewEntity.SetSpawnerSource(EnumSpawnerSource.Dynamic);
                GameManager.Instance.World.SpawnEntityInWorld(NewEntity);
                if (Task == "Stay")
                {
                    EntityUtilities.SetCurrentOrder(NewEntity.entityId, EntityUtilities.Orders.Stay);
                }
                if (Task == "Patrol")
                {
                    EntityUtilities.SetCurrentOrder(NewEntity.entityId, EntityUtilities.Orders.Patrol);
                }
                if (Task == "Wander")
                {
                    EntityUtilities.SetCurrentOrder(NewEntity.entityId, EntityUtilities.Orders.Wander);
                }

                _blockValue.meta2 = (byte)1;
                _world.SetBlockRPC(_clrIdx, _blockPos, _blockValue);
            }
        }
    }
コード例 #10
0
        private bool AutoInitializeElementOfGroupItem(Item item)
        {
            var config = ElementsConfig.Instance;
            IReadOnlySet <string> grpNames;

            if (!EntityGroups.TryGetGroupsPerItem(item.type, out grpNames))
            {
                return(false);
            }

            float autoChance = -1f;

            foreach (string grpName in grpNames)
            {
                if (config.AutoAssignedAnyOfItemGroup.ContainsKey(grpName))
                {
                    autoChance = config.AutoAssignedAnyOfItemGroup[grpName];
                    break;
                }
            }

            if (autoChance == -1f)
            {
                return(false);
            }

            ElementDefinition elemDef = ElementDefinition.PickDefinitionForItem(autoChance);

            if (elemDef != null)
            {
                this.Elements.Add(elemDef);
            }

            return(true);
        }
コード例 #11
0
    public override void Execute(MinEventParams _params)
    {
        for (int j = 0; j < this.targets.Count; j++)
        {
            EntityAliveSDX entity = this.targets[j] as EntityAliveSDX;
            if (entity)
            {
                int EntityID = entity.entityClass;

                // If the group is set, then use it.
                if (!string.IsNullOrEmpty(this.strSpawnGroup))
                {
                    EntityID = EntityGroups.GetRandomFromGroup(this.strSpawnGroup);
                }

                Entity NewEntity = EntityFactory.CreateEntity(EntityID, entity.position, entity.rotation);
                if (NewEntity)
                {
                    NewEntity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
                    GameManager.Instance.World.SpawnEntityInWorld(NewEntity);
                    Debug.Log("An entity was created: " + NewEntity.ToString());
                    if (NewEntity is EntityAliveSDX)
                    {
                        Debug.Log("Setting Mother ID to Baby: " + entity.entityId + " for " + NewEntity.entityId);
                        (NewEntity as EntityAliveSDX).Buffs.SetCustomVar("Mother", entity.entityId, true);
                    }
                }
                else
                {
                    Debug.Log(" Could not Spawn baby for: " + entity.EntityName + " : " + entity.entityId);
                }
            }
        }
    }
コード例 #12
0
        public void OnCreated(User user)
        {
            var questionsAndAnswers = authz.CreateEntitiesGroup(EntityGroups.QuestionsAndAnswers(user));
            var submissions         = authz.CreateEntitiesGroup(EntityGroups.Submissions(user));

            pbs.Allow(MessageOperation.View).For(user).On(questionsAndAnswers).DefaultLevel().Save();
            pbs.Allow(SubmissionOperation.View).For(user).On(submissions).DefaultLevel().Save();
        }
コード例 #13
0
 public Result <EntityGroups> GetEntityGroups()
 {
     if (_entityGroups == null)
     {
         var config = new EntityGroupsFile(_gamePaths);
         _entityGroups = _gameDataRepository.GetConfigData(config);
         _entityGroups = _linkerFactory.GetLinker(_entityGroups).Link(_entities);
     }
     return(Result.Ok(_entityGroups));
 }
コード例 #14
0
		public override void Setup()
		{
			base.Setup();

			EntityManager.CreateEntity(EntityGroups.GetValue(new ByteFlag(1)));
			EntityManager.CreateEntity(EntityGroups.GetValue(new ByteFlag(1, 2)));
			EntityManager.CreateEntity(EntityGroups.GetValue(new ByteFlag(2)));
			EntityManager.CreateEntity(EntityGroups.GetValue(new ByteFlag(2, 3)));
			EntityManager.CreateEntity(EntityGroups.GetValue(new ByteFlag(3)));
		}
コード例 #15
0
ファイル: BiomeData.cs プロジェクト: Zipcore/7dtd-WalkerSim
        public int GetZombieClass(World world, Chunk chunk, int x, int y, PRNG prng)
        {
            ChunkAreaBiomeSpawnData spawnData = chunk.GetChunkBiomeSpawnData();

            if (spawnData == null)
            {
#if DEBUG
                Log.Out("No biome spawn data present");
#endif
                return(-1);
            }

            var biomeData = world.Biomes.GetBiome(spawnData.biomeId);
            if (biomeData == null)
            {
#if DEBUG
                Log.Out("No biome data for biome id {0}", spawnData.biomeId);
#endif
                return(-1);
            }

            BiomeSpawnEntityGroupList biomeSpawnEntityGroupList = list[biomeData.m_sBiomeName];
            if (biomeSpawnEntityGroupList == null)
            {
#if DEBUG
                Log.Out("No biome spawn group specified for {0}", biomeData.m_sBiomeName);
#endif
                return(-1);
            }

            var numGroups = biomeSpawnEntityGroupList.list.Count;
            if (numGroups == 0)
            {
#if DEBUG
                Log.Out("No biome spawn group is empty for {0}", biomeData.m_sBiomeName);
#endif
                return(-1);
            }

            var dayTime = world.IsDaytime() ? EDaytime.Day : EDaytime.Night;
            for (int i = 0; i < 5; i++)
            {
                int pickIndex = prng.Get(0, numGroups);

                var pick = biomeSpawnEntityGroupList.list[pickIndex];
                if (pick.daytime == EDaytime.Any || pick.daytime == dayTime)
                {
                    int lastClassId = -1;
                    return(EntityGroups.GetRandomFromGroup(pick.entityGroupRefName, ref lastClassId));
                }
            }

            return(-1);
        }
コード例 #16
0
		public void GroupChangeUpdate()
		{
			var entity = EntityManager.CreateEntity(EntityGroups.GetValue(new ByteFlag(1, 2, 3)));
			var entityGroup = EntityManager.Entities.Filter(EntityGroups.GetValue(new ByteFlag(1, 2)), EntityMatches.All);

			Assert.That(entityGroup.Count, Is.EqualTo(2));

			entity.Groups = EntityGroups.Nothing;

			Assert.That(entityGroup.Count, Is.EqualTo(1));
		}
コード例 #17
0
        public void GetLinker_GivenEntityGroups_ReturnsCorrectLinker()
        {
            //Arrange
            var entityGroups  = new EntityGroups();
            var linkerFactory = new LinkerFactory();

            //Act
            var linker = linkerFactory.GetLinker(entityGroups);

            //Assert
            Assert.IsInstanceOfType(linker, typeof(EntityGroupsLinker));
        }
コード例 #18
0
ファイル: SpawnManager.cs プロジェクト: kangkang198778/BCM
        private static void SpawnForEntity(int targetEntityId, IDictionary <string, string> settings)
        {
            // todo: delay between spawns based on command settings

            var entities = GameManager.Instance.World.Entities.dict;

            if (!entities.ContainsKey(targetEntityId))
            {
                Log.Out($"{Config.ModPrefix} Player not found: {targetEntityId}");

                return;
            }

            var targetEntity = entities[targetEntityId];

            if (targetEntity == null)
            {
                Log.Out($"{Config.ModPrefix}Target entity was not found in world");

                return;
            }

            //if player is dead turn off spawner if set with end_on_death flag (default == true)
            if (targetEntity.IsDead() && (!settings.ContainsKey("end_on_death") || settings["end_on_death"] == "true"))
            {
                settings["enabled"] = "false";

                return;
            }

            if (!settings.TryGetValue("group", out var groupName))
            {
                groupName = "ZombiesAll";
            }

            if (!EntityGroups.list.ContainsKey(groupName))
            {
                Log.Out($"{Config.ModPrefix}Entity group not found {groupName}");

                return;
            }

            var classId = EntityGroups.GetRandomFromGroup(groupName);

            if (!EntityClass.list.ContainsKey(classId))
            {
                Log.Out($"{Config.ModPrefix}Entity class not found {classId}");

                return;
            }

            EntitySpawner.SpawnQueue.Enqueue(GetSpawnForTarget(settings, targetEntity, classId));
        }
コード例 #19
0
        protected Entity(EntityGroups group)
        {
            Group       = group;
            orientation = quat.Identity;
            attachments = new List <EntityAttachment>();
            Components  = new ComponentCollection();

            // -1 means that the entity had no explicit ID given when spawned from a fragment file.
            Id = -1;
            IsUpdateEnabled = true;
            IsDrawEnabled   = true;
        }
コード例 #20
0
        public EntityGroup CreateEntityGroup(EntityGroups groups)
        {
            var entityGroup = new EntityGroup();

            for (int i = 0; i < parent.Count; i++)
            {
                var entity = parent[i];
                entityGroup.UpdateEntity(entity, IsEntityGroupValid(entity, groups));
            }

            return(entityGroup);
        }
コード例 #21
0
        public EntityGroup GetGroupByEntityGroup(EntityGroups groups)
        {
            EntityGroup entityGroup;

            if (!entityGroups.TryGetValue(groups, out entityGroup))
            {
                entityGroup          = CreateEntityGroup(groups);
                entityGroups[groups] = entityGroup;
            }

            return(entityGroup);
        }
コード例 #22
0
        public override void Load()
        {
            HamstarHelpersMod.Instance = this;

            this.LoadConfigs();

            if (!this.HasUnhandledExceptionLogger && this.Config.DebugModeUnhandledExceptionLogging)
            {
                this.HasUnhandledExceptionLogger            = true;
                AppDomain.CurrentDomain.UnhandledException += HamstarHelpersMod.UnhandledLogger;
            }

            this.LoadHelpers = new TmlHelpers.LoadHelpers();
            this.Promises    = new Promises();

            this.Timers                    = new Timers();
            this.LogHelpers                = new DebugHelpers.LogHelpers();
            this.ModMetaDataManager        = new TmlHelpers.ModMetaDataManager();
            this.BuffHelpers               = new BuffHelpers.BuffHelpers();
            this.NetHelpers                = new NetHelpers.NetHelpers();
            this.ItemIdentityHelpers       = new ItemHelpers.ItemIdentityHelpers();
            this.NPCIdentityHelpers        = new NPCHelpers.NPCIdentityHelpers();
            this.ProjectileIdentityHelpers = new ProjectileHelpers.ProjectileIdentityHelpers();
            this.BuffIdentityHelpers       = new BuffHelpers.BuffIdentityHelpers();
            this.NPCBannerHelpers          = new NPCHelpers.NPCBannerHelpers();
            this.RecipeHelpers             = new RecipeHelpers.RecipeHelpers();
            this.TmlPlayerHelpers          = new TmlHelpers.TmlPlayerHelpers();
            this.WorldHelpers              = new WorldHelpers.WorldHelpers();
            this.ControlPanel              = new UIControlPanel();
            this.ModLockHelpers            = new TmlHelpers.ModHelpers.ModLockHelpers();
            this.EntityGroups              = new EntityGroups();
            this.PlayerMessages            = new PlayerMessages();
            this.Inbox           = new InboxControl();
            this.ModVersionGet   = new ModVersionGet();
            this.ServerBrowser   = new ServerBrowserReporter();
            this.MenuItemMngr    = new MenuItemManager();
            this.MenuUIMngr      = new MenuUIManager();
            this.OldMenuItemMngr = new Utilities.Menu.OldMenuItemManager();
            this.MusicHelpers    = new MusicHelpers();

#pragma warning disable 612, 618
            TmlHelpers.AltNPCInfo.DataInitialize();
            TmlHelpers.AltProjectileInfo.DataInitialize();
#pragma warning restore 612, 618

            if (!this.Config.DisableControlPanelHotkey)
            {
                this.ControlPanelHotkey = this.RegisterHotKey("Mod Helpers Control Panel", "O");
            }

            this.LoadModData();
        }
コード例 #23
0
        public void UnloadModules()
        {
            this.Loadables.OnModsUnload();

            this.Loadables                  = null;
            this.ReflectionHelpers          = null;
            this.PacketProtocolMngr         = null;
            this.ExceptionMngr              = null;
            this.Timers                     = null;
            this.LogHelpers                 = null;
            this.ModFeaturesHelpers         = null;
            this.BuffHelpers                = null;
            this.NetHelpers                 = null;
            this.NPCAttributeHelpers        = null;
            this.ProjectileAttributeHelpers = null;
            this.BuffIdentityHelpers        = null;
            this.NPCBannerHelpers           = null;
            this.RecipeFinderHelpers        = null;
            this.RecipeGroupHelpers         = null;
            this.PlayerHooks                = null;
            this.LoadHelpers                = null;
            this.GetModInfo                 = null;
            this.GetModTags                 = null;
            this.WorldStateHelpers          = null;
            this.ModLock                    = null;
            this.EntityGroups               = null;
            this.AnimatedColors             = null;
            this.AnimatedTextures           = null;
            this.PlayerMessages             = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.LoadHooks             = null;
            this.CustomLoadHooks       = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.Server                = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo          = null;
            this.RecipeHack           = null;
            this.ModListHelpers       = null;
            this.ItemAttributeHelpers = null;
            this.WorldTimeHooks       = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
コード例 #24
0
        /*Tuple<IAuthorizationRepository, IPermissionsBuilderService> Init(ISession session)
         * {
         *      using (var childContainer = new WindsorContainer()
         *              .Register(Component.For<ISession>().Instance(session)))
         *      {
         *              container.AddChildContainer(childContainer);
         *              return Tuple.Create(childContainer.Resolve<IAuthorizationRepository>(), childContainer.Resolve<IPermissionsBuilderService>());
         *      }
         * }
         *
         * readonly IWindsorContainer container;
         * public void OnPostInsert(PostInsertEvent @event)
         * {
         *      var contest = @event.Entity as Contest;
         *      if(contest != null)
         *      {
         *              var rs = Init(@event.Session);
         *              OnContestCreated(contest, rs);
         *      }
         *      return;
         * }
         *
         * public bool OnPreUpdate(PreUpdateEvent ev)
         * {
         *      var contest = ev.Entity as Contest;
         *      if (contest != null)
         *      {
         *              var rs = Init(ev.Session);
         *              var authz = rs.Item1;
         *              var pbs = rs.Item2;
         *
         *              var isPublicIndex = PropertyIndex(ev, "IsPublic");
         *              var isActiveIndex = PropertyIndex(ev, "IsActive");
         *              var judgeIndex = PropertyIndex(ev, "Owner");
         *              var ownerIndex = PropertyIndex(ev, "Judge");
         *
         *              var oldIsPublic = (bool)ev.OldState[isPublicIndex];
         *              var newIsPublic = (bool)ev.State[isPublicIndex];
         *
         *              var oldIsActive = (bool)ev.OldState[isActiveIndex];
         *              var newIsActive = (bool)ev.State[isActiveIndex];
         *
         *              var oldOwner = (User)ev.OldState[ownerIndex];
         *              var newOwner = (User)ev.State[ownerIndex];
         *
         *              var oldJudge = (User)ev.OldState[judgeIndex];
         *              var newJudge = (User)ev.State[judgeIndex];
         *
         *              if(oldIsPublic != newIsPublic)
         *                      OnIsPublicChanged(contest, newIsPublic, pbs);
         *
         *              if(oldIsActive != newIsActive)
         *                      OnIsActiveChanged(contest, newIsActive, authz);
         *
         *              if(oldOwner != newOwner)
         *                      OnOwnerChanged(contest, oldOwner, authz);
         *
         *              if (oldJudge != newJudge)
         *                      OnJudgeChanged(contest, oldJudge, authz);
         *      }
         *      return false;
         * }
         *
         * static int PropertyIndex(PreUpdateEvent @event, string propName)
         * {
         *      return Array.IndexOf(@event.Persister.PropertyNames, propName);
         * }*/

        public void OnCreated(Contest contest)
        {
            var judges = authz.CreateUsersGroup(UserGroups.ContestJudges(contest));
            var owners = authz.CreateUsersGroup(UserGroups.ContestOwners(contest));

            authz.CreateUsersGroup(UserGroups.ContestParticipants(contest));

            OnOwnerChanged(contest, null);
            OnJudgeChanged(contest, null);
            OnIsPublicChanged(contest, contest.IsPublic);

            var judgeOps = new[]
            {
                ContestOperation.View,
                ContestOperation.ViewMonitor,
                ContestOperation.ManageMessages,
            };

            var ownerOps = new[]
            {
                ContestOperation.ChangeAdministration,
                ContestOperation.EditProblems,
                ContestOperation.EditSettings,
                ContestOperation.ManageParticipationApplications,
                ContestOperation.ManageProblems,
                ContestOperation.ManageRights,
                ContestOperation.RejudgeProblems,
                ContestOperation.Submit,
            }.Concat(judgeOps);

            foreach (var op in judgeOps)
            {
                pbs.Allow(op).For(judges).On(contest).DefaultLevel().Save();
            }

            foreach (var op in ownerOps)
            {
                pbs.Allow(op).For(owners).On(contest).DefaultLevel().Save();
            }

            var submissions         = authz.CreateEntitiesGroup(EntityGroups.Submissions(contest));
            var questionsAndAnswers = authz.CreateEntitiesGroup(EntityGroups.QuestionsAndAnswers(contest));

            pbs.Allow(MessageOperation.View).For(judges).On(questionsAndAnswers).DefaultLevel().Save();
            pbs.Allow(MessageOperation.View).For(owners).On(questionsAndAnswers).DefaultLevel().Save();

            pbs.Allow(SubmissionOperation.View).For(judges).On(submissions).DefaultLevel().Save();
            pbs.Allow(SubmissionOperation.View).For(owners).On(submissions).DefaultLevel().Save();
        }
コード例 #25
0
        public override void Unload()
        {
            this.UnloadModData();

            this.Promises.FulfillModUnloadPromises();

            try {
                if (this.HasUnhandledExceptionLogger)
                {
                    this.HasUnhandledExceptionLogger            = false;
                    AppDomain.CurrentDomain.UnhandledException -= HamstarHelpersMod.UnhandledLogger;
                }
            } catch { }

            this.ExceptionMngr             = null;
            this.Timers                    = null;
            this.ConfigJson                = null;
            this.PacketProtocols           = null;
            this.LogHelpers                = null;
            this.ModMetaDataManager        = null;
            this.BuffHelpers               = null;
            this.NetHelpers                = null;
            this.ItemIdentityHelpers       = null;
            this.NPCIdentityHelpers        = null;
            this.ProjectileIdentityHelpers = null;
            this.BuffIdentityHelpers       = null;
            this.NPCBannerHelpers          = null;
            this.RecipeHelpers             = null;
            this.TmlPlayerHelpers          = null;
            this.LoadHelpers               = null;
            this.ModVersionGet             = null;
            this.WorldHelpers              = null;
            this.ModLockHelpers            = null;
            this.EntityGroups              = null;
            this.AnimatedColors            = null;
            this.PlayerMessages            = null;
            this.Inbox = null;
            this.ControlPanelHotkey = null;
            this.ControlPanel       = null;
            this.ServerBrowser      = null;
            this.MenuItemMngr       = null;
            this.MenuUIMngr         = null;
            this.OldMenuItemMngr    = null;
            this.MusicHelpers       = null;
            this.Promises           = null;

            HamstarHelpersMod.Instance = null;
        }
コード例 #26
0
    public override void Execute(MinEventParams _params)
    {
        if (!SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer)
        {
            return;
        }

        for (int j = 0; j < this.targets.Count; j++)
        {
            Debug.Log("SpawnBabySDX()");
            EntityAlive entity = this.targets[j] as EntityAlive;
            if (entity)
            {
                Debug.Log("SpawnBabySDX(): Is an EntityAlive");
                int EntityID = entity.entityClass;

                // If the group is set, then use it.
                if (!string.IsNullOrEmpty(this.strSpawnGroup))
                {
                    int ClassID = 0;
                    EntityID = EntityGroups.GetRandomFromGroup(this.strSpawnGroup, ref ClassID);
                }
                Vector3 transformPos;
                entity.world.GetRandomSpawnPositionMinMaxToPosition(entity.position, 2, 6, 2, true, out transformPos, false);

                Entity NewEntity = EntityFactory.CreateEntity(EntityID, transformPos, entity.rotation) as Entity;
                if (NewEntity)
                {
                    NewEntity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
                    GameManager.Instance.World.SpawnEntityInWorld(NewEntity);
                    Debug.Log("An entity was created: " + NewEntity.ToString());
                    if (NewEntity is EntityAlive)
                    {
                        Debug.Log("Setting " + this.strCvar + " ID to: " + entity.entityId + " for " + NewEntity.entityId);
                        (NewEntity as EntityAlive).Buffs.SetCustomVar(strCvar, entity.entityId, true);
                    }
                }
                else
                {
                    Debug.Log(" Could not Spawn baby for: " + entity.name + " : " + entity.entityId);
                }
            }
            else
            {
                Debug.Log("SpawnBabySDX(): Not an EntityAlive");
            }
        }
    }
コード例 #27
0
        public void ConvertToXml_GivenValidObject_MapsCorrectly()
        {
            //Arrange
            var entityGroupsMapper = new EntityGroupsMapper(_entityGroupMapper.Object);
            var entityGroups       = new EntityGroups()
            {
                new EntityGroup("test")
            };

            //Act
            var xml = entityGroupsMapper.Convert(entityGroups);

            //Assert
            Assert.IsInstanceOfType(xml, typeof(entitygroups));
            Assert.AreEqual(1, xml.Items.Length);
        }
コード例 #28
0
        public void GroupSendMessage()
        {
            var entity      = EntityManager.CreateEntity(EntityGroups.GetValue(new ByteFlag(1, 2, 3)));
            var component1  = Substitute.For <DummyComponent1>();
            var component2  = Substitute.For <DummyComponent2>();
            var entityGroup = EntityManager.Entities.Filter(EntityGroups.GetValue(new ByteFlag(1, 2)), EntityMatches.All);

            entity.Add(component1);
            entity.Add(component2);
            entityGroup.BroadcastMessage(0);

            component1.Received(1).MessageNoArgument();
            component1.Received(1).OnMessage(0);
            component2.Received(1).MessageNoArgument();
            component2.Received(1).OnMessage(0);
        }
コード例 #29
0
        public void UnloadOuter()
        {
            this.ReflectionHelpers         = null;
            this.PacketProtocolMngr        = null;
            this.ExceptionMngr             = null;
            this.Timers                    = null;
            this.ConfigJson                = null;
            this.LogHelpers                = null;
            this.ModFeaturesHelpers        = null;
            this.BuffHelpers               = null;
            this.NetHelpers                = null;
            this.ItemIdentityHelpers       = null;
            this.NPCIdentityHelpers        = null;
            this.ProjectileIdentityHelpers = null;
            this.BuffIdentityHelpers       = null;
            this.NPCBannerHelpers          = null;
            this.RecipeIdentityHelpers     = null;
            this.RecipeGroupHelpers        = null;
            this.PlayerHooks               = null;
            this.LoadHelpers               = null;
            this.GetModInfo                = null;
            this.GetModTags                = null;
            this.WorldStateHelpers         = null;
            this.ModLock                   = null;
            this.EntityGroups              = null;
            this.AnimatedColors            = null;
            this.PlayerMessages            = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.CustomEntMngr         = null;
            this.Promises              = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.ServerInfo            = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo    = null;
            this.RecipeHack     = null;
            this.ModListHelpers = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
コード例 #30
0
        private void LoadModules()
        {
            this.Loadables.OnModsLoad();

            this.ReflectionHelpers = new ReflectionHelpers();
            this.DataStore         = new DataStore();
            this.LoadHooks         = new LoadHooks();
            this.CustomLoadHooks   = new CustomLoadHooks();
            this.LoadHelpers       = new LoadHelpers();

            this.Timers             = new Timers();
            this.LogHelpers         = new LogHelpers();
            this.ModFeaturesHelpers = new ModFeaturesHelpers();
            this.PacketProtocolMngr = new PacketProtocolManager();

            this.BuffHelpers                = new BuffHelpers();
            this.NetHelpers                 = new NetPlayHelpers();
            this.NPCAttributeHelpers        = new NPCAttributeHelpers();
            this.ProjectileAttributeHelpers = new ProjectileAttributeHelpers();
            this.BuffIdentityHelpers        = new BuffAttributesHelpers();
            this.NPCBannerHelpers           = new NPCBannerHelpers();
            this.RecipeFinderHelpers        = new RecipeFinderHelpers();
            this.RecipeGroupHelpers         = new RecipeGroupHelpers();
            this.PlayerHooks                = new ExtendedPlayerHooks();
            this.WorldTimeHooks             = new WorldTimeHooks();
            this.WorldStateHelpers          = new WorldStateHelpers();
            this.ControlPanel               = new UIControlPanel();
            this.ModLock               = new ModLockService();
            this.EntityGroups          = new EntityGroups();
            this.PlayerMessages        = new PlayerMessages();
            this.Inbox                 = new InboxControl();
            this.GetModInfo            = new GetModInfo();
            this.GetModTags            = new GetModTags();
            this.MenuItemMngr          = new MenuItemManager();
            this.MenuContextMngr       = new MenuContextServiceManager();
            this.MusicHelpers          = new MusicHelpers();
            this.PlayerIdentityHelpers = new PlayerIdentityHelpers();
            this.CustomHotkeys         = new CustomHotkeys();
            this.XnaHelpers            = new XNAHelpers();
            this.Server                = new Server();
            //this.PlayerDataMngr = new PlayerDataManager();
            this.SupportInfo          = new SupportInfoDisplay();
            this.RecipeHack           = new RecipeHack();
            this.ModListHelpers       = new ModListHelpers();
            this.ItemAttributeHelpers = new ItemAttributeHelpers();
        }
コード例 #31
0
ファイル: Actor.cs プロジェクト: LaserYGD/Zeldo-CSharp
        // TODO: Use actor flags to optimize controller creation (and to return early from some functions).
        protected Actor(EntityGroups group, bool canTraverseGround = true) : base(group)
        {
            aerialController   = new AerialController(this);
            platformController = new PlatformController(this);

            // Some actors can't run on the ground (like flying enemies), so it would be wasteful to create the ground
            // controller.
            if (canTraverseGround)
            {
                groundController = new GroundController(this);
            }

            // TODO: Consider allowing actors to spawn directly on the ground (via a raycast).
            // This assumes that all actors spawn in the air (likely just above the ground).
            activeController = aerialController;
            facing           = vec2.UnitX;
        }