1675{
1677
1679
1681
1688
1689
1690
1696
1702
1704
1708
1709
1711 {
1713
1714
1715 RegisterNetSyncVariableInt( "m_SyncParts01" );
1716 RegisterNetSyncVariableInt( "m_SyncParts02" );
1717 RegisterNetSyncVariableInt( "m_SyncParts03" );
1718 RegisterNetSyncVariableInt( "m_InteractedPartId" );
1719 RegisterNetSyncVariableInt( "m_PerformedActionId" );
1720 RegisterNetSyncVariableBool( "m_HasBase" );
1721
1722
1723 ConstructionInit();
1724
1725 if (ConfigIsExisting("hybridAttachments"))
1726 {
1729 }
1730 if (ConfigIsExisting("mountables"))
1731 {
1734 }
1735
1737 SetAllowDamage(true);
1738 }
1739
1741 {
1742 return "disableBaseDamage";
1743 }
1744
1746 {
1747 return true;
1748 }
1749
1751 {
1752 return EInventoryIconVisibility.HIDE_VICINITY;
1753 }
1754
1756 {
1757 super.InitItemSounds();
1758
1762
1767 }
1768
1770 {
1771 return "putDown_FenceKit_SoundSet";
1772 }
1773
1775 {
1776 return "Shelter_Site_Build_Loop_SoundSet";
1777 }
1778
1779
1781 {
1783 {
1784 SetSynchDirty();
1785 }
1786 }
1787
1789 {
1791 super.OnVariablesSynchronized();
1792
1794 }
1795
1797 {
1798
1800
1801
1803
1804
1806 }
1807
1808
1810 {
1811
1812 int offset;
1813 int mask;
1814
1815 if ( part_id >= 1 && part_id <= 31 )
1816 {
1817 offset = part_id - 1;
1818 mask = 1 << offset;
1819
1821 }
1822 else if ( part_id >= 32 && part_id <= 62 )
1823 {
1824 offset = ( part_id % 32 );
1825 mask = 1 << offset;
1826
1828 }
1829 else if ( part_id >= 63 && part_id <= 93 )
1830 {
1831 offset = ( part_id % 63 );
1832 mask = 1 << offset;
1833
1835 }
1836 }
1837
1839 {
1840
1841 int offset;
1842 int mask;
1843
1844 if ( part_id >= 1 && part_id <= 31 )
1845 {
1846 offset = part_id - 1;
1847 mask = 1 << offset;
1848
1850 }
1851 else if ( part_id >= 32 && part_id <= 62 )
1852 {
1853 offset = ( part_id % 32 );
1854 mask = 1 << offset;
1855
1857 }
1858 else if ( part_id >= 63 && part_id <= 93 )
1859 {
1860 offset = ( part_id % 63 );
1861 mask = 1 << offset;
1862
1864 }
1865 }
1866
1868 {
1869
1870 int offset;
1871 int mask;
1872
1873 if ( part_id >= 1 && part_id <= 31 )
1874 {
1875 offset = part_id - 1;
1876 mask = 1 << offset;
1877
1879 {
1880 return true;
1881 }
1882 }
1883 else if ( part_id >= 32 && part_id <= 62 )
1884 {
1885 offset = ( part_id % 32 );
1886 mask = 1 << offset;
1887
1889 {
1890 return true;
1891 }
1892 }
1893 else if ( part_id >= 63 && part_id <= 93 )
1894 {
1895 offset = ( part_id % 63 );
1896 mask = 1 << offset;
1897
1899 {
1900 return true;
1901 }
1902 }
1903
1904 return false;
1905 }
1906
1908 {
1911 }
1912
1914 {
1915
1918 }
1919
1921 {
1923 {
1926
1927 switch( build_action_id )
1928 {
1932 }
1933 }
1934 }
1935
1936
1938 {
1940 bool is_base = part.
IsBase();
1943 if ( is_part_built_sync )
1944 {
1946 {
1950
1951 if (is_base)
1952 {
1955 }
1956 }
1957 }
1958 else
1959 {
1961 {
1965
1966 if (is_base)
1967 {
1970 }
1971 }
1972 }
1973
1974
1976 }
1977
1978
1980 {
1983
1984 for ( int i = 0; i < construction_parts.Count(); ++i )
1985 {
1986 string key = construction_parts.GetKey( i );
1989 }
1990
1991
1993 }
1994
1996 {
1999
2000 for ( int i = 0; i < construction_parts.Count(); ++i )
2001 {
2002 string key = construction_parts.GetKey( i );
2004
2005 if ( value.
GetId() ==
id )
2006 {
2007 return value;
2008 }
2009 }
2010
2011 return NULL;
2012 }
2013
2014
2015
2017 {
2019 }
2020
2022 {
2024 }
2025
2027 {
2028 return true;
2029 }
2030
2032 {
2033 return false;
2034 }
2035
2036
2038 {
2041 {
2043 }
2044
2045 return construction_kit;
2046 }
2047
2049 {
2052 {
2054 }
2055 }
2056
2058 {
2060 }
2061
2063 {
2064 return "";
2065 }
2066
2068 {
2070 g_Game.ObjectDelete( construction_kit );
2071 }
2072
2073
2075 {
2077 g_Game.ObjectDelete(
this );
2078 }
2079
2080
2082 {
2083 super.EEDelete(parent);
2084
2086 {
2087 areaDamage.Destroy();
2088 }
2089
2090 }
2091
2093 {
2094 super.OnStoreSave( ctx );
2095
2096
2100
2102 }
2103
2105 {
2106 if ( !super.OnStoreLoad( ctx, version ) )
2107 return false;
2108
2109
2110
2112 {
2114 return false;
2115 }
2117 {
2119 return false;
2120 }
2122 {
2124 return false;
2125 }
2126
2127
2129 {
2131 return false;
2132 }
2133
2134
2135 return true;
2136 }
2137
2139 {
2140 super.AfterStoreLoad();
2141
2143 {
2145 }
2146 }
2147
2149 {
2150
2152
2153
2156
2157
2159 }
2160
2162 {
2163 super.OnCreatePhysics();
2164
2165 ConstructionInit();
2167 }
2168
2170 {
2172 return;
2173
2174 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
2175 }
2176
2178 {
2180 {
2182 }
2183
2184 super.EEOnAfterLoad();
2185 }
2186
2188 {
2189 super.EEItemAttached( item, slot_name );
2190
2194 }
2195
2197 {
2198 super.EEItemDetached( item, slot_name );
2199
2202 }
2203
2204 protected void OnSetSlotLock(
int slotId,
bool locked,
bool was_locked )
2205 {
2208
2211 }
2212
2213
2215 {
2216 return true;
2217 }
2218
2219
2220
2222 {
2224
2225
2226 if (construtionPart.
IsBase())
2227 {
2229
2230
2232 }
2233
2234
2236
2237
2239
2240
2242
2244
2246
2247
2249
2250
2252 }
2253
2255 {
2256
2258 }
2259
2260
2262 {
2265
2266
2268
2269
2271
2272
2274
2275
2277
2279
2280
2282
2283
2285
2286
2287 if (construtionPart.
IsBase())
2288 {
2289
2291 }
2292 }
2293
2295 {
2296
2298 }
2299
2300
2301 void OnPartDestroyedServer(Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false)
2302 {
2305
2306
2308
2309
2311
2312
2314
2315
2317
2319
2320
2322
2323
2325
2326
2327 if (construtionPart.
IsBase())
2328 {
2329
2331 }
2332 }
2333
2335 {
2336
2338 }
2339
2340
2342 {
2344
2347 }
2348
2350 {
2352
2354 {
2356 }
2357 else
2358 {
2360 }
2361
2363 }
2364
2366 {
2368
2370 foreach (
string slotName : attachmentSlots)
2371 {
2373 }
2374
2375
2378 else
2380
2382 }
2383
2385 {
2386 string slotNameMounted = slot_name + "_Mounted";
2387 EntityAI attachment = FindAttachmentBySlotName(slot_name);
2388
2389 if (attachment)
2390 {
2391 BarbedWire barbedWire = BarbedWire.Cast(attachment);
2392 if (barbedWire && barbedWire.IsMounted())
2394 else
2396
2397 if (is_locked)
2398 {
2399 SetAnimationPhase(slotNameMounted, 0);
2400 SetAnimationPhase(slot_name, 1);
2401 }
2402 else
2403 {
2404 SetAnimationPhase(slotNameMounted, 1);
2405 SetAnimationPhase(slot_name, 0);
2406 }
2407 }
2408 else
2409 {
2410 SetAnimationPhase(slotNameMounted, 1);
2411 SetAnimationPhase(slot_name, 1);
2412
2414 }
2415 }
2416
2417
2419 {
2422
2425
2428
2429 foreach (
string slotName : attachmentSlots)
2430 {
2432 }
2433
2434
2436 {
2439
2441 }
2442 else
2443 {
2446
2448 }
2449
2452 }
2453
2455 {
2456
2458 return;
2459
2460 string slot_name_mounted = slot_name + "_Mounted";
2461 EntityAI attachment = FindAttachmentBySlotName( slot_name );
2462
2463
2465 RemoveProxyPhysics( slot_name_mounted );
2466 RemoveProxyPhysics( slot_name );
2467
2468 if ( attachment )
2469 {
2471 if ( is_locked )
2472 {
2474 AddProxyPhysics( slot_name_mounted );
2475 }
2476 else
2477 {
2479 AddProxyPhysics( slot_name );
2480 }
2481 }
2482 }
2483
2485 {
2486 SetAffectPathgraph( true, false );
2488 }
2489
2491 {
2492 return true;
2493 }
2494
2496 {
2497 return true;
2498 }
2499
2501 {
2502 if ( attachment )
2503 {
2505 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
2506
2507 return GetInventory().GetSlotLock( inventory_location.
GetSlot() );
2508 }
2509
2510 return false;
2511 }
2512
2514 {
2516 }
2517
2518
2520 {
2521 string config_path = "CfgVehicles" + " " + entity.GetType() + " " + "attachments";
2522 if (
g_Game.ConfigIsExisting( config_path ) )
2523 {
2524 g_Game.ConfigGetTextArray( config_path, attachment_slots );
2525 }
2526 }
2527
2529 {
2530 return true;
2531 }
2532
2534 {
2535 return true;
2536 }
2537
2539 {
2540 return true;
2541 }
2542
2543
2545 {
2548 }
2549
2551 {
2553 }
2554
2556 {
2558 }
2559
2561 {
2562 int attachment_count = GetInventory().AttachmentCount();
2563 if ( attachment_count > 0 )
2564 {
2565 if (
HasBase() && attachment_count == 1 )
2566 {
2567 return false;
2568 }
2569
2570 return true;
2571 }
2572
2573 return false;
2574 }
2575
2577 {
2578 return true;
2579 }
2580
2582 {
2583 return false;
2584 }
2585
2586
2588 {
2589 return false;
2590 }
2591
2593 {
2594 return false;
2595 }
2596
2597
2599 {
2600 return false;
2601 }
2602
2603
2604
2606 {
2607 return true;
2608 }
2609
2611 {
2612 return true;
2613 }
2614
2617 {
2618 return false;
2619 }
2620
2621
2623 {
2624 return false;
2625 }
2626
2627
2629 {
2630 return true;
2631 }
2632
2633
2635 {
2636 if (
HasBase() || GetInventory().AttachmentCount() > 0 )
2637 {
2638 return false;
2639 }
2640
2641 return true;
2642 }
2643
2645 {
2648
2649 return item;
2650 }
2651
2652
2654 {
2656 {
2657
2659
2660
2663
2665 if ( MemoryPointExists( slot_name + "_min" ) )
2666 {
2667 min_max[0] = GetMemoryPointPos( slot_name + "_min" );
2668 }
2669 if ( MemoryPointExists( slot_name + "_max" ) )
2670 {
2671 min_max[1] = GetMemoryPointPos( slot_name + "_max" );
2672 }
2673
2674
2677
2678
2681 center = ModelToWorld( center );
2682
2683
2686
2687 areaDamage.SetExtents( extents[0], extents[1] );
2688 areaDamage.SetAreaPosition( center );
2692 areaDamage.SetHitZones( { "Torso","LeftHand","LeftLeg","LeftFoot","RightHand","RightLeg","RightFoot" } );
2693 areaDamage.SetAmmoName( "BarbedWireHit" );
2694 areaDamage.Spawn();
2695
2697 }
2698 }
2699
2701 {
2702 if ( angle_deg != 0 )
2703 {
2704
2706
2707
2709 if ( MemoryPointExists( "rotate_axis" ) )
2710 {
2711 rotate_axis = ModelToWorld( GetMemoryPointPos( "rotate_axis" ) );
2712 }
2713 float r_center_x = (
Math.
Cos( angle_deg *
Math.
DEG2RAD ) * ( center[0] - rotate_axis[0] ) ) - (
Math.
Sin( angle_deg *
Math.
DEG2RAD ) * ( center[2] - rotate_axis[2] ) ) + rotate_axis[0];
2714 float r_center_z = (
Math.
Sin( angle_deg *
Math.
DEG2RAD ) * ( center[0] - rotate_axis[0] ) ) + (
Math.
Cos( angle_deg *
Math.
DEG2RAD ) * ( center[2] - rotate_axis[2] ) ) + rotate_axis[2];
2715 center[0] = r_center_x;
2716 center[2] = r_center_z;
2717 }
2718 }
2719
2721 {
2723 {
2726 {
2727 if (areaDamage)
2728 {
2729 areaDamage.Destroy();
2730 }
2731
2733 }
2734 }
2735 }
2736
2738 {
2739 return true;
2740 }
2741
2742
2743
2744
2746 {
2748 }
2749
2751 {
2753 }
2754
2756 {
2758 }
2759
2761 {
2763
2764 switch ( material_type )
2765 {
2771 }
2772
2773 return "";
2774 }
2775
2777 {
2779
2780 switch ( material_type )
2781 {
2787 }
2788
2789 return "";
2790 }
2791
2792
2794 {
2796 {
2797
2799 {
2800 SetHealth(slot_name,"Health",item.GetHealth());
2801 }
2802 }
2803 }
2804
2806 {
2807 return 111;
2808 }
2809
2811 {
2812 super.SetActions();
2813
2817 }
2818
2820 {
2822 if (!construction)
2823 return;
2824
2826 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
2827 {
2830 {
2832 }
2833 }
2834 }
2835
2837 {
2839 if (!construction)
2840 return;
2841
2843 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
2844 {
2847 {
2848 construction.HandleEntityFalling(part.
GetPartName());
2849 }
2850 }
2851 }
2852
2855 {
2857 return;
2858
2861
2862 if (DestroyOnFall())
2863 {
2865 {
2867 }
2868 else
2869 {
2871 {
2873 }
2875 }
2876 }
2877 }
2878
2880 {
2881 if (HasAnyAttachmentsOrCargo())
2882 {
2885 }
2886 }
2887
2888
2889
2890
2891
2894 {
2895 return null;
2896 }
2897
2899 {
2901 }
2902
2904 {
2907
2908 Man p;
2909
2910 #ifdef SERVER
2912 g_Game.GetWorld().GetPlayerList(players);
2913 if (players.Count())
2914 p = players[0];
2915 #else
2917 #endif
2918
2920 {
2921 bool excluded = false;
2923 if (excludes)
2924 {
2925 foreach (string exclude : excludes)
2926 {
2928 {
2929 excluded = true;
2930 break;
2931 }
2932 }
2933 }
2934
2935 if (!excluded)
2936 {
2938 }
2939 }
2940
2942 }
2943
2945
2947 [
Obsolete(
"handled in the Construction component directly")]
2949 {
2950 }
2951
2952 [
Obsolete(
"handled in the Construction component directly")]
2954 {
2955 }
2956
2957 [
Obsolete(
"obsolete debug method")]
2959 {
2960 }
2961}
2962
2964{
2965#ifdef BSB_DEBUG
2967#else
2968
2969#endif
2970}
2972{
2973#ifdef BSB_DEBUG_SPAM
2975#else
2976
2977#endif
2978}
const int AT_DISMANTLE_PART
const int AT_DESTROY_PART
ref ConstructionBasic m_Construction
void AddAction(typename actionName)
void RemoveAction(typename actionName)
void AreaDamageManager(EntityAI parent)
void OnPartDismantledClient(string part_name, int action_id)
const string ANIMATION_DEPLOYED
override int GetHideIconMask()
override void OnStoreSave(ParamsWriteContext ctx)
void SetActionFromSyncData()
bool CheckMemoryPointVerticalDistance(float max_dist, string selection, PlayerBase player)
override void OnDebugSpawn()
array< string > OnDebugSpawnBuildExcludes()
Excludes certain parts from being built by OnDebugSpawn, uses Contains to compare.
void DropAttachmentAndCargoItems()
void SoundDestroyStart(string part_name)
const string SOUND_BUILD_WOOD_LOG
void SoundBuildStart(string part_name)
void UpdateAttachmentVisuals(string slot_name, bool is_locked)
void CalcDamageAreaRotation(float angle_deg, out vector center, out vector orientation)
override bool CanObstruct()
bool HasAttachmentsBesidesBase()
override void InitItemSounds()
void RegisterPartForSync(int part_id)
ConstructionBasic CreateConstructionComponent()
const string SOUND_DISMANTLE_METAL
void SetPartsAfterStoreLoad()
void DestroyConstruction()
ref array< string > m_HybridAttachments
override string GetFoldSoundset()
string GetDismantleSoundByMaterial(string part_name)
bool IsAttachmentSlotLocked(EntityAI attachment)
override bool IsFacingPlayer(PlayerBase player, string selection)
void OnPartBuiltClient(string part_name, int action_id)
bool HasProperDistance(string selection, PlayerBase player)
override void OnCreatePhysics()
void OnPartBuiltServer(notnull Man player, string part_name, int action_id)
void RegisterActionForSync(int part_id, int action_id)
const string SOUND_BUILD_WOOD_PLANK
void SetPartsFromSyncData()
ref array< string > m_Mountables
const string SOUND_BUILD_WIRE
void ResetActionSyncData()
override string GetInvulnerabilityTypeString()
void OnPartDismantledServer(notnull Man player, string part_name, int action_id)
void CheckForHybridAttachments(EntityAI item, string slot_name)
override void EEOnAfterLoad()
override void EEItemDetached(EntityAI item, string slot_name)
vector GetKitSpawnPosition()
override void OnItemFallRebuilding()
@Note for modders: This method and is subject to change!
bool CheckSlotVerticalDistance(int slot_id, PlayerBase player)
void GetAttachmentSlots(EntityAI entity, out array< string > attachment_slots)
override bool IsDeployable()
void OnPartDestroyedClient(string part_name, int action_id)
void UnregisterPartForSync(int part_id)
void bsbDebugSpam(string s)
override void OnVariablesSynchronized()
bool PerformRoofCheckForBase(string partName, PlayerBase player, out bool result)
Construction GetConstruction()
void SoundDismantleStart(string part_name)
ConstructionPart GetConstructionPartById(int id)
string GetConstructionKitType()
bool CheckLevelVerticalDistance(float max_dist, string selection, PlayerBase player)
void OnPartDestroyedServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
bool CanFoldBaseBuildingObject()
override int GetDamageSystemVersionChange()
const string SOUND_DISMANTLE_WOOD_PLANK
override void EEItemAttached(EntityAI item, string slot_name)
const string SOUND_DISMANTLE_WOOD_LOG
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
const string SOUND_BUILD_WOOD_STAIRS
ItemBase FoldBaseBuildingObject()
override ConstructionBasic GetConstructionBasic()
override bool CanPutInCargo(EntityAI parent)
override bool CanUseConstruction()
override void AfterStoreLoad()
void SetPartFromSyncData(ConstructionPart part)
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
override bool IgnoreOutOfReachCondition()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override bool ShowZonesHealth()
void UpdateAttachmentPhysics(string slot_name, bool is_locked)
void HandleFallingForConstructedParts()
override bool IsPlayerInside(PlayerBase player, string selection)
string GetBuildSoundByMaterial(string part_name)
ItemBase CreateConstructionKit()
const string SOUND_DISMANTLE_WIRE
bool MustBeBuiltFromOutside()
Some buildings can only be built from outside.
override bool IsTakeable()
float m_ConstructionKitHealth
override void EEDelete(EntityAI parent)
override void SetActions()
void HandleItemFalling(ConstructionPart part)
void DestroyConstructionKit(ItemBase construction_kit)
void CreateConstructionKitInHands(notnull PlayerBase player)
void ItemFall(vector min, vector max)
override bool CanUseConstructionBuild()
void OnSynchronizedClient()
void SynchronizeBaseState()
override bool IsIgnoredByConstruction()
ref map< string, ref AreaDamageManager > m_DamageTriggers
void SetBaseState(bool has_base)
const string SOUND_BUILD_METAL
override string GetLoopFoldSoundset()
void OnSetSlotLock(int slotId, bool locked, bool was_locked)
override bool CanPutIntoHands(EntityAI parent)
bool IsPartBuildInSyncData(int part_id)
override bool CanRemoveFromCargo(EntityAI parent)
void DestroyConstructedParts()
const string SOUND_DISMANTLE_WOOD_STAIRS
const int ECE_PLACE_ON_SURFACE
PlayerSpawnPreset slotName
ConstructionMaterialType
used to guide action sound selection, mostly. Could be also used for particles and stuff,...
string GetLoopFoldSoundset()
ItemSoundHandler GetItemSoundHandler()
bool m_FixDamageSystemInit
void ItemSoundHandler(ItemBase parent)
override void SetLoopInterval(float time)
A particular version of the deferred loop used to not damage players inside vehicles.
override void SetDeferDuration(float time)
static bool GetDisableRefundMaterialsOnFall()
static bool GetDisableDropAttachmentsOnFall()
static bool GetDisableItemFalling()
override void DestroyPartServer(Man player, string part_name, int action_id, bool destroyed_by_connected_part=false)
just declared for module 3 use
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
Wrapper class for managing sound through SEffectManager.
proto native int GetSlot()
returns slot id if current type is Attachment
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
static bool IsBaseBuildingLogEnable()
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override string GetDebugName()
Serializer ParamsReadContext
Serializer ParamsWriteContext
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
void Obsolete(string msg="")
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static const float DEG2RAD
vector GetPosition()
Get the world position of the Effect.
bool Contains(string sample)
Returns true if sample is substring of string.