public void onMultiSelect(SimSet set) { EditorTree EditorTree = "EditorTree"; EditorGui EditorGui = "EditorGui"; EditorGui.EditorGuiStatusBar EditorGuiStatusBar = "EditorGuiStatusBar"; ETransformSelection ETransformSelection = "ETransformSelection"; int count = set.getCount(); int i = 0; for (uint x = 0; x < set.getCount(); x++) { SimObject obj = set.getObject(x); if (obj.isMethod("onEditorSelect")) { obj.call("onEditorSelect", count.AsString()); } i++; EditorTree.addSelection(obj, i == count); EditorGui.currentEditor.onObjectSelected(obj); } // Inform the camera console.commandToServer("EditorOrbitCameraSelectChange", new string[] { count.AsString(), getSelectionCentroid().AsString() }); EditorGuiStatusBar.setSelectionObjectsByCount(getSelectionSize().AsString()); // Update the Transform Selection window, if it is // visible. if (ETransformSelection.isVisible()) { ETransformSelection.onSelectionChanged(); } }
public static CustomDemoPlayer SpawnOnPath(string ainame, SimSet path) { if (!omni.console.isObject(path)) return null; Marker node = path.getObject((uint)r.Next(0, path.getCount() - 1)); TransformF transform = node.getTransform(); return Spawn(ainame, transform); }
public void scanGroup(SimSet group) { GuiEditorGui.GuiEditor GuiEditor = "GuiEditor"; for (uint i = 0; i < group.getCount(); i++) { SimObject obj = group.getObject(i); if (obj.isMemberOfClass("GuiControl")) { if (obj.getClassName() == "GuiCanvas") this.scanGroup((GuiCanvas) obj); else { string name; if (obj.getName() == "") name = "(unnamed) - " + obj; else name = obj.getName() + " - " + obj; bool skip = false; foreach (string guiEntry in sGlobal["$GuiEditor::GuiFilterList"].Split('\t')) { if (obj.getName() == guiEntry) { skip = true; break; } } if (!skip) this.add(name, obj); } } else if (obj.isMemberOfClass("SimGroup") && ( //(%obj.internalName !$= "EditorGuiGroup" /* Copyright (C) 2013 WinterLeaf Entertainment LLC. */&& %obj.internalName !$= "IngameGuiGroup" ) // Don't put our editor's GUIs in the list /*||*/ GuiEditor["showEditorGuis"].AsBool())) // except if explicitly requested. { // Scan nested SimGroups for GuiControls. this.scanGroup((SimGroup) obj); } } }
public virtual void FollowPath(SimSet path, int node) { stopThread(0); if (!path.isObject() || !isObject()) { this["path"] = ""; return; } if (node > path.getCount() - 1) this["targetNode"] = (path.getCount() - 1).AsString(); else this["targetNode"] = node.AsString(); if ((this["path"]) == path) MoveToNode(this["currentNode"].AsUint()); else { this["path"] = path; MoveToNode(0); } }
public override int onThrow(ShapeBase player, int amount) { if (amount == 0) { amount = 1; } if (this["maxInventory"] != string.Empty) { if (amount > this["maxInventory"].AsInt()) { amount = this["maxInventory"].AsInt(); } } if (amount == 0) { return(0); } player.decInventory(this, amount); TransformF rot = new TransformF(player.getEulerRotation()); ObjectCreator tc_obj = new ObjectCreator("AITurretShape", string.Empty); tc_obj["datablock"] = this.getName(); tc_obj["rotation"] = "0 0 1 " + rot.mPositionZ; tc_obj["count"] = "1"; tc_obj["sourceObject"] = player; tc_obj["client"] = player["client"]; tc_obj["isAiControlled"] = true; AITurretShape obj = tc_obj.Create(); ((SimSet)"MissionGroup").pushToBack(obj); //todo change to csharp obj.addToIgnoreList(player); GameConnection client = player["client"]; if (client.isObject()) { if (client["ownedTurrets"] == string.Empty) { client["ownedTurrets"] = new ObjectCreator("SimSet", string.Empty).Create().AsString(); } SimSet SimSet_id = client["ownedTurrets"]; int countofitems = SimSet_id.getCount(); for (uint i = 0; i < countofitems; i++) { AITurretShape turret = SimSet_id.getObject(i); turret.addToIgnoreList(obj); obj.addToIgnoreList(turret); } SimSet_id.pushToBack(obj); } return(obj); }
public virtual bool SpawnPlayer(string spawnpoint, bool nocontrol) { Player player = this["player"]; if (player.isObject()) { console.error("Attempting to create a player for a client that already has one!"); return(false); } if ((spawnpoint.Split(' ').GetUpperBound(0) == 0) && (spawnpoint.isObject())) { // Attempt to treat %spawnPoint as an object string spawnclass = sGlobal["$Game::DefaultPlayerClass"]; string spawndatablock = sGlobal["$Game::DefaultPlayerDataBlock"]; SimObject ospawnpoint = spawnpoint; // Overrides by the %spawnPoint if (ospawnpoint["spawnClass"] != "") { spawnclass = ospawnpoint["spawnClass"]; //spawndatablock = ospawnpoint["spawnDataBlock"]; } else if (ospawnpoint["spawnDatablock"] != "") { // This may seem redundant given the above but it allows // the SpawnSphere to override the datablock without // overriding the default player class spawndatablock = ospawnpoint["spawnDatablock"]; } string spawnproperties = ospawnpoint["spawnProperties"]; string spawnScript = ospawnpoint["spawnScript"]; // Spawn with the engine's Sim::spawnObject() function player = Util.spawnObject(spawnclass, spawndatablock, "", spawnproperties, spawnScript, typeof(Player).FullName); //player.TickCounterNotifyServer = true; //player.TickCounterAdd("TestCheck", 100); //player.TickNotifyBefore = true; //player.TickNotifyClient = true; //player.TickNotifyServer = true; //player.TickNotifyBefore = true; // If we have an object do some initial setup if (console.isObject(player)) { // Pick a location within the spawn sphere. player.setTransform(PointInSpawnSphere(player, (spawnpoint))); } else { // If we weren't able to create the player object then warn the user // When the player clicks OK in one of these message boxes, we will fall through // to the "if (!isObject(%player))" check below. if (console.GetVarString(spawndatablock).Trim() != "") { WinterLeaf.Demo.Full.Models.User.GameCode.Client.Gui.messageBox.MessageBoxOK("Spawn Player Failed", "Unable to create a player with class " + spawnclass + " and datablock " + spawndatablock + ".\n\nStarting as an Observer instead.", ""); } else { WinterLeaf.Demo.Full.Models.User.GameCode.Client.Gui.messageBox.MessageBoxOK("Spawn Player Failed", "Unable to create a player with class " + spawnclass + ".\n\nStarting as an Observer instead.", ""); } } } else { // Create a default player player = console.SpawnObject(sGlobal["$Game::DefaultPlayerClass"], sGlobal["$Game::DefaultPlayerDataBlock"], string.Empty, string.Empty, string.Empty); if (player.isMemberOfClass("Player")) { //if (SimObject.SimObject_isMemberOfClass(player, "Player")) console.warn("Trying to spawn a class that does not derive from player!!!!!"); } // Treat %spawnPoint as a transform player.setTransform(new TransformF(spawnpoint)); } // Update the default camera to start with the player if (!console.isObject(player)) { this["spawnCamera"] = spawnpoint; return(false); } ((SimSet)"MissionCleanup").pushToBack(player); // Update the default camera to start with the player // Store the client object on the player object for // future reference player["client"] = this; // If the player's client has some owned turrets, make sure we let them // know that we're a friend too. if (this["ownedTurrets"].AsInt() >= 1) { SimSet turrets = this["ownedTurrets"]; for (uint i = 0; i < turrets.getCount(); i++) { ((AITurretShape)turrets.getObject(i)).addToIgnoreList(player); } } player.setShapeName(this["playerName"]); SimDataBlock playerdata = player.getDataBlock(); player.setEnergyLevel(playerdata["maxEnergy"].AsFloat()); if (this["skin"] != string.Empty) { string availableSkins = playerdata["availableSkins"]; foreach (GameConnection other in ClientGroup.Where(other => other != this)) { availableSkins = availableSkins.Replace(console.GetVarString(other + ".skin"), " "); availableSkins = availableSkins.Replace(" ", " "); } List <string> availskin = availableSkins.Split('\t').ToList(); if (availskin.Count > 0) { int r = new Random().Next(0, availskin.Count - 1); this["skin"] = availskin[r]; } } player.setSkinName(this["skin"]); this["player"] = player; console.error("--->Player ID is " + player); SimObject control = null; if (console.GetVarString("$startWorldEditor") == "1") { control = this["camera"]; Camera c = this["camera"]; c.setMode("Fly"); console.Call("EditorGui", "syncCameraGui"); } else { control = player; } if (!nocontrol) { this.setControlObject(control); } int team = new Random().Next(1, 2); player.AddObjectTo_MobSearchGroup(team); message.MessageClient(this, "System", "Your on Team " + team); console.error(DateTime.Now + " --- PLAYER JOIN::Name '" + Util.StripMLControlChars(player.getShapeName()) + "'::ID '" + player + "'"); return(true); }
public virtual void onDeath(GameBase sourceobject, GameConnection sourceclient, string damagetype, string damloc) { if (this.isObject()) { if (this["ownedTurrets"] == string.Empty) { this["ownedTurrets"] = new ObjectCreator("SimSet").Create().AsString(); } SimSet simSet = this["ownedTurrets"]; for (uint i = 0; i < simSet.getCount(); i++) { ((SimObject)simSet.getObject(i)).schedule("10", "delete"); } } // clear the weaponHUD this.refreshWeaponHud(0, string.Empty, string.Empty, string.Empty, 0); Player player = this["player"]; // Clear out the name on the corpse player.setShapeName(string.Empty); // Update the numerical Health HUD //PlayerUpdateHealth(player); // Switch the client over to the death cam and unhook the player object. Camera camera = this["camera"]; if (camera.isObject() && player.isObject()) { camera.setMode("Corpse", player, string.Empty, string.Empty); //camera.call("setMode", "Corpse", player, string.Empty, string.Empty); this.setControlObject(camera); } else { console.print("------------>Failed to Switch the client over to the death cam."); } this["player"] = "0"; // Display damage appropriate kill message string sendMsgFunction = "sendMsgClientKilled_" + damagetype; //if (!console.isFunction(sendMsgFunction)) // { // sendMsgFunction = "sendMsgClientKilled_Default"; // } console.Call(sendMsgFunction, new string[] { "MsgClientKilled", this, sourceclient, damloc }); // Dole out points and check for win if ((damagetype == "Suicide") || (sourceclient == this)) { IncDeaths(this, "1", "1"); IncScore(this, "-1", "0"); } else { IncDeaths(this, "1", "0"); IncScore(sourceclient, "1", "1"); IncKills(sourceclient, "1", "0"); } if (iGlobal["$Game::EndGameScore"] > 0 && sourceclient["kills"].AsInt() >= iGlobal["$Game::EndGameScore"]) { missionLoad.cycleGame(); } }
public void onMultiSelect(SimSet set) { EditorTree EditorTree = "EditorTree"; EditorGui EditorGui = "EditorGui"; EditorGui.EditorGuiStatusBar EditorGuiStatusBar = "EditorGuiStatusBar"; ETransformSelection ETransformSelection = "ETransformSelection"; int count = set.getCount(); int i = 0; for (uint x = 0; x < set.getCount(); x++) { SimObject obj = set.getObject(x); if (obj.isMethod("onEditorSelect")) obj.call("onEditorSelect", count.AsString()); i++; EditorTree.addSelection(obj, i == count); EditorGui.currentEditor.onObjectSelected(obj); } // Inform the camera console.commandToServer("EditorOrbitCameraSelectChange", new string[] {count.AsString(), getSelectionCentroid().AsString()}); EditorGuiStatusBar.setSelectionObjectsByCount(getSelectionSize().AsString()); // Update the Transform Selection window, if it is // visible. if (ETransformSelection.isVisible()) ETransformSelection.onSelectionChanged(); }
public static string MissionBoundsExtents(SimSet group) { string box = "0 0 0 0 0 0"; int count = group.getCount(); for (uint i = 0; i < count; i++) { // Skip LevelInfos. Need a way to detect other non-SceneObjects. // Also skip GroundPlanes. They're too big. SimObject obj = group.getObject(i); //var cls = obj.getClassName(); string cls = obj.GetType().Name; if (cls == "LevelInfo" || cls == "GroundPlane" || cls == "GroundCover") continue; // Get world box - might have to recurse into nested SimGroups. string wbox = "0 0 0 0 0 0"; if (cls == "SimGroup" || cls == "SimSet" || cls == "Path") wbox = MissionBoundsExtents((SimSet) obj); else if (obj.GetType() == typeof (SceneObject) && ((SceneObject) obj).getType() == omni.iGlobal["$TypeMasks::StaticObjectType"] && !(((SceneObject) obj).getType() == omni.iGlobal["$TypeMasks::EnvironmentObjectType"])) wbox = ((SceneObject) obj).getWorldBox().AsString(); else continue; // Update min point. for (int j = 0; j < 3; j++) { if (omni.Util.getWord(box, j).AsInt() > omni.Util.getWord(wbox, j).AsInt()) box = omni.Util.setWord(box, j, omni.Util.getWord(wbox, j)); } // Update max point. for (int j = 3; j < 6; j++) { if (omni.Util.getWord(box, j).AsInt() < omni.Util.getWord(wbox, j).AsInt()) box = omni.Util.setWord(box, j, omni.Util.getWord(wbox, j)); } } return box; }
public static void sfxStopAll(SimSet channel) { channel = sfxOldChannelToGroup(channel); if (!channel.isObject()) return; for (uint i = 0; i < channel.getCount(); i++) ((SFXSource) channel.getObject(i)).stop(-1); //SFXSource.stop(channel.getObject(i), -1); }
public void selectAllControlsInSet(SimSet set, bool deselect) { if (!set.isObject()) return; for (uint i = 0; i < set.getCount(); i++) { SimObject obj = set.getObject(i); if (!obj.isMemberOfClass("GuiControl")) continue; if (!deselect) this.addSelection(obj); else this.removeSelection(obj); } }