2168{
2170
2172
2174
2181
2182
2183
2189
2195
2197
2201
2202
2204 {
2206
2207
2208 RegisterNetSyncVariableInt( "m_SyncParts01" );
2209 RegisterNetSyncVariableInt( "m_SyncParts02" );
2210 RegisterNetSyncVariableInt( "m_SyncParts03" );
2211 RegisterNetSyncVariableInt( "m_InteractedPartId" );
2212 RegisterNetSyncVariableInt( "m_PerformedActionId" );
2213 RegisterNetSyncVariableBool( "m_HasBase" );
2214
2215
2216 ConstructionInit();
2217
2218 if (ConfigIsExisting("hybridAttachments"))
2219 {
2222 }
2223 if (ConfigIsExisting("mountables"))
2224 {
2227 }
2228
2230 SetAllowDamage(true);
2231 }
2232
2234 {
2235 return "disableBaseDamage";
2236 }
2237
2239 {
2240 return true;
2241 }
2242
2244 {
2245 return EInventoryIconVisibility.HIDE_VICINITY;
2246 }
2247
2249 {
2250 super.InitItemSounds();
2251
2255
2260 }
2261
2263 {
2264 return "putDown_FenceKit_SoundSet";
2265 }
2266
2268 {
2269 return "Shelter_Site_Build_Loop_SoundSet";
2270 }
2271
2272
2274 {
2276 {
2277 SetSynchDirty();
2278 }
2279 }
2280
2282 {
2284 super.OnVariablesSynchronized();
2285
2287 }
2288
2290 {
2291
2293
2294
2296
2297
2299 }
2300
2301
2303 {
2304
2305 int offset;
2306 int mask;
2307
2308 if ( part_id >= 1 && part_id <= 31 )
2309 {
2310 offset = part_id - 1;
2311 mask = 1 << offset;
2312
2314 }
2315 else if ( part_id >= 32 && part_id <= 62 )
2316 {
2317 offset = ( part_id % 32 );
2318 mask = 1 << offset;
2319
2321 }
2322 else if ( part_id >= 63 && part_id <= 93 )
2323 {
2324 offset = ( part_id % 63 );
2325 mask = 1 << offset;
2326
2328 }
2329 }
2330
2332 {
2333
2334 int offset;
2335 int mask;
2336
2337 if ( part_id >= 1 && part_id <= 31 )
2338 {
2339 offset = part_id - 1;
2340 mask = 1 << offset;
2341
2343 }
2344 else if ( part_id >= 32 && part_id <= 62 )
2345 {
2346 offset = ( part_id % 32 );
2347 mask = 1 << offset;
2348
2350 }
2351 else if ( part_id >= 63 && part_id <= 93 )
2352 {
2353 offset = ( part_id % 63 );
2354 mask = 1 << offset;
2355
2357 }
2358 }
2359
2361 {
2362
2363 int offset;
2364 int mask;
2365
2366 if ( part_id >= 1 && part_id <= 31 )
2367 {
2368 offset = part_id - 1;
2369 mask = 1 << offset;
2370
2372 {
2373 return true;
2374 }
2375 }
2376 else if ( part_id >= 32 && part_id <= 62 )
2377 {
2378 offset = ( part_id % 32 );
2379 mask = 1 << offset;
2380
2382 {
2383 return true;
2384 }
2385 }
2386 else if ( part_id >= 63 && part_id <= 93 )
2387 {
2388 offset = ( part_id % 63 );
2389 mask = 1 << offset;
2390
2392 {
2393 return true;
2394 }
2395 }
2396
2397 return false;
2398 }
2399
2401 {
2404 }
2405
2407 {
2408
2411 }
2412
2414 {
2416 {
2419
2420 switch( build_action_id )
2421 {
2425 }
2426 }
2427 }
2428
2429
2431 {
2433 bool is_base = part.
IsBase();
2436 if ( is_part_built_sync )
2437 {
2439 {
2443
2444 if (is_base)
2445 {
2448 }
2449 }
2450 }
2451 else
2452 {
2454 {
2458
2459 if (is_base)
2460 {
2463 }
2464 }
2465 }
2466
2467
2469 }
2470
2471
2473 {
2476
2477 for ( int i = 0; i < construction_parts.Count(); ++i )
2478 {
2479 string key = construction_parts.GetKey( i );
2482 }
2483
2484
2486 }
2487
2489 {
2492
2493 for ( int i = 0; i < construction_parts.Count(); ++i )
2494 {
2495 string key = construction_parts.GetKey( i );
2497
2498 if ( value.
GetId() ==
id )
2499 {
2500 return value;
2501 }
2502 }
2503
2504 return NULL;
2505 }
2506
2507
2508
2510 {
2512 }
2513
2515 {
2517 }
2518
2520 {
2521 return true;
2522 }
2523
2525 {
2526 return false;
2527 }
2528
2529
2531 {
2534 {
2536 }
2537
2538 return construction_kit;
2539 }
2540
2542 {
2545 {
2547 }
2548 }
2549
2551 {
2553 }
2554
2556 {
2557 return "";
2558 }
2559
2561 {
2563 g_Game.ObjectDelete( construction_kit );
2564 }
2565
2566
2568 {
2570 g_Game.ObjectDelete(
this );
2571 }
2572
2573
2575 {
2576 super.EEDelete(parent);
2577
2579 {
2580 areaDamage.Destroy();
2581 }
2582
2583 }
2584
2586 {
2587 super.OnStoreSave( ctx );
2588
2589
2593
2595 }
2596
2598 {
2599 if ( !super.OnStoreLoad( ctx, version ) )
2600 return false;
2601
2602
2603
2605 {
2607 return false;
2608 }
2610 {
2612 return false;
2613 }
2615 {
2617 return false;
2618 }
2619
2620
2622 {
2624 return false;
2625 }
2626
2627
2628 return true;
2629 }
2630
2632 {
2633 super.AfterStoreLoad();
2634
2636 {
2638 }
2639 }
2640
2642 {
2643
2645
2646
2649
2650
2652 }
2653
2655 {
2656 super.OnCreatePhysics();
2657
2658 ConstructionInit();
2660 }
2661
2663 {
2665 return;
2666
2667 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
2668 }
2669
2671 {
2673 {
2675 }
2676
2677 super.EEOnAfterLoad();
2678 }
2679
2681 {
2682 super.EEItemAttached( item, slot_name );
2683
2687 }
2688
2690 {
2691 super.EEItemDetached( item, slot_name );
2692
2695 }
2696
2697 protected void OnSetSlotLock(
int slotId,
bool locked,
bool was_locked )
2698 {
2701
2704 }
2705
2706
2708 {
2709 return true;
2710 }
2711
2712
2713
2715 {
2717
2718
2719 if (construtionPart.
IsBase())
2720 {
2722
2723
2725 }
2726
2727
2729
2730
2732
2733
2735
2737
2739
2740
2742
2743
2745 }
2746
2748 {
2749
2751 }
2752
2753
2755 {
2758
2759
2761
2762
2764
2765
2767
2768
2770
2772
2773
2775
2776
2778
2779
2780 if (construtionPart.
IsBase())
2781 {
2782
2784 }
2785 }
2786
2788 {
2789
2791 }
2792
2793
2794 void OnPartDestroyedServer(Man player,
string part_name,
int action_id,
bool destroyed_by_connected_part =
false)
2795 {
2798
2799
2801
2802
2804
2805
2807
2808
2810
2812
2813
2815
2816
2818
2819
2820 if (construtionPart.
IsBase())
2821 {
2822
2824 }
2825 }
2826
2828 {
2829
2831 }
2832
2833
2835 {
2837
2840 }
2841
2843 {
2845
2847 {
2849 }
2850 else
2851 {
2853 }
2854
2856 }
2857
2859 {
2861
2863 foreach (
string slotName : attachmentSlots)
2864 {
2866 }
2867
2868
2871 else
2873
2875 }
2876
2878 {
2879 string slotNameMounted = slot_name + "_Mounted";
2880 EntityAI attachment = FindAttachmentBySlotName(slot_name);
2881
2882 if (attachment)
2883 {
2884 BarbedWire barbedWire = BarbedWire.Cast(attachment);
2885 if (barbedWire && barbedWire.IsMounted())
2887 else
2889
2890 if (is_locked)
2891 {
2892 SetAnimationPhase(slotNameMounted, 0);
2893 SetAnimationPhase(slot_name, 1);
2894 }
2895 else
2896 {
2897 SetAnimationPhase(slotNameMounted, 1);
2898 SetAnimationPhase(slot_name, 0);
2899 }
2900 }
2901 else
2902 {
2903 SetAnimationPhase(slotNameMounted, 1);
2904 SetAnimationPhase(slot_name, 1);
2905
2907 }
2908 }
2909
2910
2912 {
2915
2918
2921
2922 foreach (
string slotName : attachmentSlots)
2923 {
2925 }
2926
2927
2929 {
2932
2934 }
2935 else
2936 {
2939
2941 }
2942
2945 }
2946
2948 {
2949
2951 return;
2952
2953 string slot_name_mounted = slot_name + "_Mounted";
2954 EntityAI attachment = FindAttachmentBySlotName( slot_name );
2955
2956
2958 RemoveProxyPhysics( slot_name_mounted );
2959 RemoveProxyPhysics( slot_name );
2960
2961 if ( attachment )
2962 {
2964 if ( is_locked )
2965 {
2967 AddProxyPhysics( slot_name_mounted );
2968 }
2969 else
2970 {
2972 AddProxyPhysics( slot_name );
2973 }
2974 }
2975 }
2976
2978 {
2979 SetAffectPathgraph( true, false );
2981 }
2982
2984 {
2985 return true;
2986 }
2987
2989 {
2990 return true;
2991 }
2992
2994 {
2995 if ( attachment )
2996 {
2998 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
2999
3000 return GetInventory().GetSlotLock( inventory_location.
GetSlot() );
3001 }
3002
3003 return false;
3004 }
3005
3007 {
3009 }
3010
3011
3013 {
3014 string config_path = "CfgVehicles" + " " + entity.GetType() + " " + "attachments";
3015 if (
g_Game.ConfigIsExisting( config_path ) )
3016 {
3017 g_Game.ConfigGetTextArray( config_path, attachment_slots );
3018 }
3019 }
3020
3022 {
3023 return true;
3024 }
3025
3027 {
3028 return true;
3029 }
3030
3032 {
3033 return true;
3034 }
3035
3036
3038 {
3041 }
3042
3044 {
3046 }
3047
3049 {
3051 }
3052
3054 {
3055 int attachment_count = GetInventory().AttachmentCount();
3056 if ( attachment_count > 0 )
3057 {
3058 if (
HasBase() && attachment_count == 1 )
3059 {
3060 return false;
3061 }
3062
3063 return true;
3064 }
3065
3066 return false;
3067 }
3068
3070 {
3071 return true;
3072 }
3073
3075 {
3076 return false;
3077 }
3078
3079
3081 {
3082 return false;
3083 }
3084
3086 {
3087 return false;
3088 }
3089
3090
3092 {
3093 return false;
3094 }
3095
3096
3097
3099 {
3100 return true;
3101 }
3102
3104 {
3105 return true;
3106 }
3107
3110 {
3111 return false;
3112 }
3113
3114
3116 {
3117 return false;
3118 }
3119
3120
3122 {
3123 return true;
3124 }
3125
3126
3128 {
3129 if (
HasBase() || GetInventory().AttachmentCount() > 0 )
3130 {
3131 return false;
3132 }
3133
3134 return true;
3135 }
3136
3138 {
3141
3142 return item;
3143 }
3144
3145
3147 {
3149 {
3150
3152
3153
3156
3158 if ( MemoryPointExists( slot_name + "_min" ) )
3159 {
3160 min_max[0] = GetMemoryPointPos( slot_name + "_min" );
3161 }
3162 if ( MemoryPointExists( slot_name + "_max" ) )
3163 {
3164 min_max[1] = GetMemoryPointPos( slot_name + "_max" );
3165 }
3166
3167
3170
3171
3174 center = ModelToWorld( center );
3175
3176
3179
3180 areaDamage.SetExtents( extents[0], extents[1] );
3181 areaDamage.SetAreaPosition( center );
3185 areaDamage.SetHitZones( { "Torso","LeftHand","LeftLeg","LeftFoot","RightHand","RightLeg","RightFoot" } );
3186 areaDamage.SetAmmoName( "BarbedWireHit" );
3187 areaDamage.Spawn();
3188
3190 }
3191 }
3192
3194 {
3195 if ( angle_deg != 0 )
3196 {
3197
3199
3200
3202 if ( MemoryPointExists( "rotate_axis" ) )
3203 {
3204 rotate_axis = ModelToWorld( GetMemoryPointPos( "rotate_axis" ) );
3205 }
3206 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];
3207 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];
3208 center[0] = r_center_x;
3209 center[2] = r_center_z;
3210 }
3211 }
3212
3214 {
3216 {
3219 {
3220 if (areaDamage)
3221 {
3222 areaDamage.Destroy();
3223 }
3224
3226 }
3227 }
3228 }
3229
3231 {
3232 return true;
3233 }
3234
3235
3236
3237
3239 {
3241 }
3242
3244 {
3246 }
3247
3249 {
3251 }
3252
3254 {
3256
3257 switch ( material_type )
3258 {
3264 }
3265
3266 return "";
3267 }
3268
3270 {
3272
3273 switch ( material_type )
3274 {
3280 }
3281
3282 return "";
3283 }
3284
3285
3287 {
3289 {
3290
3292 {
3293 SetHealth(slot_name,"Health",item.GetHealth());
3294 }
3295 }
3296 }
3297
3299 {
3300 return 111;
3301 }
3302
3304 {
3305 super.SetActions();
3306
3310 }
3311
3313 {
3315 if (!construction)
3316 return;
3317
3319 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
3320 {
3323 {
3325 }
3326 }
3327 }
3328
3330 {
3332 if (!construction)
3333 return;
3334
3336 for ( int i = constructionParts.Count() - 1; i >= 0; --i )
3337 {
3340 {
3341 construction.HandleEntityFalling(part.
GetPartName());
3342 }
3343 }
3344 }
3345
3348 {
3350 return;
3351
3354
3355 if (DestroyOnFall())
3356 {
3358 {
3360 }
3361 else
3362 {
3364 {
3366 }
3368 }
3369 }
3370 }
3371
3373 {
3374 if (HasAnyAttachmentsOrCargo())
3375 {
3378 }
3379 }
3380
3381
3382
3383
3384
3387 {
3388 return null;
3389 }
3390
3392 {
3394 }
3395
3397 {
3400
3401 Man p;
3402
3403 #ifdef SERVER
3405 g_Game.GetWorld().GetPlayerList(players);
3406 if (players.Count())
3407 p = players[0];
3408 #else
3410 #endif
3411
3413 {
3414 bool excluded = false;
3416 if (excludes)
3417 {
3418 foreach (string exclude : excludes)
3419 {
3421 {
3422 excluded = true;
3423 break;
3424 }
3425 }
3426 }
3427
3428 if (!excluded)
3429 {
3431 }
3432 }
3433
3435 }
3436
3438
3440 [
Obsolete(
"handled in the Construction component directly")]
3442 {
3443 }
3444
3445 [
Obsolete(
"handled in the Construction component directly")]
3447 {
3448 }
3449
3450 [
Obsolete(
"obsolete debug method")]
3452 {
3453 }
3454}
3455
3457{
3458#ifdef BSB_DEBUG
3460#else
3461
3462#endif
3463}
3465{
3466#ifdef BSB_DEBUG_SPAM
3468#else
3469
3470#endif
3471}
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.