private static void SpawnMobHelper(Mob newMob) { mobTable.Add(newMob.mobItem.Id, newMob); newMob.mobItem.World.ItemCache.AddItem(newMob.mobItem); newMob.mobItem.UpdateRegionSimple(); GlobalVars.log.InfoFormat("adding bot to botman"); // send event var eventInstance = new BotSpawn { ItemId = newMob.mobItem.Id, Position = newMob.mobItem.Position, Rotation = newMob.mobItem.Rotation, }; SendParameters sp = MmoActorOperationHandler.GetDefaultSP(); // sp.Unreliable = false; var eventData = new EventData((byte)EventCode.BotSpawn, eventInstance); var message = new ItemEventMessage(newMob.mobItem, eventData, sp); newMob.mobItem.EventChannel.Publish(message); ((MmoActorOperationHandler)serverPeer.CurrentOperationHandler).AddItem(newMob.mobItem); //todo add bot to radar, just check that the world is the right one // ((World)this.World).Radar.AddItem(item, operation.Position); }
private void BotSpawnProfileCreate() { string[] result = (string[])BotSpawn?.CallHook("ProfileExists", "DynamicPVP"); if (true) //if (result[0] == "false") { //DebugPrint("BotsSpawn Does not contain custom profile `DynamicPVP`.", true); var _profile = JsonConvert.SerializeObject(new DataProfile()); result = (string[])BotSpawn?.CallHook("CreateNewProfile", BotSpawnProfileName, _profile); if (result[0] == "false") { DebugPrint($"BotsSpawn failed to add/update `DynamicPVP`.\n{result[1]}", true); } else { result = (string[])BotSpawn?.CallHook("ProfileExists", "DynamicPVP"); if (result[0] == "false") { DebugPrint($"Added but failed show `DynamicPVP`.\n{result[1]}", true); } else { DebugPrint("Succesfully updated custom profile `DynamicPVP`.", true); } } } else { DebugPrint("Custom profile `DynamicPVP` already exists.", true); } }
void Spawn(Entity entity, BotSpawn botSpawnFromEntity, LevelSize levelSize) { Random rand = new Random((uint)System.DateTime.Now.ToBinary()); float maxX = levelSize.X / 2; float minX = -maxX; float maxY = levelSize.Y / 2; float minY = -maxY; for (var i = 0; i < botSpawnFromEntity.Count; ++i) { var position = new float3(rand.NextFloat(minX, maxX), 0, rand.NextFloat(minY, maxY)); // Create our new Bot entity var instance = EntityManager.Instantiate(botSpawnFromEntity.Prefab); // Set correct bot location EntityManager.SetComponentData(instance, new Translation { Value = position }); EntityManager.AddComponent(instance, typeof(BotTag)); EntityManager.AddComponentData(instance, new CollisionSize { Value = botSpawnFromEntity.CollisionSize }); EntityManager.AddComponentData(instance, new BotSpeed { Value = new float2(rand.NextFloat(botSpawnFromEntity.MinSpeed, botSpawnFromEntity.MaxSpeed), rand.NextFloat(botSpawnFromEntity.MinSpeed, botSpawnFromEntity.MaxSpeed)) }); } EntityManager.DestroyEntity(entity); }
bool SpawnBots(Vector3 zoneLocation, string zoneProfile, string zoneGroupID) { if (!String.IsNullOrEmpty(zoneProfile)) { string[] result = (string[])BotSpawn?.CallHook("AddGroupSpawn", zoneLocation, zoneProfile, zoneGroupID); if (result == null || result.Length < 2) { DebugPrint("AddGroupSpawn returned invalid response.", false); return(false); } switch (result[0]) { case "true": return(true); case "false": return(false); case "error": DebugPrint($"ERROR: AddGroupSpawn failed: {result[1]}", true); return(false); default: return(false); } } return(false); }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var spawnerData = new BotSpawn { // The referenced prefab will be converted due to DeclareReferencedPrefabs. // So here we simply map the game object to an entity reference to that prefab. Prefab = conversionSystem.GetPrimaryEntity(Prefab), Count = Count, MinSpeed = MinSpeed, MaxSpeed = MaxSpeed, CollisionSize = CollisionSize }; dstManager.AddComponentData(entity, spawnerData); }
bool RemoveBots(string zoneGroupID) { string[] result = (string[])BotSpawn?.CallHook("RemoveGroupSpawn", zoneGroupID); if (result == null || result.Length < 2) { DebugPrint("RemoveGroupSpawn returned invalid response.", false); return(false); } else if (result[0] == "error") { DebugPrint($"ERROR: RemoveGroupSpawn failed: {result[1]}", true); return(false); } else { return(true); } }
string[] AddProfile(DataProfile profile) => (string[])BotSpawn?.CallHook("CreateNewProfile", "DynamicPVP", profile);
string[] CheckProfile(string profile) => (string[])BotSpawn?.CallHook("ProfileExists", profile);
string[] RemoveBots(string zoneGroupID) => (String[])BotSpawn?.CallHook("RemoveGroupSpawn", zoneGroupID);
// BotSpawn API string[] SpawnBots(Vector3 zoneLocation, string zoneProfile, string zoneGroupID) => (String[])BotSpawn?.CallHook("AddGroupSpawn", zoneLocation, zoneProfile, zoneGroupID);