meta data for this page
Vehicles/VehicleScripts/NetworkEvents/SnowCannonEvents.lua
This file contains all event that are relevant for the SnowCannon.
25 26 EventSetCannonTurnedOn = EventSetCannonTurnedOn or ExtensionOf(BaseEvent); 27 28 InitVanillaEvent(EventSetCannonTurnedOn, "EventSetCannonTurnedOn"); 29 30 function EventSetCannonTurnedOn:sendData(entity, cannonIndex, isOn) 31 streamWriteEntityId(entity); 32 33 streamBeginWriteBitwise(); 34 streamWriteUIntN(cannonIndex, 4); 35 streamWriteBit(isOn); 36 -- 3 bits unused 37 streamEndWriteBitwise(); 38 end; 39 40 function EventSetCannonTurnedOn:receiveData(connection) 41 local entity = streamReadEntityId(); 42 43 streamBeginReadBitwise(); 44 local cannonIndex = streamReadUIntN(4); 45 local isOn = streamReadBit(); 46 -- 3 bits still unused 47 streamEndReadBitwise(); 48 49 if entity ~= nil then 50 entity:setIsCannonTurnedOn(cannonIndex, isOn, true); 51 end; 52 53 self:broadcastEvent(connection, entity, cannonIndex, isOn); 54 end; 55 56 57 EventSetCannonGroupId = EventSetCannonGroupId or ExtensionOf(BaseEvent); 58 59 InitVanillaEvent(EventSetCannonGroupId, "EventSetCannonGroupId"); 60 61 function EventSetCannonGroupId:sendData(entity, groupId) 62 streamWriteEntityId(entity); 63 streamWriteUInt16(groupId); 64 end; 65 66 function EventSetCannonGroupId:receiveData(connection) 67 local entity = streamReadEntityId(); 68 local groupId = streamReadUInt16(); 69 70 if entity ~= nil then 71 entity:setSnowCannonGroupId(groupId, true); 72 end; 73 74 self:broadcastEvent(connection, entity, groupId); 75 end; 76 77 78 EventSetCannonRotation = EventSetCannonRotation or ExtensionOf(BaseEvent); 79 80 InitVanillaEvent(EventSetCannonRotation, "EventSetCannonRotation"); 81 82 function EventSetCannonRotation:sendData(entity, cannonIndex, axis, rotation) 83 streamWriteEntityId(entity); 84 85 streamBeginWriteBitwise(); 86 streamWriteUIntN(cannonIndex, 4); 87 streamWriteUIntN(axis, 4); 88 streamEndWriteBitwise(); 89 90 streamWriteFloat(rotation); 91 end; 92 93 function EventSetCannonRotation:receiveData(connection) 94 local entity = streamReadEntityId(); 95 96 streamBeginReadBitwise(); 97 local cannonIndex = streamReadUIntN(4); 98 local axis = streamReadUIntN(4); 99 streamEndReadBitwise(); 100 101 local rotation = streamReadFloat(); 102 103 if entity ~= nil then 104 if axis == 0 then 105 entity:setCannonRotationX(cannonIndex, rotation, true); 106 else 107 entity:setCannonRotationY(cannonIndex, rotation, true); 108 end; 109 end; 110 111 self:broadcastEvent(connection, entity, cannonIndex, axis, rotation); 112 end;
Copyright
All contents of this page may be used for modding use for Winter Resort Simulator - Season 2 only. Any use exceeding this regulation is not permitted.
Copyright (C) HR Innoways, 2021. All Rights Reserved.