예제 #1
0
        private static void Spawn(ConCommandArgs args)
        {
            var spawnCardStr = args.userArgs[0];
            var eliteStr     = args.userArgs.Count > 1 ? args.userArgs[1] : "";

            var spawnCard = Resources.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/" + spawnCardStr);

            if (spawnCard == null)
            {
                Debug.LogWarning($"Could not locate character spawn card asset with name {spawnCardStr}; should be 'cscBeetle' for spawning a beetle, for instance");
                return;
            }

            EliteAffixCard affixCard = null;

            if (!string.IsNullOrEmpty(eliteStr))
            {
                affixCard = EsoLib.Cards.FirstOrDefault(c => EliteCatalog
                                                        .GetEliteDef(c.eliteType).modifierToken.ToLower()
                                                        .Contains(eliteStr.ToLower()));
            }

            var user = LocalUserManager.GetFirstLocalUser();
            var body = user.cachedBody;

            if (body?.master == null)
            {
                Debug.LogError("Cannot find local user body!");
                return;
            }

            var placement = new DirectorPlacementRule
            {
                spawnOnTarget   = body.transform,
                maxDistance     = 40,
                placementMode   = DirectorPlacementRule.PlacementMode.Approximate,
                preventOverhead = false
            };

            var rng = new Xoroshiro128Plus((ulong)DateTime.Now.Ticks);

            if (EsoLib.TrySpawnElite(spawnCard, affixCard, placement, rng) == null)
            {
                Debug.LogWarning("Failed to spawn elite; try again somewhere less crowded");
            }
        }
예제 #2
0
 public EsoPlugin()
 {
     EsoLib.Init();
     R2API.Utils.CommandHelper.AddToConsoleWhenReady();
 }