2113{
2115
2117
2119
2126
2127
2128
2134
2140
2142
2146
2147
2149 {
2151
2152
2153 RegisterNetSyncVariableInt( "m_SyncParts01" );
2154 RegisterNetSyncVariableInt( "m_SyncParts02" );
2155 RegisterNetSyncVariableInt( "m_SyncParts03" );
2156 RegisterNetSyncVariableInt( "m_InteractedPartId" );
2157 RegisterNetSyncVariableInt( "m_PerformedActionId" );
2158 RegisterNetSyncVariableBool( "m_HasBase" );
2159
2160
2161 ConstructionInit();
2162
2163 if (ConfigIsExisting("hybridAttachments"))
2164 {
2167 }
2168 if (ConfigIsExisting("mountables"))
2169 {
2172 }
2173
2175 SetAllowDamage(true);
2176 }
2177
2179 {
2180 return "disableBaseDamage";
2181 }
2182
2184 {
2185 return true;
2186 }
2187
2189 {
2190 return EInventoryIconVisibility.HIDE_VICINITY;
2191 }
2192
2194 {
2195 super.InitItemSounds();
2196
2200
2205 }
2206
2208 {
2209 return "putDown_FenceKit_SoundSet";
2210 }
2211
2213 {
2214 return "Shelter_Site_Build_Loop_SoundSet";
2215 }
2216
2217
2219 {
2221 {
2222 SetSynchDirty();
2223 }
2224 }
2225
2227 {
2229 super.OnVariablesSynchronized();
2230
2232 }
2233
2235 {
2236
2238
2239
2241
2242
2244 }
2245
2246
2248 {
2249
2250 int offset;
2251 int mask;
2252
2253 if ( part_id >= 1 && part_id <= 31 )
2254 {
2255 offset = part_id - 1;
2256 mask = 1 << offset;
2257
2259 }
2260 else if ( part_id >= 32 && part_id <= 62 )
2261 {
2262 offset = ( part_id % 32 );
2263 mask = 1 << offset;
2264
2266 }
2267 else if ( part_id >= 63 && part_id <= 93 )
2268 {
2269 offset = ( part_id % 63 );
2270 mask = 1 << offset;
2271
2273 }
2274 }
2275
2277 {
2278
2279 int offset;
2280 int mask;
2281
2282 if ( part_id >= 1 && part_id <= 31 )
2283 {
2284 offset = part_id - 1;
2285 mask = 1 << offset;
2286
2288 }
2289 else if ( part_id >= 32 && part_id <= 62 )
2290 {
2291 offset = ( part_id % 32 );
2292 mask = 1 << offset;
2293
2295 }
2296 else if ( part_id >= 63 && part_id <= 93 )
2297 {
2298 offset = ( part_id % 63 );
2299 mask = 1 << offset;
2300
2302 }
2303 }
2304
2306 {
2307
2308 int offset;
2309 int mask;
2310
2311 if ( part_id >= 1 && part_id <= 31 )
2312 {
2313 offset = part_id - 1;
2314 mask = 1 << offset;
2315
2317 {
2318 return true;
2319 }
2320 }
2321 else if ( part_id >= 32 && part_id <= 62 )
2322 {
2323 offset = ( part_id % 32 );
2324 mask = 1 << offset;
2325
2327 {
2328 return true;
2329 }
2330 }
2331 else if ( part_id >= 63 && part_id <= 93 )
2332 {
2333 offset = ( part_id % 63 );
2334 mask = 1 << offset;
2335
2337 {
2338 return true;
2339 }
2340 }
2341
2342 return false;
2343 }
2344
2346 {
2349 }
2350
2352 {
2353
2356 }
2357
2359 {
2361 {
2364
2365 switch( build_action_id )
2366 {
2370 }
2371 }
2372 }
2373
2374
2376 {
2378 bool is_base = part.
IsBase();
2381 if ( is_part_built_sync )
2382 {
2384 {
2388
2389 if (is_base)
2390 {
2393 }
2394 }
2395 }
2396 else
2397 {
2399 {
2403
2404 if (is_base)
2405 {
2408 }
2409 }
2410 }
2411
2412
2414 }
2415
2416
2418 {
2421
2422 for ( int i = 0; i < construction_parts.Count(); ++i )
2423 {
2424 string key = construction_parts.GetKey( i );
2427 }
2428
2429
2431 }
2432
2434 {
2437
2438 for ( int i = 0; i < construction_parts.Count(); ++i )
2439 {
2440 string key = construction_parts.GetKey( i );
2442
2443 if ( value.
GetId() ==
id )
2444 {
2445 return value;
2446 }
2447 }
2448
2449 return NULL;
2450 }
2451
2452
2453
2455 {
2457 }
2458
2460 {
2462 }
2463
2465 {
2466 return true;
2467 }
2468
2470 {
2471 return false;
2472 }
2473
2474
2476 {
2479 {
2481 }
2482
2483 return construction_kit;
2484 }
2485
2487 {
2490 {
2492 }
2493 }
2494
2496 {
2498 }
2499
2501 {
2502 return "";
2503 }
2504
2506 {
2508 g_Game.ObjectDelete( construction_kit );
2509 }
2510
2511
2513 {
2515 g_Game.ObjectDelete(
this );
2516 }
2517
2518
2520 {
2521 super.EEDelete(parent);
2522
2524 {
2525 areaDamage.Destroy();
2526 }
2527
2528 }
2529
2531 {
2532 super.OnStoreSave( ctx );
2533
2534
2538
2540 }
2541
2543 {
2544 if ( !super.OnStoreLoad( ctx, version ) )
2545 return false;
2546
2547
2548
2550 {
2552 return false;
2553 }
2555 {
2557 return false;
2558 }
2560 {
2562 return false;
2563 }
2564
2565
2567 {
2569 return false;
2570 }
2571
2572
2573 return true;
2574 }
2575
2577 {
2578 super.AfterStoreLoad();
2579
2581 {
2583 }
2584 }
2585
2587 {
2588
2590
2591
2594
2595
2597 }
2598
2600 {
2601 super.OnCreatePhysics();
2602
2603 ConstructionInit();
2605 }
2606
2608 {
2610 return;
2611
2612 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
2613 }
2614
2616 {
2618 {
2620 }
2621
2622 super.EEOnAfterLoad();
2623 }
2624
2626 {
2627 super.EEItemAttached( item, slot_name );
2628
2632 }
2633
2635 {
2636 super.EEItemDetached( item, slot_name );
2637
2640 }
2641
2642 protected void OnSetSlotLock(
int slotId,
bool locked,
bool was_locked )
2643 {
2646
2649 }
2650
2651
2653 {
2654 return true;
2655 }
2656
2657
2658
2660 {
2662
2663
2664 if (construtionPart.
IsBase())
2665 {
2667
2668
2670 }
2671
2672
2674
2675
2677
2678
2680
2682
2684
2685
2687
2688
2690 }
2691
2693 {
2694
2696 }
2697
2698
2700 {
2703
2704
2706
2707
2709
2710
2712
2713
2715
2717
2718
2720
2721
2723
2724
2725 if (construtionPart.
IsBase())
2726 {
2727
2729 }
2730 }
2731
2733 {
2734
2736 }
2737
2738
2739 void OnPartDestroyedServer(Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false)
2740 {
2743
2744
2746
2747
2749
2750
2752
2753
2755
2757
2758
2760
2761
2763
2764
2765 if (construtionPart.
IsBase())
2766 {
2767
2769 }
2770 }
2771
2773 {
2774
2776 }
2777
2778
2780 {
2782
2785 }
2786
2788 {
2790
2792 {
2794 }
2795 else
2796 {
2798 }
2799
2801 }
2802
2804 {
2806
2808 foreach (
string slotName : attachmentSlots)
2809 {
2811 }
2812
2813
2816 else
2818
2820 }
2821
2823 {
2824 string slotNameMounted = slot_name + "_Mounted";
2825 EntityAI attachment = FindAttachmentBySlotName(slot_name);
2826
2827 if (attachment)
2828 {
2829 BarbedWire barbedWire = BarbedWire.Cast(attachment);
2830 if (barbedWire && barbedWire.IsMounted())
2832 else
2834
2835 if (is_locked)
2836 {
2837 SetAnimationPhase(slotNameMounted, 0);
2838 SetAnimationPhase(slot_name, 1);
2839 }
2840 else
2841 {
2842 SetAnimationPhase(slotNameMounted, 1);
2843 SetAnimationPhase(slot_name, 0);
2844 }
2845 }
2846 else
2847 {
2848 SetAnimationPhase(slotNameMounted, 1);
2849 SetAnimationPhase(slot_name, 1);
2850
2852 }
2853 }
2854
2855
2857 {
2860
2863
2866
2867 foreach (
string slotName : attachmentSlots)
2868 {
2870 }
2871
2872
2874 {
2877
2879 }
2880 else
2881 {
2884
2886 }
2887
2890 }
2891
2893 {
2894
2896 return;
2897
2898 string slot_name_mounted = slot_name + "_Mounted";
2899 EntityAI attachment = FindAttachmentBySlotName( slot_name );
2900
2901
2903 RemoveProxyPhysics( slot_name_mounted );
2904 RemoveProxyPhysics( slot_name );
2905
2906 if ( attachment )
2907 {
2909 if ( is_locked )
2910 {
2912 AddProxyPhysics( slot_name_mounted );
2913 }
2914 else
2915 {
2917 AddProxyPhysics( slot_name );
2918 }
2919 }
2920 }
2921
2923 {
2924 SetAffectPathgraph( true, false );
2926 }
2927
2929 {
2930 return true;
2931 }
2932
2934 {
2935 return true;
2936 }
2937
2939 {
2940 if ( attachment )
2941 {
2943 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
2944
2945 return GetInventory().GetSlotLock( inventory_location.
GetSlot() );
2946 }
2947
2948 return false;
2949 }
2950
2952 {
2954 }
2955
2956
2958 {
2959 string config_path = "CfgVehicles" + " " + entity.GetType() + " " + "attachments";
2960 if (
g_Game.ConfigIsExisting( config_path ) )
2961 {
2962 g_Game.ConfigGetTextArray( config_path, attachment_slots );
2963 }
2964 }
2965
2967 {
2968 return true;
2969 }
2970
2972 {
2973 return true;
2974 }
2975
2977 {
2978 return true;
2979 }
2980
2981
2983 {
2986 }
2987
2989 {
2991 }
2992
2994 {
2996 }
2997
2999 {
3000 int attachment_count = GetInventory().AttachmentCount();
3001 if ( attachment_count > 0 )
3002 {
3003 if (
HasBase() && attachment_count == 1 )
3004 {
3005 return false;
3006 }
3007
3008 return true;
3009 }
3010
3011 return false;
3012 }
3013
3015 {
3016 return true;
3017 }
3018
3020 {
3021 return false;
3022 }
3023
3024
3026 {
3027 return false;
3028 }
3029
3031 {
3032 return false;
3033 }
3034
3035
3037 {
3038 return false;
3039 }
3040
3041
3042
3044 {
3045 return true;
3046 }
3047
3049 {
3050 return true;
3051 }
3052
3055 {
3056 return false;
3057 }
3058
3059
3061 {
3062 return false;
3063 }
3064
3065
3067 {
3068 return true;
3069 }
3070
3071
3073 {
3074 if (
HasBase() || GetInventory().AttachmentCount() > 0 )
3075 {
3076 return false;
3077 }
3078
3079 return true;
3080 }
3081
3083 {
3086
3087 return item;
3088 }
3089
3090
3092 {
3094 {
3095
3097
3098
3101
3103 if ( MemoryPointExists( slot_name + "_min" ) )
3104 {
3105 min_max[0] = GetMemoryPointPos( slot_name + "_min" );
3106 }
3107 if ( MemoryPointExists( slot_name + "_max" ) )
3108 {
3109 min_max[1] = GetMemoryPointPos( slot_name + "_max" );
3110 }
3111
3112
3115
3116
3119 center = ModelToWorld( center );
3120
3121
3124
3125 areaDamage.SetExtents( extents[0], extents[1] );
3126 areaDamage.SetAreaPosition( center );
3130 areaDamage.SetHitZones( { "Torso","LeftHand","LeftLeg","LeftFoot","RightHand","RightLeg","RightFoot" } );
3131 areaDamage.SetAmmoName( "BarbedWireHit" );
3132 areaDamage.Spawn();
3133
3135 }
3136 }
3137
3139 {
3140 if ( angle_deg != 0 )
3141 {
3142
3144
3145
3147 if ( MemoryPointExists( "rotate_axis" ) )
3148 {
3149 rotate_axis = ModelToWorld( GetMemoryPointPos( "rotate_axis" ) );
3150 }
3151 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];
3152 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];
3153 center[0] = r_center_x;
3154 center[2] = r_center_z;
3155 }
3156 }
3157
3159 {
3161 {
3164 {
3165 if (areaDamage)
3166 {
3167 areaDamage.Destroy();
3168 }
3169
3171 }
3172 }
3173 }
3174
3176 {
3177 return true;
3178 }
3179
3180
3181
3182
3184 {
3186 }
3187
3189 {
3191 }
3192
3194 {
3196 }
3197
3199 {
3201
3202 switch ( material_type )
3203 {
3209 }
3210
3211 return "";
3212 }
3213
3215 {
3217
3218 switch ( material_type )
3219 {
3225 }
3226
3227 return "";
3228 }
3229
3230
3232 {
3234 {
3235
3237 {
3238 SetHealth(slot_name,"Health",item.GetHealth());
3239 }
3240 }
3241 }
3242
3244 {
3245 return 111;
3246 }
3247
3249 {
3250 super.SetActions();
3251
3255 }
3256
3258 {
3260 if (!construction)
3261 return;
3262
3264 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
3265 {
3268 {
3270 }
3271 }
3272 }
3273
3275 {
3277 if (!construction)
3278 return;
3279
3281 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
3282 {
3285 {
3286 construction.HandleEntityFalling(part.
GetPartName());
3287 }
3288 }
3289 }
3290
3293 {
3295 return;
3296
3299
3300 if (DestroyOnFall())
3301 {
3303 {
3305 }
3306 else
3307 {
3309 {
3311 }
3313 }
3314 }
3315 }
3316
3318 {
3319 if (HasAnyAttachmentsOrCargo())
3320 {
3323 }
3324 }
3325
3326
3327
3328
3329
3332 {
3333 return null;
3334 }
3335
3337 {
3339 }
3340
3342 {
3345
3346 Man p;
3347
3348 #ifdef SERVER
3350 g_Game.GetWorld().GetPlayerList(players);
3351 if (players.Count())
3352 p = players[0];
3353 #else
3355 #endif
3356
3358 {
3359 bool excluded = false;
3361 if (excludes)
3362 {
3363 foreach (string exclude : excludes)
3364 {
3366 {
3367 excluded = true;
3368 break;
3369 }
3370 }
3371 }
3372
3373 if (!excluded)
3374 {
3376 }
3377 }
3378
3380 }
3381
3383
3385 [
Obsolete(
"handled in the Construction component directly")]
3387 {
3388 }
3389
3390 [
Obsolete(
"handled in the Construction component directly")]
3392 {
3393 }
3394
3395 [
Obsolete(
"obsolete debug method")]
3397 {
3398 }
3399}
3400
3402{
3403#ifdef BSB_DEBUG
3405#else
3406
3407#endif
3408}
3410{
3411#ifdef BSB_DEBUG_SPAM
3413#else
3414
3415#endif
3416}
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.