-
Notifications
You must be signed in to change notification settings - Fork 5
Drop Item process
Process of installing item on mech was redone. All game default methods(ValidateAdd, OnMechLabDrop) not used at all, so if you mod implement some manipulation with mechlab this manipulation must be reworked to use this system.
Adding item split on 5 stages, you can add actions to any stage using given interfaces and Validator helper class. if during any stage Error registred - adding process canceled, item dropped to bin/shop and error message displayed for user.
Quick validation to check if this item can be installed. Include game-defaults checks on AllowedLocation and if Location Destroyed moved here. You can add own validation use
- PreValidateDropDelegate with Validator.RegisterDropValidator(pre: your delegate). it will be called for every adding item
- IPreValidateDrop.PreValidateDrop() - will be called when item with component impementing this interface adding
-
MechLabItemSlotElement item
- item to add(for interface it same item that contain this component) -
LocationHelper location
- wraper for location widget. it have some usefull methods to access widget privates -
MechLabHelper mechlab
- wraper for MechLabPanel
-
string return value
- String.Empty if validation passed, Error message for user if not
note: in this stage you can aslo do actions, that not require adding items. for example i I have seen a implementation of "drop item change existing item" - pre validation is good place to do this. error message in this case can be used as message to user like "Item Upgraded!"
In this stage validators check if it can add item and do replace if required. Default hardpoints check(try to replace first weapon if all hardpoints ocuped or return error if no hardpoints of this type) moved here. You can add validators using
- ReplaceValidateDropDelegate with Validator.RegisterDropValidator(replace: your delegate)
- IReplaceValidateDrop - interface.
-
MechLabItemSlotElement drop_item
- dropped item -
LocationHelper location
- location to drop -
ref MechLabItemSlotElement current_replace
- link to found replace. if not null - replace found by other validator and you can recheck or change it.
-
string return value
- String.Empty if validation passed, Error message for user if not -
ref MechLabItemSlotElement current_replace
- item for replace
In this stage dropped and replaced item packed to actions and Adjustment do for each of them. For example - you add or replace XL-Engine. it have 2 side torso items so this items must be added/removed too. You can add actions in this stage using IAdjustValidateDrop
interface. It have 2 methods
-
ValidateDropOnAdd
- called for added item -
ValidateDropOnRemove
- called for replaced item(if replacement exist)
-
MechLabItemSlotElement item
added or removed item -
LocationHelper location
- location helper -
MechLabHelper mechlab
- mechlab helper
-
IEnumerable<IChange>
- list of additional actions to do
In this stage all action packed to new inventory and validators must check this inventory. Game-default size and jumpjets check moved here. You can add validators using
- PostValidateDropDelegate with Validator.RegisterDropValidator(post: your delegate) - called for each item dropped
- IPostValidateDrop interface. called if dropped(not replaced!) item have custom component with this interface
-
MechLabItemSlotElement drop_item
- dropped item, mostly for error messages -
MechDef mech
- mech under edit -
List<InvItem> new_inventory
- new inventory list, InvItem - simple structure, which contain MechComponentRef and its new location. As changes dont applied now MechComponentRef.MountedLocation contain current item location(None if this newly added item) -
List<IChange> changes
- list of all changes
-
string return value
- String.Empty if validation passed, Error message for user if not
Simple do all planned actions one by one.