public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); this.positions.Add(transform.Position); transform.Add(new CommandBinding(transform.Delete, delegate() { this.positions.Remove(transform.Position); })); entity.CannotSuspendByDistance = true; VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main); this.SetMain(entity, main); transform.EditorProperties(); attachable.EditorProperties(); entity.Add(new Updater ( delegate(float dt) { Entity player = PlayerFactory.Instance; if (player != null && player.Active) { Player p = player.Get <Player>(); float y = p.Character.Transform.Value.Translation.Y; float limit = transform.Position.Value.Y; if (y < limit + absoluteLimit || (y < limit && p.Character.LinearVelocity.Value.Y < velocityThreshold)) { p.Die.Execute(); } } else { player = null; } } )); }
/************************/ /*** Public Functions ***/ /************************/ public void OnUpdate(float deltaTime, Transform transform) { transform.Add(speed, deltaTime); }
// ---------------------------------------------------------------------------------------- // Location constructor (five target tables, not just one) // ---------------------------------------------------------------------------------------- public ParameterizedLocation() : base("Location", 50) { // -------------------------------------------------------------------------- // Set general module values // -------------------------------------------------------------------------- ImportItemTable = "Location_Import_Item"; RealIdColumn = "RealLocationId"; MainTable = "location_Master"; MainTablePk = "location_ID"; try { // -------------------------------------------------------------------------- // Set ETL extract dictionary parameters, Set error codes for input columns // -------------------------------------------------------------------------- Extract.Add("location_ID", new ExtractField("location_ID", 2, 1, "^[0-9]+$", "int", 10, "1805", "1806", "1807", "1808", "1809")); // start location_Master Extract.Add("Agency_ID", new ExtractField("location_ID", 0, -1, "^[0-9]+$", "int", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Agency_Name", new ExtractField("location_Name", 0, -1, "", "string", 80, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Agency_Active", new ExtractField("location_Active", 0, -1, "^[01]$", "bit", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Create_Date", new ExtractField("Create_Date", 0, -1, "^'?(19|20)[0-9][0-9]-[01][0-9]-[0-3][0-9]", "date", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_2_ID2", new ExtractField("location_ID", 0, -1, "^[0-9]+$", "int", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Address1", new ExtractField("location_Address", 0, -1, "", "string", 50, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Address2", new ExtractField("", 0, -1, "", "string", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("City", new ExtractField("location_City", 0, -1, "", "string", 50, "1800", "1800", "1800", "1800", "1800")); Extract.Add("State", new ExtractField("", 0, -1, "", "string", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Zip", new ExtractField("location_Zip", 0, -1, "", "string", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Phone", new ExtractField("location_Phone", 0, -1, "", "string", 13, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Contact_Name", new ExtractField("location_Contact_Name", 0, -1, "", "string", 50, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Email_Address", new ExtractField("location_Email", 0, -1, "", "string", 4000, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Active", new ExtractField("location_Active", 0, -1, "^[01]$", "bit", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("County_Id", new ExtractField("", 0, -1, "^[0-9]+$", "int", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Agency_code", new ExtractField("", 0, -1, "", "string", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_1_ID", new ExtractField("location_ID", 0, -1, "^[0-9]+$", "int", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_1_name", new ExtractField("location_Name", 0, -1, "", "string", 128, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_1_active", new ExtractField("location_Active", 0, -1, "^[01]$", "bit", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_1_create_date", new ExtractField("Level_1_create_date", 0, -1, "^'?(19|20)[0-9][0-9]-[01][0-9]-[0-3][0-9]", "date", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_2_ID", new ExtractField("location_ID", 0, -1, "^[0-9]+$", "int", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_1_ID2", new ExtractField("", 0, -1, "^[0-9]+$", "int", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_2_name", new ExtractField("location_Name", 0, -1, "", "string", 80, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_2_active", new ExtractField("location_Active", 0, -1, "^[01]$", "bit", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Level_21_createDate", new ExtractField("Create_Date", 0, -1, "^'?(19|20)[0-9][0-9]-[01][0-9]-[0-3][0-9]", "date", 10, "1800", "1800", "1800", "1800", "1800")); Extract.Add("Agency_ID1", new ExtractField("location_ID", 0, -1, "^[0-9]+$", "int", 10, "1815", "1816", "1817", "1818", "1819")); Extract.Add("Agency_ID2", new ExtractField("Agency_ID", 1, 2, "^[0-9]+$", "int", 10, "1825", "1826", "1827", "1828", "1829")); Extract.Add("location_Name", new ExtractField("location_Name", 2, 8, "", "string", 80, "1835", "1836", "1837", "1838", "1839")); Extract.Add("location_Address", new ExtractField("location_Address", 1, 9, "", "string", 50, "1845", "1846", "1847", "1848", "1849")); Extract.Add("location_City", new ExtractField("location_City", 1, 10, "", "string", 50, "1855", "1856", "1857", "1858", "1859")); Extract.Add("location_Zip", new ExtractField("location_Zip", 1, 11, "^[0-9]{5}(-[0-9]{4})?$", "string", 10, "1865", "1866", "1867", "1868", "1869")); Extract.Add("location_Phone", new ExtractField("location_Phone", 1, 7, "^[-0-9.() extEXT]+$", "string", 13, "1875", "1876", "1877", "1878", "1879")); Extract.Add("locationContactName", new ExtractField("location_Contact_Name", 1, 12, "", "string", 50, "1885", "1886", "1887", "1888", "1889")); Extract.Add("location_Active", new ExtractField("location_Active", 2, 5, "^[01]$", "bit", 1, "1895", "1896", "1897", "1898", "1899")); Extract.Add("location_Local_ID", new ExtractField("location_Local_ID", 1, 3, "^[0-9]+$", "int", 10, "1905", "1906", "1907", "1908", "1909")); Extract.Add("locationCreateDate", new ExtractField("Create_Date", 1, 6, "^'?(19|20)[0-9][0-9]-[01][0-9]-[0-3][0-9]", "date", 24, "1915", "1916", "1917", "1918", "1919")); Extract.Add("location_Email", new ExtractField("location_Email", 1, 13, "", "string", 4000, "1925", "1926", "1927", "1928", "1929")); Extract.Add("Network_ID", new ExtractField("Network_ID", 1, 4, "^[0-9]+$", "int", 10, "1935", "1936", "1937", "1938", "1939")); Extract.Add("locationCountyId", new ExtractField("", 0, -1, "", "string", 10, "1945", "1946", "1947", "1948", "1949")); Extract.Add("locationState", new ExtractField("", 0, -1, "", "string", 2, "1955", "1956", "1957", "1958", "1959")); ExtractField field = Extract["locationState"]; } catch { } try { // -------------------------------------------------------------------------- // Set ETL archive dictionary parameters // -------------------------------------------------------------------------- Mirror.Add("LocationImportId", new MirrorField("Location_Import_ID", "@LocationImportId", true, "int", 10)); Mirror.Add("ImportSummaryId", new MirrorField("Import_Summary_ID", "@ImportSummaryId", true, "int", 10)); Mirror.Add("ImportStatus", new MirrorField("Import_Status", "@ImportStatus", true, "string", 16)); Mirror.Add("DB_Location_ID", new MirrorField("location_ID", "@location_ID", true, "int", 10)); // location_ID //Mirror.Add("location_ID" , new MirrorField("location_ID" , "@location_ID" , true , "int" , 10)); // location_ID //Mirror.Add("Agency_ID" , new MirrorField("location_ID" , "@Agency_ID" , true , "int" , 10)); //Mirror.Add("Agency_Name" , new MirrorField("location_Name" , "@Agency_Name" , true , "string", 80)); //Mirror.Add("Agency_Active" , new MirrorField("location_Active" , "@Agency_Active" , true , "bit" , 10)); //Mirror.Add("Create_Date" , new MirrorField("Create_Date" , "@Create_Date" , true , "date" , 10)); //Mirror.Add("Level_2_ID2" , new MirrorField("location_ID" , "@Level_2_ID2" , true , "int" , 10)); //Mirror.Add("Address1" , new MirrorField("location_Address" , "@Address1" , true , "string", 50)); //Mirror.Add("Address2" , new MirrorField("" , "@Address2" , true , "string", 10)); //Mirror.Add("City" , new MirrorField("location_City" , "@City" , true , "string", 50)); //Mirror.Add("State" , new MirrorField("" , "@State" , true , "string", 10)); //Mirror.Add("Zip" , new MirrorField("location_Zip" , "@Zip" , true , "string", 10)); //Mirror.Add("Phone" , new MirrorField("location_Phone" , "@Phone" , true , "string", 13)); //Mirror.Add("Contact_Name" , new MirrorField("location_Contact_Name", "@Contact_Name" , true , "string", 50)); //Mirror.Add("Email_Address" , new MirrorField("location_Email" , "@Email_Address" , true , "string", 4000)); //Mirror.Add("Active" , new MirrorField("location_Active" , "@Active" , true , "bit" , 10)); //Mirror.Add("County_Id" , new MirrorField("" , "@County_Id" , true , "int" , 10)); //Mirror.Add("Agency_code" , new MirrorField("" , "@Agency_code" , true , "string", 10)); //Mirror.Add("Level_1_ID" , new MirrorField("location_ID" , "@Level_1_ID" , true , "int" , 10)); //Mirror.Add("Level_1_name" , new MirrorField("location_Name" , "@Level_1_name" , true , "string", 128)); //Mirror.Add("Level_1_active" , new MirrorField("location_Active" , "@Level_1_active" , true , "bit" , 10)); //Mirror.Add("Level_1_create_date", new MirrorField("Level_1_create_date" , "@Level_1_create_date", true , "date" , 10)); //Mirror.Add("Level_2_ID" , new MirrorField("location_ID" , "@Level_2_ID" , true , "int" , 10)); //Mirror.Add("Level_1_ID2" , new MirrorField("" , "@Level_1_ID2" , true , "int" , 10)); //Mirror.Add("Level_2_name" , new MirrorField("location_Name" , "@Level_2_name" , true , "string", 80)); //Mirror.Add("Level_2_active" , new MirrorField("location_Active" , "@Level_2_active" , true , "bit" , 10)); //Mirror.Add("Level_21_createDate", new MirrorField("Create_Date" , "@Level_21_createDate", true , "date" , 10)); //Mirror.Add("Agency_ID1" , new MirrorField("location_ID" , "@Agency_ID1" , true , "int" , 10)); Mirror.Add("Agency_ID2", new MirrorField("Agency_ID", "@Agency_ID2", true, "int", 10)); // Agency_ID Mirror.Add("location_Name", new MirrorField("location_Name", "@location_Name", true, "string", 80)); // location_Name Mirror.Add("location_Address", new MirrorField("location_Address", "@location_Address", true, "string", 50)); // location_Address Mirror.Add("location_City", new MirrorField("location_City", "@location_City", true, "string", 50)); // location_City Mirror.Add("location_Zip", new MirrorField("location_Zip", "@location_Zip", true, "string", 10)); // location_Zip Mirror.Add("location_Phone", new MirrorField("location_Phone", "@location_Phone", true, "string", 13)); // location_Phone Mirror.Add("locationContactName", new MirrorField("location_Contact_Name", "@locationContactName", true, "string", 50)); // location_Contact_Name Mirror.Add("location_Active", new MirrorField("location_Active", "@location_Active", true, "bit", 1)); // location_Active Mirror.Add("location_Local_ID", new MirrorField("location_Local_ID", "@location_Local_ID", true, "int", 10)); // location_Local_ID Mirror.Add("locationCreateDate", new MirrorField("Create_Date", "@locationCreateDate", true, "date", 24)); // Create_Date Mirror.Add("location_Email", new MirrorField("location_Email", "@location_Email", true, "string", 4000)); // location_Email; Mirror.Add("Network_ID", new MirrorField("Network_ID", "@Network_ID", true, "int", 10)); // Network_ID //Mirror.Add("locationCountyId" , new MirrorField("" , "@locationCountyId" , true , "string", 10)) //Mirror.Add("locationState" , new MirrorField("" , "@locationState" , true , "string", 2)); } catch { } try { // -------------------------------------------------------------------------- // Set ETL transform dictionary parameters // -------------------------------------------------------------------------- Transform.Add("LocationImportId", new TransformField("N", "I", "N", "", "", "LocationImportId", "")); Transform.Add("ImportSummaryId", new TransformField("N", "", "N", "", "", "ImportSummaryId", "")); Transform.Add("ImportStatus", new TransformField("N", "", "N", "", "", "ImportStatus", "")); Transform.Add("location_ID", new TransformField("K", "R", "I" + "K", "", "location_ID", "DB_Location_ID", "location_ID")); Transform.Add("Agency_ID", new TransformField("D", "N", "I" + "K", "", "Agency_ID", "", "Agency_ID")); Transform.Add("Agency_Name", new TransformField("D", "N", "", "", "Agency_Name", "", "Agency_Name")); Transform.Add("Agency_Active", new TransformField("D", "N", "", "", "Agency_Active", "", "Agency_Active")); Transform.Add("Create_Date", new TransformField("D", "N", "", "", "Create_Date", "", "Create_Date")); Transform.Add("Level_2_ID2", new TransformField("D", "N", "", "", "Level_2_ID2", "", "Level_2_ID2")); Transform.Add("Address1", new TransformField("D", "N", "", "", "Address1", "", "Address1")); Transform.Add("Address2", new TransformField("N", "N", "B", "", "Address2", "", "Address2")); Transform.Add("City", new TransformField("D", "N", "", "", "City", "", "City")); Transform.Add("State", new TransformField("N", "N", "V", "VA", "State", "", "State")); Transform.Add("Zip", new TransformField("D", "N", "", "", "location_Zip", "", "Zip")); Transform.Add("Phone", new TransformField("D", "N", "", "", "Phone", "", "Phone")); Transform.Add("Contact_Name", new TransformField("D", "N", "", "", "Contact_Name", "", "Contact_Name")); Transform.Add("Email_Address", new TransformField("D", "N", "", "", "Email_Address", "", "Email_Address")); Transform.Add("Active", new TransformField("D", "N", "", "", "Active", "", "Active")); Transform.Add("County_Id", new TransformField("N", "N", "B", "", "County_Id", "", "County_Id")); Transform.Add("Agency_code", new TransformField("N", "N", "B", "", "Agency_code", "", "Agency_code")); Transform.Add("Level_1_ID", new TransformField("D", "N", "I" + "K" + "V", "55", "Level_1_ID", "", "Level_1_ID")); Transform.Add("Level_1_name", new TransformField("D", "N", "V", "Virginia", "Level_1_name", "", "Level_1_name")); Transform.Add("Level_1_active", new TransformField("D", "N", "V", "1", "Level_1_active", "", "Level_1_active")); Transform.Add("Level_1_create_date", new TransformField("D", "N", "V", "3/17/2015", "Level_1_create_date", "", "Level_1_create_date")); Transform.Add("Level_2_ID", new TransformField("D", "N", "I" + "K", "", "Level_2_ID", "", "Level_2_ID")); Transform.Add("Level_1_ID2", new TransformField("N", "N", "V", "55", "Level_1_ID2", "", "Level_1_ID2")); Transform.Add("Level_2_name", new TransformField("D", "N", "", "", "Level_2_name", "", "Level_2_name")); Transform.Add("Level_2_active", new TransformField("D", "N", "", "", "Level_2_active", "", "Level_2_active")); Transform.Add("Level_21_createDate", new TransformField("D", "N", "", "", "Level_21_createDate", "", "Level_21_createDate")); Transform.Add("Agency_ID1", new TransformField("D", "N", "", "", "location_ID", "", "Agency_ID1")); Transform.Add("Agency_ID2", new TransformField("", "", "N", "", "Agency_ID2", "Agency_ID2", "Agency_ID2")); Transform.Add("location_Name", new TransformField("", "", "", "", "location_Name", "location_Name", "location_Name")); Transform.Add("location_Address", new TransformField("", "", "", "", "location_Address", "location_Address", "location_Address")); Transform.Add("location_City", new TransformField("", "", "", "", "location_City", "location_City", "location_City")); Transform.Add("location_Zip", new TransformField("", "", "", "", "location_Zip", "location_Zip", "location_Zip")); Transform.Add("location_Phone", new TransformField("", "", "", "", "location_Phone", "location_Phone", "location_Phone")); Transform.Add("locationContactName", new TransformField("", "", "", "", "locationContactName", "locationContactName", "locationContactName")); Transform.Add("location_Active", new TransformField("", "", "", "", "location_Active", "location_Active", "location_Active")); Transform.Add("location_Local_ID", new TransformField("", "", "", "", "location_Local_ID", "location_Local_ID", "location_Local_ID")); Transform.Add("locationCreateDate", new TransformField("", "", "", "", "locationCreateDate", "locationCreateDate", "locationCreateDate")); Transform.Add("location_Email", new TransformField("", "", "", "", "location_Email", "location_Email", "location_Email")); Transform.Add("Network_ID", new TransformField("", "", "", "", "Network_ID", "Network_ID", "Network_ID")); Transform.Add("locationCountyId", new TransformField("N", "N", "", "", "locationCountyId", "", "locationCountyId")); Transform.Add("locationState", new TransformField("", "N", "V", "VA", "State", "", "locationState")); } catch { } try { // -------------------------------------------------------------------------- // Set ETL load dictionary parameters // -------------------------------------------------------------------------- Load.Add("Agency_ID", new LoadField("Agency_Master", "Agency_ID", 2, "@Agency_ID", "int", 10)); Load.Add("Agency_Name", new LoadField("Agency_Master", "Agency_Name", 2, "@Agency_Name", "string", 4000)); Load.Add("Agency_Active", new LoadField("Agency_Master", "Agency_Active", 2, "@Agency_Active", "bit", 10)); Load.Add("Create_Date", new LoadField("Agency_Master", "Create_Date", 2, "@Create_Date", "date", 10)); Load.Add("Level_2_ID2", new LoadField("Agency_Master", "Level_2_ID", 1, "@Level_2_ID2", "int", 10)); Load.Add("Address1", new LoadField("Agency_Master", "Address1", 1, "@Address1", "string", 100)); Load.Add("Address2", new LoadField("Agency_Master", "Address2", 1, "@Address2", "string", 100)); Load.Add("City", new LoadField("Agency_Master", "City", 1, "@City", "string", 100)); Load.Add("State", new LoadField("Agency_Master", "State", 1, "@State", "string", 2)); Load.Add("Zip", new LoadField("Agency_Master", "Zip", 1, "@Zip", "string", 10)); Load.Add("Phone", new LoadField("Agency_Master", "Phone", 1, "@Phone", "string", 20)); Load.Add("Contact_Name", new LoadField("Agency_Master", "Contact_Name", 1, "@Contact_Name", "string", 100)); Load.Add("Email_Address", new LoadField("Agency_Master", "Email_Address", 1, "@Email_Address", "string", 100)); Load.Add("Active", new LoadField("Agency_Master", "Active", 2, "@Active", "bit", 1)); Load.Add("County_Id", new LoadField("Agency_Master", "County_Id", 1, "@County_Id", "int", 10)); Load.Add("Agency_code", new LoadField("Agency_Master", "Agency_code", 1, "@Agency_code", "string", 10)); Load.Add("Level_1_ID", new LoadField("Level_1", "Level_1_ID", 2, "@Level_1_ID", "int", 10)); Load.Add("Level_1_name", new LoadField("Level_1", "Level_1_name", 2, "@Level_1_name", "string", 100)); Load.Add("Level_1_active", new LoadField("Level_1", "Level_1_active", 2, "@Level_1_active", "bit", 1)); Load.Add("Level_1_create_date", new LoadField("Level_1", "Level_1_create_date", 2, "@Level_1_create_date", "date", 10)); Load.Add("Level_2_ID", new LoadField("Level_2", "Level_2_ID", 2, "@Level_2_ID", "int", 10)); Load.Add("Level_1_ID2", new LoadField("Level_2", "Level_1_ID", 2, "@Level_1_ID2", "int", 10)); Load.Add("Level_2_name", new LoadField("Level_2", "Level_2_name", 2, "@Level_2_name", "string", 100)); Load.Add("Level_2_active", new LoadField("Level_2", "Level_2_active", 2, "@Level_2_active", "bit", 1)); Load.Add("Level_21_createDate", new LoadField("Level_2", "Level_21_create_date", 2, "@Level_21_createDate", "date", 24)); Load.Add("location_ID", new LoadField("location_Master", "location_ID", 2, "@location_ID", "int", 10)); Load.Add("Agency_ID1", new LoadField("location_Master", "Agency_ID", 1, "@Agency_ID1", "int", 10)); Load.Add("Agency_ID2", new LoadField("location_Master", "Agency_ID", 0, "@Agency_ID2", "int", 10)); Load.Add("location_Name", new LoadField("location_Master", "location_Name", 2, "@location_Name", "string", 80)); Load.Add("location_Address", new LoadField("location_Master", "location_Address", 1, "@location_Address", "string", 50)); Load.Add("location_City", new LoadField("location_Master", "location_City", 1, "@location_City", "string", 50)); Load.Add("location_Zip", new LoadField("location_Master", "location_Zip", 1, "@location_Zip", "string", 10)); Load.Add("location_Phone", new LoadField("location_Master", "location_Phone", 1, "@location_Phone", "string", 13)); Load.Add("locationContactName", new LoadField("location_Master", "location_Contact_Name", 1, "@locationContactName", "string", 50)); Load.Add("location_Active", new LoadField("location_Master", "location_Active", 2, "@location_Active", "bit", 1)); Load.Add("location_Local_ID", new LoadField("location_Master", "location_Local_ID", 1, "@location_Local_ID", "int", 10)); Load.Add("locationCreateDate", new LoadField("location_Master", "Create_Date", 1, "@Create_Date", "date", 24)); Load.Add("location_Email", new LoadField("location_Master", "location_Email", 1, "@location_Email", "string", 4000)); Load.Add("Network_ID", new LoadField("location_Master", "Network_ID", 1, "@Network_ID", "int", 10)); Load.Add("locationCountyId", new LoadField("location_Master", "County_Id", 1, "@County_Id", "int", 10)); Load.Add("locationState", new LoadField("location_Master", "[State]", 1, "@State", "string", 50)); } catch { } this.CheckDictionaryConnections(); }
public override void Bind(Entity entity, Main main, bool creating = false) { Transform transform = entity.GetOrCreate <Transform>("Transform"); this.SetMain(entity, main); VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, true, false); attachable.Enabled.Value = true; if (!main.EditorEnabled) { // -1 means we're currently submerged, anything above 0 is the timestamp of the last time we were submerged float submerged = -1.0f; float lastEmit = 0.0f; Water submergedWater = null; Property <Vector3> coordinatePos = new Property <Vector3>(); VoxelAttachable.BindTarget(entity, coordinatePos); Action check = delegate() { Water nowSubmerged = Water.Get(coordinatePos); if (nowSubmerged == null && main.TotalTime - submerged < 1.0f) { Entity ve = attachable.AttachedVoxel.Value.Target; if (ve != null) { Voxel v = ve.Get <Voxel>(); Voxel.Box b = v.GetBox(attachable.Coord); if (b != null) { BoundingBox box = new BoundingBox(v.GetRelativePosition(b.X, b.Y, b.Z), v.GetRelativePosition(b.X + b.Width, b.Y + b.Height, b.Z + b.Depth)); if (submergedWater != null && main.TotalTime - lastEmit > 0.1f) { Water.SplashParticles(main, box.Transform(v.Transform), v, submergedWater.Position.Value.Y); lastEmit = main.TotalTime; } } } } if (nowSubmerged != null) { submerged = -1.0f; submergedWater = nowSubmerged; } else if (submerged == -1.0f && nowSubmerged == null) { Sound.PostEvent(AK.EVENTS.PLAY_WATER_SPLASH_OUT_BIG, transform.Position); submerged = main.TotalTime; } }; transform.Add(new NotifyBinding(check, coordinatePos)); entity.Add(new PostInitialization(delegate() { submerged = Water.Get(coordinatePos) != null ? -1.0f : -2.0f; })); } entity.Add("AttachOffset", attachable.Offset); entity.Add("AttachVector", attachable.Vector); }
public override void Bind(Entity entity, Main main, bool creating = false) { Main.Config settings = main.Settings; Transform transform = entity.GetOrCreate <Transform>("Transform"); entity.CannotSuspend = true; PlayerFactory.Instance = entity; this.SetMain(entity, main); FPSInput input = new FPSInput(); input.EnabledWhenPaused = false; entity.Add("Input", input); Updater parkour = entity.Create <Updater>(); Updater jumper = entity.Create <Updater>(); Player player = entity.GetOrCreate <Player>("Player"); AnimatedModel firstPersonModel = entity.GetOrCreate <AnimatedModel>("FirstPersonModel"); firstPersonModel.MapContent = false; firstPersonModel.Serialize = false; firstPersonModel.Filename.Value = "Models\\joan-firstperson"; firstPersonModel.CullBoundingBox.Value = false; AnimatedModel model = entity.GetOrCreate <AnimatedModel>("Model"); model.MapContent = false; model.Serialize = false; model.Filename.Value = "Models\\joan"; model.CullBoundingBox.Value = false; AnimationController anim = entity.GetOrCreate <AnimationController>("AnimationController"); RotationController rotation = entity.GetOrCreate <RotationController>("Rotation"); BlockPredictor predictor = entity.GetOrCreate <BlockPredictor>("BlockPredictor"); Jump jump = entity.GetOrCreate <Jump>("Jump"); RollKickSlide rollKickSlide = entity.GetOrCreate <RollKickSlide>("RollKickSlide"); Vault vault = entity.GetOrCreate <Vault>("Vault"); WallRun wallRun = entity.GetOrCreate <WallRun>("WallRun"); VoxelTools voxelTools = entity.GetOrCreate <VoxelTools>("VoxelTools"); Footsteps footsteps = entity.GetOrCreate <Footsteps>("Footsteps"); FallDamage fallDamage = entity.GetOrCreate <FallDamage>("FallDamage"); CameraController cameraControl = entity.GetOrCreate <CameraController>("CameraControl"); FPSCamera fpsCamera = entity.GetOrCreate <FPSCamera>("FPSCamera"); fpsCamera.Enabled.Value = false; Rumble rumble = entity.GetOrCreate <Rumble>("Rumble"); Property <Vector3> floor = new Property <Vector3>(); transform.Add(new Binding <Vector3>(floor, () => transform.Position + new Vector3(0, player.Character.Height * -0.5f, 0), transform.Position, player.Character.Height)); AkGameObjectTracker.Attach(entity, floor); predictor.Add(new Binding <Vector3>(predictor.FootPosition, floor)); predictor.Add(new Binding <Vector3>(predictor.LinearVelocity, player.Character.LinearVelocity)); predictor.Add(new Binding <float>(predictor.Rotation, rotation.Rotation)); predictor.Add(new Binding <float>(predictor.MaxSpeed, player.Character.MaxSpeed)); predictor.Add(new Binding <float>(predictor.JumpSpeed, player.Character.JumpSpeed)); predictor.Add(new Binding <bool>(predictor.IsSupported, player.Character.IsSupported)); jump.Add(new Binding <bool>(jump.Crouched, player.Character.Crouched)); jump.Add(new TwoWayBinding <bool>(player.Character.IsSupported, jump.IsSupported)); jump.Add(new TwoWayBinding <bool>(player.Character.HasTraction, jump.HasTraction)); jump.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, jump.LinearVelocity)); jump.Add(new TwoWayBinding <BEPUphysics.Entities.Entity>(jump.SupportEntity, player.Character.SupportEntity)); jump.Add(new TwoWayBinding <Vector3>(jump.SupportVelocity, player.Character.SupportVelocity)); jump.Add(new Binding <Vector2>(jump.AbsoluteMovementDirection, player.Character.MovementDirection)); jump.Add(new Binding <WallRun.State>(jump.WallRunState, wallRun.CurrentState)); jump.Add(new Binding <float>(jump.Rotation, rotation.Rotation)); jump.Add(new Binding <Vector3>(jump.Position, transform.Position)); jump.Add(new Binding <Vector3>(jump.FloorPosition, floor)); jump.Add(new Binding <float>(jump.MaxSpeed, player.Character.MaxSpeed)); jump.Add(new Binding <float>(jump.JumpSpeed, player.Character.JumpSpeed)); jump.Add(new Binding <float>(jump.Mass, player.Character.Mass)); jump.Add(new Binding <float>(jump.LastRollKickEnded, rollKickSlide.LastRollKickEnded)); jump.Add(new Binding <Voxel>(jump.WallRunMap, wallRun.WallRunVoxel)); jump.Add(new Binding <Direction>(jump.WallDirection, wallRun.WallDirection)); jump.Add(new CommandBinding <Voxel, Voxel.Coord, Direction>(jump.WalkedOn, footsteps.WalkedOn)); jump.Add(new CommandBinding(jump.DeactivateWallRun, (Action)wallRun.Deactivate)); jump.Add(new CommandBinding <float>(jump.FallDamage, fallDamage.ApplyJump)); jump.Predictor = predictor; jump.Bind(model); jump.Add(new TwoWayBinding <Voxel>(wallRun.LastWallRunMap, jump.LastWallRunMap)); jump.Add(new TwoWayBinding <Direction>(wallRun.LastWallDirection, jump.LastWallDirection)); jump.Add(new TwoWayBinding <bool>(rollKickSlide.CanKick, jump.CanKick)); jump.Add(new TwoWayBinding <float>(player.Character.LastSupportedSpeed, jump.LastSupportedSpeed)); wallRun.Add(new Binding <bool>(wallRun.IsSwimming, player.Character.IsSwimming)); wallRun.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, wallRun.LinearVelocity)); wallRun.Add(new TwoWayBinding <Vector3>(transform.Position, wallRun.Position)); wallRun.Add(new TwoWayBinding <bool>(player.Character.IsSupported, wallRun.IsSupported)); wallRun.Add(new CommandBinding(wallRun.LockRotation, (Action)rotation.Lock)); wallRun.Add(new CommandBinding <float>(wallRun.UpdateLockedRotation, rotation.UpdateLockedRotation)); vault.Add(new CommandBinding(wallRun.Vault, delegate() { vault.Go(true); })); wallRun.Predictor = predictor; wallRun.Add(new Binding <float>(wallRun.Height, player.Character.Height)); wallRun.Add(new Binding <float>(wallRun.JumpSpeed, player.Character.JumpSpeed)); wallRun.Add(new Binding <float>(wallRun.MaxSpeed, player.Character.MaxSpeed)); wallRun.Add(new TwoWayBinding <float>(rotation.Rotation, wallRun.Rotation)); wallRun.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, wallRun.AllowUncrouch)); wallRun.Add(new TwoWayBinding <bool>(player.Character.HasTraction, wallRun.HasTraction)); wallRun.Add(new Binding <float>(wallRun.LastWallJump, jump.LastWallJump)); player.Add(new Binding <WallRun.State>(player.Character.WallRunState, wallRun.CurrentState)); input.Bind(rollKickSlide.RollKickButton, settings.RollKick); rollKickSlide.Add(new Binding <bool>(rollKickSlide.EnableCrouch, player.EnableCrouch)); rollKickSlide.Add(new Binding <float>(rollKickSlide.Rotation, rotation.Rotation)); rollKickSlide.Add(new Binding <bool>(rollKickSlide.IsSwimming, player.Character.IsSwimming)); rollKickSlide.Add(new Binding <bool>(rollKickSlide.IsSupported, player.Character.IsSupported)); rollKickSlide.Add(new Binding <Vector3>(rollKickSlide.FloorPosition, floor)); rollKickSlide.Add(new Binding <float>(rollKickSlide.Height, player.Character.Height)); rollKickSlide.Add(new Binding <float>(rollKickSlide.MaxSpeed, player.Character.MaxSpeed)); rollKickSlide.Add(new Binding <float>(rollKickSlide.JumpSpeed, player.Character.JumpSpeed)); rollKickSlide.Add(new Binding <Vector3>(rollKickSlide.SupportVelocity, player.Character.SupportVelocity)); rollKickSlide.Add(new TwoWayBinding <bool>(wallRun.EnableEnhancedWallRun, rollKickSlide.EnableEnhancedRollSlide)); rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, rollKickSlide.AllowUncrouch)); rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.Crouched, rollKickSlide.Crouched)); rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, rollKickSlide.EnableWalking)); rollKickSlide.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, rollKickSlide.LinearVelocity)); rollKickSlide.Add(new TwoWayBinding <Vector3>(transform.Position, rollKickSlide.Position)); rollKickSlide.Predictor = predictor; rollKickSlide.Bind(model); rollKickSlide.VoxelTools = voxelTools; rollKickSlide.Add(new CommandBinding(rollKickSlide.DeactivateWallRun, (Action)wallRun.Deactivate)); rollKickSlide.Add(new CommandBinding(rollKickSlide.Footstep, footsteps.Footstep)); rollKickSlide.Add(new CommandBinding(rollKickSlide.LockRotation, (Action)rotation.Lock)); SoundKiller.Add(entity, AK.EVENTS.STOP_PLAYER_SLIDE_LOOP); vault.Add(new Binding <Vector3>(vault.Position, transform.Position)); vault.Add(new Binding <Vector3>(vault.FloorPosition, floor)); vault.Add(new Binding <float>(vault.MaxSpeed, player.Character.MaxSpeed)); vault.Add(new Binding <WallRun.State>(vault.WallRunState, wallRun.CurrentState)); vault.Add(new CommandBinding(vault.LockRotation, (Action)rotation.Lock)); vault.Add(new CommandBinding(vault.DeactivateWallRun, (Action)wallRun.Deactivate)); vault.Add(new TwoWayBinding <float>(player.Character.LastSupportedSpeed, vault.LastSupportedSpeed)); vault.Add(new CommandBinding <float>(vault.FallDamage, fallDamage.Apply)); vault.Bind(model); vault.Predictor = predictor; vault.Add(new TwoWayBinding <float>(rotation.Rotation, vault.Rotation)); vault.Add(new TwoWayBinding <bool>(player.Character.IsSupported, vault.IsSupported)); vault.Add(new TwoWayBinding <bool>(player.Character.HasTraction, vault.HasTraction)); vault.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, vault.LinearVelocity)); vault.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, vault.EnableWalking)); vault.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, vault.AllowUncrouch)); vault.Add(new TwoWayBinding <bool>(player.Character.Crouched, vault.Crouched)); vault.Add(new Binding <float>(vault.Radius, player.Character.Radius)); rotation.Add(new TwoWayBinding <Vector2>(rotation.Mouse, input.Mouse)); rotation.Add(new Binding <bool>(rotation.Rolling, rollKickSlide.Rolling)); rotation.Add(new Binding <bool>(rotation.Kicking, rollKickSlide.Kicking)); rotation.Add(new Binding <Vault.State>(rotation.VaultState, vault.CurrentState)); rotation.Add(new Binding <WallRun.State>(rotation.WallRunState, wallRun.CurrentState)); voxelTools.Add(new Binding <float>(voxelTools.Height, player.Character.Height)); voxelTools.Add(new Binding <float>(voxelTools.SupportHeight, player.Character.SupportHeight)); voxelTools.Add(new Binding <Vector3>(voxelTools.Position, transform.Position)); anim.Add(new Binding <bool>(anim.IsSupported, player.Character.IsSupported)); anim.Add(new Binding <WallRun.State>(anim.WallRunState, wallRun.CurrentState)); anim.Add(new Binding <bool>(anim.EnableWalking, player.Character.EnableWalking)); anim.Add(new Binding <bool>(anim.Crouched, player.Character.Crouched)); anim.Add(new Binding <Vector3>(anim.LinearVelocity, player.Character.LinearVelocity)); anim.Add(new Binding <Vector2>(anim.Movement, input.Movement)); anim.Add(new Binding <Vector2>(anim.Mouse, input.Mouse)); anim.Add(new Binding <float>(anim.Rotation, rotation.Rotation)); anim.Add(new Binding <Voxel>(anim.WallRunMap, wallRun.WallRunVoxel)); anim.Add(new Binding <Direction>(anim.WallDirection, wallRun.WallDirection)); anim.Add(new Binding <bool>(anim.IsSwimming, player.Character.IsSwimming)); anim.Add(new Binding <bool>(anim.Kicking, rollKickSlide.Kicking)); anim.Add(new Binding <Vector3>(anim.SupportVelocity, player.Character.SupportVelocity)); anim.Add ( new Binding <bool> ( anim.EnableLean, () => player.Character.EnableWalking.Value && player.Character.IsSupported.Value && input.Movement.Value.Y > 0.5f, player.Character.EnableWalking, player.Character.IsSupported, input.Movement ) ); anim.Bind(model); // Camera control model.UpdateWorldTransforms(); cameraControl.Add(new Binding <Vector2>(cameraControl.Mouse, input.Mouse)); cameraControl.Add(new Binding <float>(cameraControl.Lean, x => x * (float)Math.PI * 0.05f, anim.Lean)); cameraControl.Add(new Binding <Vector3>(cameraControl.LinearVelocity, player.Character.LinearVelocity)); cameraControl.Add(new Binding <float>(cameraControl.MaxSpeed, player.Character.MaxSpeed)); cameraControl.Add(new Binding <Matrix>(cameraControl.CameraBone, model.GetBoneTransform("Camera"))); cameraControl.Add(new Binding <Matrix>(cameraControl.HeadBone, model.GetBoneTransform("ORG-head"))); cameraControl.Add(new Binding <Matrix>(cameraControl.ModelTransform, model.Transform)); cameraControl.Add(new Binding <float>(cameraControl.BaseCameraShakeAmount, () => MathHelper.Clamp((player.Character.LinearVelocity.Value.Length() - (player.Character.MaxSpeed * 2.5f)) / (player.Character.MaxSpeed * 4.0f), 0, 1), player.Character.LinearVelocity, player.Character.MaxSpeed)); cameraControl.Offset = model.GetBoneTransform("Camera").Value.Translation - model.GetBoneTransform("ORG-head").Value.Translation; float heightOffset = 0.1f; #if VR if (main.VR) { heightOffset = 0.4f; } #endif cameraControl.Offset += new Vector3(0, heightOffset, 0); rumble.Add(new Binding <float>(rumble.CameraShake, cameraControl.TotalCameraShake)); rumble.Add(new CommandBinding <float>(fallDamage.Rumble, rumble.Go)); rumble.Add(new CommandBinding <float>(player.Rumble, rumble.Go)); rumble.Add(new CommandBinding <float>(rollKickSlide.Rumble, rumble.Go)); firstPersonModel.Add(new Binding <bool>(firstPersonModel.Enabled, x => !x, cameraControl.ThirdPerson)); model.Add(new ChangeBinding <bool>(cameraControl.ThirdPerson, delegate(bool old, bool value) { if (value && !old) { model.UnsupportedTechniques.Remove(Technique.Clip); model.UnsupportedTechniques.Remove(Technique.Render); } else if (old && !value) { model.UnsupportedTechniques.Add(Technique.Clip); model.UnsupportedTechniques.Add(Technique.Render); } })); Lemma.Console.Console.AddConCommand(new Console.ConCommand("third_person", "Toggle third-person view (WARNING: EXPERIMENTAL)", delegate(Console.ConCommand.ArgCollection args) { cameraControl.ThirdPerson.Value = !cameraControl.ThirdPerson; })); entity.Add(new CommandBinding(entity.Delete, delegate() { Lemma.Console.Console.RemoveConCommand("third_person"); })); #if DEVELOPMENT ModelAlpha debugCylinder = new ModelAlpha(); debugCylinder.Filename.Value = "AlphaModels\\cylinder"; debugCylinder.Add(new Binding <Matrix>(debugCylinder.Transform, transform.Matrix)); debugCylinder.Serialize = false; debugCylinder.Alpha.Value = 0.25f; debugCylinder.Add(new Binding <bool>(debugCylinder.Enabled, cameraControl.ThirdPerson)); debugCylinder.Add(new Binding <Vector3>(debugCylinder.Scale, delegate() { return(new Vector3(player.Character.Radius * 2.0f, player.Character.Height, player.Character.Radius * 2.0f)); }, player.Character.Height, player.Character.Radius)); entity.Add(debugCylinder); #endif // When rotation is locked, we want to make sure the player can't turn their head // 180 degrees from the direction they're facing #if VR if (main.VR) { input.MaxY.Value = input.MinY.Value = 0; } else #endif input.Add(new Binding <float>(input.MaxY, () => rotation.Locked ? (float)Math.PI * 0.3f : (float)Math.PI * 0.4f, rotation.Locked)); input.Add(new Binding <float>(input.MinX, () => rotation.Locked ? rotation.Rotation + ((float)Math.PI * -0.4f) : 0.0f, rotation.Rotation, rotation.Locked)); input.Add(new Binding <float>(input.MaxX, () => rotation.Locked ? rotation.Rotation + ((float)Math.PI * 0.4f) : 0.0f, rotation.Rotation, rotation.Locked)); input.Add(new NotifyBinding(delegate() { input.Mouse.Changed(); }, rotation.Locked)); // Make sure the rotation locking takes effect even if the player doesn't move the mouse // Setup rendering properties model.Materials = firstPersonModel.Materials = new Model.Material[3]; // Hoodie and shoes model.Materials[0] = new Model.Material { SpecularIntensity = 0.0f, SpecularPower = 1.0f, }; // Hands model.Materials[1] = new Model.Material { SpecularIntensity = 0.3f, SpecularPower = 2.0f, }; // Pants and skin model.Materials[2] = new Model.Material { SpecularIntensity = 0.5f, SpecularPower = 20.0f, }; firstPersonModel.Bind(model); // Third person model only gets rendered for shadows. No regular rendering or reflections. model.UnsupportedTechniques.Add(Technique.Clip); model.UnsupportedTechniques.Add(Technique.Render); // First-person model only used for regular rendering. No shadows or reflections. firstPersonModel.UnsupportedTechniques.Add(Technique.Shadow); firstPersonModel.UnsupportedTechniques.Add(Technique.Clip); // Build UI UIRenderer ui = new UIRenderer(); ui.DrawOrder.Value = -1; ui.EnabledWhenPaused = true; ui.EnabledInEditMode = false; entity.Add("UI", ui); input.Add(new Binding <float>(input.MouseSensitivity, settings.MouseSensitivity)); input.Add(new Binding <bool>(input.InvertMouseX, settings.InvertMouseX)); input.Add(new Binding <bool>(input.InvertMouseY, settings.InvertMouseY)); input.Add(new Binding <PCInput.PCInputBinding>(input.LeftKey, settings.Left)); input.Add(new Binding <PCInput.PCInputBinding>(input.RightKey, settings.Right)); input.Add(new Binding <PCInput.PCInputBinding>(input.BackwardKey, settings.Backward)); input.Add(new Binding <PCInput.PCInputBinding>(input.ForwardKey, settings.Forward)); model.StartClip("Idle", 0, true, AnimatedModel.DefaultBlendTime); // Set up AI agent Agent agent = entity.GetOrCreate <Agent>(); agent.Add(new TwoWayBinding <float>(player.Health, agent.Health)); agent.Add(new Binding <Vector3>(agent.Position, () => transform.Position.Value + new Vector3(0, player.Character.Height * -0.5f, 0), transform.Position, player.Character.Height)); agent.Add(new Binding <bool>(agent.Loud, () => player.Character.MovementDirection.Value.LengthSquared() > 0 && !player.Character.Crouched, player.Character.Crouched)); // Blocks BlockCloud blockCloud = entity.GetOrCreate <BlockCloud>("BlockCloud"); blockCloud.Scale.Value = 0.5f; blockCloud.Add(new Binding <Vector3>(blockCloud.Position, () => transform.Position.Value + new Vector3(0, player.Character.Height + player.Character.LinearVelocity.Value.Y, 0), transform.Position, player.Character.Height, player.Character.LinearVelocity)); blockCloud.Blocks.ItemAdded += delegate(int index, Entity.Handle block) { Entity e = block.Target; if (e != null) { e.Serialize = false; PhysicsBlock.CancelPlayerCollisions(e.Get <PhysicsBlock>()); } }; PointLight blockLight = entity.Create <PointLight>(); blockLight.Add(new Binding <Vector3>(blockLight.Position, blockCloud.AveragePosition)); blockLight.Add(new Binding <bool, int>(blockLight.Enabled, x => x > 0, blockCloud.Blocks.Length)); blockLight.Attenuation.Value = 30.0f; blockLight.Add(new Binding <Vector3, Voxel.t>(blockLight.Color, delegate(Voxel.t t) { switch (t) { case Voxel.t.GlowBlue: return(new Vector3(0.7f, 0.7f, 0.9f)); case Voxel.t.GlowYellow: return(new Vector3(0.9f, 0.9f, 0.7f)); default: return(new Vector3(0.8f, 0.8f, 0.8f)); } }, blockCloud.Type)); // Death entity.Add(new CommandBinding(player.Die, blockCloud.Clear)); entity.Add(new CommandBinding(player.Die, delegate() { Session.Recorder.Event(main, "Die"); if (agent.Killed || Agent.Query(transform.Position, 0.0f, 10.0f, x => x != agent) != null) { Session.Recorder.Event(main, "Killed"); AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_DEATH, entity); main.Spawner.RespawnDistance = Spawner.KilledRespawnDistance; main.Spawner.RespawnInterval = Spawner.KilledRespawnInterval; } entity.Add(new Animation(new Animation.Execute(entity.Delete))); })); player.EnabledInEditMode = false; Action updateFallSound = delegate() { float speed = player.Character.LinearVelocity.Value.Length(); float maxSpeed = player.Character.MaxSpeed * 1.25f; float value; if (speed > maxSpeed) { value = (speed - maxSpeed) / (maxSpeed * 2.0f); } else { value = 0.0f; } AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.SFX_PLAYER_FALL, value); }; updateFallSound(); AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_FALL, entity); player.Add(new NotifyBinding(updateFallSound, player.Character.LinearVelocity)); SoundKiller.Add(entity, AK.EVENTS.STOP_PLAYER_FALL); player.Add(new TwoWayBinding <Matrix>(transform.Matrix, player.Character.Transform)); model.Add(new Binding <Matrix>(model.Transform, delegate() { const float leanAmount = (float)Math.PI * 0.1f; return(Matrix.CreateTranslation(0, (player.Character.Height * -0.5f) - player.Character.SupportHeight, 0) * Matrix.CreateRotationZ(anim.Lean * leanAmount) * Matrix.CreateRotationY(rotation.Rotation) * transform.Matrix); }, transform.Matrix, rotation.Rotation, player.Character.Height, player.Character.SupportHeight, anim.Lean)); firstPersonModel.Add(new Binding <Matrix>(firstPersonModel.Transform, model.Transform)); firstPersonModel.Add(new Binding <Vector3>(firstPersonModel.Scale, model.Scale)); WallRun.State[] footstepWallrunStates = new[] { WallRun.State.Left, WallRun.State.Right, WallRun.State.Straight, WallRun.State.None, }; footsteps.Add(new Binding <bool>(footsteps.SoundEnabled, () => !player.Character.Crouched && footstepWallrunStates.Contains(wallRun.CurrentState) || (player.Character.IsSupported && player.Character.EnableWalking), player.Character.IsSupported, player.Character.EnableWalking, wallRun.CurrentState, player.Character.Crouched)); footsteps.Add(new Binding <Vector3>(footsteps.Position, transform.Position)); footsteps.Add(new Binding <float>(footsteps.Rotation, rotation.Rotation)); footsteps.Add(new Binding <float>(footsteps.CharacterHeight, player.Character.Height)); footsteps.Add(new Binding <float>(footsteps.SupportHeight, player.Character.SupportHeight)); footsteps.Add(new Binding <bool>(footsteps.IsSupported, player.Character.IsSupported)); footsteps.Add(new Binding <bool>(footsteps.IsSwimming, player.Character.IsSwimming)); footsteps.Add(new CommandBinding <float>(footsteps.Damage, agent.Damage)); footsteps.Add(new CommandBinding <Voxel, Voxel.Coord, Direction>(wallRun.WalkedOn, footsteps.WalkedOn)); model.Trigger("Run", 0.16f, footsteps.Footstep); model.Trigger("Run", 0.58f, footsteps.Footstep); model.Trigger("WallRunLeft", 0.16f, footsteps.Footstep); model.Trigger("WallRunLeft", 0.58f, footsteps.Footstep); model.Trigger("WallRunRight", 0.16f, footsteps.Footstep); model.Trigger("WallRunRight", 0.58f, footsteps.Footstep); model.Trigger("WallRunStraight", 0.16f, footsteps.Footstep); model.Trigger("WallRunStraight", 0.58f, footsteps.Footstep); model.Trigger("TurnLeft", 0.15f, footsteps.Footstep); model.Trigger("TurnRight", 0.15f, footsteps.Footstep); model.Trigger("TopOut", 1.0f, new Command { Action = delegate() { AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_GRUNT, entity); } }); main.UI.IsMouseVisible.Value = false; SkinnedModel.Clip sprintAnimation = model["Sprint"], runAnimation = model["Run"]; // Movement binding player.Add(new Binding <Vector2>(player.Character.MovementDirection, delegate() { Vector2 movement = input.Movement; if (movement.LengthSquared() == 0.0f) { return(Vector2.Zero); } Matrix matrix = Matrix.CreateRotationY(rotation.Rotation); Vector2 forwardDir = new Vector2(matrix.Forward.X, matrix.Forward.Z); Vector2 rightDir = new Vector2(matrix.Right.X, matrix.Right.Z); return(-(forwardDir * movement.Y) - (rightDir * movement.X)); }, input.Movement, rotation.Rotation)); player.Character.Crouched.Value = true; player.Character.AllowUncrouch.Value = true; // Fall damage fallDamage.Add(new Binding <bool>(fallDamage.IsSupported, player.Character.IsSupported)); fallDamage.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, fallDamage.LinearVelocity)); fallDamage.Add(new TwoWayBinding <float>(player.Health, fallDamage.Health)); fallDamage.Add(new CommandBinding <BEPUphysics.BroadPhaseEntries.Collidable, ContactCollection>(player.Character.Collided, fallDamage.Collided)); fallDamage.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, fallDamage.EnableWalking)); fallDamage.Add(new TwoWayBinding <bool>(player.EnableMoves, fallDamage.EnableMoves)); fallDamage.Add(new TwoWayBinding <bool>(fallDamage.Landing, rotation.Landing)); fallDamage.Add(new CommandBinding(fallDamage.LockRotation, (Action)rotation.Lock)); fallDamage.Add(new CommandBinding <float>(fallDamage.PhysicsDamage, agent.Damage)); fallDamage.Bind(model); // Swim up input.Bind(player.Character.SwimUp, settings.Jump); float parkourTime = 0; float jumpTime = 0; const float gracePeriod = 1.0f; jumper.Action = delegate(float dt) { if (player.EnableMoves && player.Character.EnableWalking && vault.CurrentState.Value == Vault.State.None && !rollKickSlide.Rolling && !rollKickSlide.Kicking && jumpTime < gracePeriod) { if (jump.Go()) { parkour.Enabled.Value = false; jumper.Enabled.Value = false; } jumpTime += dt; } else { jumper.Enabled.Value = false; } }; jumper.Add(new CommandBinding(jumper.Enable, delegate() { jumpTime = 0; })); jumper.Enabled.Value = false; entity.Add(jumper); // Jumping input.Bind(settings.Jump, PCInput.InputState.Down, delegate() { jumper.Enabled.Value = true; }); input.Bind(settings.Jump, PCInput.InputState.Up, delegate() { jumper.Enabled.Value = false; }); // Wall-run, vault, predictive parkour.Action = delegate(float dt) { if (player.EnableMoves && player.Character.EnableWalking && !(player.Character.Crouched && player.Character.IsSupported) && vault.CurrentState.Value == Vault.State.None && !rollKickSlide.Kicking && !rollKickSlide.Rolling && wallRun.CurrentState.Value == WallRun.State.None && parkourTime < gracePeriod) { bool didSomething = false; bool parkourBeganThisFrame = parkourTime == 0; if (predictor.PossibilityCount > 0) { // In slow motion, prefer left and right wall-running if (!(didSomething = wallRun.Activate(WallRun.State.Left, parkourBeganThisFrame))) { if (!(didSomething = wallRun.Activate(WallRun.State.Right, parkourBeganThisFrame))) { if (!(didSomething = vault.Go(parkourBeganThisFrame))) { didSomething = wallRun.Activate(WallRun.State.Straight, parkourBeganThisFrame); } } } } else { // In normal mode, prefer straight wall-running if (!(didSomething = vault.Go(parkourBeganThisFrame))) { if (!(didSomething = wallRun.Activate(WallRun.State.Straight, parkourBeganThisFrame))) { if (!(didSomething = wallRun.Activate(WallRun.State.Left, parkourBeganThisFrame))) { didSomething = wallRun.Activate(WallRun.State.Right, parkourBeganThisFrame); } } } } if (didSomething) { jumper.Enabled.Value = false; player.SlowMotion.Value = false; parkour.Enabled.Value = false; } else if (parkourBeganThisFrame) { if (blockCloud.Blocks.Length > 0) { player.SlowMotion.Value = true; predictor.ClearPossibilities(); predictor.PredictPlatforms(); predictor.PredictWalls(); } else if (player.EnableSlowMotion) { player.SlowMotion.Value = true; } } parkourTime += dt; } else { parkour.Enabled.Value = false; } }; parkour.Add(new CommandBinding(parkour.Enable, delegate() { parkourTime = 0; })); entity.Add(parkour); parkour.Enabled.Value = false; input.Bind(settings.Parkour, PCInput.InputState.Down, delegate() { parkour.Enabled.Value = true; }); input.Bind(settings.Parkour, PCInput.InputState.Up, delegate() { parkour.Enabled.Value = false; wallRun.Deactivate(); if (player.SlowMotion) { player.SlowMotion.Value = false; } }); input.Bind(settings.RollKick, PCInput.InputState.Down, delegate() { if (player.EnableMoves && player.Character.EnableWalking) { rollKickSlide.Go(); parkour.Enabled.Value = false; jumper.Enabled.Value = false; } }); input.Bind(settings.RollKick, PCInput.InputState.Up, delegate() { if (!rollKickSlide.Rolling && !rollKickSlide.Kicking) { player.Character.AllowUncrouch.Value = true; } }); // Special ability /* * input.Bind(settings.SpecialAbility, PCInput.InputState.Down, delegate() * { * Voxel.GlobalRaycastResult hit = Voxel.GlobalRaycast(main.Camera.Position, main.Camera.Forward, main.Camera.FarPlaneDistance, null); * if (hit.Voxel != null && hit.Voxel.GetType() != typeof(DynamicVoxel)) * { * VoxelRip.Go(hit.Voxel, hit.Coordinate.Value, 7, delegate(List<DynamicVoxel> results) * { * foreach (DynamicVoxel v in results) * { * v.IsAffectedByGravity.Value = false; * v.LinearVelocity.Value = hit.Voxel.GetAbsoluteVector(hit.Normal.GetVector()) * 7.0f + new Vector3((float)this.random.NextDouble() * 2.0f - 1.0f, (float)this.random.NextDouble() * 2.0f - 1.0f, (float)this.random.NextDouble() * 2.0f - 1.0f); + } + }); + } + }); */ // Player data bindings entity.Add(new PostInitialization { delegate() { Entity dataEntity = PlayerDataFactory.Instance; PlayerData playerData = dataEntity.Get <PlayerData>(); // HACK. Overwriting the property rather than binding the two together. Oh well. // This is because I haven't written a two-way list binding. footsteps.RespawnLocations = playerData.RespawnLocations; // Bind player data properties entity.Add(new TwoWayBinding <float>(WorldFactory.Instance.Get <World>().CameraShakeAmount, cameraControl.CameraShakeAmount)); entity.Add(new TwoWayBinding <bool>(playerData.EnableRoll, rollKickSlide.EnableRoll)); entity.Add(new TwoWayBinding <bool>(playerData.EnableCrouch, player.EnableCrouch)); entity.Add(new TwoWayBinding <bool>(playerData.EnableKick, rollKickSlide.EnableKick)); entity.Add(new TwoWayBinding <bool>(playerData.EnableWallRun, wallRun.EnableWallRun)); entity.Add(new TwoWayBinding <bool>(playerData.EnableWallRunHorizontal, wallRun.EnableWallRunHorizontal)); entity.Add(new TwoWayBinding <bool>(playerData.EnableEnhancedWallRun, wallRun.EnableEnhancedWallRun)); entity.Add(new TwoWayBinding <bool>(playerData.EnableMoves, player.EnableMoves)); entity.Add(new TwoWayBinding <float>(playerData.MaxSpeed, player.Character.MaxSpeed)); entity.Add(new TwoWayBinding <Voxel.t>(playerData.CloudType, blockCloud.Type)); entity.Add(new TwoWayBinding <bool>(playerData.ThirdPerson, cameraControl.ThirdPerson)); entity.Add(new TwoWayBinding <bool>(playerData.EnableSlowMotion, player.EnableSlowMotion)); Phone phone = dataEntity.GetOrCreate <Phone>("Phone"); entity.Add ( new Binding <bool> ( phone.CanReceiveMessages, () => player.Character.IsSupported && !player.Character.IsSwimming && !player.Character.Crouched, player.Character.IsSupported, player.Character.IsSwimming, player.Character.Crouched ) ); PhoneNote.Attach(main, entity, player, model, input, phone, player.Character.EnableWalking, playerData.PhoneActive, playerData.NoteActive); PlayerUI.Attach(main, entity, ui, player.Health, rotation.Rotation, playerData.NoteActive, playerData.PhoneActive); } }); fpsCamera.Add(new Binding <Vector2>(fpsCamera.Mouse, input.Mouse)); fpsCamera.Add(new Binding <Vector2>(fpsCamera.Movement, input.Movement)); input.Bind(fpsCamera.SpeedMode, settings.Parkour); input.Bind(fpsCamera.Up, settings.Jump); fpsCamera.Add(new Binding <bool>(fpsCamera.Down, input.GetKey(Keys.LeftControl))); Lemma.Console.Console.AddConCommand(new ConCommand("noclip", "Toggle free camera mode", delegate(ConCommand.ArgCollection args) { bool freeCameraMode = !fpsCamera.Enabled; fpsCamera.Enabled.Value = freeCameraMode; cameraControl.Enabled.Value = !freeCameraMode; firstPersonModel.Enabled.Value = !freeCameraMode; model.Enabled.Value = !freeCameraMode; ui.Enabled.Value = !freeCameraMode; player.Character.EnableWalking.Value = !freeCameraMode; player.EnableMoves.Value = !freeCameraMode; player.Character.Body.IsAffectedByGravity = !freeCameraMode; if (freeCameraMode) { AkSoundEngine.PostEvent(AK.EVENTS.STOP_PLAYER_BREATHING_SOFT, entity); } else { transform.Position.Value = main.Camera.Position; } })); entity.Add(new CommandBinding(entity.Delete, delegate() { Lemma.Console.Console.RemoveConCommand("noclip"); if (fpsCamera.Enabled) // Movement is disabled. Re-enable it. { player.Character.EnableWalking.Value = true; player.EnableMoves.Value = true; } PlayerFactory.Instance = null; })); }
public override void Bind(Entity entity, Main main, bool creating = false) { if (ParticleSystem.Get(main, "Snow") == null) { ParticleSystem.Add(main, "Snow", new ParticleSystem.ParticleSettings { TextureName = "Particles\\default", EffectFile = "Effects\\ParticleSnow", MaxParticles = 50000, Duration = TimeSpan.FromSeconds(SnowFactory.MaxLifetime), MinHorizontalVelocity = -1.0f, MaxHorizontalVelocity = 1.0f, MinVerticalVelocity = -1.0f, MaxVerticalVelocity = 1.0f, Gravity = new Vector3(0.0f, 0.0f, 0.0f), MinRotateSpeed = 0.0f, MaxRotateSpeed = 0.0f, MinStartSize = 0.05f, MaxStartSize = 0.15f, MinEndSize = 0.05f, MaxEndSize = 0.15f, MinColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f), MaxColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f), EmitterVelocitySensitivity = 1.0f, BlendState = BlendState.Opaque, Material = new Components.Model.Material { SpecularIntensity = 0.0f, SpecularPower = 1.0f }, }); ParticleSystem.Add(main, "Wind", new ParticleSystem.ParticleSettings { TextureName = "Particles\\wind", EffectFile = "Effects\\ParticleVolume", MaxParticles = 10000, Duration = TimeSpan.FromSeconds(SnowFactory.MaxWindLifetime), MinHorizontalVelocity = -1.0f, MaxHorizontalVelocity = 1.0f, MinVerticalVelocity = -1.0f, MaxVerticalVelocity = 1.0f, Gravity = new Vector3(0.0f, 0.0f, 0.0f), MinRotateSpeed = -1.0f, MaxRotateSpeed = 1.0f, MinStartSize = 20.0f, MaxStartSize = 30.0f, MinEndSize = 30.0f, MaxEndSize = 45.0f, MinColor = new Vector4(1.0f, 1.0f, 1.0f, 0.2f), MaxColor = new Vector4(1.0f, 1.0f, 1.0f, 0.2f), EmitterVelocitySensitivity = 1.0f, BlendState = BlendState.AlphaBlend, }); } entity.CannotSuspendByDistance = true; Transform transform = entity.GetOrCreate <Transform>("Transform"); ParticleWind wind = entity.GetOrCreate <ParticleWind>("Wind"); ParticleEmitter emitter = entity.GetOrCreate <ParticleEmitter>("Emitter"); emitter.Add(new Binding <Vector3>(emitter.Jitter, wind.Jitter)); ParticleEmitter windEmitter = entity.GetOrCreate <ParticleEmitter>("WindEmitter"); windEmitter.Add(new Binding <Vector3>(windEmitter.Jitter, wind.Jitter)); Property <Vector3> dir = new Property <Vector3>(); transform.Add(new Binding <Vector3, Quaternion>(dir, x => Vector3.Transform(Vector3.Down, x), transform.Quaternion)); wind.Add(new Binding <Quaternion>(wind.Orientation, transform.Quaternion)); emitter.Add(new Binding <Vector3, float>(emitter.Position, x => new Vector3(0, x * ParticleWind.StartHeightMultiplier, 0), wind.Speed)); windEmitter.Add(new Binding <Vector3, float>(windEmitter.Position, x => new Vector3(0, x * ParticleWind.StartHeightMultiplier * 2, 0), wind.Speed)); emitter.AddParticle = delegate(Vector3 position, Vector3 velocity, float prime) { Vector3 kernelCoord = (position + wind.Jitter) / wind.KernelSpacing; float distance = wind.RaycastDistances[Math.Max(0, Math.Min(ParticleWind.KernelSize - 1, (int)kernelCoord.X)), Math.Max(0, Math.Min(ParticleWind.KernelSize - 1, (int)kernelCoord.Z))]; if (distance > 0) { float lifetime = Math.Min(distance / wind.Speed, SnowFactory.MaxLifetime); if (lifetime > prime) { emitter.ParticleSystem.AddParticle(main.Camera.Position + Vector3.Transform(position, transform.Quaternion), dir.Value * wind.Speed.Value, lifetime, -1.0f, prime); } } }; windEmitter.AddParticle = delegate(Vector3 position, Vector3 velocity, float prime) { Vector3 kernelCoord = (position + wind.Jitter) / wind.KernelSpacing; float distance = wind.RaycastDistances[Math.Max(0, Math.Min(ParticleWind.KernelSize - 1, (int)kernelCoord.X)), Math.Max(0, Math.Min(ParticleWind.KernelSize - 1, (int)kernelCoord.Z))]; if (distance > 0) { float lifetime = Math.Min((distance + ParticleWind.StartHeightMultiplier) / wind.Speed, SnowFactory.MaxWindLifetime); if (lifetime > prime) { windEmitter.ParticleSystem.AddParticle(main.Camera.Position + Vector3.Transform(position, transform.Quaternion), dir.Value * wind.Speed.Value, lifetime, -1.0f, prime); } } }; this.SetMain(entity, main); emitter.ParticleType.Value = "Snow"; windEmitter.ParticleType.Value = "Wind"; entity.Add("KernelSpacing", wind.KernelSpacing); entity.Add("ParticlesPerSecond", emitter.ParticlesPerSecond); entity.Add("WindParticlesPerSecond", windEmitter.ParticlesPerSecond); entity.Add("Wind", wind.Speed); entity.Add(new PostInitialization { delegate() { wind.Update(); emitter.Prime(Vector3.Zero); windEmitter.Prime(Vector3.Zero); } }); }
public override void AttachEditorComponents(Entity entity, Main main) { Transform transform = entity.Get <Transform>(); Zone zone = entity.Get <Zone>(); EntityConnectable.AttachEditorComponents(entity, "ConnectedEntities", zone.ConnectedEntities); ModelAlpha model = new ModelAlpha(); model.Filename.Value = "AlphaModels\\sphere"; model.Color.Value = this.Color; model.Scale.Value = new Vector3(0.5f); model.Serialize = false; entity.Add("EditorModel", model); model.Add(new Binding <bool>(model.Enabled, Editor.EditorModelsVisible)); model.Add(new Binding <Matrix, Vector3>(model.Transform, x => Matrix.CreateTranslation(x), transform.Position)); Property <Vector3> corner1 = new Property <Vector3> { Value = zone.BoundingBox.Value.Min }; Property <Vector3> corner2 = new Property <Vector3> { Value = zone.BoundingBox.Value.Max }; entity.Add(new Binding <BoundingBox>(zone.BoundingBox, delegate() { Vector3 a = corner1, b = corner2; return(new BoundingBox(new Vector3(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z)), new Vector3(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Max(a.Z, b.Z)))); }, corner1, corner2)); Transform cornerTransform1 = this.addCornerModel(entity, entity.EditorSelected); cornerTransform1.Add(new TwoWayBinding <Vector3, Vector3> ( corner1, x => Vector3.Transform(x, Matrix.Invert(transform.Matrix)), new[] { transform.Matrix }, cornerTransform1.Position, x => Vector3.Transform(x, transform.Matrix), new[] { transform.Matrix } )); Transform cornerTransform2 = this.addCornerModel(entity, entity.EditorSelected); cornerTransform2.Add(new TwoWayBinding <Vector3, Vector3> ( corner2, x => Vector3.Transform(x, Matrix.Invert(transform.Matrix)), new[] { transform.Matrix }, cornerTransform2.Position, x => Vector3.Transform(x, transform.Matrix), new[] { transform.Matrix } )); ModelAlpha box = new ModelAlpha(); box.Filename.Value = "AlphaModels\\box"; box.Color.Value = new Vector3(this.Color.X, this.Color.Y, this.Color.Z); box.Alpha.Value = 0.125f; box.Serialize = false; box.DrawOrder.Value = 11; // In front of water box.DisableCulling.Value = true; entity.Add(box); box.Add(new Binding <Matrix>(box.Transform, delegate() { BoundingBox b = zone.BoundingBox; return(Matrix.CreateScale(b.Max - b.Min) * Matrix.CreateTranslation((b.Min + b.Max) * 0.5f) * transform.Matrix); }, zone.BoundingBox, transform.Matrix)); box.Add(new Binding <bool>(box.Enabled, entity.EditorSelected)); box.Add(new Binding <BoundingBox>(box.BoundingBox, zone.BoundingBox)); box.CullBoundingBox.Value = false; }
// Load the monster.txt drop file. private void LoadDropFile(bool edit) { var lines = (edit == false) ? File.ReadAllLines(GetPathOfSelectedItem()) : textBoxDropList.Lines; for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith(";Gold")) { if (lines[i + 1].StartsWith("1/")) { var workingLine = lines[i + 1].Split(' '); GoldOdds = workingLine[0].Remove(0, 2); Gold = workingLine[2]; break; } else { GoldOdds = "0"; Gold = "0"; } } } string[] Headers = new string[37] { ";Weapons", ";Armours", ";Helmets", ";Necklaces", ";Bracelets", ";Rings", ";Amulets", ";Belts", ";Boots", ";Stones", ";Torches", ";Potions", ";Ores", ";Meat", ";Crafting Materials", ";Scrolls", ";Gems", ";Mount", ";Books", ";Nothing", ";Script", ";Reins", ";Bells", ";Saddle", ";Ribbon", ";Mask", ";Food", ";Hook", ";Float", ";Bait", ";Finder", ";Reel", ";Fish", ";Quest", ";Awakening", ";Pets", ";Transform" }; for (int i = 0; i < Headers.Length; i++) { for (int j = 0; j < lines.Length; j++) { if (lines[j].StartsWith(Headers[i])) { for (int k = j + 1; k < lines.Length; k++) { if (lines[k].StartsWith(";")) { break; } var workingLine = lines[k].Split(' '); if (workingLine.Length < 2) { continue; } var quest = ""; if (workingLine.Length > 2 && workingLine[2] == "Q") { quest = workingLine[2]; } DropItem newDropItem = new DropItem { Odds = workingLine[0], Name = workingLine[1], Quest = quest }; switch (i) { case 0: Weapon.Add(newDropItem); break; case 1: Armour.Add(newDropItem); break; case 2: Helmet.Add(newDropItem); break; case 3: Necklace.Add(newDropItem); break; case 4: Bracelet.Add(newDropItem); break; case 5: Ring.Add(newDropItem); break; case 6: Amulet.Add(newDropItem); break; case 7: Belt.Add(newDropItem); break; case 8: Boot.Add(newDropItem); break; case 9: Stone.Add(newDropItem); break; case 10: Torch.Add(newDropItem); break; case 11: Potion.Add(newDropItem); break; case 12: Ore.Add(newDropItem); break; case 13: Meat.Add(newDropItem); break; case 14: CraftingMaterial.Add(newDropItem); break; case 15: Scrolls.Add(newDropItem); break; case 16: Gem.Add(newDropItem); break; case 17: Mount.Add(newDropItem); break; case 18: Book.Add(newDropItem); break; case 19: Nothing.Add(newDropItem); break; case 20: Script.Add(newDropItem); break; case 21: Reins.Add(newDropItem); break; case 22: Bells.Add(newDropItem); break; case 23: Saddle.Add(newDropItem); break; case 24: Ribbon.Add(newDropItem); break; case 25: Mask.Add(newDropItem); break; case 26: Food.Add(newDropItem); break; case 27: Hook.Add(newDropItem); break; case 28: Float.Add(newDropItem); break; case 29: Bait.Add(newDropItem); break; case 30: Finder.Add(newDropItem); break; case 31: Reel.Add(newDropItem); break; case 32: Fish.Add(newDropItem); break; case 33: Quest.Add(newDropItem); break; case 34: Awakening.Add(newDropItem); break; case 35: Pets.Add(newDropItem); break; case 36: Transform.Add(newDropItem); break; default: break; } } } } } }
// Add the item to the drop list private void buttonAdd_Click(object sender, EventArgs e) { int dropChance; int.TryParse(textBoxItemOdds.Text, out dropChance); if (dropChance < 1) { dropChance = 1; } string quest = QuestOnlyCheckBox.Checked ? "Q" : ""; try { switch (tabControlSeperateItems.SelectedTab.Tag.ToString()) { case "Weapon": Weapon.Add(new DropItem { Name = listBoxWeapon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Armour": Armour.Add(new DropItem { Name = listBoxArmour.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Helmet": Helmet.Add(new DropItem { Name = listBoxHelmet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Necklace": Necklace.Add(new DropItem { Name = listBoxNecklace.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Bracelet": Bracelet.Add(new DropItem { Name = listBoxBracelet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Ring": Ring.Add(new DropItem { Name = listBoxRing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Amulet": Amulet.Add(new DropItem { Name = listBoxAmulet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Belt": Belt.Add(new DropItem { Name = listBoxBelt.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Boots": Boot.Add(new DropItem { Name = listBoxBoot.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Stone": Stone.Add(new DropItem { Name = listBoxStone.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Torch": Torch.Add(new DropItem { Name = listBoxTorch.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Potion": Potion.Add(new DropItem { Name = listBoxPotion.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Ore": Ore.Add(new DropItem { Name = listBoxOre.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Meat": Meat.Add(new DropItem { Name = listBoxMeat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "CraftingMaterial": CraftingMaterial.Add(new DropItem { Name = listBoxCraftingMaterial.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}" }); break; case "Scroll": Scrolls.Add(new DropItem { Name = listBoxScroll.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Gem": Gem.Add(new DropItem { Name = listBoxGem.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Mount": Mount.Add(new DropItem { Name = listBoxMount.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Book": Book.Add(new DropItem { Name = listBoxBook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Nothing": Nothing.Add(new DropItem { Name = listBoxNothing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Script": Script.Add(new DropItem { Name = listBoxScript.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Reins": Reins.Add(new DropItem { Name = listBoxReins.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Bells": Bells.Add(new DropItem { Name = listBoxBells.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Saddle": Saddle.Add(new DropItem { Name = listBoxSaddle.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Ribbon": Ribbon.Add(new DropItem { Name = listBoxRibbon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Mask": Mask.Add(new DropItem { Name = listBoxMask.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Food": Food.Add(new DropItem { Name = listBoxFood.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Hook": Hook.Add(new DropItem { Name = listBoxHook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Float": Float.Add(new DropItem { Name = listBoxFloat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Bait": Bait.Add(new DropItem { Name = listBoxBait.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Finder": Finder.Add(new DropItem { Name = listBoxFinder.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Reel": Reel.Add(new DropItem { Name = listBoxReel.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Fish": Fish.Add(new DropItem { Name = listBoxFish.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Quest": Quest.Add(new DropItem { Name = listBoxQuest.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Awakening": Awakening.Add(new DropItem { Name = listBoxAwakening.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Pets": Pets.Add(new DropItem { Name = listBoxPets.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; case "Transform": Transform.Add(new DropItem { Name = listBoxTransform.SelectedItem.ToString().Replace(" ", string.Empty), Odds = $"1/{dropChance}", Quest = quest }); break; } UpdateDropFile(); } catch { //No item selected when trying to add an item to the drop } }
/// <summary> /// Adds GameObject as a child to the Transform. /// Objects position and rotation are set to localPosition and localRotation. /// </summary> /// <param name="transform"></param> /// <param name="child"></param> /// <returns></returns> public static Transform Add(this Transform transform, Component child) { return(transform.Add(child.gameObject)); }