123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- class ActionLightItemOnFireCB : ActionContinuousBaseCB
- {
- override void CreateActionComponent()
- {
- m_ActionData.m_ActionComponent = new CAContinuousTime( UATimeSpent.FIREPLACE_IGNITE );
- }
- }
- class ActionLightItemOnFire: ActionContinuousBase
- {
- void ActionLightItemOnFire()
- {
- m_CallbackClass = ActionLightItemOnFireCB;
- m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_STARTFIRE;
- m_FullBody = true;
- m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
-
- m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_HIGH;
- m_Text = "#ignite";
- }
-
- override void CreateConditionComponents()
- {
- m_ConditionTarget = new CCTNonRuined( UAMaxDistances.DEFAULT );
- m_ConditionItem = new CCINonRuined;
- }
- override bool CanBePerformedFromQuickbar()
- {
- return true;
- }
-
- // Removed as a fix for igniting Torch by Matchbox through drag&drop in inventory
- /*override bool CanBePerformedFromInventory()
- {
- return true;
- }*/
-
- // Check if ignite candidate is in cargo of something or not.
- bool IsItemInCargoOfSomething(ItemBase item)
- {
- if ( item.GetInventory() )
- {
- InventoryLocation loc = new InventoryLocation;
- item.GetInventory().GetCurrentInventoryLocation(loc);
-
- if ( loc.GetIdx() > -1 )
- {
- return true;
- }
- }
-
- return false;
- }
-
- override bool ActionConditionContinue( ActionData action_data )
- {
- FireworksBase fireworks = FireworksBase.Cast( action_data.m_Target.GetObject() );
-
- if (fireworks)
- {
- return true;//something might begin occluding the item after the ignition began, we don't want that to cancel the ignition process, not the prettiest solution, but it works
- }
- else
- {
- return ActionCondition(action_data.m_Player, action_data.m_Target,action_data.m_MainItem);
- }
- }
-
- override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
- {
- ItemBase targetItem = ItemBase.Cast(target.GetObject());
-
- if (targetItem && item)
- {
- // when igniting item on the ground with igniter in hands
- if (!targetItem.IsIgnited() && !IsItemInCargoOfSomething(targetItem) && item.CanIgniteItem(targetItem) && targetItem.CanBeIgnitedBy(item))
- {
- // oven stage of standard fireplace
- if (targetItem.IsKindOf("Fireplace"))
- {
- if (Fireplace.Cast(targetItem).IsOven())
- return true;
-
- if (Fireplace.CanIgniteEntityAsFireplace(targetItem))
- return true;
-
- return false;
- }
-
- return true;
- }
- // when igniting item in hands from something on ground
- else if (!item.IsIgnited() && !IsItemInCargoOfSomething(item) && targetItem.CanIgniteItem(item) && item.CanBeIgnitedBy(targetItem))
- {
- return true;
- }
- }
-
- return false;
- }
-
- override void OnFinishProgressServer( ActionData action_data )
- {
- ClearActionJuncture(action_data);
- ItemBase target_item = ItemBase.Cast( action_data.m_Target.GetObject() );
- ItemBase item = action_data.m_MainItem;
-
- bool is_ignition_successful;
- ItemBase ignited_item; //item that was lit on fire
- ItemBase fire_source_item; //item that was the source of fire
-
- if ( item.CanIgniteItem( target_item ) )
- {
- is_ignition_successful = target_item.IsThisIgnitionSuccessful( item );
- ignited_item = target_item;
- fire_source_item = item;
- }
- else if ( item.CanBeIgnitedBy( target_item ) )
- {
- is_ignition_successful = target_item.IsTargetIgnitionSuccessful( item );
- ignited_item = item;
- fire_source_item = target_item;
- }
-
- if ( is_ignition_successful )
- {
- fire_source_item.OnIgnitedTarget( ignited_item );
- ignited_item.OnIgnitedThis( fire_source_item );
- }
- else
- {
- fire_source_item.OnIgnitedTargetFailed( ignited_item );
- ignited_item.OnIgnitedThisFailed( fire_source_item );
- }
- }
-
- //setup
- override bool SetupAction( PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL )
- {
- if ( super.SetupAction( player, target, item, action_data, extra_data ) )
- {
- ItemBase target_item = ItemBase.Cast( target.GetObject() );
- if ( target_item )
- {
- SetIgnitingAnimation( target_item );
- }
-
- return true;
- }
-
- return false;
- }
-
- void SetIgnitingAnimation( ItemBase target_item )
- {
- if ( target_item.HasFlammableMaterial() )
- {
- m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_STARTFIRE;
- }
- else
- {
- m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_CRAFTING;
- }
- }
- }
|